Elliptic Curve Digital Signature Algorithm per SEC 2.0 section 4.1. See: - [[ https://secg.org/sec1-v2.pdf ]]

Collection Info

View Source
Collection
core
Path
crypto/ecdsa
Entries
23

Source Files

Types

3

Curve #

Source
Curve :: Curve

Curve the curve identifier associated with a given Private_Key or Public_Key

Procedures

16

private_key_bytes #

Source
private_key_bytes :: proc(priv_key: ^Private_Key, dst: []u8) {…}

private_key_bytes sets dst to byte-encoding of priv_key.

private_key_clear #

Source
private_key_clear :: proc "contextless" (priv_key: ^Private_Key) {…}

private_key_clear clears priv_key to the uninitialized state.

private_key_equal #

Source
private_key_equal :: proc(p, q: ^Private_Key) -> bool {…}

private_key_equal returns true if and only if (⟺) the private keys are equal, in constant time.

private_key_generate #

Source
private_key_generate :: proc(priv_key: ^Private_Key, curve: Curve) -> bool {…}

private_key_generate uses the system entropy source to generate a new Private_Key. This will only fail if and only if (⟺) the system entropy source is missing or broken.

private_key_set_bytes #

Source
private_key_set_bytes :: proc(priv_key: ^Private_Key, curve: Curve, b: []u8) -> bool {…}

private_key_set_bytes decodes a byte-encoded private key, and returns true if and only if (⟺) the operation was successful.

public_key_bytes #

Source
public_key_bytes :: proc(pub_key: ^Public_Key, dst: []u8) {…}

public_key_bytes sets dst to byte-encoding of pub_key.

public_key_clear #

Source
public_key_clear :: proc "contextless" (pub_key: ^Public_Key) {…}

public_key_clear clears pub_key to the uninitialized state.

public_key_equal #

Source
public_key_equal :: proc(p, q: ^Public_Key) -> bool {…}

public_key_equal returns true if and only if (⟺) the public keys are equal, in constant time.

public_key_set_bytes #

Source
public_key_set_bytes :: proc(pub_key: ^Public_Key, curve: Curve, b: []u8) -> bool {…}

public_key_set_bytes decodes a byte-encoded public key, and returns true if and only if (⟺) the operation was successful.

public_key_set_priv #

Source
public_key_set_priv :: proc(pub_key: ^Public_Key, priv_key: ^Private_Key) {…}

public_key_set_priv sets pub_key to the public component of priv_key.

sign_asn1 #

Source
@(require_results)
sign_asn1 :: proc(priv_key: ^Private_Key, hash_algo: Algorithm, msg: []u8, allocator: Allocator, deterministic: bool = !crypto.HAS_RAND_BYTES) -> ([]u8, bool) {…}

sign_asn1 returns the signature by priv_key over msg hased using hash_algo using the signing procedure as specified in SEC 1, Version 2.0, Section 4.1.3. ASN.1 DER requires minimal encoding, and the format is clunky and variable-length so for simplicity we allocate the signature. The signature format is ASN1. `SEQUECE `{ r INTEGER, s INTEGER }`.

sign_raw #

Source
@(require_results)
sign_raw :: proc(priv_key: ^Private_Key, hash_algo: Algorithm, msg, sig: []u8, deterministic: bool = !crypto.HAS_RAND_BYTES) -> bool {…}

sign_raw writes the signature by priv_key over msg hased using hash_algo to sig, using the signing procedure as specified in SEC 1, Version 2.0, Section 4.1.3. The signature format is `r | s`.

verify_asn1 #

Source
@(require_results)
verify_asn1 :: proc(pub_key: ^Public_Key, hash_algo: Algorithm, msg, sig: []u8) -> bool {…}

verify_asn1 returns true if and only if (⟺) sig is a valid signature by pub_key over msg, hased using hash_algo, per the verification procedure specifed in SEC 1, Version 2.0, Section 4.1.4. The signature format is ASN.1 `SEQUENCE { r INTEGER, s INTEGER }`.

verify_raw #

Source
@(require_results)
verify_raw :: proc(pub_key: ^Public_Key, hash_algo: Algorithm, msg, sig: []u8) -> bool {…}

verify_raw returns true if and only if (⟺) sig is a valid signature by pub_key over msg, hased using hash_algo, per the verification procedure specifed in SEC 1, Version 2.0, Section 4.1.4. The signature format is `r | s`.

Variables

4

CURVE_NAMES #

Source
CURVE_NAMES: [Curve]string = [Curve]string{.Invalid = "Invalid", .SECP256R1 = "secp256r1", .SECP384R1 = "secp384r1"}

CURVE_NAMES is the Curve to curve name string.

PRIVATE_KEY_SIZES #

Source
PRIVATE_KEY_SIZES: [Curve]int = [Curve]int{.Invalid = 0, .SECP256R1 = secec.SC_SIZE_P256R1, .SECP384R1 = secec.SC_SIZE_P384R1}

PRIVATE_KEY_SIZES is the Curve to private key size in bytes.

PUBLIC_KEY_SIZES #

Source
PUBLIC_KEY_SIZES: [Curve]int = [Curve]int{.Invalid = 0, .SECP256R1 = 1 + 2 * secec.FE_SIZE_P256R1, .SECP384R1 = 1 + 2 * secec.FE_SIZE_P384R1}

PUBLIC_KEY_SIZES is the Curve to public key size in bytes.

RAW_SIGNATURE_SIZES #

Source
RAW_SIGNATURE_SIZES: [Curve]int = [Curve]int{.Invalid = 0, .SECP256R1 = 2 * secec.SC_SIZE_P256R1, .SECP384R1 = 2 * secec.SC_SIZE_P384R1}

RAW_SIGNATURE_SIZES is the Curve to "raw" signature size in bytes.