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
Public EC key from buffer #498
Comments
Coincidentally or not, I've been working on this exact part of the code and come up with the following solution: public_key_oct = buffer.read_string
begin
curvename = OpenSSL::PKey::EC::CurveNameAlias[curve_name_in_key]
group = OpenSSL::PKey::EC::Group.new(curvename)
point = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new(public_key_oct, 2))
asn1 = OpenSSL::ASN1::Sequence([
OpenSSL::ASN1::Sequence([
OpenSSL::ASN1::ObjectId("id-ecPublicKey"),
OpenSSL::ASN1::ObjectId(curvename)
]),
OpenSSL::ASN1::BitString(point.to_octet_string(:uncompressed))
])
key = OpenSSL::PKey::EC.new(asn1.to_der)
return key I'm not entirely sure whether this is the right solution, but it seems to be and it does fix the failing tests. |
ClearlyClaire
added a commit
to ClearlyClaire/cose-ruby
that referenced
this issue
Mar 15, 2022
PKey objects are immutable in OpenSSL 3.0, so the `to_pkey` methods had to be rewritten. Unfortunately, the `openssl` gem does not seem to provide a convenient way to build PKeys from individual parameters. Instead, this commits goes through ASN.1 representations of the keys, as suggested in ruby/openssl#498 (comment)
@sergiodj thank you so much for this! |
@sergiodj thank you for the code! You saved my evening of bashing my head against the weird #public_key APIs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In net-ssh, there is following code:
Which fails with OpenSSL 3.x:
Unfortunately, I struggle to find the right equivalent to implement this with immutable pkeys.
The text was updated successfully, but these errors were encountered: