| 751 | } |
| 752 | |
| 753 | static int |
| 754 | ccp_configure_session_auth(struct ccp_session *sess, |
| 755 | const struct rte_crypto_sym_xform *xform) |
| 756 | { |
| 757 | const struct rte_crypto_auth_xform *auth_xform = NULL; |
| 758 | size_t i; |
| 759 | |
| 760 | auth_xform = &xform->auth; |
| 761 | |
| 762 | sess->auth.digest_length = auth_xform->digest_length; |
| 763 | if (auth_xform->op == RTE_CRYPTO_AUTH_OP_GENERATE) |
| 764 | sess->auth.op = CCP_AUTH_OP_GENERATE; |
| 765 | else |
| 766 | sess->auth.op = CCP_AUTH_OP_VERIFY; |
| 767 | switch (auth_xform->algo) { |
| 768 | case RTE_CRYPTO_AUTH_MD5_HMAC: |
| 769 | if (sess->auth_opt) { |
| 770 | sess->auth.algo = CCP_AUTH_ALGO_MD5_HMAC; |
| 771 | sess->auth.offset = ((CCP_SB_BYTES << 1) - |
| 772 | MD5_DIGEST_SIZE); |
| 773 | sess->auth.key_length = auth_xform->key.length; |
| 774 | sess->auth.block_size = MD5_BLOCK_SIZE; |
| 775 | memset(sess->auth.key, 0, sess->auth.block_size); |
| 776 | rte_memcpy(sess->auth.key, auth_xform->key.data, |
| 777 | auth_xform->key.length); |
| 778 | } else |
| 779 | return -1; /* HMAC MD5 not supported on CCP */ |
| 780 | break; |
| 781 | case RTE_CRYPTO_AUTH_SHA1: |
| 782 | sess->auth.engine = CCP_ENGINE_SHA; |
| 783 | sess->auth.algo = CCP_AUTH_ALGO_SHA1; |
| 784 | sess->auth.ut.sha_type = CCP_SHA_TYPE_1; |
| 785 | sess->auth.ctx = (void *)ccp_sha1_init; |
| 786 | sess->auth.ctx_len = CCP_SB_BYTES; |
| 787 | sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE; |
| 788 | break; |
| 789 | case RTE_CRYPTO_AUTH_SHA1_HMAC: |
| 790 | if (sess->auth_opt) { |
| 791 | if (auth_xform->key.length > SHA1_BLOCK_SIZE) |
| 792 | return -1; |
| 793 | sess->auth.algo = CCP_AUTH_ALGO_SHA1_HMAC; |
| 794 | sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE; |
| 795 | sess->auth.block_size = SHA1_BLOCK_SIZE; |
| 796 | sess->auth.key_length = auth_xform->key.length; |
| 797 | memset(sess->auth.key, 0, sess->auth.block_size); |
| 798 | rte_memcpy(sess->auth.key, auth_xform->key.data, |
| 799 | auth_xform->key.length); |
| 800 | } else { |
| 801 | if (auth_xform->key.length > SHA1_BLOCK_SIZE) |
| 802 | return -1; |
| 803 | sess->auth.engine = CCP_ENGINE_SHA; |
| 804 | sess->auth.algo = CCP_AUTH_ALGO_SHA1_HMAC; |
| 805 | sess->auth.ut.sha_type = CCP_SHA_TYPE_1; |
| 806 | sess->auth.ctx_len = CCP_SB_BYTES; |
| 807 | sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE; |
| 808 | sess->auth.block_size = SHA1_BLOCK_SIZE; |
| 809 | sess->auth.key_length = auth_xform->key.length; |
| 810 | memset(sess->auth.key, 0, sess->auth.block_size); |
no test coverage detected