31 #ifndef __BOLOS_CRYPTO_H__
33 #define __BOLOS_CRYPTO_H__
54 int bls_rng(uint8_t *buffer,
size_t len);
135 int bls_hash(bls_hash_t *hash,
int mode,
136 const uint8_t WIDE *in,
size_t len, uint8_t *out);
225 const uint8_t WIDE *in,
size_t len, uint8_t *mac);
817 const uint8_t WIDE *P,
const uint8_t WIDE *Q);
847 const uint8_t WIDE *rawkey,
size_t key_len,
876 const uint8_t WIDE *rawkey,
size_t key_len,
950 const uint8_t WIDE *hash,
size_t hash_len, uint8_t *sig);
983 const uint8_t WIDE *hash,
size_t hash_len, uint8_t *sig);
1016 const uint8_t WIDE *hash,
size_t hash_len, uint8_t *sig);
1049 const uint8_t WIDE *hash,
size_t hash_len, uint8_t *sig);
1085 const uint8_t WIDE *public_point, uint8_t *secret);
1108 uint16_t
bls_crc16(
const void WIDE *buffer,
size_t len);
1130 uint16_t
bls_crc16_update(
unsigned short crc,
const void WIDE *buffer,
size_t len);
1152 void bls_math_addm(uint8_t* r,
const uint8_t WIDE *a,
const uint8_t WIDE *b,
const uint8_t WIDE *m,
size_t len);
1168 int bls_math_cmp(
const uint8_t WIDE *a,
const uint8_t WIDE *b,
size_t len);
1194 const uint8_t WIDE *m,
size_t len_m);
1196 #endif //__BOLOS_CRYPTO_H__
void bls_math_modm(uint8_t *v, size_t len_v, const uint8_t WIDE *m, size_t len_m)
Reduce in place (left zero padded) the given value : v = v mod m.
int bls_math_cmp(const uint8_t WIDE *a, const uint8_t WIDE *b, size_t len)
Compare to unsigned long big-endian integer.
int bls_rsa_init_public_key(const bls_rsa_keypair_data_t WIDE *keyData, bls_rsa_abstract_public_key_t *key)
Initialize a public RSA Key.
int bls_ecfp_generate_pair(bls_curve_t curve, bls_ecfp_public_key_t *public_key, bls_ecfp_private_key_t *private_key, uint8_t *d)
Generate a ecfp key pair.
int bls_ecdsa_sign(bls_ecfp_private_key_t WIDE *key, int mode, bls_md_t hashID, const uint8_t WIDE *hash, size_t hash_len, uint8_t *sig)
Sign a hash message according to ECDSA scheme.
Definition: bolos_crypto_platform_tee.h:78
int bls_schnorr_verify(bls_ecfp_public_key_t WIDE *key, int mode, bls_md_t hashID, const uint8_t WIDE *hash, size_t hash_len, uint8_t *sig)
Verify a hash message signature according to Schnorr scheme.
uint8_t bls_rng_u8(void)
generate a random byte
int bls_aes_iv_gcm(bls_aes_key_t WIDE *key, int mode, const bls_area_t *in, const bls_area_t *iv, const bls_area_t WIDE *aadTag, bls_area_t *out)
Add data to an AES GCM operation.
int bls_des_iv(bls_des_key_t WIDE *key, int mode, const bls_area_t *iv, const bls_area_t *in, bls_area_t *out)
Add data to a DES operation using an Initialization Vector.
int bls_rsa_pub(bls_rsa_abstract_public_key_t WIDE *key, int mode, bls_md_t hashID, const bls_area_t *src, const bls_area_t *dest)
Perform a RSA public operation.
int bls_rsa_init_private_key(const bls_rsa_keypair_data_t WIDE *keyData, bls_rsa_abstract_private_key_t *key)
Initialize a private RSA Key.
int bls_sha512_init(bls_sha512_t *hash)
Initialize a sha512 context.
Definition: bolos_crypto_platform_tee.h:68
int bls_ecdsa_init_private_key(bls_curve_t curve, const uint8_t WIDE *rawkey, size_t key_len, bls_ecfp_private_key_t *key)
Initialize a private ECFP Key.
int bls_des(bls_des_key_t WIDE *key, int mode, const bls_area_t *in, bls_area_t *out)
Add data to a DES operation.
int bls_rsa_generate_keypair(int modulus_len, bls_rsa_abstract_private_key_t *privateKey, bls_rsa_abstract_public_key_t *publicKey, bls_rsa_keypair_data_t *generatedKeypairInfo)
Generate a RSA keypair.
Definition: bolos_crypto_platform_tee.h:140
uint16_t bls_crc16_update(unsigned short crc, const void WIDE *buffer, size_t len)
Update a 16 bits checksum value.
int bls_ecfp_add_point(const bls_curve_domain_t WIDE *domain, uint8_t *R, const uint8_t WIDE *P, const uint8_t WIDE *Q)
Add two affine point.
int bls_des_init_key(const uint8_t WIDE *rawkey, size_t key_len, bls_des_key_t *key)
Initialize a DES Key.
int bls_hmac_ripemd160_init(bls_hmac_ripemd160_t *hmac, const uint8_t WIDE *key, size_t key_len)
Initialize a HMAC sha512 context.
Definition: bolos_crypto_platform_tee.h:45
int bls_aes_init_key(const uint8_t WIDE *rawkey, size_t key_len, bls_aes_key_t *key)
Initialize an AES Key.
Definition: bolos_crypto_platform_tee.h:144
Definition: bolos_crypto_platform_tee.h:102
int bls_hmac(bls_hmac_t *hmac, int mode, const uint8_t WIDE *in, size_t len, uint8_t *mac)
Add more data to HMAC.
Definition: bolos_crypto_platform_tee.h:114
int bls_aes(bls_aes_key_t WIDE *key, int mode, const bls_area_t *in, bls_area_t *out)
Add data to an AES operation.
int bls_rng(uint8_t *buffer, size_t len)
generate a random buffer
int bls_math_is_zero(const uint8_t WIDE *a, size_t len)
Compare to unsigned long big-endian integer to zero.
Definition: bolos_crypto_platform_tee.h:125
Definition: bolos_crypto_common.h:216
int bls_rsa_init_private_key_crt(const bls_rsa_crt_t WIDE *crtParameters, bls_rsa_abstract_private_key_t *key)
Initialize a private RSA Key with CRT parameters.
Definition: bolos_crypto_platform_tee.h:130
Definition: bolos_crypto_common.h:202
int bls_ecdsa_init_public_key(bls_curve_t curve, const uint8_t WIDE *rawkey, size_t key_len, bls_ecfp_public_key_t *key)
Initialize a public ECFP Key.
Definition: bolos_crypto_platform_tee.h:40
int bls_schnorr_sign(bls_ecfp_private_key_t WIDE *key, int mode, bls_md_t hashID, const uint8_t WIDE *hash, size_t hash_len, uint8_t *sig)
Sign a hash message according to Schnorr scheme.
int bls_ecdsa_verify(bls_ecfp_public_key_t WIDE *key, int mode, bls_md_t hashID, const uint8_t WIDE *hash, size_t hash_len, uint8_t *sig)
Verify a hash message signature according to ECDSA scheme.
int bls_ecfp_is_valid_point(const bls_curve_domain_t WIDE *domain, const uint8_t WIDE *point)
Verify that a given point is really on the specified curve.
int bls_rsa_get_public_key_data(bls_rsa_abstract_public_key_t *publicKey, bls_rsa_keypair_data_t *keyInfo)
Retrieve a RSA public key information.
Definition: bolos_crypto_platform_tee.h:148
int bls_hash(bls_hash_t *hash, int mode, const uint8_t WIDE *in, size_t len, uint8_t *out)
Add more data to hash.
int bls_hmac_sha256_init(bls_hmac_sha256_t *hmac, const uint8_t WIDE *key, size_t key_len)
Initialize a HMAC sha256 context.
Definition: bolos_crypto_platform_tee.h:50
int bls_hmac_sha512_init(bls_hmac_sha512_t *hmac, const uint8_t WIDE *key, size_t key_len)
Initialize a HMAC sha512 context.
int bls_ecfp_get_public_component(const bls_ecfp_public_key_t *public_key, uint8_t *W)
Return the uncompressed point of a public ECFP Key.
int bls_pbkdf2(bls_md_t hash, const bls_area_t *password, const bls_area_t *salt, int iterations, uint8_t *out)
Stretch a password using PBKDF2.
Definition: bolos_crypto_platform_tee.h:63
int bls_aes_iv(bls_aes_key_t WIDE *key, int mode, const bls_area_t *iv, const bls_area_t *in, bls_area_t *out)
Add data to an AES operation using an Initialization Vector.
int bls_rsa_priv(bls_rsa_abstract_private_key_t WIDE *key, int mode, bls_md_t hashID, const bls_area_t *src, const bls_area_t *dest)
Perform a RSA private operation.
uint16_t bls_crc16(const void WIDE *buffer, size_t len)
Compute a 16 bits checksum value.
Describe a buffer and length data structure.
Definition: bolos_core.h:38
int bls_ripemd160_init(bls_ripemd160_t *hash)
Initialize a ripmd160 context.
bls_curve_domain_t WIDE * bls_ecfp_get_domain(bls_curve_t curve)
Retrieve the domain of the curve.
void bls_math_addm(uint8_t *r, const uint8_t WIDE *a, const uint8_t WIDE *b, const uint8_t WIDE *m, size_t len)
Modular addition of tow big integer of the size: r = a+b mod m.
int bls_ecdh(bls_ecfp_private_key_t WIDE *key, int mode, const uint8_t WIDE *public_point, uint8_t *secret)
Compute a shared secret according to ECDH specifiaction.
int bls_sha1_init(bls_sha1_t *hash)
Initialize a sha1 context.
int bls_sha256_init(bls_sha256_t *hash)
Initialize a sha256 context.
Definition: bolos_crypto_platform_tee.h:35
Definition: bolos_crypto_platform_tee.h:73