fsl_caam_h.patch 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. --- fsl_caam.h 2023-06-23 00:08:46.491699533 -0700
  2. +++ fsl_caam-expanded.h 2023-06-23 00:10:22.702730462 -0700
  3. @@ -3038,6 +3038,164 @@
  4. *@}
  5. */ /* end of caam_driver_pkha */
  6. +
  7. +/* define for application to check for ECC CAAM additions */
  8. +#define CAAM_ECC_EXPANSION
  9. +#define CAAM_PKHA_ENC_PRI_AESECB 0x00000004
  10. +#define CAAM_ECDSEL_SHIFT 7
  11. +#define CAAM_ECDSA_P256 (0x02 << CAAM_ECDSEL_SHIFT)
  12. +#define CAAM_ECDSA_P384 (0x03 << CAAM_ECDSEL_SHIFT)
  13. +#define CAAM_ECDSA_P521 (0x04 << CAAM_ECDSEL_SHIFT)
  14. +
  15. +/*!
  16. + * brief generate ECC Keypair.
  17. + *
  18. + * This function generates ECC private/public key pair.
  19. + *
  20. + * param base CAAM peripheral base address
  21. + * param[out] k private key
  22. + * param[in,out] sizeK pointer to size variable. On input it holds size of input k in bytes. On output it holds size of
  23. + * of generated private key k in bytes.
  24. + * param[out] p public key
  25. + * param[in,out] sizeP pointer to size variable. On input it holds size of input p in bytes. On output it holds size of
  26. + * of generated public key p in bytes.
  27. + * param keyType type of ECC key, i.e P256 / P384
  28. + * param enc option to create black key
  29. + * return Operation status.
  30. + */
  31. +status_t CAAM_ECC_Keygen(CAAM_Type *base,
  32. + caam_handle_t *handle,
  33. + uint8_t *k,
  34. + size_t *sizeK,
  35. + uint8_t *p,
  36. + size_t *sizeP,
  37. + int keyType,
  38. + uint32_t enc);
  39. +
  40. +/*!
  41. + * brief generate ECC signature.
  42. + *
  43. + * This function creates an ECC signature.
  44. + *
  45. + * param base CAAM peripheral base address
  46. + * param[in] k private key
  47. + * param[in] sizeK holds size of input k in bytes.
  48. + * param[in] hash contains the hash to sign
  49. + * param[in] sizeHash is the size of 'hash' in bytes.
  50. + * param[out] sig signature output
  51. + * param[in,out] sizeSig pointer to size variable. On input it holds size of input sig in bytes. On output it holds size of
  52. + * of generated signature in bytes.
  53. + * param keyType type of ECC key i.e P256 / P384
  54. + * param enc option to use black key
  55. + * return Operation status.
  56. + */
  57. +status_t CAAM_ECC_Sign(CAAM_Type *base,
  58. + caam_handle_t *handle,
  59. + const uint8_t *k,
  60. + size_t sizeK,
  61. + const uint8_t *hash,
  62. + size_t sizeHash,
  63. + uint8_t *r,
  64. + size_t sizeR,
  65. + uint8_t *s,
  66. + size_t sizeS,
  67. + int keyType,
  68. + uint32_t enc);
  69. +
  70. +/*!
  71. + * brief do an ECC verify.
  72. + *
  73. + * This function verifies an ECC signature.
  74. + *
  75. + * param base CAAM peripheral base address
  76. + * param[in] p public key
  77. + * param[in] sizeP pointer to size variable. On input it holds size of input k in bytes. On output it holds size of
  78. + * of generated private key k in bytes.
  79. + * param[in] sig signature to verify
  80. + * param[in] sizeSig size of signature in bytes
  81. + * param[in] hash contains the hash to sign
  82. + * param[in] sizeHash is the size of 'hash' in bytes.
  83. + * param keyType type of ECC key i.e P256 / P384
  84. + * param enc option to use black key
  85. + * return Operation status.
  86. + */
  87. +status_t CAAM_ECC_Verify(CAAM_Type *base,
  88. + caam_handle_t *handle,
  89. + const uint8_t *p,
  90. + size_t sizeP,
  91. + const uint8_t *r,
  92. + size_t sizeR,
  93. + const uint8_t *s,
  94. + size_t sizeS,
  95. + const uint8_t *hash,
  96. + size_t sizeHash,
  97. + int keyType);
  98. +
  99. +/*!
  100. + * brief generate ECC shared secret.
  101. + *
  102. + * This function creates an ECC shared secret.
  103. + *
  104. + * param base CAAM peripheral base address
  105. + * param[in] k private key
  106. + * param[in] sizeK holds size of input k in bytes.
  107. + * param[in] pub contains the public key (x,y)
  108. + * param[in] sizePub is the size of 'pub' in bytes.
  109. + * param[out] out output buffer to hold shared secret
  110. + * param[in] sizeOut size of out buffer
  111. + * param keyType type of ECC key i.e P256 / P384
  112. + * param enc option to use black key
  113. + * return Operation status.
  114. + */
  115. +status_t CAAM_ECC_ECDH(CAAM_Type *base,
  116. + caam_handle_t *handle,
  117. + const uint8_t *k,
  118. + size_t sizeK,
  119. + const uint8_t *pub,
  120. + size_t sizePub,
  121. + uint8_t *out,
  122. + size_t sizeOut,
  123. + int keyType,
  124. + uint32_t enc);
  125. +
  126. +
  127. +/* define for application to check for ECC CAAM additions */
  128. +#define CAAM_BLOB_EXPANSION
  129. +#define CAAM_RED_BLOB 1
  130. +#define CAAM_BLACK_BLOB 2
  131. +#define CAAM_ENCAP_BLOB 0x07000000
  132. +#define CAAM_DECAP_BLOB 0x06000000
  133. +#define CAAM_SM_KEYMODSZ 8
  134. +#define CAAM_KEYMODSZ 16
  135. +#define CAAM_PADDING_SIZE_BLOB 48
  136. +
  137. +/*!
  138. + * brief create or open a NXP blob.
  139. + *
  140. + * This function creates or opens a blob.
  141. + *
  142. + * param base CAAM peripheral base address
  143. + * param[in] in buffer to do operation on
  144. + * param[in] sizeIn holds size of input in in bytes.
  145. + * param[out] out buffer to hold the result of the operation
  146. + * param[in] sizeOut size in bytes of out buffer
  147. + * param[in] keyMod key that is used when creating or opening blob
  148. + * param[in] keyModSz size in bytes of keyMod
  149. + * param dir encap or decap of blob
  150. + * param color black or red blob type
  151. + * return Operation status.
  152. + */
  153. +status_t CAAM_Blob(CAAM_Type *base,
  154. + caam_handle_t *handle,
  155. + uint8_t *in,
  156. + size_t sizeIn,
  157. + uint8_t *out,
  158. + size_t sizeOut,
  159. + uint8_t *keyMod,
  160. + size_t keyModSz,
  161. + uint32_t dir,
  162. + uint32_t color);
  163. +
  164. #if defined(__cplusplus)
  165. }
  166. #endif