Linux-libre 4.9.123-gnu
[librecmc/linux-libre.git] / drivers / crypto / caam / caampkc.h
1 /*
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
10 #ifndef _PKC_DESC_H_
11 #define _PKC_DESC_H_
12 #include "compat.h"
13 #include "pdb.h"
14
15 /**
16  * caam_rsa_key - CAAM RSA key structure. Keys are allocated in DMA zone.
17  * @n           : RSA modulus raw byte stream
18  * @e           : RSA public exponent raw byte stream
19  * @d           : RSA private exponent raw byte stream
20  * @n_sz        : length in bytes of RSA modulus n
21  * @e_sz        : length in bytes of RSA public exponent
22  * @d_sz        : length in bytes of RSA private exponent
23  */
24 struct caam_rsa_key {
25         u8 *n;
26         u8 *e;
27         u8 *d;
28         size_t n_sz;
29         size_t e_sz;
30         size_t d_sz;
31 };
32
33 /**
34  * caam_rsa_ctx - per session context.
35  * @key         : RSA key in DMA zone
36  * @dev         : device structure
37  */
38 struct caam_rsa_ctx {
39         struct caam_rsa_key key;
40         struct device *dev;
41 };
42
43 /**
44  * rsa_edesc - s/w-extended rsa descriptor
45  * @src_nents     : number of segments in input scatterlist
46  * @dst_nents     : number of segments in output scatterlist
47  * @sec4_sg_bytes : length of h/w link table
48  * @sec4_sg_dma   : dma address of h/w link table
49  * @sec4_sg       : pointer to h/w link table
50  * @pdb           : specific RSA Protocol Data Block (PDB)
51  * @hw_desc       : descriptor followed by link tables if any
52  */
53 struct rsa_edesc {
54         int src_nents;
55         int dst_nents;
56         int sec4_sg_bytes;
57         dma_addr_t sec4_sg_dma;
58         struct sec4_sg_entry *sec4_sg;
59         union {
60                 struct rsa_pub_pdb pub;
61                 struct rsa_priv_f1_pdb priv_f1;
62         } pdb;
63         u32 hw_desc[];
64 };
65
66 /* Descriptor construction primitives. */
67 void init_rsa_pub_desc(u32 *desc, struct rsa_pub_pdb *pdb);
68 void init_rsa_priv_f1_desc(u32 *desc, struct rsa_priv_f1_pdb *pdb);
69
70 #endif