diff options
| author | Gowrishankar Muthukrishnan <[email protected]> | 2024-10-04 11:41:05 +0530 |
|---|---|---|
| committer | Akhil Goyal <[email protected]> | 2024-10-09 22:04:19 +0200 |
| commit | 8a97564b1c1e035daaa0cdda553edd46178889e2 (patch) | |
| tree | d6e89c79fecf6ac973884b776f441e42df04b4c7 /examples/fips_validation | |
| parent | 0e3b2fc18c6b9bae9c6d51779bcd2b057ba0e300 (diff) | |
cryptodev: move RSA padding information into xform
RSA padding information could be a xform entity rather than part of
crypto op, as it seems associated with hashing algorithm used for
the entire crypto session, where this algorithm is used in message
digest itself. Even in virtIO standard spec, this info is associated
in the asymmetric session creation. Hence, moving this info from
crypto op into xform structure.
Signed-off-by: Gowrishankar Muthukrishnan <[email protected]>
Acked-by: Arkadiusz Kusztal <[email protected]>
Acked-by: Akhil Goyal <[email protected]>
Diffstat (limited to 'examples/fips_validation')
| -rw-r--r-- | examples/fips_validation/main.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index 522373ac1d..b34015ad9f 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -926,31 +926,7 @@ prepare_rsa_op(void) __rte_crypto_op_reset(env.op, RTE_CRYPTO_OP_TYPE_ASYMMETRIC); asym = env.op->asym; - asym->rsa.padding.type = info.interim_info.rsa_data.padding; - asym->rsa.padding.hash = info.interim_info.rsa_data.auth; - if (env.digest) { - if (asym->rsa.padding.type == RTE_CRYPTO_RSA_PADDING_PKCS1_5) { - int b_len = 0; - uint8_t b[32]; - - b_len = get_hash_oid(asym->rsa.padding.hash, b); - if (b_len < 0) { - RTE_LOG(ERR, USER1, "Failed to get digest info for hash %d\n", - asym->rsa.padding.hash); - return -EINVAL; - } - - if (b_len) { - msg.len = env.digest_len + b_len; - msg.val = rte_zmalloc(NULL, msg.len, 0); - rte_memcpy(msg.val, b, b_len); - rte_memcpy(msg.val + b_len, env.digest, env.digest_len); - rte_free(env.digest); - env.digest = msg.val; - env.digest_len = msg.len; - } - } msg.val = env.digest; msg.len = env.digest_len; } else { @@ -1619,6 +1595,34 @@ prepare_rsa_xform(struct rte_crypto_asym_xform *xform) xform->rsa.e.length = vec.rsa.e.len; xform->rsa.n.data = vec.rsa.n.val; xform->rsa.n.length = vec.rsa.n.len; + + xform->rsa.padding.type = info.interim_info.rsa_data.padding; + xform->rsa.padding.hash = info.interim_info.rsa_data.auth; + if (env.digest) { + if (xform->rsa.padding.type == RTE_CRYPTO_RSA_PADDING_PKCS1_5) { + struct fips_val msg; + int b_len = 0; + uint8_t b[32]; + + b_len = get_hash_oid(xform->rsa.padding.hash, b); + if (b_len < 0) { + RTE_LOG(ERR, USER1, "Failed to get digest info for hash %d\n", + xform->rsa.padding.hash); + return -EINVAL; + } + + if (b_len) { + msg.len = env.digest_len + b_len; + msg.val = rte_zmalloc(NULL, msg.len, 0); + rte_memcpy(msg.val, b, b_len); + rte_memcpy(msg.val + b_len, env.digest, env.digest_len); + rte_free(env.digest); + env.digest = msg.val; + env.digest_len = msg.len; + } + } + } + return 0; } |
