ddn.crypto.kex.ecdh

ECDH key agreement over NIST P-256 (secp256r1).

Implements Elliptic Curve Diffie-Hellman using the P-256 curve for TLS 1.3 key exchange. The shared secret is the x-coordinate of the resulting point, per SEC 1.

Types 1

structEcdhP256

ECDH key pair for P-256.

Holds the private scalar and public point. Use sharedSecret() to compute the ECDH shared secret with a peer's public key.

Fields
private BigInt d_
private Point Q_
Methods
EcdhP256 generate(SecureRandom rng)Generate a new random ECDH P-256 key pair.
ubyte[] sharedSecret(const(ubyte)[] peerX, const(ubyte)[] peerY)Compute the ECDH shared secret with a peer's public key.
ubyte[] publicKeyX() @propertyReturns: The public key x-coordinate as 32 bytes.
ubyte[] publicKeyY() @propertyReturns: The public key y-coordinate as 32 bytes.
ubyte[] publicKeyUncompressed() @propertyReturns: The raw public key as 65 bytes (0x04 || x || y).

Functions 3

private fnBigInt bytesToBigInt(const(ubyte)[] bytes) @safe pure
private fnubyte[] bigIntToFixedBytes(BigInt val, size_t len)
private fnubyte[] bigIntToBytesUnsigned(BigInt val)