46static struct pt protothread;
48static uECC_Curve uecc_curve;
53csprng_adapter(uint8_t *dest,
unsigned size)
62 uECC_set_rng(csprng_adapter);
74 if(c == &ecc_curve_p_256) {
75 uecc_curve = uECC_secp256r1();
76 }
else if(c == &ecc_curve_p_192) {
77 uecc_curve = uECC_secp192r1();
87ecc_get_protothread(
void)
92PT_THREAD(ecc_validate_public_key(
const uint8_t *public_key,
97 *result = !uECC_valid_public_key(public_key, uecc_curve);
103ecc_compress_public_key(
const uint8_t *uncompressed_public_key,
104 uint8_t *compressed_public_key)
106 uECC_compress(uncompressed_public_key, compressed_public_key, uecc_curve);
109PT_THREAD(ecc_decompress_public_key(
const uint8_t *compressed_public_key,
110 uint8_t *uncompressed_public_key,
115 uECC_decompress(compressed_public_key,
116 uncompressed_public_key,
123PT_THREAD(ecc_sign(
const uint8_t *message_hash,
124 const uint8_t *private_key,
130 *result = !uECC_sign(private_key,
139PT_THREAD(ecc_verify(
const uint8_t *signature,
140 const uint8_t *message_hash,
141 const uint8_t *public_key,
146 *result = !uECC_verify(public_key,
155PT_THREAD(ecc_generate_key_pair(uint8_t *public_key,
156 uint8_t *private_key,
161 *result = !uECC_make_key(public_key,
168PT_THREAD(ecc_generate_shared_secret(
const uint8_t *public_key,
169 const uint8_t *private_key,
170 uint8_t *shared_secret,
175 *result = !uECC_shared_secret(public_key,
An OFB-AES-128-based CSPRNG.
bool csprng_rand(uint8_t *result, size_t len)
Generates a cryptographic random number.
void process_mutex_init(process_mutex_t *mutex)
Initializes a process mutex.
void process_mutex_unlock(process_mutex_t *mutex)
Unlocks a process mutex.
#define PT_BEGIN(pt)
Declare the start of a protothread inside the C function implementing the protothread.
#define PT_THREAD(name_args)
Declaration of a protothread.
#define PT_END(pt)
Declare the end of a protothread.
Platform-independent SHA-256 API.
Parameters of an ECC curve in little-endian word order.
const size_t bytes
Size of the curve in bytes.
Structure of a process mutex.