class OpenSSL::PKey::EC

Defined in:

openssl_ext/pkey/ec.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class OpenSSL::PKey::PKey

finalize finalize, private? : Bool private?, public? public?, sign(digest, data) sign, to_der(io)
to_der
to_der
, to_pem(io : IO, cipher : OpenSSL::Cipher | Nil = nil, passphrase = nil)
to_pem(cipher : OpenSSL::Cipher, passphrase)
to_pem
to_pem
, to_unsafe : Pointer(LibCrypto::EvpPKey) to_unsafe, verify(digest, signature, data) verify

Constructor methods inherited from class OpenSSL::PKey::PKey

new(pkey : Pointer(LibCrypto::EvpPKey), is_private : Bool)
new(is_private : Bool)
new(encoded : String, passphrase = nil, is_private = true)
new(io : IO, passphrase = nil, is_private = true)
new

Constructor Detail

def self.new(key : String) #

[View source]
def self.new(io : IO) #

[View source]
def self.new(size : Int32) #

[View source]

Class Method Detail

def self.compute_shared_secret(private_key : OpenSSL::PKey::EC, peer_public_key : OpenSSL::PKey::EC) : Bytes #

OpenSSL 3.x ECDH using EVP_PKEY_derive Returns the raw ECDH shared secret (no KDF). Feed this into HKDF, etc.


[View source]
def self.from_private_bytes(bytes : Bytes, curve : String = "P-256") #

Create EC key from raw private key bytes For P-256, expects 32 bytes; for P-384, expects 48 bytes, etc.


[View source]
def self.from_public_bytes(bytes : Bytes, curve : String = "P-256") #

Create public key from raw bytes (uncompressed format: 0x04 + x + y)


[View source]
def self.generate(size : Int32) #

[View source]
def self.generate(type : String) #

[View source]
def self.generate_by_curve_name(curve_name : String) #

Generate EC key by curve name (supports non-NIST curves like secp256k1)


[View source]

Instance Method Detail

def ec_sign(data) #

[View source]
def ec_verify(digest, signature) #

[View source]
def group #

[View source]
def group_degree #

[View source]
def private_key_bytes : Bytes #

Export private key as raw bytes


[View source]
def public_key #

[View source]
def public_key_bytes : Bytes #

Export public key as raw bytes (uncompressed format: 0x04 + x + y)


[View source]
def to_der(io) #

[View source]
def to_pem(io) #

[View source]
def to_text #

[View source]