pkc_desc.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include "caampkc.h"
  10. #include "desc_constr.h"
  11. /* Descriptor for RSA Public operation */
  12. void init_rsa_pub_desc(u32 *desc, struct rsa_pub_pdb *pdb)
  13. {
  14. init_job_desc_pdb(desc, 0, sizeof(*pdb));
  15. append_cmd(desc, pdb->sgf);
  16. append_ptr(desc, pdb->f_dma);
  17. append_ptr(desc, pdb->g_dma);
  18. append_ptr(desc, pdb->n_dma);
  19. append_ptr(desc, pdb->e_dma);
  20. append_cmd(desc, pdb->f_len);
  21. append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSAENC_PUBKEY);
  22. }
  23. /* Descriptor for RSA Private operation - Private Key Form #1 */
  24. void init_rsa_priv_f1_desc(u32 *desc, struct rsa_priv_f1_pdb *pdb)
  25. {
  26. init_job_desc_pdb(desc, 0, sizeof(*pdb));
  27. append_cmd(desc, pdb->sgf);
  28. append_ptr(desc, pdb->g_dma);
  29. append_ptr(desc, pdb->f_dma);
  30. append_ptr(desc, pdb->n_dma);
  31. append_ptr(desc, pdb->d_dma);
  32. append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
  33. RSA_PRIV_KEY_FRM_1);
  34. }
  35. /* Descriptor for RSA Private operation - Private Key Form #2 */
  36. void init_rsa_priv_f2_desc(u32 *desc, struct rsa_priv_f2_pdb *pdb)
  37. {
  38. init_job_desc_pdb(desc, 0, sizeof(*pdb));
  39. append_cmd(desc, pdb->sgf);
  40. append_ptr(desc, pdb->g_dma);
  41. append_ptr(desc, pdb->f_dma);
  42. append_ptr(desc, pdb->d_dma);
  43. append_ptr(desc, pdb->p_dma);
  44. append_ptr(desc, pdb->q_dma);
  45. append_ptr(desc, pdb->tmp1_dma);
  46. append_ptr(desc, pdb->tmp2_dma);
  47. append_cmd(desc, pdb->p_q_len);
  48. append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
  49. RSA_PRIV_KEY_FRM_2);
  50. }
  51. /* Descriptor for RSA Private operation - Private Key Form #3 */
  52. void init_rsa_priv_f3_desc(u32 *desc, struct rsa_priv_f3_pdb *pdb)
  53. {
  54. init_job_desc_pdb(desc, 0, sizeof(*pdb));
  55. append_cmd(desc, pdb->sgf);
  56. append_ptr(desc, pdb->g_dma);
  57. append_ptr(desc, pdb->f_dma);
  58. append_ptr(desc, pdb->c_dma);
  59. append_ptr(desc, pdb->p_dma);
  60. append_ptr(desc, pdb->q_dma);
  61. append_ptr(desc, pdb->dp_dma);
  62. append_ptr(desc, pdb->dq_dma);
  63. append_ptr(desc, pdb->tmp1_dma);
  64. append_ptr(desc, pdb->tmp2_dma);
  65. append_cmd(desc, pdb->p_q_len);
  66. append_operation(desc, OP_TYPE_UNI_PROTOCOL | OP_PCLID_RSADEC_PRVKEY |
  67. RSA_PRIV_KEY_FRM_3);
  68. }