pkc_desc.c 2.3 KB

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