mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 00:56:31 +08:00
set or check ciphertext length
This commit is contained in:
1 parent
03ede654f2
commit
8e7fe9021a
1 file changed
+24
@@ -285,6 +285,18 @@ int gcm_decrypt(const uint8_t* ciphertext, int ciphertext_len, uint8_t* key, int
|
||||
memset(tag, 0, gcmTagLen);
|
||||
uint8_t iv[nonceLen];
|
||||
memset(iv, 0, nonceLen);
|
||||
|
||||
// Extract ciphertext length
|
||||
int ciphertext_length =
|
||||
((ciphertext[3] & 0xff) << 24) |
|
||||
((ciphertext[2] & 0xff) << 16) |
|
||||
((ciphertext[1] & 0xff) << 8) |
|
||||
((ciphertext[0] & 0xff));
|
||||
|
||||
if (ciphertext_len > 0 && ciphertext_len != ciphertext_length) {
|
||||
throw ParquetException("Wrong ciphertext length");
|
||||
}
|
||||
ciphertext_len = ciphertext_length;
|
||||
|
||||
// Extracting IV and tag
|
||||
std::copy(ciphertext + bufferSizeLen, ciphertext + bufferSizeLen + nonceLen, iv);
|
||||
@@ -333,6 +345,18 @@ int ctr_decrypt(const uint8_t* ciphertext, int ciphertext_len, uint8_t* key, int
|
||||
|
||||
uint8_t iv[ctrIvLen];
|
||||
memset(iv, 0, ctrIvLen);
|
||||
|
||||
// Extract ciphertext length
|
||||
int ciphertext_length =
|
||||
((ciphertext[3] & 0xff) << 24) |
|
||||
((ciphertext[2] & 0xff) << 16) |
|
||||
((ciphertext[1] & 0xff) << 8) |
|
||||
((ciphertext[0] & 0xff));
|
||||
|
||||
if (ciphertext_len > 0 && ciphertext_len != ciphertext_length) {
|
||||
throw ParquetException("Wrong ciphertext length");
|
||||
}
|
||||
ciphertext_len = ciphertext_length;
|
||||
|
||||
// Extracting IV and tag
|
||||
std::copy(ciphertext + bufferSizeLen, ciphertext + bufferSizeLen + ctrIvLen, iv);
|
||||
|
||||
Reference in new issue
Block a user