Class: JWA::Algorithms::KeyManagement::EcdhEs
- Inherits:
-
Object
- Object
- JWA::Algorithms::KeyManagement::EcdhEs
- Defined in:
- lib/jwa/algorithms/key_management/ecdh_es.rb
Instance Method Summary collapse
- #decrypt(public_key) ⇒ Object
-
#encrypt(public_key) ⇒ Object
This is technically not an encryption, but to keep the same interface with other classes, let’s name it this way.
-
#initialize(ephemeral_key, enc_algorithm, apu, apv) ⇒ EcdhEs
constructor
A new instance of EcdhEs.
Constructor Details
#initialize(ephemeral_key, enc_algorithm, apu, apv) ⇒ EcdhEs
Returns a new instance of EcdhEs.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jwa/algorithms/key_management/ecdh_es.rb', line 11 def initialize(ephemeral_key, enc_algorithm, apu, apv) @ephemeral_key = ephemeral_key @key_length = enc_algorithm.key_length * 8 algorithm_id = length_encode(enc_algorithm.enc_name) apu = length_encode(apu) apv = length_encode(apv) supp_pub_info = [@key_length].pack('N') supp_priv_info = '' @info = algorithm_id + apu + apv + supp_pub_info + supp_priv_info end |
Instance Method Details
#decrypt(public_key) ⇒ Object
33 34 35 |
# File 'lib/jwa/algorithms/key_management/ecdh_es.rb', line 33 def decrypt(public_key) encrypt(public_key) end |
#encrypt(public_key) ⇒ Object
This is technically not an encryption, but to keep the same interface with other classes, let’s name it this way.
26 27 28 29 30 31 |
# File 'lib/jwa/algorithms/key_management/ecdh_es.rb', line 26 def encrypt(public_key) z = @ephemeral_key.dh_compute_key(public_key) concat_kdf = Support::ConcatKDF.new(Digest::SHA256.new) concat_kdf.run(z, @info, @key_length) end |