Changeset View
Changeset View
Standalone View
Standalone View
sys/crypto/ccp/ccp_hardware.c
Show First 20 Lines • Show All 1,350 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
ccp_collect_iv(struct cryptop *crp, const struct crypto_session_params *csp, | ccp_collect_iv(struct cryptop *crp, const struct crypto_session_params *csp, | ||||
char *iv) | char *iv) | ||||
{ | { | ||||
crypto_read_iv(crp, iv); | crypto_read_iv(crp, iv); | ||||
/* | /* | ||||
* If the input IV is 12 bytes, append an explicit counter of 1. | * Append an explicit counter of 1 for GCM. | ||||
*/ | */ | ||||
if (csp->csp_cipher_alg == CRYPTO_AES_NIST_GCM_16 && | if (csp->csp_cipher_alg == CRYPTO_AES_NIST_GCM_16) | ||||
csp->csp_ivlen == 12) | |||||
*(uint32_t *)&iv[12] = htobe32(1); | *(uint32_t *)&iv[12] = htobe32(1); | ||||
if (csp->csp_cipher_alg == CRYPTO_AES_XTS && | if (csp->csp_cipher_alg == CRYPTO_AES_XTS && | ||||
csp->csp_ivlen < AES_BLOCK_LEN) | csp->csp_ivlen < AES_BLOCK_LEN) | ||||
memset(&iv[csp->csp_ivlen], 0, AES_BLOCK_LEN - csp->csp_ivlen); | memset(&iv[csp->csp_ivlen], 0, AES_BLOCK_LEN - csp->csp_ivlen); | ||||
/* Reverse order of IV material for HW */ | /* Reverse order of IV material for HW */ | ||||
INSECURE_DEBUG(NULL, "%s: IV: %16D len: %u\n", __func__, iv, " ", | INSECURE_DEBUG(NULL, "%s: IV: %16D len: %u\n", __func__, iv, " ", | ||||
▲ Show 20 Lines • Show All 737 Lines • Show Last 20 Lines |