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