module JOSE::JWA::ECDH_ES

Overview

ECDH-ES key agreement with Concat KDF.

Defined in:

jose/jwa/ecdh_es.cr

Class Method Summary

Class Method Detail

def self.compute_shared_secret(our_private : LibCrypto::EC_KEY, their_public : LibCrypto::EC_KEY) : Bytes #

Computes ECDH shared secret between our private key and the other party's public key. Returns the x-coordinate (Z_AB) as bytes. Caller is responsible for freeing both keys if needed.


[View source]
def self.crv_for_nid(nid : Int32) : String #

Returns the JWK crv string for a curve nid.


[View source]
def self.derive_key(shared_secret : Bytes, algorithm : String, key_bits : Int32, apu : Bytes = Bytes.empty, apv : Bytes = Bytes.empty) : Bytes #

Derives a symmetric key via Concat KDF (SHA-256 single-pass).


[View source]
def self.ec_field_size(key : LibCrypto::EC_KEY) : Int32 #

Returns the field coordinate size in bytes for the curve of key.


[View source]
def self.ec_field_size_for_nid(nid : Int32) : Int32 #

Returns the field coordinate byte length for the given curve nid (32 for P-256, 48 for P-384, or 66 for P-521).


[View source]
def self.generate_ephemeral(nid : Int32) : LibCrypto::EC_KEY #

Generates a fresh ephemeral EC key pair for the given curve NID. Caller must free with LibCrypto.ec_key_free.


[View source]
def self.nid_for_crv(crv : String) : Int32 #

Returns the OpenSSL NID for the JWK crv string ("P-256", "P-384", or "P-521").


[View source]
def self.public_key_bytes(key : LibCrypto::EC_KEY) : Bytes #

Returns uncompressed public key bytes (04 ‖ x ‖ y) for an EC key.


[View source]