blob: 9e2ce6fe2e43f7717e462f558c31cf997a4888ad [file] [log] [blame]
Tudor Ambarus8c419772016-07-04 13:12:08 +03001/*
2 * caam - Freescale FSL CAAM support for Public Key Cryptography descriptors
3 *
4 * Copyright 2016 Freescale Semiconductor, Inc.
5 *
6 * There is no Shared Descriptor for PKC so that the Job Descriptor must carry
7 * all the desired key parameters, input and output pointers.
8 */
9#include "caampkc.h"
10#include "desc_constr.h"
11
12/* Descriptor for RSA Public operation */
13void init_rsa_pub_desc(u32 *desc, struct rsa_pub_pdb *pdb)
14{
15 init_job_desc_pdb(desc, 0, sizeof(*pdb));
16 append_cmd(desc, pdb->sgf);
17 append_ptr(desc, pdb->f_dma);
18 append_ptr(desc, pdb->g_dma);
19 append_ptr(desc, pdb->n_dma);
20 append_ptr(desc, pdb->e_dma);
21 append_cmd(desc, pdb->f_len);
22 append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSAENC_PUBKEY);
23}
24
25/* Descriptor for RSA Private operation - Private Key Form #1 */
26void init_rsa_priv_f1_desc(u32 *desc, struct rsa_priv_f1_pdb *pdb)
27{
28 init_job_desc_pdb(desc, 0, sizeof(*pdb));
29 append_cmd(desc, pdb->sgf);
30 append_ptr(desc, pdb->g_dma);
31 append_ptr(desc, pdb->f_dma);
32 append_ptr(desc, pdb->n_dma);
33 append_ptr(desc, pdb->d_dma);
34 append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
35 RSA_PRIV_KEY_FRM_1);
36}
Radu Alexe52e26d72017-04-25 16:26:38 +030037
38/* Descriptor for RSA Private operation - Private Key Form #2 */
39void init_rsa_priv_f2_desc(u32 *desc, struct rsa_priv_f2_pdb *pdb)
40{
41 init_job_desc_pdb(desc, 0, sizeof(*pdb));
42 append_cmd(desc, pdb->sgf);
43 append_ptr(desc, pdb->g_dma);
44 append_ptr(desc, pdb->f_dma);
45 append_ptr(desc, pdb->d_dma);
46 append_ptr(desc, pdb->p_dma);
47 append_ptr(desc, pdb->q_dma);
48 append_ptr(desc, pdb->tmp1_dma);
49 append_ptr(desc, pdb->tmp2_dma);
50 append_cmd(desc, pdb->p_q_len);
51 append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
52 RSA_PRIV_KEY_FRM_2);
53}
Radu Alexe4a651b12017-04-25 16:26:39 +030054
55/* Descriptor for RSA Private operation - Private Key Form #3 */
56void init_rsa_priv_f3_desc(u32 *desc, struct rsa_priv_f3_pdb *pdb)
57{
58 init_job_desc_pdb(desc, 0, sizeof(*pdb));
59 append_cmd(desc, pdb->sgf);
60 append_ptr(desc, pdb->g_dma);
61 append_ptr(desc, pdb->f_dma);
62 append_ptr(desc, pdb->c_dma);
63 append_ptr(desc, pdb->p_dma);
64 append_ptr(desc, pdb->q_dma);
65 append_ptr(desc, pdb->dp_dma);
66 append_ptr(desc, pdb->dq_dma);
67 append_ptr(desc, pdb->tmp1_dma);
68 append_ptr(desc, pdb->tmp2_dma);
69 append_cmd(desc, pdb->p_q_len);
70 append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
71 RSA_PRIV_KEY_FRM_3);
72}