diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2019-01-26 14:09:44 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-01-26 14:09:44 +0100 |
commit | 8ec80d1f5dca6510aae726356a5f1f327e199b8f (patch) | |
tree | 66069da74304cccb9a94d41e2fbf023bcc2b4635 /src/libcrypto.c | |
parent | 8ddbe7bec623e3ab16f654b7aab7a0e74781f73d (diff) | |
download | libssh-8ec80d1f5dca6510aae726356a5f1f327e199b8f.tar.gz libssh-8ec80d1f5dca6510aae726356a5f1f327e199b8f.tar.xz libssh-8ec80d1f5dca6510aae726356a5f1f327e199b8f.zip |
libcrypto: Use size_t for size calculations
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/libcrypto.c')
-rw-r--r-- | src/libcrypto.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libcrypto.c b/src/libcrypto.c index d94efbf0..d578903f 100644 --- a/src/libcrypto.c +++ b/src/libcrypto.c @@ -729,7 +729,8 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher, { size_t authlen, aadlen; u_char lastiv[1]; - int outlen = 0; + int tmplen = 0; + size_t outlen; int rc; (void) seq; @@ -750,10 +751,11 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher, /* Pass over the authenticated data (not encrypted) */ rc = EVP_EncryptUpdate(cipher->ctx, NULL, - &outlen, + &tmplen, (unsigned char *)in, (int)aadlen); - if (rc == 0 || outlen != (int)aadlen) { + outlen = tmplen; + if (rc == 0 || outlen != aadlen) { SSH_LOG(SSH_LOG_WARNING, "Failed to pass authenticated data"); return; } @@ -762,9 +764,10 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher, /* Encrypt the rest of the data */ rc = EVP_EncryptUpdate(cipher->ctx, (unsigned char *)out + aadlen, - &outlen, + &tmplen, (unsigned char *)in + aadlen, (int)len - aadlen); + outlen = tmplen; if (rc != 1 || outlen != (int)len - aadlen) { SSH_LOG(SSH_LOG_WARNING, "EVP_EncryptUpdate failed"); return; @@ -773,7 +776,7 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher, /* compute tag */ rc = EVP_EncryptFinal(cipher->ctx, NULL, - &outlen); + &tmplen); if (rc < 0) { SSH_LOG(SSH_LOG_WARNING, "EVP_EncryptFinal failed: Failed to create a tag"); return; |