roc_hash_sha256_gen(opad, (uint32_t *)&hmac_opad_ipad[0]);
roc_hash_sha256_gen(ipad, (uint32_t *)&hmac_opad_ipad[64]);
break;
+ case RTE_CRYPTO_AUTH_SHA384_HMAC:
+ roc_hash_sha512_gen(opad, (uint64_t *)&hmac_opad_ipad[0], 384);
+ roc_hash_sha512_gen(ipad, (uint64_t *)&hmac_opad_ipad[64], 384);
+ break;
+ case RTE_CRYPTO_AUTH_SHA512_HMAC:
+ roc_hash_sha512_gen(opad, (uint64_t *)&hmac_opad_ipad[0], 512);
+ roc_hash_sha512_gen(ipad, (uint64_t *)&hmac_opad_ipad[64], 512);
+ break;
default:
break;
}
break;
case RTE_CRYPTO_AUTH_SHA1_HMAC:
w2->s.auth_type = ROC_IE_OT_SA_AUTH_SHA1;
- ipsec_hmac_opad_ipad_gen(auth_xfrm, hmac_opad_ipad);
-
- tmp_key = (uint64_t *)hmac_opad_ipad;
- for (i = 0; i < (int)(ROC_CTX_MAX_OPAD_IPAD_LEN /
- sizeof(uint64_t));
- i++)
- tmp_key[i] = rte_be_to_cpu_64(tmp_key[i]);
break;
case RTE_CRYPTO_AUTH_SHA256_HMAC:
w2->s.auth_type = ROC_IE_OT_SA_AUTH_SHA2_256;
- ipsec_hmac_opad_ipad_gen(auth_xfrm, hmac_opad_ipad);
-
- tmp_key = (uint64_t *)hmac_opad_ipad;
- for (i = 0; i < (int)(ROC_CTX_MAX_OPAD_IPAD_LEN /
- sizeof(uint64_t));
- i++)
- tmp_key[i] = rte_be_to_cpu_64(tmp_key[i]);
+ break;
+ case RTE_CRYPTO_AUTH_SHA384_HMAC:
+ w2->s.auth_type = ROC_IE_OT_SA_AUTH_SHA2_384;
+ break;
+ case RTE_CRYPTO_AUTH_SHA512_HMAC:
+ w2->s.auth_type = ROC_IE_OT_SA_AUTH_SHA2_512;
break;
default:
return -ENOTSUP;
}
+ ipsec_hmac_opad_ipad_gen(auth_xfrm, hmac_opad_ipad);
+
+ tmp_key = (uint64_t *)hmac_opad_ipad;
+ for (i = 0;
+ i < (int)(ROC_CTX_MAX_OPAD_IPAD_LEN / sizeof(uint64_t));
+ i++)
+ tmp_key[i] = rte_be_to_cpu_64(tmp_key[i]);
+
key = cipher_xfrm->cipher.key.data;
length = cipher_xfrm->cipher.key.length;
}
ctl->auth_type == ROC_IE_ON_SA_AUTH_NULL) {
template = &out_sa->aes_gcm.template;
ctx_len = offsetof(struct roc_ie_on_outb_sa, aes_gcm.template);
- } else if (ctl->auth_type == ROC_IE_ON_SA_AUTH_SHA1) {
- template = &out_sa->sha1.template;
- ctx_len = offsetof(struct roc_ie_on_outb_sa, sha1.template);
- } else if (ctl->auth_type == ROC_IE_ON_SA_AUTH_SHA2_256) {
- template = &out_sa->sha2.template;
- ctx_len = offsetof(struct roc_ie_on_outb_sa, sha2.template);
} else {
- return -EINVAL;
+ switch (ctl->auth_type) {
+ case ROC_IE_ON_SA_AUTH_SHA1:
+ template = &out_sa->sha1.template;
+ ctx_len = offsetof(struct roc_ie_on_outb_sa,
+ sha1.template);
+ break;
+ case ROC_IE_ON_SA_AUTH_SHA2_256:
+ case ROC_IE_ON_SA_AUTH_SHA2_384:
+ case ROC_IE_ON_SA_AUTH_SHA2_512:
+ template = &out_sa->sha2.template;
+ ctx_len = offsetof(struct roc_ie_on_outb_sa,
+ sha2.template);
+ break;
+ default:
+ return -EINVAL;
+ }
}
ip4 = (struct rte_ipv4_hdr *)&template->ip4.ipv4_hdr;
auth_key = auth_xform->auth.key.data;
auth_key_len = auth_xform->auth.key.length;
- if (auth_xform->auth.algo == RTE_CRYPTO_AUTH_SHA1_HMAC)
+ switch (auth_xform->auth.algo) {
+ case RTE_CRYPTO_AUTH_NULL:
+ break;
+ case RTE_CRYPTO_AUTH_SHA1_HMAC:
memcpy(out_sa->sha1.hmac_key, auth_key, auth_key_len);
- else if (auth_xform->auth.algo == RTE_CRYPTO_AUTH_SHA256_HMAC)
+ break;
+ case RTE_CRYPTO_AUTH_SHA256_HMAC:
+ case RTE_CRYPTO_AUTH_SHA384_HMAC:
+ case RTE_CRYPTO_AUTH_SHA512_HMAC:
memcpy(out_sa->sha2.hmac_key, auth_key, auth_key_len);
+ break;
+ default:
+ plt_err("Unsupported auth algorithm %u",
+ auth_xform->auth.algo);
+ return -ENOTSUP;
+ }
}
inst_tmpl = &sa->inst;
auth_key = auth_xform->auth.key.data;
auth_key_len = auth_xform->auth.key.length;
- if (auth_xform->auth.algo == RTE_CRYPTO_AUTH_SHA1_HMAC) {
+ switch (auth_xform->auth.algo) {
+ case RTE_CRYPTO_AUTH_NULL:
+ break;
+ case RTE_CRYPTO_AUTH_SHA1_HMAC:
memcpy(in_sa->sha1_or_gcm.hmac_key, auth_key,
auth_key_len);
ctx_len = offsetof(struct roc_ie_on_inb_sa,
sha1_or_gcm.selector);
- } else if (auth_xform->auth.algo ==
- RTE_CRYPTO_AUTH_SHA256_HMAC) {
+ break;
+ case RTE_CRYPTO_AUTH_SHA256_HMAC:
+ case RTE_CRYPTO_AUTH_SHA384_HMAC:
+ case RTE_CRYPTO_AUTH_SHA512_HMAC:
memcpy(in_sa->sha2.hmac_key, auth_key, auth_key_len);
ctx_len = offsetof(struct roc_ie_on_inb_sa,
sha2.selector);
+ break;
+ default:
+ plt_err("Unsupported auth algorithm %u",
+ auth_xform->auth.algo);
+ return -ENOTSUP;
}
}