Increasing random buffer and checks.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -420,7 +420,10 @@ static int cmd_reset_retry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int cmd_challenge() {
|
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;
|
res_APDU_size = apdu.expected_res_size;
|
||||||
return SW_OK();
|
return SW_OK();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,12 @@ void random_fini (void)
|
|||||||
* Return pointer to random 32-byte
|
* Return pointer to random 32-byte
|
||||||
*/
|
*/
|
||||||
void random_bytes_free (const uint8_t *p);
|
void random_bytes_free (const uint8_t *p);
|
||||||
|
#define MAX_RANDOM_BUFFER 1024
|
||||||
const uint8_t * random_bytes_get (size_t len)
|
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) {
|
for (int ix = 0; ix < len; ix += RANDOM_BYTES_LENGTH) {
|
||||||
neug_wait_full ();
|
neug_wait_full ();
|
||||||
memcpy(return_word+ix/sizeof(uint32_t), random_word, RANDOM_BYTES_LENGTH);
|
memcpy(return_word+ix/sizeof(uint32_t), random_word, RANDOM_BYTES_LENGTH);
|
||||||
|
|||||||
Reference in New Issue
Block a user