MCPcopy Create free account
hub / github.com/F-Stack/f-stack / generate_partial_hash

Function generate_partial_hash

dpdk/drivers/crypto/ccp/ccp_crypto.c:440–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438}
439
440static int generate_partial_hash(struct ccp_session *sess)
441{
442
443 uint8_t ipad[sess->auth.block_size];
444 uint8_t opad[sess->auth.block_size];
445 uint8_t *ipad_t, *opad_t;
446 uint32_t *hash_value_be32, hash_temp32[8];
447 uint64_t *hash_value_be64, hash_temp64[8];
448 int i, count;
449 uint8_t *hash_value_sha3;
450
451 opad_t = ipad_t = (uint8_t *)sess->auth.key;
452
453 hash_value_be32 = (uint32_t *)((uint8_t *)sess->auth.pre_compute);
454 hash_value_be64 = (uint64_t *)((uint8_t *)sess->auth.pre_compute);
455
456 /* considering key size is always equal to block size of algorithm */
457 for (i = 0; i < sess->auth.block_size; i++) {
458 ipad[i] = (ipad_t[i] ^ HMAC_IPAD_VALUE);
459 opad[i] = (opad_t[i] ^ HMAC_OPAD_VALUE);
460 }
461
462 switch (sess->auth.algo) {
463 case CCP_AUTH_ALGO_SHA1_HMAC:
464 count = SHA1_DIGEST_SIZE >> 2;
465
466 if (partial_hash_sha1(ipad, (uint8_t *)hash_temp32))
467 return -1;
468 for (i = 0; i < count; i++, hash_value_be32++)
469 *hash_value_be32 = hash_temp32[count - 1 - i];
470
471 hash_value_be32 = (uint32_t *)((uint8_t *)sess->auth.pre_compute
472 + sess->auth.ctx_len);
473 if (partial_hash_sha1(opad, (uint8_t *)hash_temp32))
474 return -1;
475 for (i = 0; i < count; i++, hash_value_be32++)
476 *hash_value_be32 = hash_temp32[count - 1 - i];
477 return 0;
478 case CCP_AUTH_ALGO_SHA224_HMAC:
479 count = SHA256_DIGEST_SIZE >> 2;
480
481 if (partial_hash_sha224(ipad, (uint8_t *)hash_temp32))
482 return -1;
483 for (i = 0; i < count; i++, hash_value_be32++)
484 *hash_value_be32 = hash_temp32[count - 1 - i];
485
486 hash_value_be32 = (uint32_t *)((uint8_t *)sess->auth.pre_compute
487 + sess->auth.ctx_len);
488 if (partial_hash_sha224(opad, (uint8_t *)hash_temp32))
489 return -1;
490 for (i = 0; i < count; i++, hash_value_be32++)
491 *hash_value_be32 = hash_temp32[count - 1 - i];
492 return 0;
493 case CCP_AUTH_ALGO_SHA3_224_HMAC:
494 hash_value_sha3 = sess->auth.pre_compute;
495 if (partial_hash_sha3_224(ipad, hash_value_sha3))
496 return -1;
497

Callers 1

Calls 9

partial_hash_sha3_224Function · 0.85
partial_hash_sha3_256Function · 0.85
partial_hash_sha3_384Function · 0.85
partial_hash_sha3_512Function · 0.85
partial_hash_sha1Function · 0.70
partial_hash_sha224Function · 0.70
partial_hash_sha256Function · 0.70
partial_hash_sha384Function · 0.70
partial_hash_sha512Function · 0.70

Tested by

no test coverage detected