facil.io

#./fio-stl/154 p256.h

5 public symbols.

#Functions

#fio_ecdsa_p256_verify

c
int fio_ecdsa_p256_verify(const uint8_t *sig, size_t sig_len, const uint8_t *msg_hash, const uint8_t *pubkey, size_t pubkey_len)

Verifies an ECDSA P-256 signature.

Parameters:

  • sig - DER-encoded signature (SEQUENCE { r INTEGER, s INTEGER })
  • sig_len - Length of signature in bytes
  • msg_hash - SHA-256 hash of the message (32 bytes)
  • pubkey - Uncompressed public key (65 bytes: 0x04 || x || y)
  • pubkey_len - Length of public key (must be 65)

Returns:

  • 0 on success (valid signature), -1 on failure (invalid signature)

Symbol type: function

#fio_ecdsa_p256_sign

c
int fio_ecdsa_p256_sign(uint8_t *sig, size_t *sig_len, size_t sig_capacity, const uint8_t msg_hash[32], const uint8_t secret_key[32])

Signs a message hash using ECDSA P-256.

Parameters:

  • sig - Output: DER-encoded signature (max 72 bytes)
  • sig_len - Output: actual signature length
  • sig_capacity - Capacity of signature buffer (should be >= 72)
  • msg_hash - SHA-256 hash of the message (32 bytes)
  • secret_key - 32-byte secret key (scalar, big-endian)

Returns:

  • 0 on success, -1 on failure

Symbol type: function

#fio_ecdsa_p256_verify_raw

c
int fio_ecdsa_p256_verify_raw(const uint8_t r[32], const uint8_t s[32], const uint8_t msg_hash[32], const uint8_t pubkey_x[32], const uint8_t pubkey_y[32])

Verifies an ECDSA P-256 signature with raw r,s values.

Parameters:

  • r - The r component of the signature (32 bytes, big-endian)
  • s - The s component of the signature (32 bytes, big-endian)
  • msg_hash - SHA-256 hash of the message (32 bytes)
  • pubkey_x - X coordinate of public key (32 bytes, big-endian)
  • pubkey_y - Y coordinate of public key (32 bytes, big-endian)

Returns:

  • 0 on success (valid signature), -1 on failure (invalid signature)

Symbol type: function

#fio_p256_keypair

c
int fio_p256_keypair(uint8_t secret_key[32], uint8_t public_key[65])

Generates a P-256 keypair for ECDHE key exchange.

Parameters:

  • secret_key - Output: 32-byte secret key (scalar, big-endian)
  • public_key - Output: 65-byte uncompressed public key (0x04 || x || y)

Returns:

  • 0 on success, -1 on failure

Symbol type: function

#fio_p256_shared_secret

c
int fio_p256_shared_secret(uint8_t shared_secret[32], const uint8_t secret_key[32], const uint8_t *their_public_key, size_t their_public_key_len)

Computes P-256 ECDH shared secret.

Parameters:

  • shared_secret - Output: 32-byte shared secret (x-coordinate of result)
  • secret_key - 32-byte secret key (scalar, big-endian)
  • their_public_key - Their public key (uncompressed 65 bytes, or compressed 33 bytes)
  • their_public_key_len - Length of their public key (33 or 65)

Returns:

  • 0 on success, -1 on failure (invalid key, point at infinity, etc.)

Symbol type: function