caampkc.h 1.8 KB

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