You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling #check_key against an OpenSSL::PKey::EC instance representing an invalid point for the group, the method always returns true.
I believe this is because OpenSSL 3 deprecated EC_KEY_check_key, and the underlying call is swapped out for EVP_PKEY_public_check in the 3.x branch.
However, the EVP_PKEY_public_check does not serve the same purpose as EC_KEY_check_key.
EVP_PKEY_public_check validates only the resulting public component, and does not validate the private component. I believe EVP_PKEY_pairwise_check is closer to the behavior of EC_KEY_check_key, where both the public and private components are validated, though it seems to assume the presence of a private component.
Reproducer
# check.rbver=ARGV[0]gem'openssl',verrequire'openssl'# ECDSA secp384r1 encoded key where the point is not on the curvepem=<<~INVALID_KEY-----BEGIN EC PRIVATE KEY-----MIGkAgEBBDDA1Tm0m7YhkfeVpFuarAJYVlHp2tQj+1fOBiLa10t9E8TiQO/hVfxBvGaVEQwOheWgBwYFK4EEACKhZANiAASyGqmryZGqdpsq5gEDIfNvgC3AwSJxiBCLXKHBTFRp+tCezLDOK/6V8KK/vVGBJlGFW6/I7ahyXprxS7xs7hPA9iz5YiuqXlu+lbrIpZOz7b73hyQQCkvbBO/Avg+hPAk=-----END EC PRIVATE KEY-----INVALID_KEYbeginresult=OpenSSL::PKey::EC.new(pem).check_keyrescue=eresult=e.messageendputsformat('%25s: %s','RUBY_VERSION',RUBY_VERSION)putsformat('%25s: %s','OPENSSL_LIBRARY_VERSION',OpenSSL::OPENSSL_LIBRARY_VERSION)putsformat('%25s: %s','OPENSSL_VERSION',OpenSSL::VERSION)putsformat('%25s: %s','result',result)
When calling
#check_key
against anOpenSSL::PKey::EC
instance representing an invalid point for the group, the method always returns true.I believe this is because OpenSSL 3 deprecated
EC_KEY_check_key
, and the underlying call is swapped out forEVP_PKEY_public_check
in the 3.x branch.However, the
EVP_PKEY_public_check
does not serve the same purpose asEC_KEY_check_key
.EVP_PKEY_public_check
validates only the resulting public component, and does not validate the private component. I believeEVP_PKEY_pairwise_check
is closer to the behavior ofEC_KEY_check_key
, where both the public and private components are validated, though it seems to assume the presence of a private component.Reproducer
OpenSSL 1.1.1
OpenSSL 3.0.2
The text was updated successfully, but these errors were encountered: