Crypto API Reference
Contents
Crypto API Reference#
The Crypto API provides an abstraction layer with the cryptography implementation.
ED25519 Keypair#
-
struct iota_keypair_t#
Ed25519 Keypair.
Random Bytes#
-
void iota_crypto_randombytes(uint8_t *const buf, const size_t len)#
fill-in random bytes into the given byte buffer.
- Parameters
buf – [out] A buffer holds random bytes
len – [in] The length of byte buffer
ED25519 keypair#
-
void iota_crypto_keypair(uint8_t const seed[], iota_keypair_t *keypair)#
derives key pair from a given seed(IOTA_SEED_BYTES)
- Parameters
seed – [in] A given seed with length of IOTA_SEED_BYTES
keypair – [out] A keypair derived from the seed
ED25519 Signature#
-
int iota_crypto_sign(uint8_t const priv_key[], uint8_t msg[], size_t msg_len, uint8_t signature[])#
signs message by the given private key
- Parameters
priv_key – [in] The private key
msg – [in] A byte buffer holds the message data
msg_len – [in] The length of the message
signature – [out] The output signature
- Returns
int 0 on successful
HMAC-SHA-256#
-
int iota_crypto_hmacsha256(uint8_t const secret_key[], uint8_t msg[], size_t msg_len, uint8_t auth[])#
HMAC-SHA-256 interface.
- Parameters
secret_key – [in] The private/secret key
msg – [in] A buffer holds message data
msg_len – [in] The length of message
auth – [out] The output authentication
- Returns
int 0 on successful
HMAC-SHA-512#
-
int iota_crypto_hmacsha512(uint8_t const secret_key[], uint8_t msg[], size_t msg_len, uint8_t auth[])#
HMAC-SHA-512 interface.
- Parameters
secret_key – [in] The private/secret key
msg – [in] A buffer holds message data
msg_len – [in] The length of message
auth – [out] The output authentication
- Returns
int 0 on successful
SHA-256#
-
int iota_crypto_sha256(uint8_t const msg[], size_t msg_len, uint8_t hash[])#
SHA-256 HASH.
- Parameters
msg – [in] message data
msg_len – [in] the length of data
hash – [out] the output hash
- Returns
int 0 on success
SHA-512#
-
int iota_crypto_sha512(uint8_t const msg[], size_t msg_len, uint8_t hash[])#
SHA-512 HASH.
- Parameters
msg – [in] message data
msg_len – [in] the length of data
hash – [out] the output hash
- Returns
int 0 on success
Blake2b#
-
int iota_blake2b_sum(uint8_t const msg[], size_t msg_len, uint8_t out[], size_t out_len)#
Blake2b hash function.
- Parameters
msg – [in] The message to hash
msg_len – [in] The length of message
out – [out] An output hash
out_len – [out] The length of output hash
- Returns
int 0 on success
PBKDF2 HMAC#
-
int iota_crypto_pbkdf2_hmac_sha512(char const pwd[], size_t pwd_len, char const salt[], size_t salt_len, int32_t iterations, uint8_t dk[], size_t dk_len)#
PBKDF2 HMAC SHA512.
Ref: https://datatracker.ietf.org/doc/html/rfc2898#section-5.2
- Parameters
pwd – [in] password buffer, an octet string
pwd_len – [in] the length of password
salt – [in] salt buffer, an octet string
salt_len – [in] the length of salt
iterations – [in] iteration count, must be bigger than 0
dk – [out] derived key
dk_len – [in] the length of derived key
- Returns
int 0 on success