[openssl-dev] [RFC 3/4] evp/e_aes: Expose GCM IV
Boris Pismenny
borisp at mellanox.com
Wed Jun 7 12:35:48 UTC 2017
This commit exposes the generated GCM IV to applications.
Change-Id: If058f9d55c101e3efb6c988c26071145ebcbf0e8
Signed-off-by: Boris Pismenny <borisp at mellanox.com>
---
crypto/evp/e_aes.c | 8 ++++++++
include/openssl/evp.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c
index f504c68..3da8bf2 100644
--- a/crypto/evp/e_aes.c
+++ b/crypto/evp/e_aes.c
@@ -1331,6 +1331,14 @@ static int aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
memcpy(ptr, EVP_CIPHER_CTX_buf_noconst(c), arg);
return 1;
+ case EVP_CTRL_GCM_GET_IV:
+ if (gctx->iv_gen != 1)
+ return 0;
+ if (gctx->ivlen != arg)
+ return 0;
+ memcpy(ptr, gctx->iv, arg);
+ return 1;
+
case EVP_CTRL_GCM_SET_IV_FIXED:
/* Special case: -1 length restores whole IV */
if (arg == -1) {
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index b9c83b2..39b0dbd 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -289,6 +289,7 @@ int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
# define EVP_CTRL_GCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
# define EVP_CTRL_GCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED
# define EVP_CTRL_GCM_IV_GEN 0x13
+# define EVP_CTRL_GCM_GET_IV 0x14
# define EVP_CTRL_CCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN
# define EVP_CTRL_CCM_GET_TAG EVP_CTRL_AEAD_GET_TAG
# define EVP_CTRL_CCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
--
1.8.3.1
More information about the openssl-dev
mailing list