class
OpenSSL::PKey::EC
- OpenSSL::PKey::EC
- OpenSSL::PKey::PKey
- Reference
- Object
Defined in:
openssl_ext/pkey/ec.crConstructors
Class Method Summary
-
.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).
-
.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.
-
.from_public_bytes(bytes : Bytes, curve : String = "P-256")
Create public key from raw bytes (uncompressed format: 0x04 + x + y)
- .generate(size : Int32)
- .generate(type : String)
-
.generate_by_curve_name(curve_name : String)
Generate EC key by curve name (supports non-NIST curves like secp256k1)
Instance Method Summary
- #ec_sign(data)
- #ec_verify(digest, signature)
- #group
- #group_degree
-
#private_key_bytes : Bytes
Export private key as raw bytes
- #public_key
-
#public_key_bytes : Bytes
Export public key as raw bytes (uncompressed format: 0x04 + x + y)
- #to_der(io)
- #to_pem(io)
- #to_text
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
Class Method Detail
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.
def self.from_public_bytes(bytes : Bytes, curve : String = "P-256")
#
Create public key from raw bytes (uncompressed format: 0x04 + x + y)
def self.generate_by_curve_name(curve_name : String)
#
Generate EC key by curve name (supports non-NIST curves like secp256k1)