struct rte_crypto_rsa_xform *rsa = &sess->rsa_ctx;
size_t mod_len = xfrm_rsa->n.length;
size_t exp_len = xfrm_rsa->e.length;
- size_t len = (mod_len / 2);
uint64_t total_size;
+ size_t len = 0;
+
+ if (qt.p.length != 0 && qt.p.data == NULL)
+ return -EINVAL;
/* Make sure key length used is not more than mod_len/2 */
if (qt.p.data != NULL)
- len = RTE_MIN(len, qt.p.length);
+ len = (((mod_len / 2) < qt.p.length) ? 0 : qt.p.length);
/* Total size required for RSA key params(n,e,(q,dQ,p,dP,qInv)) */
total_size = mod_len + exp_len + 5 * len;
rsa->qt.dQ.data = rsa->qt.q.data + qt.q.length;
memcpy(rsa->qt.dQ.data, qt.dQ.data, qt.dQ.length);
rsa->qt.p.data = rsa->qt.dQ.data + qt.dQ.length;
- memcpy(rsa->qt.p.data, qt.p.data, qt.p.length);
+ if (qt.p.data != NULL)
+ memcpy(rsa->qt.p.data, qt.p.data, qt.p.length);
rsa->qt.dP.data = rsa->qt.p.data + qt.p.length;
memcpy(rsa->qt.dP.data, qt.dP.data, qt.dP.length);
rsa->qt.qInv.data = rsa->qt.dP.data + qt.dP.length;
switch (sess->xfrm_type) {
case RTE_CRYPTO_ASYM_XFORM_RSA:
rsa = &sess->rsa_ctx;
- if (rsa->n.data)
- rte_free(rsa->n.data);
+ rte_free(rsa->n.data);
break;
case RTE_CRYPTO_ASYM_XFORM_MODEX:
mod = &sess->mod_ctx;
- if (mod->modulus.data)
- rte_free(mod->modulus.data);
+ rte_free(mod->modulus.data);
break;
case RTE_CRYPTO_ASYM_XFORM_ECDSA:
/* Fall through */
* Please note, private key, order cannot exceed prime
* length i.e 3 * p_align.
*/
- dlen = sizeof(fpm_table_iova) + k_align + m_align + p_align * 3;
+ dlen = sizeof(fpm_table_iova) + k_align + m_align + p_align * 5;
memset(dptr, 0, dlen);
memcpy(dptr, ecdsa->message.data, message_len);
dptr += m_align;
+ memcpy(dptr, ec_grp->consta.data, prime_len);
+ dptr += p_align;
+
+ memcpy(dptr, ec_grp->constb.data, prime_len);
+ dptr += p_align;
+
/* Setup opcodes */
w4.s.opcode_major = ROC_AE_MAJOR_OP_ECDSA;
w4.s.opcode_minor = ROC_AE_MINOR_OP_ECDSA_SIGN;
w4.s.param1 = curveid | (message_len << 8);
- w4.s.param2 = k_len;
+ w4.s.param2 = (pkey_len << 8) | k_len;
w4.s.dlen = dlen;
inst->w4.u64 = w4.u64;
* Please note sign, public key and order can not exceed prime length
* i.e. 6 * p_align
*/
- dlen = sizeof(fpm_table_iova) + m_align + (6 * p_align);
+ dlen = sizeof(fpm_table_iova) + m_align + (8 * p_align);
memset(dptr, 0, dlen);
memcpy(dptr + qy_offset, ecdsa->q.y.data, qy_len);
dptr += p_align;
+ memcpy(dptr, ec_grp->consta.data, prime_len);
+ dptr += p_align;
+
+ memcpy(dptr, ec_grp->constb.data, prime_len);
+ dptr += p_align;
+
/* Setup opcodes */
w4.s.opcode_major = ROC_AE_MAJOR_OP_ECDSA;
w4.s.opcode_minor = ROC_AE_MINOR_OP_ECDSA_VERIFY;
* scalar length),
* Please note point length is equivalent to prime of the curve
*/
- dlen = 3 * p_align + scalar_align;
+ dlen = 5 * p_align + scalar_align;
x1_offset = prime_len - x1_len;
y1_offset = prime_len - y1_len;
dptr += scalar_align;
memcpy(dptr, ec_grp->prime.data, ec_grp->prime.length);
dptr += p_align;
+ memcpy(dptr, ec_grp->consta.data, ec_grp->consta.length);
+ dptr += p_align;
+ memcpy(dptr, ec_grp->constb.data, ec_grp->constb.length);
+ dptr += p_align;
/* Setup opcodes */
w4.s.opcode_major = ROC_AE_MAJOR_OP_ECC;