summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/cr50/tpm2/aes.c6
-rw-r--r--chip/g/dcrypto/dcrypto.h4
-rw-r--r--chip/g/dcrypto/gcm.c6
3 files changed, 9 insertions, 7 deletions
diff --git a/board/cr50/tpm2/aes.c b/board/cr50/tpm2/aes.c
index cc4d83d7e7..5fe431222a 100644
--- a/board/cr50/tpm2/aes.c
+++ b/board/cr50/tpm2/aes.c
@@ -403,7 +403,8 @@ static void aes_command_handler(void *cmd_body,
size_t count;
struct GCM_CTX ctx;
- DCRYPTO_gcm_init(&ctx, key_local.b, iv_local.b, iv_len);
+ DCRYPTO_gcm_init(&ctx, key_len, key_local.b,
+ iv_local.b, iv_len);
DCRYPTO_gcm_aad(&ctx, aad, aad_len);
count = DCRYPTO_gcm_decrypt(
&ctx, out_local.b, sizeof(out_local.b),
@@ -437,7 +438,8 @@ static void aes_command_handler(void *cmd_body,
size_t count;
struct GCM_CTX ctx;
- DCRYPTO_gcm_init(&ctx, key_local.b, iv_local.b, iv_len);
+ DCRYPTO_gcm_init(&ctx, key_len, key_local.b,
+ iv_local.b, iv_len);
DCRYPTO_gcm_aad(&ctx, aad, aad_len);
count = DCRYPTO_gcm_encrypt(
&ctx, out_local.b, sizeof(out_local.b),
diff --git a/chip/g/dcrypto/dcrypto.h b/chip/g/dcrypto/dcrypto.h
index 7bab4b864b..1de0d63b03 100644
--- a/chip/g/dcrypto/dcrypto.h
+++ b/chip/g/dcrypto/dcrypto.h
@@ -80,8 +80,8 @@ struct GCM_CTX {
};
/* Initialize the GCM context structure. */
-void DCRYPTO_gcm_init(struct GCM_CTX *ctx, const uint8_t *key,
- const uint8_t *iv, size_t iv_len);
+void DCRYPTO_gcm_init(struct GCM_CTX *ctx, uint32_t key_bits,
+ const uint8_t *key, const uint8_t *iv, size_t iv_len);
/* Additional authentication data to include in the tag calculation. */
void DCRYPTO_gcm_aad(struct GCM_CTX *ctx, const uint8_t *aad_data, size_t len);
/* Encrypt & decrypt return the number of bytes written to out
diff --git a/chip/g/dcrypto/gcm.c b/chip/g/dcrypto/gcm.c
index 2caddf4741..cd035bbd54 100644
--- a/chip/g/dcrypto/gcm.c
+++ b/chip/g/dcrypto/gcm.c
@@ -82,8 +82,8 @@ static void gcm_init_iv(
}
}
-void DCRYPTO_gcm_init(struct GCM_CTX *ctx, const uint8_t *key,
- const uint8_t *iv, size_t iv_len)
+void DCRYPTO_gcm_init(struct GCM_CTX *ctx, uint32_t key_bits,
+ const uint8_t *key, const uint8_t *iv, size_t iv_len)
{
int i;
const uint32_t zero[4] = {0, 0, 0, 0};
@@ -93,7 +93,7 @@ void DCRYPTO_gcm_init(struct GCM_CTX *ctx, const uint8_t *key,
memset(ctx, 0, sizeof(struct GCM_CTX));
/* Initialize AES engine in CTR mode, and set the counter to 0. */
- DCRYPTO_aes_init(key, 128, (const uint8_t *) zero,
+ DCRYPTO_aes_init(key, key_bits, (const uint8_t *) zero,
CIPHER_MODE_CTR, ENCRYPT_MODE);
/* Set H to AES(ZERO). */
DCRYPTO_aes_block((const uint8_t *) zero, (uint8_t *) H);