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();
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);
110 uint8_t *uncompressed_public_key,
115 uECC_decompress(compressed_public_key,
116 uncompressed_public_key,
124 const uint8_t *private_key,
130 *result = !uECC_sign(private_key,
140 const uint8_t *message_hash,
141 const uint8_t *public_key,
146 *result = !uECC_verify(public_key,
156 uint8_t *private_key,
161 *result = !uECC_make_key(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.
char ecc_verify(const uint8_t *signature, const uint8_t *message_hash, const uint8_t *public_key, int *const result)
char ecc_decompress_public_key(const uint8_t *compressed_public_key, uint8_t *uncompressed_public_key, int *const result)
char ecc_generate_key_pair(uint8_t *public_key, uint8_t *private_key, int *const result)
char ecc_sign(const uint8_t *message_hash, const uint8_t *private_key, uint8_t *signature, int *const result)
char ecc_generate_shared_secret(const uint8_t *public_key, const uint8_t *private_key, uint8_t *shared_secret, int *const result)
char ecc_validate_public_key(const uint8_t *public_key, int *const result)
void ecc_disable(void)
Shuts down the ECC driver and unlocks the mutex.
void ecc_init(void)
Initializes ECC.
process_mutex_t * ecc_get_mutex(void)
Provides a mutex to be locked before proceeding with ecc_enable().
struct pt * ecc_get_protothread(void)
Provides the protothread that runs long-running ECC operations.
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.
Structure of a process mutex.