| 228 | } |
| 229 | |
| 230 | static void |
| 231 | ccp_init_hmac_digest(struct ccp_session *s, const char *key, int klen) |
| 232 | { |
| 233 | union authctx auth_ctx; |
| 234 | struct auth_hash *axf; |
| 235 | u_int i; |
| 236 | |
| 237 | /* |
| 238 | * If the key is larger than the block size, use the digest of |
| 239 | * the key as the key instead. |
| 240 | */ |
| 241 | axf = s->hmac.auth_hash; |
| 242 | if (klen > axf->blocksize) { |
| 243 | axf->Init(&auth_ctx); |
| 244 | axf->Update(&auth_ctx, key, klen); |
| 245 | axf->Final(s->hmac.ipad, &auth_ctx); |
| 246 | explicit_bzero(&auth_ctx, sizeof(auth_ctx)); |
| 247 | klen = axf->hashsize; |
| 248 | } else |
| 249 | memcpy(s->hmac.ipad, key, klen); |
| 250 | |
| 251 | memset(s->hmac.ipad + klen, 0, axf->blocksize - klen); |
| 252 | memcpy(s->hmac.opad, s->hmac.ipad, axf->blocksize); |
| 253 | |
| 254 | for (i = 0; i < axf->blocksize; i++) { |
| 255 | s->hmac.ipad[i] ^= HMAC_IPAD_VAL; |
| 256 | s->hmac.opad[i] ^= HMAC_OPAD_VAL; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | static bool |
| 261 | ccp_aes_check_keylen(int alg, int klen) |
no test coverage detected