Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/safexcel/safexcel.c
Show First 20 Lines • Show All 1,312 Lines • ▼ Show 20 Lines | safexcel_setkey_xcbcmac(const uint8_t *key, int klen, uint32_t *hashkey) | ||||
memset(hashkey, 0, 2 * AES_BLOCK_LEN); | memset(hashkey, 0, 2 * AES_BLOCK_LEN); | ||||
off = 2 * AES_BLOCK_LEN / sizeof(uint32_t); | off = 2 * AES_BLOCK_LEN / sizeof(uint32_t); | ||||
for (i = 0; i < klen / sizeof(uint32_t); i++, key += 4) | for (i = 0; i < klen / sizeof(uint32_t); i++, key += 4) | ||||
hashkey[i + off] = htobe32(le32dec(key)); | hashkey[i + off] = htobe32(le32dec(key)); | ||||
} | } | ||||
static void | static void | ||||
safexcel_setkey_hmac_digest(struct auth_hash *ahash, union authctx *ctx, | safexcel_setkey_hmac_digest(const struct auth_hash *ahash, union authctx *ctx, | ||||
char *buf) | char *buf) | ||||
{ | { | ||||
int hashwords, i; | int hashwords, i; | ||||
switch (ahash->type) { | switch (ahash->type) { | ||||
case CRYPTO_SHA1_HMAC: | case CRYPTO_SHA1_HMAC: | ||||
hashwords = ahash->hashsize / sizeof(uint32_t); | hashwords = ahash->hashsize / sizeof(uint32_t); | ||||
for (i = 0; i < hashwords; i++) | for (i = 0; i < hashwords; i++) | ||||
Show All 25 Lines | |||||
/* | /* | ||||
* Pre-compute the inner and outer digests used in the HMAC algorithm. | * Pre-compute the inner and outer digests used in the HMAC algorithm. | ||||
*/ | */ | ||||
static void | static void | ||||
safexcel_setkey_hmac(const struct crypto_session_params *csp, | safexcel_setkey_hmac(const struct crypto_session_params *csp, | ||||
const uint8_t *key, int klen, uint8_t *ipad, uint8_t *opad) | const uint8_t *key, int klen, uint8_t *ipad, uint8_t *opad) | ||||
{ | { | ||||
union authctx ctx; | union authctx ctx; | ||||
struct auth_hash *ahash; | const struct auth_hash *ahash; | ||||
ahash = crypto_auth_hash(csp); | ahash = crypto_auth_hash(csp); | ||||
hmac_init_ipad(ahash, key, klen, &ctx); | hmac_init_ipad(ahash, key, klen, &ctx); | ||||
safexcel_setkey_hmac_digest(ahash, &ctx, ipad); | safexcel_setkey_hmac_digest(ahash, &ctx, ipad); | ||||
hmac_init_opad(ahash, key, klen, &ctx); | hmac_init_opad(ahash, key, klen, &ctx); | ||||
safexcel_setkey_hmac_digest(ahash, &ctx, opad); | safexcel_setkey_hmac_digest(ahash, &ctx, opad); | ||||
explicit_bzero(&ctx, ahash->ctxsize); | explicit_bzero(&ctx, ahash->ctxsize); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,256 Lines • Show Last 20 Lines |