| 284 | } |
| 285 | |
| 286 | static void |
| 287 | swcr_authprepare(struct auth_hash *axf, struct swcr_auth *sw, |
| 288 | const uint8_t *key, int klen) |
| 289 | { |
| 290 | |
| 291 | switch (axf->type) { |
| 292 | case CRYPTO_SHA1_HMAC: |
| 293 | case CRYPTO_SHA2_224_HMAC: |
| 294 | case CRYPTO_SHA2_256_HMAC: |
| 295 | case CRYPTO_SHA2_384_HMAC: |
| 296 | case CRYPTO_SHA2_512_HMAC: |
| 297 | case CRYPTO_NULL_HMAC: |
| 298 | case CRYPTO_RIPEMD160_HMAC: |
| 299 | hmac_init_ipad(axf, key, klen, sw->sw_ictx); |
| 300 | hmac_init_opad(axf, key, klen, sw->sw_octx); |
| 301 | break; |
| 302 | case CRYPTO_POLY1305: |
| 303 | case CRYPTO_BLAKE2B: |
| 304 | case CRYPTO_BLAKE2S: |
| 305 | axf->Setkey(sw->sw_ictx, key, klen); |
| 306 | axf->Init(sw->sw_ictx); |
| 307 | break; |
| 308 | default: |
| 309 | panic("%s: algorithm %d doesn't use keys", __func__, axf->type); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | /* |
| 314 | * Compute or verify hash. |
no test coverage detected