-
Notifications
You must be signed in to change notification settings - Fork 3
[PWCI] "crypto/openssl: Add support for SHA3 algorithms" #596
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 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -92,6 +92,14 @@ digest_name_get(enum rte_crypto_auth_algorithm algo) | |||||||||||||||||||||||||||||
| return OSSL_DIGEST_NAME_SHA2_384; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA512_HMAC: | ||||||||||||||||||||||||||||||
| return OSSL_DIGEST_NAME_SHA2_512; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_224_HMAC: | ||||||||||||||||||||||||||||||
| return OSSL_DIGEST_NAME_SHA3_224; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_256_HMAC: | ||||||||||||||||||||||||||||||
| return OSSL_DIGEST_NAME_SHA3_256; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_384_HMAC: | ||||||||||||||||||||||||||||||
| return OSSL_DIGEST_NAME_SHA3_384; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_512_HMAC: | ||||||||||||||||||||||||||||||
| return OSSL_DIGEST_NAME_SHA3_512; | ||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||
| return NULL; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
@@ -270,6 +278,22 @@ get_auth_algo(enum rte_crypto_auth_algorithm sessalgo, | |||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA512_HMAC: | ||||||||||||||||||||||||||||||
| *algo = EVP_sha512(); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_224: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_224_HMAC: | ||||||||||||||||||||||||||||||
| *algo = EVP_sha3_224(); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_256: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_256_HMAC: | ||||||||||||||||||||||||||||||
| *algo = EVP_sha3_256(); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_384: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_384_HMAC: | ||||||||||||||||||||||||||||||
| *algo = EVP_sha3_384(); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_512: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_512_HMAC: | ||||||||||||||||||||||||||||||
| *algo = EVP_sha3_512(); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||
| res = -EINVAL; | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
|
|
@@ -659,6 +683,10 @@ openssl_set_session_auth_parameters(struct openssl_session *sess, | |||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA256: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA384: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA512: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_224: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_256: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_384: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_512: | ||||||||||||||||||||||||||||||
|
Comment on lines
+686
to
+689
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. Plain SHA3 authentication requires OpenSSL 1.1.1+ version guard. These SHA3 auth cases call get_auth_algo which uses EVP_sha3_* functions only available in OpenSSL 1.1.1+. Add version guards to prevent compilation errors on older versions. Suggested fix case RTE_CRYPTO_AUTH_SHA384:
case RTE_CRYPTO_AUTH_SHA512:
+#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
case RTE_CRYPTO_AUTH_SHA3_224:
case RTE_CRYPTO_AUTH_SHA3_256:
case RTE_CRYPTO_AUTH_SHA3_384:
case RTE_CRYPTO_AUTH_SHA3_512:
+#endif
sess->auth.mode = OPENSSL_AUTH_AS_AUTH;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| sess->auth.mode = OPENSSL_AUTH_AS_AUTH; | ||||||||||||||||||||||||||||||
| if (get_auth_algo(xform->auth.algo, | ||||||||||||||||||||||||||||||
| &sess->auth.auth.evp_algo) != 0) | ||||||||||||||||||||||||||||||
|
|
@@ -714,6 +742,10 @@ openssl_set_session_auth_parameters(struct openssl_session *sess, | |||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA256_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA384_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA512_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_224_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_256_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_384_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_512_HMAC: | ||||||||||||||||||||||||||||||
| sess->auth.mode = OPENSSL_AUTH_AS_HMAC; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| algo = digest_name_get(xform->auth.algo); | ||||||||||||||||||||||||||||||
|
|
@@ -744,6 +776,10 @@ openssl_set_session_auth_parameters(struct openssl_session *sess, | |||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA256_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA384_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA512_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_224_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_256_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_384_HMAC: | ||||||||||||||||||||||||||||||
| case RTE_CRYPTO_AUTH_SHA3_512_HMAC: | ||||||||||||||||||||||||||||||
|
Comment on lines
+779
to
+782
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. SHA3 HMAC in legacy branch requires version guard for OpenSSL 1.1.1+. This else branch handles OpenSSL < 3.0, but SHA3 support still requires OpenSSL 1.1.1+. The code will fail to compile on OpenSSL 1.0.x and 1.1.0. Suggested fix case RTE_CRYPTO_AUTH_SHA256_HMAC:
case RTE_CRYPTO_AUTH_SHA384_HMAC:
case RTE_CRYPTO_AUTH_SHA512_HMAC:
+#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
+#endif
sess->auth.mode = OPENSSL_AUTH_AS_HMAC;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| sess->auth.mode = OPENSSL_AUTH_AS_HMAC; | ||||||||||||||||||||||||||||||
| sess->auth.hmac.ctx = HMAC_CTX_new(); | ||||||||||||||||||||||||||||||
| if (get_auth_algo(xform->auth.algo, | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
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.
Missing version guard for SHA3 functions will cause compilation errors.
EVP_sha3_224/256/384/512 functions were introduced in OpenSSL 1.1.1, but these cases are not version-guarded. Since the codebase supports OpenSSL 1.0.x (see guards at line 26), this will cause compilation failures on older OpenSSL versions.
Suggested fix
📝 Committable suggestion