Fixes following Gidon's comments

This commit is contained in:
Revital1 Eres committed 2019-05-29 13:50:24 +03:00
1 parent 535d0e28c3
commit b570e8e9bd
2 files changed
+11 -12

No files matched your search

+2 -4
View File
@@ -239,8 +239,7 @@ int AesEncryptor::AesEncryptorImpl::CtrEncrypt(const uint8_t* plaintext,
// Parquet CTR IVs are comprised of a 12-byte nonce and a 4-byte initial
// counter field.
// The first 31 bits of the initial counter field are set to 0, the last bit
// is set
// to 1.
// is set to 1.
uint8_t iv[kCtrIvLength];
memset(iv, 0, kCtrIvLength);
std::copy(nonce, nonce + kNonceLength, iv);
@@ -600,8 +599,7 @@ std::string CreateFooterAad(const std::string& aad_prefix_bytes) {
}
// Update last two bytes with new page ordinal (instead of creating new page AAD
// from
// scratch)
// from scratch)
void QuickUpdatePageAad(const std::string& AAD, int16_t new_page_ordinal) {
std::string page_ordinal_bytes = ShortToBytesLe(new_page_ordinal);
int length = static_cast<int>(AAD.size());
+9 -8
View File
@@ -43,7 +43,7 @@ constexpr int8_t kDictionaryPageHeader = 5;
constexpr int8_t kColumnIndex = 6;
constexpr int8_t kOffsetIndex = 7;
/// Do AES_GCM_CTR_V1 or AES_GCM_V1 encryption
/// Performs AES encryption operations with GCM or CTR ciphers.
class AesEncryptor {
public:
static AesEncryptor* Make(ParquetCipher::type alg_id, int key_len, bool metadata,
@@ -51,14 +51,15 @@ class AesEncryptor {
~AesEncryptor();
/// Size different between plaintext and ciphertext, for this cipher.
/// Size difference between plaintext and ciphertext, for this cipher.
int CiphertextSizeDelta();
/// Key length is passed only for validation. If different from value in
/// constructor, exception will be thrown.
/// Encrypts plaintext with the key and aad. Key length is passed only for validation.
/// If different from value in constructor, exception will be thrown.
int Encrypt(const uint8_t* plaintext, int plaintext_len, uint8_t* key, int key_len,
uint8_t* aad, int aad_len, uint8_t* ciphertext);
/// Encrypts plaintext footer, in order to compute the signature (tag).
int SignedFooterEncrypt(const uint8_t* footer, int footer_len, uint8_t* key,
int key_len, uint8_t* aad, int aad_len, uint8_t* nonce,
uint8_t* encrypted_footer);
@@ -73,7 +74,7 @@ class AesEncryptor {
std::unique_ptr<AesEncryptorImpl> impl_;
};
/// Do AES_GCM_CTR_V1 or AES_GCM_V1 decryption
/// Performs AES decryption operations with GCM or CTR ciphers.
class AesDecryptor {
public:
static AesDecryptor* Make(ParquetCipher::type alg_id, int key_len, bool metadata,
@@ -82,11 +83,11 @@ class AesDecryptor {
~AesDecryptor();
void WipeOut();
/// Size different between plaintext and ciphertext, for this cipher.
/// Size difference between plaintext and ciphertext, for this cipher.
int CiphertextSizeDelta();
/// Key length is passed only for validation. If different from value in
/// constructor, exception will be thrown.
/// Decrypts ciphertext with the key and aad. Key length is passed only for
/// validation. If different from value in constructor, exception will be thrown.
int Decrypt(const uint8_t* ciphertext, int ciphertext_len, uint8_t* key, int key_len,
uint8_t* aad, int aad_len, uint8_t* plaintext);