mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2024-09-20 11:20:08 +00:00
Increasing random buffer and checks.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
213b675b9f
commit
f1c0b12f5c
@ -420,7 +420,10 @@ static int cmd_reset_retry() {
|
||||
}
|
||||
|
||||
static int cmd_challenge() {
|
||||
res_APDU = (uint8_t *)random_bytes_get(apdu.expected_res_size);
|
||||
uint8_t *rb = (uint8_t *)random_bytes_get(apdu.expected_res_size);
|
||||
if (!rb)
|
||||
return SW_WRONG_LENGTH();
|
||||
res_APDU = rb;
|
||||
res_APDU_size = apdu.expected_res_size;
|
||||
return SW_OK();
|
||||
}
|
||||
|
@ -49,9 +49,12 @@ void random_fini (void)
|
||||
* Return pointer to random 32-byte
|
||||
*/
|
||||
void random_bytes_free (const uint8_t *p);
|
||||
#define MAX_RANDOM_BUFFER 1024
|
||||
const uint8_t * random_bytes_get (size_t len)
|
||||
{
|
||||
static uint32_t return_word[512/sizeof(uint32_t)];
|
||||
if (len > MAX_RANDOM_BUFFER)
|
||||
return NULL;
|
||||
static uint32_t return_word[MAX_RANDOM_BUFFER/sizeof(uint32_t)];
|
||||
for (int ix = 0; ix < len; ix += RANDOM_BYTES_LENGTH) {
|
||||
neug_wait_full ();
|
||||
memcpy(return_word+ix/sizeof(uint32_t), random_word, RANDOM_BYTES_LENGTH);
|
||||
|
Loading…
Reference in New Issue
Block a user