Class: HPKE::DHKEM::X25519

Inherits:
HPKE::DHKEM show all
Defined in:
lib/hpke/dhkem.rb

Instance Method Summary collapse

Methods inherited from HPKE::DHKEM

#auth_decap, #auth_encap, #auth_encap_fixed, #decap, #derive_key_pair, #deserialize_public_key, #encap, #encap_fixed, #generate_key_pair, #initialize, #serialize_public_key

Methods included from Util

#i2osp, #os2ip, #xor

Constructor Details

This class inherits a constructor from HPKE::DHKEM

Instance Method Details

#create_key_pair_from_secret(secret) ⇒ Object



295
296
297
298
299
300
301
302
303
304
305
# File 'lib/hpke/dhkem.rb', line 295

def create_key_pair_from_secret(secret)
  asn1_seq = OpenSSL::ASN1.Sequence([
    OpenSSL::ASN1.Integer(0),
    OpenSSL::ASN1.Sequence([
      OpenSSL::ASN1.ObjectId(asn1_oid)
    ]),
    OpenSSL::ASN1.OctetString("\x04\x20" + secret)
  ])

  OpenSSL::PKey.read(asn1_seq.to_der)
end

#kem_idObject



291
292
293
# File 'lib/hpke/dhkem.rb', line 291

def kem_id
  0x0020
end