Small fixes to signal-protocol-c helper functions

ref #253
This commit is contained in:
Marvin W 2018-01-04 21:06:20 +01:00
parent b482c57f3b
commit 6b58b348fa
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A

View file

@ -281,6 +281,7 @@ int signal_vala_decrypt(signal_buffer **output,
void *user_data) { void *user_data) {
int algo, mode; int algo, mode;
if (aes_cipher(cipher, key_len, &algo, &mode)) return SG_ERR_UNKNOWN; if (aes_cipher(cipher, key_len, &algo, &mode)) return SG_ERR_UNKNOWN;
if (ciphertext_len == 0) return SG_ERR_UNKNOWN;
if (iv_len != 16) return SG_ERR_UNKNOWN; if (iv_len != 16) return SG_ERR_UNKNOWN;
@ -325,7 +326,7 @@ no_error:
if (pkcs_pad) { if (pkcs_pad) {
uint8_t pad_len = out_buf[padded_len - 1]; uint8_t pad_len = out_buf[padded_len - 1];
if (pad_len > 16) goto error; if (pad_len > 16 || pad_len > padded_len) goto error;
*output = signal_buffer_create(out_buf, padded_len - pad_len); *output = signal_buffer_create(out_buf, padded_len - pad_len);
} else { } else {
*output = signal_buffer_create(out_buf, padded_len); *output = signal_buffer_create(out_buf, padded_len);