fix compile warnings, add flash locking

This commit is contained in:
Conor Patrick
2018-10-28 20:09:12 -04:00
parent 707a930d33
commit 5993aa792a
14 changed files with 107 additions and 69 deletions

View File

@@ -19,6 +19,7 @@
#include "ctap.h"
#include "device.h"
#include "app.h"
#include "log.h"
typedef enum
@@ -39,14 +40,6 @@ typedef enum
} mbedtls_ecp_group_id;
const uint8_t attestation_cert_der[];
const uint16_t attestation_cert_der_size;
const uint8_t attestation_key[];
const uint16_t attestation_key_size;
static SHA256_CTX sha256_ctx;
static const struct uECC_Curve_t * _es256_curve = NULL;
static const uint8_t * _signing_key = NULL;
@@ -105,10 +98,15 @@ void crypto_sha256_hmac_init(uint8_t * key, uint32_t klen, uint8_t * hmac)
key = master_secret;
klen = sizeof(master_secret)/2;
}
else if (key == CRYPTO_TRANSPORT_KEY)
{
key = transport_secret;
klen = 32;
}
if(klen > 64)
{
printf("Error, key size must be <= 64\n");
printf2(TAG_ERR, "Error, key size must be <= 64\n");
exit(1);
}
@@ -138,7 +136,7 @@ void crypto_sha256_hmac_final(uint8_t * key, uint32_t klen, uint8_t * hmac)
if(klen > 64)
{
printf("Error, key size must be <= 64\n");
printf2(TAG_ERR, "Error, key size must be <= 64\n");
exit(1);
}
memmove(buf, key, klen);
@@ -172,7 +170,7 @@ void crypto_ecc256_sign(uint8_t * data, int len, uint8_t * sig)
{
if ( uECC_sign(_signing_key, data, len, sig, _es256_curve) == 0)
{
printf("error, uECC failed\n");
printf2(TAG_ERR, "error, uECC failed\n");
exit(1);
}
}
@@ -209,19 +207,19 @@ void crypto_ecdsa_sign(uint8_t * data, int len, uint8_t * sig, int MBEDTLS_ECP_I
if (_key_len != 32) goto fail;
break;
default:
printf("error, invalid ECDSA alg specifier\n");
printf2(TAG_ERR, "error, invalid ECDSA alg specifier\n");
exit(1);
}
if ( uECC_sign(_signing_key, data, len, sig, curve) == 0)
{
printf("error, uECC failed\n");
printf2(TAG_ERR, "error, uECC failed\n");
exit(1);
}
return;
fail:
printf("error, invalid key length\n");
printf2(TAG_ERR, "error, invalid key length\n");
exit(1);
}
@@ -261,7 +259,7 @@ void crypto_ecc256_make_key_pair(uint8_t * pubkey, uint8_t * privkey)
{
if (uECC_make_key(pubkey, privkey, _es256_curve) != 1)
{
printf("Error, uECC_make_key failed\n");
printf2(TAG_ERR, "Error, uECC_make_key failed\n");
exit(1);
}
}
@@ -270,7 +268,7 @@ void crypto_ecc256_shared_secret(const uint8_t * pubkey, const uint8_t * privkey
{
if (uECC_shared_secret(pubkey, privkey, shared_secret, _es256_curve) != 1)
{
printf("Error, uECC_shared_secret failed\n");
printf2(TAG_ERR, "Error, uECC_shared_secret failed\n");
exit(1);
}