mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-20 03:44:15 +08:00
Fix aes_cbc_padding_decrypt bug
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2024 The GmSSL Project. All Rights Reserved.
|
||||
* Copyright 2014-2026 The GmSSL Project. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
@@ -71,6 +71,7 @@ int aes_cbc_padding_decrypt(const AES_KEY *key, const uint8_t iv[16],
|
||||
uint8_t block[16];
|
||||
size_t len = sizeof(block);
|
||||
int padding;
|
||||
int i;
|
||||
|
||||
if (inlen == 0) {
|
||||
error_print();
|
||||
@@ -90,6 +91,11 @@ int aes_cbc_padding_decrypt(const AES_KEY *key, const uint8_t iv[16],
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
for (i = 16 - padding; i < 16; i++) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
|
||||
len -= padding;
|
||||
memcpy(out + inlen - 16, block, len);
|
||||
*outlen = inlen - padding;
|
||||
|
||||
Reference in New Issue
Block a user