diff options
author | Matthias-Christian Ott <ott@mirix.org> | 2014-12-30 11:57:36 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2014-12-30 12:25:16 +0200 |
commit | 023156ae2504c1911f8f2e66a0ebde316931671c (patch) | |
tree | e443212424d65421cd5a27122290d723e72de825 | |
parent | a789896ecf4d03b57f08390eff7b5359f94faf6e (diff) | |
download | gnutls-023156ae2504c1911f8f2e66a0ebde316931671c.tar.gz |
Handle zero length plaintext for VIA PadLock functions
If the plaintext is shorter than the block size of the used cipher,
_gnutls_auth_cipher_encrypt2_tag calls _gnutls_cipher_encrypt2 with
textlen = 0. padlock_ecb_encrypt and padlock_cbc_encrypt assume that the
plaintext length (last parameter) is greater than zero and segfault
otherwise. The assembler code for both functions is automatically
generated and imported from OpenSSL, so to ease maintenance the length
should be validated in the functions that call padlock_ecb_encrypt or
padlock_cbc_encrypt.
-rw-r--r-- | lib/accelerated/x86/aes-gcm-padlock.c | 3 | ||||
-rw-r--r-- | lib/accelerated/x86/aes-padlock.c | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/accelerated/x86/aes-gcm-padlock.c b/lib/accelerated/x86/aes-gcm-padlock.c index e1ad56699b..9e92292d9f 100644 --- a/lib/accelerated/x86/aes-gcm-padlock.c +++ b/lib/accelerated/x86/aes-gcm-padlock.c @@ -54,7 +54,8 @@ static void padlock_aes_encrypt(void *_ctx, pce = ALIGN16(&ctx->expanded_key); - padlock_ecb_encrypt(dst, src, pce, length); + if (length > 0) + padlock_ecb_encrypt(dst, src, pce, length); } static void padlock_aes_set_encrypt_key(struct padlock_ctx *_ctx, diff --git a/lib/accelerated/x86/aes-padlock.c b/lib/accelerated/x86/aes-padlock.c index bccbd10d92..8ed10d8449 100644 --- a/lib/accelerated/x86/aes-padlock.c +++ b/lib/accelerated/x86/aes-padlock.c @@ -132,7 +132,8 @@ padlock_aes_cbc_encrypt(void *_ctx, const void *src, size_t src_size, pce = ALIGN16(&ctx->expanded_key); - padlock_cbc_encrypt(dst, src, pce, src_size); + if (src_size > 0) + padlock_cbc_encrypt(dst, src, pce, src_size); return 0; } @@ -147,7 +148,8 @@ padlock_aes_cbc_decrypt(void *_ctx, const void *src, size_t src_size, pcd = ALIGN16(&ctx->expanded_key); - padlock_cbc_encrypt(dst, src, pcd, src_size); + if (src_size > 0) + padlock_cbc_encrypt(dst, src, pcd, src_size); return 0; } |