minor update
Change-Id: I9d7455fc203c9d9afd1f79c46ccefbe50871eacd
diff --git a/src/detail/crypto-helpers.cpp b/src/detail/crypto-helpers.cpp
index c3c3187..92b7234 100644
--- a/src/detail/crypto-helpers.cpp
+++ b/src/detail/crypto-helpers.cpp
@@ -234,13 +234,13 @@
return outLen;
}
-int
+size_t
aesGcm128Encrypt(const uint8_t* plaintext, size_t plaintextLen, const uint8_t* associated, size_t associatedLen,
const uint8_t* key, const uint8_t* iv, uint8_t* ciphertext, uint8_t* tag)
{
EVP_CIPHER_CTX* ctx;
int len;
- int ciphertextLen;
+ size_t ciphertextLen;
if (!(ctx = EVP_CIPHER_CTX_new())) {
NDN_THROW(std::runtime_error("Cannot create and initialise the context when calling EVP_CIPHER_CTX_new()"));
}
@@ -278,14 +278,13 @@
return ciphertextLen;
}
-int
+size_t
aesGcm128Decrypt(const uint8_t* ciphertext, size_t ciphertextLen, const uint8_t* associated, size_t associatedLen,
const uint8_t* tag, const uint8_t* key, const uint8_t* iv, uint8_t* plaintext)
{
EVP_CIPHER_CTX* ctx;
int len;
- int plaintextLen;
- int ret;
+ size_t plaintextLen;
if (!(ctx = EVP_CIPHER_CTX_new())) {
NDN_THROW(std::runtime_error("Cannot create and initialise the context when calling EVP_CIPHER_CTX_new()"));
}
@@ -314,7 +313,7 @@
EVP_CIPHER_CTX_free(ctx);
NDN_THROW(std::runtime_error("Cannot set tag value when calling EVP_CIPHER_CTX_ctrl()"));
}
- ret = EVP_DecryptFinal_ex(ctx, plaintext + len, &len);
+ auto ret = EVP_DecryptFinal_ex(ctx, plaintext + len, &len);
EVP_CIPHER_CTX_free(ctx);
if (ret > 0) {
plaintextLen += len;
diff --git a/src/detail/crypto-helpers.hpp b/src/detail/crypto-helpers.hpp
index 78c8946..def7187 100644
--- a/src/detail/crypto-helpers.hpp
+++ b/src/detail/crypto-helpers.hpp
@@ -95,10 +95,10 @@
* @param iv 12 bytes IV.
* @param ciphertext The output and enough memory must be allocated beforehands.
* @param tag 16 bytes tag.
- * @return int The size of ciphertext.
+ * @return size_t The size of ciphertext.
* @throw runtime_error When there is an error in the process of encryption.
*/
-int
+size_t
aesGcm128Encrypt(const uint8_t* plaintext, size_t plaintextLen, const uint8_t* associated, size_t associatedLen,
const uint8_t* key, const uint8_t* iv, uint8_t* ciphertext, uint8_t* tag);
@@ -113,10 +113,10 @@
* @param key 16 bytes AES key.
* @param iv 12 bytes IV.
* @param plaintext The output and enough memory must be allocated beforehands.
- * @return int The size of plaintext or -1 if the verification fails.
- * @throw runtime_error When there is an error in the process of encryption.
+ * @return size_t The size of plaintext.
+ * @throw runtime_error When there is an error in the process of decryption.
*/
-int
+size_t
aesGcm128Decrypt(const uint8_t* ciphertext, size_t ciphertextLen, const uint8_t* associated, size_t associatedLen,
const uint8_t* tag, const uint8_t* key, const uint8_t* iv, uint8_t* plaintext);