ddn.crypto.key.ecdsa
ECDSA Keys and Curve Parameters.
Types 5
structCurveParams
Holds the domain parameters for a named elliptic curve.
Curve parameters are accessed via lazy-initialisation functions
curveP256, curveP384, and curveP521, each of
which returns a ref CurveParams. This avoids both DMD's unreliable static member initialisation and the module-level static this() construction-order problems that caused curve parameters to appear as zero when accessed from other modules' unittests.
structCurveDescriptor
Lightweight curve descriptor returned by getCurveDescriptor.
Holds the domain parameters for a named elliptic curve so that curve-agnostic code can look up the prime modulus p, coefficient a, base-point coordinates gx/gy, and order n by name rather than referring to a specific CurveParams instance.
Fields
string nameThe standard curve name (e.g. "P-256", "P-384", "P-521").BigInt pThe field prime modulus.BigInt aThe Weierstrass coefficient a (always −3 for NIST P-curves).BigInt bThe Weierstrass coefficient b.BigInt gxThe base-point (generator) x-coordinate.BigInt gyThe base-point (generator) y-coordinate.BigInt nThe order of the base point.structPoint
Methods
classECDSAPublicKey : PublicKey
classECDSAPrivateKey : PrivateKey
Functions 14
private fn
ubyte[] bigIntToBytes(BigInt val) @safeConverts a non-negative BigInt to minimal big-endian unsigned bytes.private fn
BigInt bytesToBigInt(const(ubyte)[] bytes) @safeConverts big-endian unsigned bytes to a BigInt.private fn
size_t curveFieldLength(string name) pure @safeReturns the byte length of the curve field element.fn
CurveParams curveP256() ref @trustedReturns the P-256 (secp256r1) curve parameters, initialising on first call. `p = 2^256 − 2^224 + 2^192 + 2^96 − 1`.fn
CurveParams curveP384() ref @trustedReturns the P-384 (secp384r1) curve parameters, initialising on first call. `p = 2^384 − 2^128 − 2^96 + 2^32 − 1`.fn
CurveParams curveP521() ref @trustedReturns the P-521 (secp521r1) curve parameters, initialising on first call. `p = 2^521 − 1` (Mersenne prime).fn
CurveDescriptor getCurveDescriptor(string name) @safeLooks up the domain parameters for a named elliptic curve.fn
ubyte[] encodeEcdsaSpki(ECDSAPublicKey key)Encodes an ECDSA public key as a DER-encoded SubjectPublicKeyInfo (SPKI) per RFC 5480.fn
ECDSAPublicKey decodeEcdsaSpki(const(ubyte)[] der)Decodes an ECDSA public key from DER-encoded SubjectPublicKeyInfo (SPKI).fn
ubyte[] encodeEcdsaPrivateKey(ECDSAPrivateKey key,
ECDSAPublicKey publicKey = null)Encodes an ECDSA private key in SEC 1 / RFC 5915 format.fn
ECDSAPrivateKey decodeEcdsaPrivateKey(const(ubyte)[] der)Decodes an ECDSA private key from SEC 1 / RFC 5915 format.Variables 6
private var
bool curveP256Init_private var
bool curveP384Init_private var
bool curveP521Init_