Skip to content

Commit

Permalink
support INTL fw
Browse files Browse the repository at this point in the history
  • Loading branch information
onlykey committed Feb 1, 2018
1 parent 67aa379 commit ccf5054
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
24 changes: 24 additions & 0 deletions onlykey/okcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ uint8_t CRYPTO_AUTH = 0;
/*************************************/
float temperaturev;
/*************************************/
/*************************************/
//RNG Assignments
/*************************************/
size_t length = 48; // First block should wait for the pool to fill up.

void recvmsg() {
int n;
Expand Down Expand Up @@ -4244,9 +4248,11 @@ bool wipebuffersafter5sec(Task* me) {
if (configmode==false) {
packet_buffer_offset = 0;
memset(packet_buffer, 0, sizeof(packet_buffer));
#ifdef US_VERSION
extern int large_resp_buffer_offset;
large_resp_buffer_offset = 0;
memset(large_resp_buffer, 0, sizeof(large_resp_buffer));
#endif
CRYPTO_AUTH = 0;
Challenge_button1 = 0;
Challenge_button2 = 0;
Expand Down Expand Up @@ -5300,3 +5306,21 @@ void temp_voltage () {
#endif
}

int RNG2(uint8_t *dest, unsigned size) {
// Generate output whenever 32 bytes of entropy have been accumulated.
// The first time through, we wait for 48 bytes for a full entropy pool.
while (!RNG.available(length)) {
//Serial.println("waiting for random number");
rngloop(); //Gather entropy
}
RNG.rand(dest, size);
length = 32;
#ifdef DEBUG
Serial.println();
Serial.print("Generating random number of size = ");
Serial.print(size);
byteprint(dest, size);
#endif
return 1;
}

1 change: 1 addition & 0 deletions onlykey/okcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ extern void SETECCPRIV (uint8_t *buffer);
extern void RESTORE (uint8_t *buffer);
extern void process_packets (uint8_t *buffer);
extern void temp_voltage ();
extern int RNG2(uint8_t *dest, unsigned size);

#ifdef __cplusplus
}
Expand Down
22 changes: 0 additions & 22 deletions onlykey/okcrypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@

#ifdef US_VERSION

/*************************************/
//RNG Assignments
/*************************************/
size_t length = 48; // First block should wait for the pool to fill up.
/*************************************/
//RSA assignments
/*************************************/
Expand Down Expand Up @@ -1110,24 +1106,6 @@ int mbedtls_rand( void *rng_state, unsigned char *output, size_t len )
return( 0 );
}

int RNG2(uint8_t *dest, unsigned size) {
// Generate output whenever 32 bytes of entropy have been accumulated.
// The first time through, we wait for 48 bytes for a full entropy pool.
while (!RNG.available(length)) {
//Serial.println("waiting for random number");
rngloop(); //Gather entropy
}
RNG.rand(dest, size);
length = 32;
#ifdef DEBUG
Serial.println();
Serial.print("Generating random number of size = ");
Serial.print(size);
byteprint(dest, size);
#endif
return 1;
}

void newhope_test ()
{
int i;
Expand Down
1 change: 0 additions & 1 deletion onlykey/okcrypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ extern int rsa_sign (int mlen, const uint8_t *msg, uint8_t *out);
extern void rsa_getpub (uint8_t type);
extern bool is_bit_set(unsigned char byte, int index);
extern int mbedtls_rand( void *rng_state, unsigned char *output, size_t len);
extern int RNG2(uint8_t *dest, unsigned size);
extern int rsa_encrypt (int len, const uint8_t *in, uint8_t *out);
extern int shared_secret (uint8_t *pub, uint8_t *secret);
extern void aes_crypto_box (uint8_t *buffer, int len, bool open);
Expand Down
2 changes: 1 addition & 1 deletion onlykey/onlykey.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define ONLYKEY_H

#define DEBUG //Enable Serial Monitor
#define US_VERSION //Define for US Version Firmare
//#define US_VERSION //Define for US Version Firmare
//#define OK_Color //Color Version

#ifndef OKCORE_H
Expand Down

0 comments on commit ccf5054

Please sign in to comment.