struct uECC_HashContext

Defined at line 304 of file gen/third_party/micro-ecc/include/micro-ecc/uECC.h

uECC_HashContext structure.

This is used to pass in an arbitrary hash function to uECC_sign_deterministic().

The structure will be used for multiple hash computations; each time a new hash

is computed, init_hash() will be called, followed by one or more calls to

update_hash(), and finally a call to finish_hash() to produce the resulting hash.

The intention is that you will create a structure that includes uECC_HashContext

followed by any hash-specific data. For example:

typedef struct SHA256_HashContext {

uECC_HashContext uECC;

SHA256_CTX ctx;

} SHA256_HashContext;

void init_SHA256(uECC_HashContext *base) {

SHA256_HashContext *context = (SHA256_HashContext *)base;

SHA256_Init(

&context

->ctx);

}

void update_SHA256(uECC_HashContext *base,

const uint8_t *message,

unsigned message_size) {

SHA256_HashContext *context = (SHA256_HashContext *)base;

SHA256_Update(

&context

->ctx, message, message_size);

}

void finish_SHA256(uECC_HashContext *base, uint8_t *hash_result) {

SHA256_HashContext *context = (SHA256_HashContext *)base;

SHA256_Final(hash_result,

&context

->ctx);

}

... when signing ...

{

uint8_t tmp[32 + 32 + 64];

SHA256_HashContext ctx = {{

&init

_SHA256,

&update

_SHA256,

&finish

_SHA256, 64, 32, tmp}};

uECC_sign_deterministic(key, message_hash,

&ctx

.uECC, signature);

}

Public Members

void (*)(const struct uECC_HashContext *) init_hash
void (*)(const struct uECC_HashContext *, const uint8_t *, unsigned int) update_hash
void (*)(const struct uECC_HashContext *, uint8_t *) finish_hash
unsigned int block_size
unsigned int result_size
uint8_t * tmp