-
Notifications
You must be signed in to change notification settings - Fork 199
Simplify native code configurations and aes_ctr_set_key #3019
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -160,8 +160,7 @@ static int aes_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key, | |||||
| if (mode == EVP_CIPH_CBC_MODE) { | ||||||
| dat->stream.cbc = aes_hw_cbc_encrypt; | ||||||
| } | ||||||
| } else if (bsaes_capable() && mode == EVP_CIPH_CBC_MODE) { | ||||||
| assert(vpaes_capable()); | ||||||
| } else if (vpaes_capable() && mode == EVP_CIPH_CBC_MODE) { | ||||||
| ret = vpaes_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks); | ||||||
| if (ret == 0) { | ||||||
| vpaes_decrypt_key_to_bsaes(&dat->ks.ks, &dat->ks.ks); | ||||||
|
|
@@ -206,7 +205,7 @@ static int aes_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key, | |||||
| #endif | ||||||
| if (mode == EVP_CIPH_CTR_MODE) { | ||||||
| #if defined(BSAES) | ||||||
| assert(bsaes_capable()); | ||||||
| assert(vpaes_capable()); | ||||||
| dat->stream.ctr = vpaes_ctr32_encrypt_blocks_with_bsaes; | ||||||
| #elif defined(VPAES_CTR32) | ||||||
| dat->stream.ctr = vpaes_ctr32_encrypt_blocks; | ||||||
|
|
@@ -288,7 +287,8 @@ ctr128_f aes_ctr_set_key(AES_KEY *aes_key, GCM128_KEY *gcm_key, | |||||
| block128_f *out_block, const uint8_t *key, | ||||||
| size_t key_bytes) { | ||||||
| // This function assumes the key length was previously validated. | ||||||
| assert(key_bytes == 128 / 8 || key_bytes == 192 / 8 || key_bytes == 256 / 8); | ||||||
| assert(key_bytes == 16 || key_bytes == 24 || key_bytes == 32); | ||||||
|
|
||||||
| if (hwaes_capable()) { | ||||||
| aes_hw_set_encrypt_key(key, (int)key_bytes * 8, aes_key); | ||||||
| if (gcm_key != NULL) { | ||||||
|
|
@@ -300,23 +300,32 @@ ctr128_f aes_ctr_set_key(AES_KEY *aes_key, GCM128_KEY *gcm_key, | |||||
| return aes_hw_ctr32_encrypt_blocks_wrapper; | ||||||
| } | ||||||
|
|
||||||
| if (vpaes_capable()) { | ||||||
|
|
||||||
| #if defined(BSAES) | ||||||
| if (vpaes_capable()) { | ||||||
| vpaes_set_encrypt_key(key, (int)key_bytes * 8, aes_key); | ||||||
| if (out_block) { | ||||||
| *out_block = vpaes_encrypt_wrapper; | ||||||
| } | ||||||
| if (gcm_key != NULL) { | ||||||
| CRYPTO_gcm128_init_key(gcm_key, aes_key, vpaes_encrypt_wrapper, 0); | ||||||
| } | ||||||
| #if defined(BSAES) | ||||||
| assert(bsaes_capable()); | ||||||
| return vpaes_ctr32_encrypt_blocks_with_bsaes; | ||||||
| #elif defined(VPAES_CTR32) | ||||||
| return vpaes_ctr32_encrypt_blocks_wrapper; | ||||||
| #else | ||||||
| return NULL; | ||||||
| } | ||||||
| #endif | ||||||
|
|
||||||
| #if defined(VPAES_CTR32) | ||||||
| if (vpaes_capable()) { | ||||||
| vpaes_set_encrypt_key(key, (int)key_bytes * 8, aes_key); | ||||||
| if (out_block) { | ||||||
| *out_block = vpaes_encrypt_wrapper; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use of undeclared identifier 'vpaes_encrypt_wrapper' [clang-diagnostic-error] *out_block = vpaes_encrypt_wrapper;
^ |
||||||
| } | ||||||
| if (gcm_key != NULL) { | ||||||
| CRYPTO_gcm128_init_key(gcm_key, aes_key, vpaes_encrypt_wrapper, 0); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use of undeclared identifier 'vpaes_encrypt_wrapper' [clang-diagnostic-error] CRYPTO_gcm128_init_key(gcm_key, aes_key, vpaes_encrypt_wrapper, 0);
^ |
||||||
| } | ||||||
| return vpaes_ctr32_encrypt_blocks_wrapper; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use of undeclared identifier 'vpaes_ctr32_encrypt_blocks_wrapper'; did you mean 'vpaes_ctr32_encrypt_blocks'? [clang-diagnostic-error]
Suggested change
Additional contextcrypto/fipsmodule/aes/internal.h:240: 'vpaes_ctr32_encrypt_blocks' declared here void vpaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len,
^ |
||||||
| } | ||||||
| #endif | ||||||
|
|
||||||
| aes_nohw_set_encrypt_key(key, (int)key_bytes * 8, aes_key); | ||||||
| if (gcm_key != NULL) { | ||||||
|
|
||||||
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.
warning: use of undeclared identifier 'aes_hw_ctr32_encrypt_blocks_wrapper'; did you mean 'aes_hw_ctr32_encrypt_blocks'? [clang-diagnostic-error]
Additional context
crypto/fipsmodule/aes/internal.h:96: 'aes_hw_ctr32_encrypt_blocks' declared here