-
Notifications
You must be signed in to change notification settings - Fork 909
CRYSPR: Add AES GCM mode with OpenSSL EVP. #2476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRYSPR: Add AES GCM mode with OpenSSL EVP. #2476
Conversation
|
|
||
| if ((ctx->flags & HCRYPT_CTX_F_ENCRYPT) /* Encrypt key */ | ||
| if (ctx->mode == HCRYPT_CTX_MODE_AESGCM) { /* AES GCM mode */ | ||
| if (cryspr_cb->cryspr->aes_set_key(HCRYPT_CTX_MODE_AESGCM, (ctx->flags & HCRYPT_CTX_F_ENCRYPT) != 0, key, key_len, aes_sek)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AES-CTR always set an Encrypt Key even for Decrypt, Isn't it the same for AES-GCM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly no. If e.g. I pass true in bEncrypt of the aes_set_key, then decryption fails on assigning the AUTH tag buffer to the context.
int crysprOpenSSL_EVP_AES_GCMCipher(bool bEncrypt, ...
{
// ...
if (!bEncrypt && !EVP_CIPHER_CTX_ctrl(aes_key, EVP_CTRL_GCM_SET_TAG, 16, out_tag)) {
ERR_print_errors_fp(stderr);
HCRYPT_LOG(LOG_ERR, "%s\n", "EVP_EncryptUpdate failed");
return -1;
}
Add AES GCM crypto mode support into the CRYSPR library if built with OpenSSL EVP (
-DUSE_ENCLIB=openssl-evp).List of Changes
HCRYPT_CTX_MODE_AESGCMto thehcrypt_Ctx.aes_gcm_cipherfunction pointer is added to theCRYSPR_methods.crysprOpenSSL_EVP_AES_GCMCipherfunction added incryspr-openssl-evp.c; it usesEVP_aes_<128/192/256>_gcmfunctions in case EVP API is enabled.crysprStub_AES_GCMCipherfunction (noop) is used otherwise.int HaiCryptCryspr_Is_AES_GCM_Supported(void)function to find out if GCM is supported. It will be useful for the handshaking procedure in follow-up PRs.HCRYPT_CIPHER_AES_GCMdefinition.Related FR #2336.