ret = cpt_fill_modex_params(sess, xform);
break;
case RTE_CRYPTO_ASYM_XFORM_ECDSA:
+ /* Fall through */
+ case RTE_CRYPTO_ASYM_XFORM_ECPM:
ret = cpt_fill_ec_params(sess, xform);
break;
default:
rte_free(mod->modulus.data);
break;
case RTE_CRYPTO_ASYM_XFORM_ECDSA:
+ /* Fall through */
+ case RTE_CRYPTO_ASYM_XFORM_ECPM:
break;
default:
CPT_LOG_DP_ERR("Invalid transform type");
struct rte_crypto_op **op;
vq_cmd_word0_t vq_cmd_w0;
uint64_t total_key_len;
- opcode_info_t opcode;
uint32_t dlen, rlen;
uint32_t base_len;
buf_ptr_t caddr;
rlen = mod_len;
/* Setup opcodes */
- opcode.s.major = CPT_MAJOR_OP_MODEX;
- opcode.s.minor = CPT_MINOR_OP_MODEX;
- vq_cmd_w0.s.opcode = opcode.flags;
+ vq_cmd_w0.s.opcode.major = CPT_MAJOR_OP_MODEX;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_MODEX;
/* GP op header */
vq_cmd_w0.s.param1 = mod_len;
struct rte_crypto_op **op;
vq_cmd_word0_t vq_cmd_w0;
uint64_t total_key_len;
- opcode_info_t opcode;
uint32_t dlen, rlen;
uint32_t in_size;
buf_ptr_t caddr;
if (rsa_op.pad == RTE_CRYPTO_RSA_PADDING_NONE) {
/* Use mod_exp operation for no_padding type */
- opcode.s.minor = CPT_MINOR_OP_MODEX;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_MODEX;
vq_cmd_w0.s.param2 = exp_len;
} else {
if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
- opcode.s.minor = CPT_MINOR_OP_PKCS_ENC;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_PKCS_ENC;
/* Public key encrypt, use BT2*/
vq_cmd_w0.s.param2 = CPT_BLOCK_TYPE2 |
((uint16_t)(exp_len) << 1);
} else if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
- opcode.s.minor = CPT_MINOR_OP_PKCS_DEC;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_PKCS_DEC;
/* Public key decrypt, use BT1 */
vq_cmd_w0.s.param2 = CPT_BLOCK_TYPE1;
/* + 2 for decrypted len */
}
}
- /* Setup opcodes */
- opcode.s.major = CPT_MAJOR_OP_MODEX;
- vq_cmd_w0.s.opcode = opcode.flags;
+ vq_cmd_w0.s.opcode.major = CPT_MAJOR_OP_MODEX;
/* GP op header */
vq_cmd_w0.s.param1 = mod_len;
struct rte_crypto_op **op;
vq_cmd_word0_t vq_cmd_w0;
uint64_t total_key_len;
- opcode_info_t opcode;
uint32_t dlen, rlen;
uint32_t in_size;
buf_ptr_t caddr;
if (rsa_op.pad == RTE_CRYPTO_RSA_PADDING_NONE) {
/*Use mod_exp operation for no_padding type */
- opcode.s.minor = CPT_MINOR_OP_MODEX_CRT;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_MODEX_CRT;
} else {
if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
- opcode.s.minor = CPT_MINOR_OP_PKCS_ENC_CRT;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_PKCS_ENC_CRT;
/* Private encrypt, use BT1 */
vq_cmd_w0.s.param2 = CPT_BLOCK_TYPE1;
} else if (rsa_op.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
- opcode.s.minor = CPT_MINOR_OP_PKCS_DEC_CRT;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_PKCS_DEC_CRT;
/* Private decrypt, use BT2 */
vq_cmd_w0.s.param2 = CPT_BLOCK_TYPE2;
/* + 2 for decrypted len */
}
}
- /* Setup opcodes */
- opcode.s.major = CPT_MAJOR_OP_MODEX;
- vq_cmd_w0.s.opcode = opcode.flags;
+ vq_cmd_w0.s.opcode.major = CPT_MAJOR_OP_MODEX;
/* GP op header */
vq_cmd_w0.s.param1 = mod_len;
cpt_fill_req_comp_addr(req, caddr);
}
-static __rte_always_inline int __hot
+static __rte_always_inline int __rte_hot
cpt_enqueue_rsa_op(struct rte_crypto_op *op,
struct asym_op_params *params,
struct cpt_asym_sess_misc *sess)
uint16_t order_len, prime_len;
uint16_t o_offset, pk_offset;
vq_cmd_word0_t vq_cmd_w0;
- opcode_info_t opcode;
uint16_t rlen, dlen;
buf_ptr_t caddr;
uint8_t *dptr;
/* Truncate input length to curve prime length */
if (message_len > prime_len)
message_len = prime_len;
- m_align = ROUNDUP8(message_len);
+ m_align = RTE_ALIGN_CEIL(message_len, 8);
- p_align = ROUNDUP8(prime_len);
- k_align = ROUNDUP8(k_len);
+ p_align = RTE_ALIGN_CEIL(prime_len, 8);
+ k_align = RTE_ALIGN_CEIL(k_len, 8);
/* Set write offset for order and private key */
o_offset = prime_len - order_len;
rlen = 2 * p_align;
/* Setup opcodes */
- opcode.s.major = CPT_MAJOR_OP_ECDSA;
- opcode.s.minor = CPT_MINOR_OP_ECDSA_SIGN;
- vq_cmd_w0.s.opcode = opcode.flags;
+ vq_cmd_w0.s.opcode.major = CPT_MAJOR_OP_ECDSA;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_ECDSA_SIGN;
/* GP op header */
vq_cmd_w0.s.param1 = curveid | (message_len << 8);
uint16_t qx_offset, qy_offset;
uint16_t p_align, m_align;
vq_cmd_word0_t vq_cmd_w0;
- opcode_info_t opcode;
buf_ptr_t caddr;
uint16_t dlen;
uint8_t *dptr;
if (message_len > prime_len)
message_len = prime_len;
- m_align = ROUNDUP8(message_len);
- p_align = ROUNDUP8(prime_len);
+ m_align = RTE_ALIGN_CEIL(message_len, 8);
+ p_align = RTE_ALIGN_CEIL(prime_len, 8);
/* Set write offset for sign, order and public key coordinates */
o_offset = prime_len - order_len;
dptr += p_align;
/* Setup opcodes */
- opcode.s.major = CPT_MAJOR_OP_ECDSA;
- opcode.s.minor = CPT_MINOR_OP_ECDSA_VERIFY;
- vq_cmd_w0.s.opcode = opcode.flags;
+ vq_cmd_w0.s.opcode.major = CPT_MAJOR_OP_ECDSA;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_ECDSA_VERIFY;
/* GP op header */
vq_cmd_w0.s.param1 = curveid | (message_len << 8);
cpt_fill_req_comp_addr(req, caddr);
}
-static __rte_always_inline int __hot
+static __rte_always_inline int __rte_hot
cpt_enqueue_ecdsa_op(struct rte_crypto_op *op,
struct asym_op_params *params,
struct cpt_asym_sess_misc *sess,
return 0;
}
+static __rte_always_inline int
+cpt_ecpm_prep(struct rte_crypto_ecpm_op_param *ecpm,
+ struct asym_op_params *asym_params,
+ uint8_t curveid)
+{
+ struct cpt_request_info *req = asym_params->req;
+ phys_addr_t mphys = asym_params->meta_buf;
+ uint16_t x1_len = ecpm->p.x.length;
+ uint16_t y1_len = ecpm->p.y.length;
+ uint16_t scalar_align, p_align;
+ uint16_t dlen, rlen, prime_len;
+ uint16_t x1_offset, y1_offset;
+ vq_cmd_word0_t vq_cmd_w0;
+ buf_ptr_t caddr;
+ uint8_t *dptr;
+
+ prime_len = ec_grp[curveid].prime.length;
+
+ /* Input buffer */
+ dptr = RTE_PTR_ADD(req, sizeof(struct cpt_request_info));
+
+ p_align = RTE_ALIGN_CEIL(prime_len, 8);
+ scalar_align = RTE_ALIGN_CEIL(ecpm->scalar.length, 8);
+
+ /*
+ * Set dlen = sum(ROUNDUP8(input point(x and y coordinates), prime,
+ * scalar length),
+ * Please note point length is equivalent to prime of the curve
+ */
+ dlen = 3 * p_align + scalar_align;
+
+ x1_offset = prime_len - x1_len;
+ y1_offset = prime_len - y1_len;
+
+ memset(dptr, 0, dlen);
+
+ /* Copy input point, scalar, prime */
+ memcpy(dptr + x1_offset, ecpm->p.x.data, x1_len);
+ dptr += p_align;
+ memcpy(dptr + y1_offset, ecpm->p.y.data, y1_len);
+ dptr += p_align;
+ memcpy(dptr, ecpm->scalar.data, ecpm->scalar.length);
+ dptr += scalar_align;
+ memcpy(dptr, ec_grp[curveid].prime.data, ec_grp[curveid].prime.length);
+ dptr += p_align;
+
+ /* Setup opcodes */
+ vq_cmd_w0.s.opcode.major = CPT_MAJOR_OP_ECC;
+ vq_cmd_w0.s.opcode.minor = CPT_MINOR_OP_ECC_UMP;
+
+ /* GP op header */
+ vq_cmd_w0.s.param1 = curveid;
+ vq_cmd_w0.s.param2 = ecpm->scalar.length;
+ vq_cmd_w0.s.dlen = dlen;
+
+ /* Filling cpt_request_info structure */
+ req->ist.ei0 = vq_cmd_w0.u64;
+ req->ist.ei1 = mphys;
+ req->ist.ei2 = mphys + dlen;
+
+ /* Result buffer will store output point where length of
+ * each coordinate will be of prime length, thus set
+ * rlen to twice of prime length.
+ */
+ rlen = p_align << 1;
+ req->rptr = dptr;
+
+ /* alternate_caddr to write completion status by the microcode */
+ req->alternate_caddr = (uint64_t *)(dptr + rlen);
+ *req->alternate_caddr = ~((uint64_t)COMPLETION_CODE_INIT);
+
+ /* Preparing completion addr, +1 for completion code */
+ caddr.vaddr = dptr + rlen + 1;
+ caddr.dma_addr = mphys + dlen + rlen + 1;
+
+ cpt_fill_req_comp_addr(req, caddr);
+ return 0;
+}
#endif /* _CPT_UCODE_ASYM_H_ */