summaryrefslogtreecommitdiff
path: root/board/cr50/u2f.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/cr50/u2f.c')
-rw-r--r--board/cr50/u2f.c79
1 files changed, 1 insertions, 78 deletions
diff --git a/board/cr50/u2f.c b/board/cr50/u2f.c
index 12af471ff9..750708012b 100644
--- a/board/cr50/u2f.c
+++ b/board/cr50/u2f.c
@@ -54,14 +54,6 @@ enum touch_state pop_check_presence(int consume)
return recent ? POP_TOUCH_YES : POP_TOUCH_NO;
}
-/* ---- non-volatile U2F state ---- */
-
-struct u2f_state {
- uint32_t salt[8];
- uint32_t salt_kek[8];
- uint32_t salt_kh[8];
-};
-
static const uint8_t k_salt = NVMEM_VAR_G2F_SALT;
static const uint8_t k_salt_deprecated = NVMEM_VAR_U2F_SALT;
@@ -138,7 +130,7 @@ static int load_state(struct u2f_state *state)
return 1;
}
-static struct u2f_state *get_state(void)
+struct u2f_state *get_state(void)
{
static int state_loaded;
static struct u2f_state state;
@@ -166,54 +158,6 @@ static int _derive_key(enum dcrypto_appid appid, const uint32_t input[8],
return result;
}
-int u2f_origin_user_keyhandle(const uint8_t *origin, const uint8_t *user,
- const uint8_t *origin_seed,
- struct u2f_key_handle *key_handle)
-{
- LITE_HMAC_CTX ctx;
- struct u2f_state *state = get_state();
-
- if (!state)
- return EC_ERROR_UNKNOWN;
-
- memcpy(key_handle->origin_seed, origin_seed, P256_NBYTES);
-
- DCRYPTO_HMAC_SHA256_init(&ctx, state->salt_kek, SHA256_DIGEST_SIZE);
- HASH_update(&ctx.hash, origin, P256_NBYTES);
- HASH_update(&ctx.hash, user, P256_NBYTES);
- HASH_update(&ctx.hash, origin_seed, P256_NBYTES);
-
- memcpy(key_handle->hmac, DCRYPTO_HMAC_final(&ctx), SHA256_DIGEST_SIZE);
-
- return EC_SUCCESS;
-}
-
-int u2f_origin_user_versioned_keyhandle(
- const uint8_t *origin, const uint8_t *user, const uint8_t *origin_seed,
- uint8_t version,
- struct u2f_versioned_key_handle_header *key_handle_header)
-{
- LITE_HMAC_CTX ctx;
- struct u2f_state *state = get_state();
-
- if (!state)
- return EC_ERROR_UNKNOWN;
-
- key_handle_header->version = version;
- memcpy(key_handle_header->origin_seed, origin_seed, P256_NBYTES);
-
- DCRYPTO_HMAC_SHA256_init(&ctx, state->salt_kek, SHA256_DIGEST_SIZE);
- HASH_update(&ctx.hash, origin, P256_NBYTES);
- HASH_update(&ctx.hash, user, P256_NBYTES);
- HASH_update(&ctx.hash, origin_seed, P256_NBYTES);
- HASH_update(&ctx.hash, &version, sizeof(key_handle_header->version));
-
- memcpy(key_handle_header->kh_hmac, DCRYPTO_HMAC_final(&ctx),
- SHA256_DIGEST_SIZE);
-
- return EC_SUCCESS;
-}
-
int u2f_origin_user_keypair(const uint8_t *key_handle, size_t key_handle_size,
p256_int *d, p256_int *pk_x, p256_int *pk_y)
{
@@ -241,27 +185,6 @@ int u2f_origin_user_keypair(const uint8_t *key_handle, size_t key_handle_size,
return EC_SUCCESS;
}
-int u2f_authorization_hmac(const uint8_t *authorization_salt,
- const struct u2f_versioned_key_handle_header *header,
- const uint8_t *auth_time_secret_hash, uint8_t *hmac)
-{
- LITE_HMAC_CTX ctx;
- struct u2f_state *state = get_state();
-
- if (!state)
- return EC_ERROR_UNKNOWN;
-
- DCRYPTO_HMAC_SHA256_init(&ctx, state->salt_kek, SHA256_DIGEST_SIZE);
- HASH_update(&ctx.hash, authorization_salt, U2F_AUTHORIZATION_SALT_SIZE);
- HASH_update(&ctx.hash, (uint8_t *)header,
- sizeof(struct u2f_versioned_key_handle_header));
- HASH_update(&ctx.hash, auth_time_secret_hash, SHA256_DIGEST_SIZE);
-
- memcpy(hmac, DCRYPTO_HMAC_final(&ctx), SHA256_DIGEST_SIZE);
-
- return EC_SUCCESS;
-}
-
int u2f_gen_kek(const uint8_t *origin, uint8_t *kek, size_t key_len)
{
uint32_t buf[P256_NDIGITS];