Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * caam - Freescale FSL CAAM support for Public Key Cryptography descriptors
0004  *
0005  * Copyright 2016 Freescale Semiconductor, Inc.
0006  *
0007  * There is no Shared Descriptor for PKC so that the Job Descriptor must carry
0008  * all the desired key parameters, input and output pointers.
0009  */
0010 #include "caampkc.h"
0011 #include "desc_constr.h"
0012 
0013 /* Descriptor for RSA Public operation */
0014 void init_rsa_pub_desc(u32 *desc, struct rsa_pub_pdb *pdb)
0015 {
0016     init_job_desc_pdb(desc, 0, SIZEOF_RSA_PUB_PDB);
0017     append_cmd(desc, pdb->sgf);
0018     append_ptr(desc, pdb->f_dma);
0019     append_ptr(desc, pdb->g_dma);
0020     append_ptr(desc, pdb->n_dma);
0021     append_ptr(desc, pdb->e_dma);
0022     append_cmd(desc, pdb->f_len);
0023     append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSAENC_PUBKEY);
0024 }
0025 
0026 /* Descriptor for RSA Private operation - Private Key Form #1 */
0027 void init_rsa_priv_f1_desc(u32 *desc, struct rsa_priv_f1_pdb *pdb)
0028 {
0029     init_job_desc_pdb(desc, 0, SIZEOF_RSA_PRIV_F1_PDB);
0030     append_cmd(desc, pdb->sgf);
0031     append_ptr(desc, pdb->g_dma);
0032     append_ptr(desc, pdb->f_dma);
0033     append_ptr(desc, pdb->n_dma);
0034     append_ptr(desc, pdb->d_dma);
0035     append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
0036              RSA_PRIV_KEY_FRM_1);
0037 }
0038 
0039 /* Descriptor for RSA Private operation - Private Key Form #2 */
0040 void init_rsa_priv_f2_desc(u32 *desc, struct rsa_priv_f2_pdb *pdb)
0041 {
0042     init_job_desc_pdb(desc, 0, SIZEOF_RSA_PRIV_F2_PDB);
0043     append_cmd(desc, pdb->sgf);
0044     append_ptr(desc, pdb->g_dma);
0045     append_ptr(desc, pdb->f_dma);
0046     append_ptr(desc, pdb->d_dma);
0047     append_ptr(desc, pdb->p_dma);
0048     append_ptr(desc, pdb->q_dma);
0049     append_ptr(desc, pdb->tmp1_dma);
0050     append_ptr(desc, pdb->tmp2_dma);
0051     append_cmd(desc, pdb->p_q_len);
0052     append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
0053              RSA_PRIV_KEY_FRM_2);
0054 }
0055 
0056 /* Descriptor for RSA Private operation - Private Key Form #3 */
0057 void init_rsa_priv_f3_desc(u32 *desc, struct rsa_priv_f3_pdb *pdb)
0058 {
0059     init_job_desc_pdb(desc, 0, SIZEOF_RSA_PRIV_F3_PDB);
0060     append_cmd(desc, pdb->sgf);
0061     append_ptr(desc, pdb->g_dma);
0062     append_ptr(desc, pdb->f_dma);
0063     append_ptr(desc, pdb->c_dma);
0064     append_ptr(desc, pdb->p_dma);
0065     append_ptr(desc, pdb->q_dma);
0066     append_ptr(desc, pdb->dp_dma);
0067     append_ptr(desc, pdb->dq_dma);
0068     append_ptr(desc, pdb->tmp1_dma);
0069     append_ptr(desc, pdb->tmp2_dma);
0070     append_cmd(desc, pdb->p_q_len);
0071     append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
0072              RSA_PRIV_KEY_FRM_3);
0073 }