hal_crypto_lld.c 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file hal_crypto_lld.c
  15. * @brief PLATFORM cryptographic subsystem low level driver source.
  16. *
  17. * @addtogroup CRYPTO
  18. * @{
  19. */
  20. #include "hal.h"
  21. #if (HAL_USE_CRY == TRUE) || defined(__DOXYGEN__)
  22. /*===========================================================================*/
  23. /* Driver local definitions. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver exported variables. */
  27. /*===========================================================================*/
  28. /** @brief CRY1 driver identifier.*/
  29. #if PLATFORM_CRY_USE_CRY1 || defined(__DOXYGEN__)
  30. CRYDriver CRYD1;
  31. #endif
  32. /*===========================================================================*/
  33. /* Driver local variables and types. */
  34. /*===========================================================================*/
  35. /*===========================================================================*/
  36. /* Driver local functions. */
  37. /*===========================================================================*/
  38. /*===========================================================================*/
  39. /* Driver interrupt handlers. */
  40. /*===========================================================================*/
  41. /*===========================================================================*/
  42. /* Driver exported functions. */
  43. /*===========================================================================*/
  44. /**
  45. * @brief Low level crypto driver initialization.
  46. *
  47. * @notapi
  48. */
  49. void cry_lld_init(void) {
  50. }
  51. /**
  52. * @brief Configures and activates the crypto peripheral.
  53. *
  54. * @param[in] cryp pointer to the @p CRYDriver object
  55. *
  56. * @notapi
  57. */
  58. void cry_lld_start(CRYDriver *cryp) {
  59. if (cryp->state == CRY_STOP) {
  60. }
  61. }
  62. /**
  63. * @brief Deactivates the crypto peripheral.
  64. *
  65. * @param[in] cryp pointer to the @p CRYDriver object
  66. *
  67. * @notapi
  68. */
  69. void cry_lld_stop(CRYDriver *cryp) {
  70. if (cryp->state == CRY_READY) {
  71. }
  72. }
  73. #if (CRY_LLD_SUPPORTS_AES == TRUE) || defined(__DOXYGEN__)
  74. /**
  75. * @brief Initializes the AES transient key.
  76. * @note It is the underlying implementation to decide which key sizes are
  77. * allowable.
  78. *
  79. * @param[in] cryp pointer to the @p CRYDriver object
  80. * @param[in] size key size in bytes
  81. * @param[in] keyp pointer to the key data
  82. * @return The operation status.
  83. * @retval CRY_NOERROR if the operation succeeded.
  84. * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
  85. * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
  86. * the specified algorithm.
  87. *
  88. * @notapi
  89. */
  90. cryerror_t cry_lld_aes_loadkey(CRYDriver *cryp,
  91. size_t size,
  92. const uint8_t *keyp) {
  93. (void)cryp;
  94. (void)size;
  95. (void)keyp;
  96. return CRY_ERR_INV_ALGO;
  97. }
  98. /**
  99. * @brief Encryption of a single block using AES.
  100. * @note The implementation of this function must guarantee that it can
  101. * be called from any context.
  102. *
  103. * @param[in] cryp pointer to the @p CRYDriver object
  104. * @param[in] key_id the key to be used for the operation, zero is
  105. * the transient key, other values are keys stored
  106. * in an unspecified way
  107. * @param[in] in buffer containing the input plaintext
  108. * @param[out] out buffer for the output cyphertext
  109. * @return The operation status.
  110. * @retval CRY_NOERROR if the operation succeeded.
  111. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  112. * device instance.
  113. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  114. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  115. * or refers to an empty key slot.
  116. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  117. * dependent.
  118. *
  119. * @notapi
  120. */
  121. cryerror_t cry_lld_encrypt_AES(CRYDriver *cryp,
  122. crykey_t key_id,
  123. const uint8_t *in,
  124. uint8_t *out) {
  125. (void)cryp;
  126. (void)key_id;
  127. (void)in;
  128. (void)out;
  129. return CRY_ERR_INV_ALGO;
  130. }
  131. /**
  132. * @brief Decryption of a single block using AES.
  133. * @note The implementation of this function must guarantee that it can
  134. * be called from any context.
  135. *
  136. * @param[in] cryp pointer to the @p CRYDriver object
  137. * @param[in] key_id the key to be used for the operation, zero is
  138. * the transient key, other values are keys stored
  139. * in an unspecified way
  140. * @param[in] in buffer containing the input cyphertext
  141. * @param[out] out buffer for the output plaintext
  142. * @return The operation status.
  143. * @retval CRY_NOERROR if the operation succeeded.
  144. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  145. * device instance.
  146. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  147. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  148. * or refers to an empty key slot.
  149. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  150. * dependent.
  151. *
  152. * @notapi
  153. */
  154. cryerror_t cry_lld_decrypt_AES(CRYDriver *cryp,
  155. crykey_t key_id,
  156. const uint8_t *in,
  157. uint8_t *out) {
  158. (void)cryp;
  159. (void)key_id;
  160. (void)in;
  161. (void)out;
  162. return CRY_ERR_INV_ALGO;
  163. }
  164. #endif
  165. #if (CRY_LLD_SUPPORTS_AES_ECB == TRUE) || defined(__DOXYGEN__)
  166. /**
  167. * @brief Encryption operation using AES-ECB.
  168. * @note The function operates on data buffers whose lenght is a multiple
  169. * of an AES block, this means that padding must be done by the
  170. * caller.
  171. *
  172. * @param[in] cryp pointer to the @p CRYDriver object
  173. * @param[in] key_id the key to be used for the operation, zero is
  174. * the transient key, other values are keys stored
  175. * in an unspecified way
  176. * @param[in] size size of the plaintext buffer, this number must
  177. * be a multiple of the selected key size
  178. * @param[in] in buffer containing the input plaintext
  179. * @param[out] out buffer for the output cyphertext
  180. * @return The operation status.
  181. * @retval CRY_NOERROR if the operation succeeded.
  182. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  183. * device instance.
  184. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  185. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  186. * or refers to an empty key slot.
  187. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  188. * dependent.
  189. *
  190. * @notapi
  191. */
  192. cryerror_t cry_lld_encrypt_AES_ECB(CRYDriver *cryp,
  193. crykey_t key_id,
  194. size_t size,
  195. const uint8_t *in,
  196. uint8_t *out) {
  197. (void)cryp;
  198. (void)key_id;
  199. (void)size;
  200. (void)in;
  201. (void)out;
  202. return CRY_ERR_INV_ALGO;
  203. }
  204. /**
  205. * @brief Decryption operation using AES-ECB.
  206. * @note The function operates on data buffers whose lenght is a multiple
  207. * of an AES block, this means that padding must be done by the
  208. * caller.
  209. *
  210. * @param[in] cryp pointer to the @p CRYDriver object
  211. * @param[in] key_id the key to be used for the operation, zero is
  212. * the transient key, other values are keys stored
  213. * in an unspecified way
  214. * @param[in] size size of the plaintext buffer, this number must
  215. * be a multiple of the selected key size
  216. * @param[in] in buffer containing the input plaintext
  217. * @param[out] out buffer for the output cyphertext
  218. * @return The operation status.
  219. * @retval CRY_NOERROR if the operation succeeded.
  220. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  221. * device instance.
  222. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  223. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  224. * or refers to an empty key slot.
  225. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  226. * dependent.
  227. *
  228. * @notapi
  229. */
  230. cryerror_t cry_lld_decrypt_AES_ECB(CRYDriver *cryp,
  231. crykey_t key_id,
  232. size_t size,
  233. const uint8_t *in,
  234. uint8_t *out) {
  235. (void)cryp;
  236. (void)key_id;
  237. (void)size;
  238. (void)in;
  239. (void)out;
  240. return CRY_ERR_INV_ALGO;
  241. }
  242. #endif
  243. #if (CRY_LLD_SUPPORTS_AES_CBC == TRUE) || defined(__DOXYGEN__)
  244. /**
  245. * @brief Encryption operation using AES-CBC.
  246. * @note The function operates on data buffers whose lenght is a multiple
  247. * of an AES block, this means that padding must be done by the
  248. * caller.
  249. *
  250. * @param[in] cryp pointer to the @p CRYDriver object
  251. * @param[in] key_id the key to be used for the operation, zero is
  252. * the transient key, other values are keys stored
  253. * in an unspecified way
  254. * @param[in] size size of the plaintext buffer, this number must
  255. * be a multiple of the selected key size
  256. * @param[in] in buffer containing the input plaintext
  257. * @param[out] out buffer for the output cyphertext
  258. * @param[in] iv 128 bits initial vector
  259. * @return The operation status.
  260. * @retval CRY_NOERROR if the operation succeeded.
  261. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  262. * device instance.
  263. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  264. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  265. * or refers to an empty key slot.
  266. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  267. * dependent.
  268. *
  269. * @notapi
  270. */
  271. cryerror_t cry_lld_encrypt_AES_CBC(CRYDriver *cryp,
  272. crykey_t key_id,
  273. size_t size,
  274. const uint8_t *in,
  275. uint8_t *out,
  276. const uint8_t *iv) {
  277. (void)cryp;
  278. (void)key_id;
  279. (void)size;
  280. (void)in;
  281. (void)out;
  282. (void)iv;
  283. return CRY_ERR_INV_ALGO;
  284. }
  285. /**
  286. * @brief Decryption operation using AES-CBC.
  287. * @note The function operates on data buffers whose lenght is a multiple
  288. * of an AES block, this means that padding must be done by the
  289. * caller.
  290. *
  291. * @param[in] cryp pointer to the @p CRYDriver object
  292. * @param[in] key_id the key to be used for the operation, zero is
  293. * the transient key, other values are keys stored
  294. * in an unspecified way
  295. * @param[in] size size of the plaintext buffer, this number must
  296. * be a multiple of the selected key size
  297. * @param[in] in buffer containing the input plaintext
  298. * @param[out] out buffer for the output cyphertext
  299. * @param[in] iv 128 bits initial vector
  300. * @return The operation status.
  301. * @retval CRY_NOERROR if the operation succeeded.
  302. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  303. * device instance.
  304. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  305. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  306. * or refers to an empty key slot.
  307. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  308. * dependent.
  309. *
  310. * @notapi
  311. */
  312. cryerror_t cry_lld_decrypt_AES_CBC(CRYDriver *cryp,
  313. crykey_t key_id,
  314. size_t size,
  315. const uint8_t *in,
  316. uint8_t *out,
  317. const uint8_t *iv) {
  318. (void)cryp;
  319. (void)key_id;
  320. (void)size;
  321. (void)in;
  322. (void)out;
  323. (void)iv;
  324. return CRY_ERR_INV_ALGO;
  325. }
  326. #endif
  327. #if (CRY_LLD_SUPPORTS_AES_CFB == TRUE) || defined(__DOXYGEN__)
  328. /**
  329. * @brief Encryption operation using AES-CFB.
  330. * @note The function operates on data buffers whose lenght is a multiple
  331. * of an AES block, this means that padding must be done by the
  332. * caller.
  333. *
  334. * @param[in] cryp pointer to the @p CRYDriver object
  335. * @param[in] key_id the key to be used for the operation, zero is
  336. * the transient key, other values are keys stored
  337. * in an unspecified way
  338. * @param[in] size size of the plaintext buffer, this number must
  339. * be a multiple of the selected key size
  340. * @param[in] in buffer containing the input plaintext
  341. * @param[out] out buffer for the output cyphertext
  342. * @param[in] iv 128 bits initial vector
  343. * @return The operation status.
  344. * @retval CRY_NOERROR if the operation succeeded.
  345. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  346. * device instance.
  347. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  348. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  349. * or refers to an empty key slot.
  350. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  351. * dependent.
  352. *
  353. * @notapi
  354. */
  355. cryerror_t cry_lld_encrypt_AES_CFB(CRYDriver *cryp,
  356. crykey_t key_id,
  357. size_t size,
  358. const uint8_t *in,
  359. uint8_t *out,
  360. const uint8_t *iv) {
  361. (void)cryp;
  362. (void)key_id;
  363. (void)size;
  364. (void)in;
  365. (void)out;
  366. (void)iv;
  367. return CRY_ERR_INV_ALGO;
  368. }
  369. /**
  370. * @brief Decryption operation using AES-CFB.
  371. * @note The function operates on data buffers whose lenght is a multiple
  372. * of an AES block, this means that padding must be done by the
  373. * caller.
  374. *
  375. * @param[in] cryp pointer to the @p CRYDriver object
  376. * @param[in] key_id the key to be used for the operation, zero is
  377. * the transient key, other values are keys stored
  378. * in an unspecified way
  379. * @param[in] size size of the plaintext buffer, this number must
  380. * be a multiple of the selected key size
  381. * @param[in] in buffer containing the input plaintext
  382. * @param[out] out buffer for the output cyphertext
  383. * @param[in] iv 128 bits initial vector
  384. * @return The operation status.
  385. * @retval CRY_NOERROR if the operation succeeded.
  386. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  387. * device instance.
  388. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  389. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  390. * or refers to an empty key slot.
  391. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  392. * dependent.
  393. *
  394. * @notapi
  395. */
  396. cryerror_t cry_lld_decrypt_AES_CFB(CRYDriver *cryp,
  397. crykey_t key_id,
  398. size_t size,
  399. const uint8_t *in,
  400. uint8_t *out,
  401. const uint8_t *iv) {
  402. (void)cryp;
  403. (void)key_id;
  404. (void)size;
  405. (void)in;
  406. (void)out;
  407. (void)iv;
  408. return CRY_ERR_INV_ALGO;
  409. }
  410. #endif
  411. #if (CRY_LLD_SUPPORTS_AES_CTR == TRUE) || defined(__DOXYGEN__)
  412. /**
  413. * @brief Encryption operation using AES-CTR.
  414. * @note The function operates on data buffers whose lenght is a multiple
  415. * of an AES block, this means that padding must be done by the
  416. * caller.
  417. *
  418. * @param[in] cryp pointer to the @p CRYDriver object
  419. * @param[in] key_id the key to be used for the operation, zero is
  420. * the transient key, other values are keys stored
  421. * in an unspecified way
  422. * @param[in] size size of the plaintext buffer, this number must
  423. * be a multiple of 16
  424. * @param[in] in buffer containing the input plaintext
  425. * @param[out] out buffer for the output cyphertext
  426. * @param[in] iv 128 bits initial vector + counter, it contains
  427. * a 96 bits IV and a 32 bits counter
  428. * @return The operation status.
  429. * @retval CRY_NOERROR if the operation succeeded.
  430. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  431. * device instance.
  432. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  433. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  434. * or refers to an empty key slot.
  435. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  436. * dependent.
  437. *
  438. * @notapi
  439. */
  440. cryerror_t cry_lld_encrypt_AES_CTR(CRYDriver *cryp,
  441. crykey_t key_id,
  442. size_t size,
  443. const uint8_t *in,
  444. uint8_t *out,
  445. const uint8_t *iv) {
  446. (void)cryp;
  447. (void)key_id;
  448. (void)size;
  449. (void)in;
  450. (void)out;
  451. (void)iv;
  452. return CRY_ERR_INV_ALGO;
  453. }
  454. /**
  455. * @brief Decryption operation using AES-CTR.
  456. * @note The function operates on data buffers whose lenght is a multiple
  457. * of an AES block, this means that padding must be done by the
  458. * caller.
  459. *
  460. * @param[in] cryp pointer to the @p CRYDriver object
  461. * @param[in] key_id the key to be used for the operation, zero is
  462. * the transient key, other values are keys stored
  463. * in an unspecified way
  464. * @param[in] size size of the plaintext buffer, this number must
  465. * be a multiple of 16
  466. * @param[in] in buffer containing the input cyphertext
  467. * @param[out] out buffer for the output plaintext
  468. * @param[in] iv 128 bits initial vector + counter, it contains
  469. * a 96 bits IV and a 32 bits counter
  470. * @return The operation status.
  471. * @retval CRY_NOERROR if the operation succeeded.
  472. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  473. * device instance.
  474. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  475. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  476. * or refers to an empty key slot.
  477. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  478. * dependent.
  479. *
  480. * @notapi
  481. */
  482. cryerror_t cry_lld_decrypt_AES_CTR(CRYDriver *cryp,
  483. crykey_t key_id,
  484. size_t size,
  485. const uint8_t *in,
  486. uint8_t *out,
  487. const uint8_t *iv) {
  488. (void)cryp;
  489. (void)key_id;
  490. (void)size;
  491. (void)in;
  492. (void)out;
  493. (void)iv;
  494. return CRY_ERR_INV_ALGO;
  495. }
  496. #endif
  497. #if (CRY_LLD_SUPPORTS_AES_GCM == TRUE) || defined(__DOXYGEN__)
  498. /**
  499. * @brief Encryption operation using AES-GCM.
  500. * @note The function operates on data buffers whose lenght is a multiple
  501. * of an AES block, this means that padding must be done by the
  502. * caller.
  503. *
  504. * @param[in] cryp pointer to the @p CRYDriver object
  505. * @param[in] key_id the key to be used for the operation, zero is
  506. * the transient key, other values are keys stored
  507. * in an unspecified way
  508. * @param[in] size size of the text buffers, this number must be a
  509. * multiple of 16
  510. * @param[in] in buffer containing the input plaintext
  511. * @param[out] out buffer for the output cyphertext
  512. * @param[in] iv 128 bits initial vector + counter, it contains
  513. * a 96 bits IV and a 32 bits counter
  514. * @param[in] aadsize size of the authentication data, this number
  515. * must be a multiple of 16
  516. * @param[in] aad buffer containing the authentication data
  517. * @param[in] authtag 128 bits buffer for the generated authentication
  518. * tag
  519. * @return The operation status.
  520. * @retval CRY_NOERROR if the operation succeeded.
  521. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  522. * device instance.
  523. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  524. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  525. * or refers to an empty key slot.
  526. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  527. * dependent.
  528. *
  529. * @notapi
  530. */
  531. cryerror_t cry_lld_encrypt_AES_GCM(CRYDriver *cryp,
  532. crykey_t key_id,
  533. size_t size,
  534. const uint8_t *in,
  535. uint8_t *out,
  536. const uint8_t *iv,
  537. size_t aadsize,
  538. const uint8_t *aad,
  539. uint8_t *authtag) {
  540. (void)cryp;
  541. (void)key_id;
  542. (void)size;
  543. (void)in;
  544. (void)out;
  545. (void)iv;
  546. (void)aadsize;
  547. (void)aad;
  548. (void)authtag;
  549. return CRY_ERR_INV_ALGO;
  550. }
  551. /**
  552. * @brief Decryption operation using AES-GCM.
  553. * @note The function operates on data buffers whose lenght is a multiple
  554. * of an AES block, this means that padding must be done by the
  555. * caller.
  556. *
  557. * @param[in] cryp pointer to the @p CRYDriver object
  558. * @param[in] key_id the key to be used for the operation, zero is
  559. * the transient key, other values are keys stored
  560. * in an unspecified way
  561. * @param[in] size size of the text buffers, this number must be a
  562. * multiple of 16
  563. * @param[in] in buffer for the output cyphertext
  564. * @param[out] out buffer containing the input plaintext
  565. * @param[in] iv 128 bits initial vector + counter, it contains
  566. * a 96 bits IV and a 32 bits counter
  567. * @param[in] aadsize size of the authentication data, this number
  568. * must be a multiple of 16
  569. * @param[in] aad buffer containing the authentication data
  570. * @param[in] authtag 128 bits buffer for the generated authentication
  571. * tag
  572. * @return The operation status.
  573. * @retval CRY_NOERROR if the operation succeeded.
  574. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  575. * device instance.
  576. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  577. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  578. * or refers to an empty key slot.
  579. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  580. * dependent.
  581. *
  582. * @notapi
  583. */
  584. cryerror_t cry_lld_decrypt_AES_GCM(CRYDriver *cryp,
  585. crykey_t key_id,
  586. size_t size,
  587. const uint8_t *in,
  588. uint8_t *out,
  589. const uint8_t *iv,
  590. size_t aadsize,
  591. const uint8_t *aad,
  592. uint8_t *authtag) {
  593. (void)cryp;
  594. (void)key_id;
  595. (void)size;
  596. (void)in;
  597. (void)out;
  598. (void)iv;
  599. (void)aadsize;
  600. (void)aad;
  601. (void)authtag;
  602. return CRY_ERR_INV_ALGO;
  603. }
  604. #endif
  605. #if (CRY_LLD_SUPPORTS_DES == TRUE) || defined(__DOXYGEN__)
  606. /**
  607. * @brief Initializes the DES transient key.
  608. * @note It is the underlying implementation to decide which key sizes are
  609. * allowable.
  610. *
  611. * @param[in] cryp pointer to the @p CRYDriver object
  612. * @param[in] size key size in bytes
  613. * @param[in] keyp pointer to the key data
  614. * @return The operation status.
  615. * @retval CRY_NOERROR if the operation succeeded.
  616. * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
  617. * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
  618. * the specified algorithm.
  619. *
  620. * @notapi
  621. */
  622. cryerror_t cry_lld_des_loadkey(CRYDriver *cryp,
  623. size_t size,
  624. const uint8_t *keyp) {
  625. (void)cryp;
  626. (void)size;
  627. (void)keyp;
  628. return CRY_ERR_INV_ALGO;
  629. }
  630. /**
  631. * @brief Encryption of a single block using (T)DES.
  632. * @note The implementation of this function must guarantee that it can
  633. * be called from any context.
  634. *
  635. * @param[in] cryp pointer to the @p CRYDriver object
  636. * @param[in] key_id the key to be used for the operation, zero is
  637. * the transient key, other values are keys stored
  638. * in an unspecified way
  639. * @param[in] in buffer containing the input plaintext
  640. * @param[out] out buffer for the output cyphertext
  641. * @return The operation status.
  642. * @retval CRY_NOERROR if the operation succeeded.
  643. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  644. * device instance.
  645. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  646. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  647. * or refers to an empty key slot.
  648. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  649. * dependent.
  650. *
  651. * @notapi
  652. */
  653. cryerror_t cry_lld_encrypt_DES(CRYDriver *cryp,
  654. crykey_t key_id,
  655. const uint8_t *in,
  656. uint8_t *out) {
  657. (void)cryp;
  658. (void)key_id;
  659. (void)in;
  660. (void)out;
  661. return CRY_ERR_INV_ALGO;
  662. }
  663. /**
  664. * @brief Decryption of a single block using (T)DES.
  665. * @note The implementation of this function must guarantee that it can
  666. * be called from any context.
  667. *
  668. *
  669. * @param[in] cryp pointer to the @p CRYDriver object
  670. * @param[in] key_id the key to be used for the operation, zero is
  671. * the transient key, other values are keys stored
  672. * in an unspecified way
  673. * @param[in] in buffer containing the input cyphertext
  674. * @param[out] out buffer for the output plaintext
  675. * @return The operation status.
  676. * @retval CRY_NOERROR if the operation succeeded.
  677. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  678. * device instance.
  679. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  680. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  681. * or refers to an empty key slot.
  682. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  683. * dependent.
  684. *
  685. * @notapi
  686. */
  687. cryerror_t cry_lld_decrypt_DES(CRYDriver *cryp,
  688. crykey_t key_id,
  689. const uint8_t *in,
  690. uint8_t *out) {
  691. (void)cryp;
  692. (void)key_id;
  693. (void)in;
  694. (void)out;
  695. return CRY_ERR_INV_ALGO;
  696. }
  697. #endif
  698. #if (CRY_LLD_SUPPORTS_DES_ECB == TRUE) || defined(__DOXYGEN__)
  699. /**
  700. * @brief Encryption operation using (T)DES-ECB.
  701. * @note The function operates on data buffers whose length is a multiple
  702. * of an DES block, this means that padding must be done by the
  703. * caller.
  704. *
  705. * @param[in] cryp pointer to the @p CRYDriver object
  706. * @param[in] key_id the key to be used for the operation, zero is
  707. * the transient key, other values are keys stored
  708. * in an unspecified way
  709. * @param[in] size size of the plaintext buffer, this number must
  710. * be a multiple of 8
  711. * @param[in] in buffer containing the input plaintext
  712. * @param[out] out buffer for the output cyphertext
  713. * @return The operation status.
  714. * @retval CRY_NOERROR if the operation succeeded.
  715. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  716. * device instance.
  717. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  718. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  719. * or refers to an empty key slot.
  720. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  721. * dependent.
  722. *
  723. * @notapi
  724. */
  725. cryerror_t cry_lld_encrypt_DES_ECB(CRYDriver *cryp,
  726. crykey_t key_id,
  727. size_t size,
  728. const uint8_t *in,
  729. uint8_t *out) {
  730. (void)cryp;
  731. (void)key_id;
  732. (void)size;
  733. (void)in;
  734. (void)out;
  735. return CRY_ERR_INV_ALGO;
  736. }
  737. /**
  738. * @brief Decryption operation using (T)DES-ECB.
  739. * @note The function operates on data buffers whose length is a multiple
  740. * of an DES block, this means that padding must be done by the
  741. * caller.
  742. *
  743. * @param[in] cryp pointer to the @p CRYDriver object
  744. * @param[in] key_id the key to be used for the operation, zero is
  745. * the transient key, other values are keys stored
  746. * in an unspecified way
  747. * @param[in] size size of the plaintext buffer, this number must
  748. * be a multiple of 8
  749. * @param[in] in buffer containing the input cyphertext
  750. * @param[out] out buffer for the output plaintext
  751. * @return T he operation status.
  752. * @retval CRY_NOERROR if the operation succeeded.
  753. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  754. * device instance.
  755. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  756. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  757. * or refers to an empty key slot.
  758. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  759. * dependent.
  760. *
  761. * @notapi
  762. */
  763. cryerror_t cry_lld_decrypt_DES_ECB(CRYDriver *cryp,
  764. crykey_t key_id,
  765. size_t size,
  766. const uint8_t *in,
  767. uint8_t *out) {
  768. (void)cryp;
  769. (void)key_id;
  770. (void)size;
  771. (void)in;
  772. (void)out;
  773. return CRY_ERR_INV_ALGO;
  774. }
  775. #endif
  776. #if (CRY_LLD_SUPPORTS_DES_CBC == TRUE) || defined(__DOXYGEN__)
  777. /**
  778. * @brief Encryption operation using (T)DES-CBC.
  779. * @note The function operates on data buffers whose length is a multiple
  780. * of an DES block, this means that padding must be done by the
  781. * caller.
  782. *
  783. * @param[in] cryp pointer to the @p CRYDriver object
  784. * @param[in] key_id the key to be used for the operation, zero is
  785. * the transient key, other values are keys stored
  786. * in an unspecified way
  787. * @param[in] size size of the plaintext buffer, this number must
  788. * be a multiple of 8
  789. * @param[in] in buffer containing the input plaintext
  790. * @param[out] out buffer for the output cyphertext
  791. * @param[in] iv 64 bits input vector
  792. * @return The operation status.
  793. * @retval CRY_NOERROR if the operation succeeded.
  794. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  795. * device instance.
  796. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  797. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  798. * or refers to an empty key slot.
  799. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  800. * dependent.
  801. *
  802. * @notapi
  803. */
  804. cryerror_t cry_lld_encrypt_DES_CBC(CRYDriver *cryp,
  805. crykey_t key_id,
  806. size_t size,
  807. const uint8_t *in,
  808. uint8_t *out,
  809. const uint8_t *iv) {
  810. (void)cryp;
  811. (void)key_id;
  812. (void)size;
  813. (void)in;
  814. (void)out;
  815. (void)iv;
  816. return CRY_ERR_INV_ALGO;
  817. }
  818. /**
  819. * @brief Decryption operation using (T)DES-CBC.
  820. * @note The function operates on data buffers whose length is a multiple
  821. * of an DES block, this means that padding must be done by the
  822. * caller.
  823. *
  824. * @param[in] cryp pointer to the @p CRYDriver object
  825. * @param[in] key_id the key to be used for the operation, zero is
  826. * the transient key, other values are keys stored
  827. * in an unspecified way
  828. * @param[in] size size of the plaintext buffer, this number must
  829. * be a multiple of 8
  830. * @param[in] in buffer containing the input cyphertext
  831. * @param[out] out buffer for the output plaintext
  832. * @param[in] iv 64 bits input vector
  833. * @return The operation status.
  834. * @retval CRY_NOERROR if the operation succeeded.
  835. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  836. * device instance.
  837. * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
  838. * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
  839. * or refers to an empty key slot.
  840. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  841. * dependent.
  842. *
  843. * @notapi
  844. */
  845. cryerror_t cry_lld_decrypt_DES_CBC(CRYDriver *cryp,
  846. crykey_t key_id,
  847. size_t size,
  848. const uint8_t *in,
  849. uint8_t *out,
  850. const uint8_t *iv) {
  851. (void)cryp;
  852. (void)key_id;
  853. (void)size;
  854. (void)in;
  855. (void)out;
  856. (void)iv;
  857. return CRY_ERR_INV_ALGO;
  858. }
  859. #endif
  860. #if (CRY_LLD_SUPPORTS_SHA1 == TRUE) || defined(__DOXYGEN__)
  861. /**
  862. * @brief Hash initialization using SHA1.
  863. * @note Use of this algorithm is not recommended because proven weak.
  864. *
  865. * @param[in] cryp pointer to the @p CRYDriver object
  866. * @param[out] sha1ctxp pointer to a SHA1 context to be initialized
  867. * @retval CRY_NOERROR if the operation succeeded.
  868. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  869. * device instance.
  870. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  871. * dependent.
  872. *
  873. * @notapi
  874. */
  875. cryerror_t cry_lld_SHA1_init(CRYDriver *cryp, SHA1Context *sha1ctxp) {
  876. (void)cryp;
  877. (void)sha1ctxp;
  878. return CRY_ERR_INV_ALGO;
  879. }
  880. /**
  881. * @brief Hash update using SHA1.
  882. * @note Use of this algorithm is not recommended because proven weak.
  883. *
  884. * @param[in] cryp pointer to the @p CRYDriver object
  885. * @param[in] sha1ctxp pointer to a SHA1 context
  886. * @param[in] size size of input buffer
  887. * @param[in] in buffer containing the input text
  888. * @return The operation status.
  889. * @retval CRY_NOERROR if the operation succeeded.
  890. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  891. * device instance.
  892. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  893. * dependent.
  894. *
  895. * @notapi
  896. */
  897. cryerror_t cry_lld_SHA1_update(CRYDriver *cryp, SHA1Context *sha1ctxp,
  898. size_t size, const uint8_t *in) {
  899. (void)cryp;
  900. (void)sha1ctxp;
  901. (void)size;
  902. (void)in;
  903. return CRY_ERR_INV_ALGO;
  904. }
  905. /**
  906. * @brief Hash finalization using SHA1.
  907. * @note Use of this algorithm is not recommended because proven weak.
  908. *
  909. * @param[in] cryp pointer to the @p CRYDriver object
  910. * @param[in] sha1ctxp pointer to a SHA1 context
  911. * @param[out] out 160 bits output buffer
  912. * @return The operation status.
  913. * @retval CRY_NOERROR if the operation succeeded.
  914. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  915. * device instance.
  916. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  917. * dependent.
  918. *
  919. * @notapi
  920. */
  921. cryerror_t cry_lld_SHA1_final(CRYDriver *cryp, SHA1Context *sha1ctxp,
  922. uint8_t *out) {
  923. (void)cryp;
  924. (void)sha1ctxp;
  925. (void)out;
  926. return CRY_ERR_INV_ALGO;
  927. }
  928. #endif
  929. #if (CRY_LLD_SUPPORTS_SHA256 == TRUE) || defined(__DOXYGEN__)
  930. /**
  931. * @brief Hash initialization using SHA256.
  932. *
  933. * @param[in] cryp pointer to the @p CRYDriver object
  934. * @param[out] sha256ctxp pointer to a SHA256 context to be initialized
  935. * @retval CRY_NOERROR if the operation succeeded.
  936. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  937. * device instance.
  938. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  939. * dependent.
  940. *
  941. * @notapi
  942. */
  943. cryerror_t cry_lld_SHA256_init(CRYDriver *cryp, SHA256Context *sha256ctxp) {
  944. (void)cryp;
  945. (void)sha256ctxp;
  946. return CRY_ERR_INV_ALGO;
  947. }
  948. /**
  949. * @brief Hash update using SHA256.
  950. *
  951. * @param[in] cryp pointer to the @p CRYDriver object
  952. * @param[in] sha256ctxp pointer to a SHA256 context
  953. * @param[in] size size of input buffer
  954. * @param[in] in buffer containing the input text
  955. * @return The operation status.
  956. * @retval CRY_NOERROR if the operation succeeded.
  957. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  958. * device instance.
  959. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  960. * dependent.
  961. *
  962. * @notapi
  963. */
  964. cryerror_t cry_lld_SHA256_update(CRYDriver *cryp, SHA256Context *sha256ctxp,
  965. size_t size, const uint8_t *in) {
  966. (void)cryp;
  967. (void)sha256ctxp;
  968. (void)size;
  969. (void)in;
  970. return CRY_ERR_INV_ALGO;
  971. }
  972. /**
  973. * @brief Hash finalization using SHA256.
  974. *
  975. * @param[in] cryp pointer to the @p CRYDriver object
  976. * @param[in] sha256ctxp pointer to a SHA256 context
  977. * @param[out] out 256 bits output buffer
  978. * @return The operation status.
  979. * @retval CRY_NOERROR if the operation succeeded.
  980. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  981. * device instance.
  982. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  983. * dependent.
  984. *
  985. * @notapi
  986. */
  987. cryerror_t cry_lld_SHA256_final(CRYDriver *cryp, SHA256Context *sha256ctxp,
  988. uint8_t *out) {
  989. (void)cryp;
  990. (void)sha256ctxp;
  991. (void)out;
  992. return CRY_ERR_INV_ALGO;
  993. }
  994. #endif
  995. #if (CRY_LLD_SUPPORTS_SHA512 == TRUE) || defined(__DOXYGEN__)
  996. /**
  997. * @brief Hash initialization using SHA512.
  998. *
  999. * @param[in] cryp pointer to the @p CRYDriver object
  1000. * @param[out] sha512ctxp pointer to a SHA512 context to be initialized
  1001. * @retval CRY_NOERROR if the operation succeeded.
  1002. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1003. * device instance.
  1004. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1005. * dependent.
  1006. *
  1007. * @notapi
  1008. */
  1009. cryerror_t cry_lld_SHA512_init(CRYDriver *cryp, SHA512Context *sha512ctxp) {
  1010. (void)cryp;
  1011. (void)sha512ctxp;
  1012. return CRY_ERR_INV_ALGO;
  1013. }
  1014. /**
  1015. * @brief Hash update using SHA512.
  1016. *
  1017. * @param[in] cryp pointer to the @p CRYDriver object
  1018. * @param[in] sha512ctxp pointer to a SHA512 context
  1019. * @param[in] size size of input buffer
  1020. * @param[in] in buffer containing the input text
  1021. * @return The operation status.
  1022. * @retval CRY_NOERROR if the operation succeeded.
  1023. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1024. * device instance.
  1025. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1026. * dependent.
  1027. *
  1028. * @notapi
  1029. */
  1030. cryerror_t cry_lld_SHA512_update(CRYDriver *cryp, SHA512Context *sha512ctxp,
  1031. size_t size, const uint8_t *in) {
  1032. (void)cryp;
  1033. (void)sha512ctxp;
  1034. (void)size;
  1035. (void)in;
  1036. return CRY_ERR_INV_ALGO;
  1037. }
  1038. /**
  1039. * @brief Hash finalization using SHA512.
  1040. *
  1041. * @param[in] cryp pointer to the @p CRYDriver object
  1042. * @param[in] sha512ctxp pointer to a SHA512 context
  1043. * @param[out] out 512 bits output buffer
  1044. * @return The operation status.
  1045. * @retval CRY_NOERROR if the operation succeeded.
  1046. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1047. * device instance.
  1048. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1049. * dependent.
  1050. *
  1051. * @notapi
  1052. */
  1053. cryerror_t cry_lld_SHA512_final(CRYDriver *cryp, SHA512Context *sha512ctxp,
  1054. uint8_t *out) {
  1055. (void)cryp;
  1056. (void)sha512ctxp;
  1057. (void)out;
  1058. return CRY_ERR_INV_ALGO;
  1059. }
  1060. #endif
  1061. #if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || defined(__DOXYGEN__)
  1062. /**
  1063. * @brief Initializes the HMAC transient key.
  1064. * @note It is the underlying implementation to decide which key sizes are
  1065. * allowable.
  1066. *
  1067. * @param[in] cryp pointer to the @p CRYDriver object
  1068. * @param[in] size key size in bytes
  1069. * @param[in] keyp pointer to the key data
  1070. * @return The operation status.
  1071. * @retval CRY_NOERROR if the operation succeeded.
  1072. * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
  1073. * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
  1074. * the specified algorithm.
  1075. *
  1076. * @notapi
  1077. */
  1078. cryerror_t cry_lld_hmac_loadkey(CRYDriver *cryp,
  1079. size_t size,
  1080. const uint8_t *keyp) {
  1081. (void)cryp;
  1082. (void)size;
  1083. (void)keyp;
  1084. return CRY_ERR_INV_ALGO;
  1085. }
  1086. /**
  1087. * @brief Hash initialization using HMAC_SHA256.
  1088. *
  1089. * @param[in] cryp pointer to the @p CRYDriver object
  1090. * @param[out] hmacsha256ctxp pointer to a HMAC_SHA256 context to be
  1091. * initialized
  1092. * @return The operation status.
  1093. * @retval CRY_NOERROR if the operation succeeded.
  1094. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1095. * device instance.
  1096. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1097. * dependent.
  1098. *
  1099. * @notapi
  1100. */
  1101. cryerror_t cry_lld_HMACSHA256_init(CRYDriver *cryp,
  1102. HMACSHA256Context *hmacsha256ctxp) {
  1103. (void)cryp;
  1104. (void)hmacsha256ctxp;
  1105. return CRY_ERR_INV_ALGO;
  1106. }
  1107. /**
  1108. * @brief Hash update using HMAC.
  1109. *
  1110. * @param[in] cryp pointer to the @p CRYDriver object
  1111. * @param[in] hmacsha256ctxp pointer to a HMAC_SHA256 context
  1112. * @param[in] size size of input buffer
  1113. * @param[in] in buffer containing the input text
  1114. * @return The operation status.
  1115. * @retval CRY_NOERROR if the operation succeeded.
  1116. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1117. * device instance.
  1118. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1119. * dependent.
  1120. *
  1121. * @notapi
  1122. */
  1123. cryerror_t cry_lld_HMACSHA256_update(CRYDriver *cryp,
  1124. HMACSHA256Context *hmacsha256ctxp,
  1125. size_t size,
  1126. const uint8_t *in) {
  1127. (void)cryp;
  1128. (void)hmacsha256ctxp;
  1129. (void)size;
  1130. (void)in;
  1131. return CRY_ERR_INV_ALGO;
  1132. }
  1133. /**
  1134. * @brief Hash finalization using HMAC.
  1135. *
  1136. * @param[in] cryp pointer to the @p CRYDriver object
  1137. * @param[in] hmacsha256ctxp pointer to a HMAC_SHA256 context
  1138. * @param[out] out 256 bits output buffer
  1139. * @return The operation status.
  1140. * @retval CRY_NOERROR if the operation succeeded.
  1141. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1142. * device instance.
  1143. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1144. * dependent.
  1145. *
  1146. * @notapi
  1147. */
  1148. cryerror_t cry_lld_HMACSHA256_final(CRYDriver *cryp,
  1149. HMACSHA256Context *hmacsha256ctxp,
  1150. uint8_t *out) {
  1151. (void)cryp;
  1152. (void)hmacsha256ctxp;
  1153. (void)out;
  1154. return CRY_ERR_INV_ALGO;
  1155. }
  1156. #endif
  1157. #if (CRY_LLD_SUPPORTS_HMAC_SHA512 == TRUE) || defined(__DOXYGEN__)
  1158. /**
  1159. * @brief Hash initialization using HMAC_SHA512.
  1160. *
  1161. * @param[in] cryp pointer to the @p CRYDriver object
  1162. * @param[out] hmacsha512ctxp pointer to a HMAC_SHA512 context to be
  1163. * initialized
  1164. * @return The operation status.
  1165. * @retval CRY_NOERROR if the operation succeeded.
  1166. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1167. * device instance.
  1168. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1169. * dependent.
  1170. *
  1171. * @notapi
  1172. */
  1173. cryerror_t cry_lld_HMACSHA512_init(CRYDriver *cryp,
  1174. HMACSHA512Context *hmacsha512ctxp) {
  1175. (void)cryp;
  1176. (void)hmacsha512ctxp;
  1177. return CRY_ERR_INV_ALGO;
  1178. }
  1179. /**
  1180. * @brief Hash update using HMAC.
  1181. *
  1182. * @param[in] cryp pointer to the @p CRYDriver object
  1183. * @param[in] hmacsha512ctxp pointer to a HMAC_SHA512 context
  1184. * @param[in] size size of input buffer
  1185. * @param[in] in buffer containing the input text
  1186. * @return The operation status.
  1187. * @retval CRY_NOERROR if the operation succeeded.
  1188. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1189. * device instance.
  1190. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1191. * dependent.
  1192. *
  1193. * @notapi
  1194. */
  1195. cryerror_t cry_lld_HMACSHA512_update(CRYDriver *cryp,
  1196. HMACSHA512Context *hmacsha512ctxp,
  1197. size_t size,
  1198. const uint8_t *in) {
  1199. (void)cryp;
  1200. (void)hmacsha512ctxp;
  1201. (void)size;
  1202. (void)in;
  1203. return CRY_ERR_INV_ALGO;
  1204. }
  1205. /**
  1206. * @brief Hash finalization using HMAC.
  1207. *
  1208. * @param[in] cryp pointer to the @p CRYDriver object
  1209. * @param[in] hmacsha512ctxp pointer to a HMAC_SHA512 context
  1210. * @param[out] out 512 bits output buffer
  1211. * @return The operation status.
  1212. * @retval CRY_NOERROR if the operation succeeded.
  1213. * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
  1214. * device instance.
  1215. * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
  1216. * dependent.
  1217. *
  1218. * @notapi
  1219. */
  1220. cryerror_t cry_lld_HMACSHA512_final(CRYDriver *cryp,
  1221. HMACSHA512Context *hmacsha512ctxp,
  1222. uint8_t *out) {
  1223. (void)cryp;
  1224. (void)hmacsha512ctxp;
  1225. (void)out;
  1226. return CRY_ERR_INV_ALGO;
  1227. }
  1228. #endif
  1229. #endif /* HAL_USE_CRY == TRUE */
  1230. /** @} */