ecx_keys: Handle weak x keys as insufficient_security alert#27597
Conversation
83d69a5 to
d3a5580
Compare
d3a5580 to
2dbdc05
Compare
Sashan
left a comment
There was a problem hiding this comment.
just fix the cstyle and you'll be good to go. thanks.
| ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_DURING_DERIVATION); | ||
| return 0; | ||
| } | ||
| ERR_raise(ERR_LIB_PROV, ERR_LIB_EC); |
There was a problem hiding this comment.
I think the indentation here is of. it needs to be moved by 4 spaces left. So it is aligned with ossl_
cstyle here is hard.
| & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_X448)) { | ||
| if (s390x_x448_mul(secret, peer->pubkey, priv->privkey) == 0) { | ||
| ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_DURING_DERIVATION); | ||
| ERR_raise(ERR_LIB_PROV, ERR_LIB_EC); |
| ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_DURING_DERIVATION); | ||
| return 0; | ||
| } | ||
| ERR_raise(ERR_LIB_PROV, ERR_LIB_EC); |
There was a problem hiding this comment.
For some reason the style check did detect issues here and this was the solution. I might check the style-checker for some errors
There was a problem hiding this comment.
The style checker has to be taken with grain of salt. It is not and cannot be perfect. We have the style: waived label that can be added after manual review of the style checker report.
There was a problem hiding this comment.
For some reason the style check did detect issues here and this was the solution. I might check the style-checker for some errors
I think c-style checker is confused by errors which exists in the file already
There was a problem hiding this comment.
Okay, I changed it back to normal and then deleted as seen below
| & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_X25519)) { | ||
| if (s390x_x25519_mul(secret, peer->pubkey, priv->privkey) == 0) { | ||
| ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_DURING_DERIVATION); | ||
| ERR_raise(ERR_LIB_PROV, ERR_LIB_EC); |
There was a problem hiding this comment.
Why are you changing the reason code? That does not make sense to me. You can test for ERR_LIB_PROV && PROV_R_FAILED_DURING_DERIVATION in libssl with no issue.
There was a problem hiding this comment.
For the first time it looked like there are more paths this error code can happen, but now I searched it up and it's used only in one place of hpke code and here. So it doesn't make sense to use a different error code here. Changed back.
| /* | ||
| * the public key probably was a weak key | ||
| */ | ||
| if (ERR_GET_REASON(ERR_peek_last_error()) == ERR_LIB_EC) { | ||
| SSLfatal(s, SSL_AD_INSUFFICIENT_SECURITY, SSL_R_BAD_ECPOINT); | ||
| } else { | ||
| SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); | ||
| } |
There was a problem hiding this comment.
I would not check the reason code at all and used SSL_AD_ILLEGAL_PARAMETER instead as suggested in #27531. The returned reason code should be SSL_R_BAD_KEY_SHARE.
There was a problem hiding this comment.
The EVP_PKEY_derive can fail on many different reasons; would it be good to report all of them as ILLEGAL_PARAMETER?
There was a problem hiding this comment.
It is IMO OK. The alert is just an alert. This is the most common case of the failure.
2dbdc05 to
56be945
Compare
56be945 to
3228720
Compare
3228720 to
33fa9ac
Compare
|
There is also #25781 which is related to this PR. |
|
This pull request is ready to merge |
33fa9ac to
a8192c4
Compare
a8192c4 to
cc2c9e6
Compare
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from #27597)
|
Merged to all the active branches. Thank you. |
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#27597)
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#27597)
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#27597)
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#27597)
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#27597)
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#27597) (cherry picked from commit 5da4ea1)
OpenSSL handles this issue with internal_error which is not giving a proper explanation of the issue.
Thank you for the report @GeorgePantelakis!
Resolves: #27531
Checklist