2 * caam - Freescale FSL CAAM support for Public Key Cryptography descriptors
4 * Copyright 2016 Freescale Semiconductor, Inc.
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.
16 * caam_priv_key_form - CAAM RSA private key representation
17 * CAAM RSA private key may have either of three forms.
19 * 1. The first representation consists of the pair (n, d), where the
20 * components have the following meanings:
22 * d the RSA private exponent
24 * 2. The second representation consists of the triplet (p, q, d), where the
25 * components have the following meanings:
26 * p the first prime factor of the RSA modulus n
27 * q the second prime factor of the RSA modulus n
28 * d the RSA private exponent
30 * 3. The third representation consists of the quintuple (p, q, dP, dQ, qInv),
31 * where the components have the following meanings:
32 * p the first prime factor of the RSA modulus n
33 * q the second prime factor of the RSA modulus n
34 * dP the first factors's CRT exponent
35 * dQ the second factors's CRT exponent
36 * qInv the (first) CRT coefficient
38 * The benefit of using the third or the second key form is lower computational
39 * cost for the decryption and signature operations.
41 enum caam_priv_key_form {
48 * caam_rsa_key - CAAM RSA key structure. Keys are allocated in DMA zone.
49 * @n : RSA modulus raw byte stream
50 * @e : RSA public exponent raw byte stream
51 * @d : RSA private exponent raw byte stream
52 * @p : RSA prime factor p of RSA modulus n
53 * @q : RSA prime factor q of RSA modulus n
54 * @dp : RSA CRT exponent of p
55 * @dp : RSA CRT exponent of q
56 * @qinv : RSA CRT coefficient
57 * @tmp1 : CAAM uses this temporary buffer as internal state buffer.
58 * It is assumed to be as long as p.
59 * @tmp2 : CAAM uses this temporary buffer as internal state buffer.
60 * It is assumed to be as long as q.
61 * @n_sz : length in bytes of RSA modulus n
62 * @e_sz : length in bytes of RSA public exponent
63 * @d_sz : length in bytes of RSA private exponent
64 * @p_sz : length in bytes of RSA prime factor p of RSA modulus n
65 * @q_sz : length in bytes of RSA prime factor q of RSA modulus n
66 * @priv_form : CAAM RSA private key representation
84 enum caam_priv_key_form priv_form;
88 * caam_rsa_ctx - per session context.
89 * @key : RSA key in DMA zone
90 * @dev : device structure
93 struct caam_rsa_key key;
98 * rsa_edesc - s/w-extended rsa descriptor
99 * @src_nents : number of segments in input scatterlist
100 * @dst_nents : number of segments in output scatterlist
101 * @sec4_sg_bytes : length of h/w link table
102 * @sec4_sg_dma : dma address of h/w link table
103 * @sec4_sg : pointer to h/w link table
104 * @pdb : specific RSA Protocol Data Block (PDB)
105 * @hw_desc : descriptor followed by link tables if any
111 dma_addr_t sec4_sg_dma;
112 struct sec4_sg_entry *sec4_sg;
114 struct rsa_pub_pdb pub;
115 struct rsa_priv_f1_pdb priv_f1;
116 struct rsa_priv_f2_pdb priv_f2;
117 struct rsa_priv_f3_pdb priv_f3;
122 /* Descriptor construction primitives. */
123 void init_rsa_pub_desc(u32 *desc, struct rsa_pub_pdb *pdb);
124 void init_rsa_priv_f1_desc(u32 *desc, struct rsa_priv_f1_pdb *pdb);
125 void init_rsa_priv_f2_desc(u32 *desc, struct rsa_priv_f2_pdb *pdb);
126 void init_rsa_priv_f3_desc(u32 *desc, struct rsa_priv_f3_pdb *pdb);