Public EC key from buffer
Open
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 276
- Forks
- 200
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 7
Description
In net-ssh, there is following code:
public_key_oct = buffer.read_string
begin
key = OpenSSL::PKey::EC.new(OpenSSL::PKey::EC::CurveNameAlias[curve_name_in_key])
group = key.group
point = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new(public_key_oct, 2))
key.public_key = point
return key
rescue OpenSSL::PKey::ECError
raise NotImplementedError, "unsupported key type `#{type}'"
end
Which fails with OpenSSL 3.x:
1) Error:
Transport::Kex::TestEcdhSHA2NistP256#test_exchange_keys_should_return_expected_results_when_successful:
OpenSSL::PKey::PKeyError: pkeys are immutable on OpenSSL 3.0
/builddir/net-ssh/lib/net/ssh/transport/openssl.rb:164:in `public_key='
/builddir/net-ssh/lib/net/ssh/transport/openssl.rb:164:in `read_keyblob'
/builddir/net-ssh/lib/net/ssh/buffer.rb:325:in `read_keyblob'
/builddir/net-ssh/lib/net/ssh/buffer.rb:248:in `read_key'
/builddir/net-ssh/lib/net/ssh/transport/kex/abstract5656.rb:54:in `send_kexinit'
/builddir/net-ssh/lib/net/ssh/transport/kex/abstract.rb:48:in `exchange_keys'
/builddir/net-ssh/test/transport/kex/test_ecdh_sha2_nistp256.rb:96:in `exchange!'
/builddir/net-ssh/test/transport/kex/test_ecdh_sha2_nistp256.rb:18:in `test_exchange_keys_should_return_expected_results_when_successful'
Unfortunately, I struggle to find the right equivalent to implement this with immutable pkeys.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/net/ssh/transport/openssl.rb around the EC public-key construction and review how the immutable-key error occurs on OpenSSL 3.x. Run test/transport/kex/test_ecdh_sha2_nistp256.rb and use its failing exchange test to verify the supported equivalent is implemented and the key exchange succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- cryptography
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100