Skip to main content

Module gost3410

Module gost3410 

Source
Expand description

GOST R 34.10-2018 (256-bit) digital signatures — HLS mechanism 10.

No mature Rust crate implements the GOST elliptic-curve signature scheme, so it is provided here from scratch over the curve mandated by the DLMS GOST profile: id-tc26-gost-3410-2012-256-paramSetB, OID 1.2.643.7.1.2.1.1.2 (Р 1323565.1.024-2019, cryptographic suite 9). The message digest is Streebog-256 (GOST R 34.11-2018).

During the HLS handshake (Р 1323565.1, §7.5.3) the signed message is SystemTitle-a ‖ SystemTitle-b ‖ challenge_a ‖ challenge_b; each party signs with its own signing key d_sign and verifies the peer’s response with the peer’s verification key Q_sign.

Keys and signatures use the profile’s fixed-width big-endian encodings: d_sign is Vec256(d) (32 octets), the verification key is π_x(Q) ‖ π_y(Q) (64 octets), and a signature is Vec256(r) ‖ Vec256(s) (64 octets), matching GOST R 34.10 and the control examples in Р 1323565.1.

Structs§

Curve 🔒
Curve parameters of id-tc26-gost-3410-2012-256-paramSetB.

Enums§

GostError
Errors from GOST signing or verification.

Functions§

curve 🔒
gost_sign
Signs message with signing key d, drawing a random k from a secure RNG.
gost_sign_with_k
Signs message with signing key d (32-octet big-endian Vec256) using a caller-supplied k (32 octets, 1 ≤ k < q). Returns Vec256(r) ‖ Vec256(s).
gost_verify
Verifies signature sig (Vec256(r) ‖ Vec256(s), 64 octets) over message with verification key q_pub (π_x(Q) ‖ π_y(Q), 64 octets).
hash_to_int 🔒
Streebog-256 digest of message as an integer. GOST R 34.10 maps the hash vector to the integer α with the first digest octet least significant.
hexint 🔒
int_le 🔒
Decodes a little-endian Vec256 scalar/coordinate.
kdf_tree
KDF_TREE_GOSTR3411_2012_256 (R 50.1.113-2016 / RFC 7836) with a one-octet counter (R = 1).
mod_sub 🔒
modinv 🔒
Modular inverse of x mod m (m prime, x != 0).
point_add 🔒
Point addition on the short-Weierstrass curve y^2 = x^3 + a·x + b (mod p).
point_mul 🔒
Scalar multiplication k·point by double-and-add.
public_key
Derives the verification key π_x(Q) ‖ π_y(Q) (64 octets) from a signing key d (Vec256), where Q = d·P.
vec256 🔒
Encodes an integer as a 32-octet Vec256. The DLMS GOST profile (Р 1323565.1) uses little-endian byte order for scalars, coordinates and signature components, unlike the big-endian mathematical notation of the GOST R 34.10 standard itself.
vko
VKO_GOST3410_2012_256 key-agreement function (R 50.1.113-2016 / RFC 7836).

Type Aliases§

Point 🔒
Affine point on the curve; None is the point at infinity.