1
0

curve448.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. /*!
  2. \ingroup Curve448
  3. \brief This function generates a Curve448 key using the given random
  4. number generator, rng, of the size given (keysize), and stores it in
  5. the given curve448_key structure. It should be called after the key
  6. structure has been initialized through wc_curve448_init().
  7. \return 0 Returned on successfully generating the key and and storing
  8. it in the given curve448_key structure.
  9. \return ECC_BAD_ARG_E Returned if the input keysize does not correspond to
  10. the keysize for a curve448 key (56 bytes).
  11. \return RNG_FAILURE_E Returned if the rng internal status is not
  12. DRBG_OK or if there is in generating the next random block with rng.
  13. \return BAD_FUNC_ARG Returned if any of the input parameters passed in
  14. are NULL.
  15. \param [in] rng Pointer to the RNG object used to generate the ecc key.
  16. \param [in] keysize Size of the key to generate. Must be 56 bytes for
  17. curve448.
  18. \param [in,out] key Pointer to the curve448_key structure in which to
  19. store the generated key.
  20. _Example_
  21. \code
  22. int ret;
  23. curve448_key key;
  24. wc_curve448_init(&key); // initialize key
  25. WC_RNG rng;
  26. wc_InitRng(&rng); // initialize random number generator
  27. ret = wc_curve448_make_key(&rng, 56, &key);
  28. if (ret != 0) {
  29. // error making Curve448 key
  30. }
  31. \endcode
  32. \sa wc_curve448_init
  33. */
  34. int wc_curve448_make_key(WC_RNG* rng, int keysize, curve448_key* key);
  35. /*!
  36. \ingroup Curve448
  37. \brief This function computes a shared secret key given a secret private
  38. key and a received public key. It stores the generated secret key in the
  39. buffer out and assigns the variable of the secret key to outlen. Only
  40. supports big endian.
  41. \return 0 Returned on successfully computing a shared secret key
  42. \return BAD_FUNC_ARG Returned if any of the input parameters passed in
  43. are NULL
  44. \param [in] private_key Pointer to the curve448_key structure initialized
  45. with the user’s private key.
  46. \param [in] public_key Pointer to the curve448_key structure containing
  47. the received public key.
  48. \param [out] out Pointer to a buffer in which to store the 56 byte computed
  49. secret key.
  50. \param [in,out] outlen Pointer in which to store the length written to the
  51. output buffer.
  52. _Example_
  53. \code
  54. int ret;
  55. byte sharedKey[56];
  56. word32 keySz;
  57. curve448_key privKey, pubKey;
  58. // initialize both keys
  59. ret = wc_curve448_shared_secret(&privKey, &pubKey, sharedKey, &keySz);
  60. if (ret != 0) {
  61. // error generating shared key
  62. }
  63. \endcode
  64. \sa wc_curve448_init
  65. \sa wc_curve448_make_key
  66. \sa wc_curve448_shared_secret_ex
  67. */
  68. int wc_curve448_shared_secret(curve448_key* private_key,
  69. curve448_key* public_key,
  70. byte* out, word32* outlen);
  71. /*!
  72. \ingroup Curve448
  73. \brief This function computes a shared secret key given a secret private
  74. key and a received public key. It stores the generated secret key in the
  75. buffer out and assigns the variable of the secret key to outlen. Supports
  76. both big and little endian.
  77. \return 0 Returned on successfully computing a shared secret key.
  78. \return BAD_FUNC_ARG Returned if any of the input parameters passed in
  79. are NULL.
  80. \param [in] private_key Pointer to the curve448_key structure initialized
  81. with the user’s private key.
  82. \param [in] public_key Pointer to the curve448_key structure containing
  83. the received public key.
  84. \param [out] out Pointer to a buffer in which to store the 56 byte computed
  85. secret key.
  86. \param [in,out] outlen Pointer in which to store the length written to the
  87. output buffer.
  88. \param [in] endian EC448_BIG_ENDIAN or EC448_LITTLE_ENDIAN to set which
  89. form to use.
  90. _Example_
  91. \code
  92. int ret;
  93. byte sharedKey[56];
  94. word32 keySz;
  95. curve448_key privKey, pubKey;
  96. // initialize both keys
  97. ret = wc_curve448_shared_secret_ex(&privKey, &pubKey, sharedKey, &keySz,
  98. EC448_BIG_ENDIAN);
  99. if (ret != 0) {
  100. // error generating shared key
  101. }
  102. \endcode
  103. \sa wc_curve448_init
  104. \sa wc_curve448_make_key
  105. \sa wc_curve448_shared_secret
  106. */
  107. int wc_curve448_shared_secret_ex(curve448_key* private_key,
  108. curve448_key* public_key,
  109. byte* out, word32* outlen, int endian);
  110. /*!
  111. \ingroup Curve448
  112. \brief This function initializes a Curve448 key. It should be called
  113. before generating a key for the structure.
  114. \return 0 Returned on successfully initializing the curve448_key structure.
  115. \return BAD_FUNC_ARG Returned when key is NULL.
  116. \param [in,out] key Pointer to the curve448_key structure to initialize.
  117. _Example_
  118. \code
  119. curve448_key key;
  120. wc_curve448_init(&key); // initialize key
  121. // make key and proceed to encryption
  122. \endcode
  123. \sa wc_curve448_make_key
  124. */
  125. int wc_curve448_init(curve448_key* key);
  126. /*!
  127. \ingroup Curve448
  128. \brief This function frees a Curve448 object.
  129. \param [in,out] key Pointer to the key object to free.
  130. _Example_
  131. \code
  132. curve448_key privKey;
  133. // initialize key, use it to generate shared secret key
  134. wc_curve448_free(&privKey);
  135. \endcode
  136. \sa wc_curve448_init
  137. \sa wc_curve448_make_key
  138. */
  139. void wc_curve448_free(curve448_key* key);
  140. /*!
  141. \ingroup Curve448
  142. \brief This function imports a curve448 private key only. (Big endian).
  143. \return 0 Returned on successfully importing private key.
  144. \return BAD_FUNC_ARG Returns if key or priv is null.
  145. \return ECC_BAD_ARG_E Returns if privSz is not equal to CURVE448_KEY_SIZE.
  146. \param [in] priv Pointer to a buffer containing the private key to import.
  147. \param [in] privSz Length of the private key to import.
  148. \param [in,out] key Pointer to the structure in which to store the imported
  149. key.
  150. _Example_
  151. \code
  152. int ret;
  153. byte priv[] = { Contents of private key };
  154. curve448_key key;
  155. wc_curve448_init(&key);
  156. ret = wc_curve448_import_private(priv, sizeof(priv), &key);
  157. if (ret != 0) {
  158. // error importing key
  159. }
  160. \endcode
  161. \sa wc_curve448_import_private_ex
  162. \sa wc_curve448_size
  163. */
  164. int wc_curve448_import_private(const byte* priv, word32 privSz,
  165. curve448_key* key);
  166. /*!
  167. \ingroup Curve448
  168. \brief curve448 private key import only. (Big or Little endian).
  169. \return 0 Returned on successfully importing private key.
  170. \return BAD_FUNC_ARG Returns if key or priv is null.
  171. \return ECC_BAD_ARG_E Returns if privSz is not equal to CURVE448_KEY_SIZE.
  172. \param [in] priv Pointer to a buffer containing the private key to import.
  173. \param [in] privSz Length of the private key to import.
  174. \param [in,out] key Pointer to the structure in which to store the imported
  175. key.
  176. \param [in] endian EC448_BIG_ENDIAN or EC448_LITTLE_ENDIAN to
  177. set which form to use.
  178. _Example_
  179. \code
  180. int ret;
  181. byte priv[] = { // Contents of private key };
  182. curve448_key key;
  183. wc_curve448_init(&key);
  184. ret = wc_curve448_import_private_ex(priv, sizeof(priv), &key,
  185. EC448_BIG_ENDIAN);
  186. if (ret != 0) {
  187. // error importing key
  188. }
  189. \endcode
  190. \sa wc_curve448_import_private
  191. \sa wc_curve448_size
  192. */
  193. int wc_curve448_import_private_ex(const byte* priv, word32 privSz,
  194. curve448_key* key, int endian);
  195. /*!
  196. \ingroup Curve448
  197. \brief This function imports a public-private key pair into a
  198. curve448_key structure. Big endian only.
  199. \return 0 Returned on importing into the curve448_key structure.
  200. \return BAD_FUNC_ARG Returns if any of the input parameters are null.
  201. \return ECC_BAD_ARG_E Returned if the input key’s key size does not match
  202. the public or private key sizes.
  203. \param [in] priv Pointer to a buffer containing the private key to import.
  204. \param [in] privSz Length of the private key to import.
  205. \param [in] pub Pointer to a buffer containing the public key to import.
  206. \param [in] pubSz Length of the public key to import.
  207. \param [in,out] key Pointer to the structure in which to store the imported
  208. keys
  209. _Example_
  210. \code
  211. int ret;
  212. byte priv[56];
  213. byte pub[56];
  214. // initialize with public and private keys
  215. curve448_key key;
  216. wc_curve448_init(&key);
  217. // initialize key
  218. ret = wc_curve448_import_private_raw(&priv, sizeof(priv), pub, sizeof(pub),
  219. &key);
  220. if (ret != 0) {
  221. // error importing keys
  222. }
  223. \endcode
  224. \sa wc_curve448_init
  225. \sa wc_curve448_make_key
  226. \sa wc_curve448_import_public
  227. \sa wc_curve448_export_private_raw
  228. */
  229. int wc_curve448_import_private_raw(const byte* priv, word32 privSz,
  230. const byte* pub, word32 pubSz, curve448_key* key);
  231. /*!
  232. \ingroup Curve448
  233. \brief This function imports a public-private key pair into a curve448_key structure. Supports both big and little endian.
  234. \return 0 Returned on importing into the curve448_key structure.
  235. \return BAD_FUNC_ARG Returns if any of the input parameters are null.
  236. \return ECC_BAD_ARG_E Returned if the input key’s key size does not match
  237. the public or private key sizes.
  238. \param [in] priv Pointer to a buffer containing the private key to import.
  239. \param [in] privSz Length of the private key to import.
  240. \param [in] pub Pointer to a buffer containing the public key to import.
  241. \param [in] pubSz Length of the public key to import.
  242. \param [in,out] key Pointer to the structure in which to store the imported
  243. keys.
  244. \param [in] endian EC448_BIG_ENDIAN or EC448_LITTLE_ENDIAN to set
  245. which form to use.
  246. _Example_
  247. \code
  248. int ret;
  249. byte priv[56];
  250. byte pub[56];
  251. // initialize with public and private keys
  252. curve448_key key;
  253. wc_curve448_init(&key);
  254. // initialize key
  255. ret = wc_curve448_import_private_raw_ex(&priv, sizeof(priv), pub,
  256. sizeof(pub), &key, EC448_BIG_ENDIAN);
  257. if (ret != 0) {
  258. // error importing keys
  259. }
  260. \endcode
  261. \sa wc_curve448_init
  262. \sa wc_curve448_make_key
  263. \sa wc_curve448_import_public
  264. \sa wc_curve448_export_private_raw
  265. \sa wc_curve448_import_private_raw
  266. */
  267. int wc_curve448_import_private_raw_ex(const byte* priv, word32 privSz,
  268. const byte* pub, word32 pubSz,
  269. curve448_key* key, int endian);
  270. /*!
  271. \ingroup Curve448
  272. \brief This function exports a private key from a curve448_key structure
  273. and stores it in the given out buffer. It also sets outLen to be the size
  274. of the exported key. Big Endian only.
  275. \return 0 Returned on successfully exporting the private key from the
  276. curve448_key structure.
  277. \return BAD_FUNC_ARG Returned if any input parameters are NULL.
  278. \return ECC_BAD_ARG_E Returned if wc_curve448_size() is not equal to key.
  279. \param [in] key Pointer to the structure from which to export the key.
  280. \param [out] out Pointer to the buffer in which to store the exported key.
  281. \param [in,out] outLen On in, is the size of the out in bytes.
  282. On out, will store the bytes written to the output buffer.
  283. _Example_
  284. \code
  285. int ret;
  286. byte priv[56];
  287. int privSz;
  288. curve448_key key;
  289. // initialize and make key
  290. ret = wc_curve448_export_private_raw(&key, priv, &privSz);
  291. if (ret != 0) {
  292. // error exporting key
  293. }
  294. \endcode
  295. \sa wc_curve448_init
  296. \sa wc_curve448_make_key
  297. \sa wc_curve448_import_private_raw
  298. \sa wc_curve448_export_private_raw_ex
  299. */
  300. int wc_curve448_export_private_raw(curve448_key* key, byte* out,
  301. word32* outLen);
  302. /*!
  303. \ingroup Curve448
  304. \brief This function exports a private key from a curve448_key structure
  305. and stores it in the given out buffer. It also sets outLen to be the size
  306. of the exported key. Can specify whether it's big or little endian.
  307. \return 0 Returned on successfully exporting the private key from the
  308. curve448_key structure.
  309. \return BAD_FUNC_ARG Returned if any input parameters are NULL.
  310. \return ECC_BAD_ARG_E Returned if wc_curve448_size() is not equal to key.
  311. \param [in] key Pointer to the structure from which to export the key.
  312. \param [out] out Pointer to the buffer in which to store the exported key.
  313. \param [in,out] outLen On in, is the size of the out in bytes.
  314. On out, will store the bytes written to the output buffer.
  315. \param [in] endian EC448_BIG_ENDIAN or EC448_LITTLE_ENDIAN to set which
  316. form to use.
  317. _Example_
  318. \code
  319. int ret;
  320. byte priv[56];
  321. int privSz;
  322. curve448_key key;
  323. // initialize and make key
  324. ret = wc_curve448_export_private_raw_ex(&key, priv, &privSz,
  325. EC448_BIG_ENDIAN);
  326. if (ret != 0) {
  327. // error exporting key
  328. }
  329. \endcode
  330. \sa wc_curve448_init
  331. \sa wc_curve448_make_key
  332. \sa wc_curve448_import_private_raw
  333. \sa wc_curve448_export_private_raw
  334. \sa wc_curve448_size
  335. */
  336. int wc_curve448_export_private_raw_ex(curve448_key* key, byte* out,
  337. word32* outLen, int endian);
  338. /*!
  339. \ingroup Curve448
  340. \brief This function imports a public key from the given in buffer and
  341. stores it in the curve448_key structure.
  342. \return 0 Returned on successfully importing the public key into the
  343. curve448_key structure.
  344. \return ECC_BAD_ARG_E Returned if the inLen parameter does not match the key
  345. size of the key structure.
  346. \return BAD_FUNC_ARG Returned if any of the input parameters are NULL.
  347. \param [in] in Pointer to the buffer containing the public key to import.
  348. \param [in] inLen Length of the public key to import.
  349. \param [in,out] key Pointer to the curve448_key structure in which to store
  350. the key.
  351. _Example_
  352. \code
  353. int ret;
  354. byte pub[56];
  355. // initialize pub with public key
  356. curve448_key key;
  357. // initialize key
  358. ret = wc_curve448_import_public(pub,sizeof(pub), &key);
  359. if (ret != 0) {
  360. // error importing key
  361. }
  362. \endcode
  363. \sa wc_curve448_init
  364. \sa wc_curve448_export_public
  365. \sa wc_curve448_import_private_raw
  366. \sa wc_curve448_import_public_ex
  367. \sa wc_curve448_check_public
  368. \sa wc_curve448_size
  369. */
  370. int wc_curve448_import_public(const byte* in, word32 inLen,
  371. curve448_key* key);
  372. /*!
  373. \ingroup Curve448
  374. \brief This function imports a public key from the given in buffer and
  375. stores it in the curve448_key structure.
  376. \return 0 Returned on successfully importing the public key into the
  377. curve448_key structure.
  378. \return ECC_BAD_ARG_E Returned if the inLen parameter does not match the
  379. key size of the key structure.
  380. \return BAD_FUNC_ARG Returned if any of the input parameters are NULL.
  381. \param [in] in Pointer to the buffer containing the public key to import.
  382. \param [in] inLen Length of the public key to import.
  383. \param [in,out] key Pointer to the curve448_key structure in which to store
  384. the key.
  385. \param [in] endian EC448_BIG_ENDIAN or EC448_LITTLE_ENDIAN to set which
  386. form to use.
  387. _Example_
  388. \code
  389. int ret;
  390. byte pub[56];
  391. // initialize pub with public key
  392. curve448_key key;
  393. // initialize key
  394. ret = wc_curve448_import_public_ex(pub, sizeof(pub), &key,
  395. EC448_BIG_ENDIAN);
  396. if (ret != 0) {
  397. // error importing key
  398. }
  399. \endcode
  400. \sa wc_curve448_init
  401. \sa wc_curve448_export_public
  402. \sa wc_curve448_import_private_raw
  403. \sa wc_curve448_import_public
  404. \sa wc_curve448_check_public
  405. \sa wc_curve448_size
  406. */
  407. int wc_curve448_import_public_ex(const byte* in, word32 inLen,
  408. curve448_key* key, int endian);
  409. /*!
  410. \ingroup Curve448
  411. \brief This function checks that a public key buffer holds a valid
  412. Curve448 key value given the endian ordering.
  413. \return 0 Returned when the public key value is valid.
  414. \return ECC_BAD_ARG_E Returned if the public key value is not valid.
  415. \return BAD_FUNC_ARG Returned if any of the input parameters are NULL.
  416. \param [in] pub Pointer to the buffer containing the public key to check.
  417. \param [in] pubLen Length of the public key to check.
  418. \param [in] endian EC448_BIG_ENDIAN or EC448_LITTLE_ENDIAN to set which
  419. form to use.
  420. _Example_
  421. \code
  422. int ret;
  423. byte pub[] = { Contents of public key };
  424. ret = wc_curve448_check_public_ex(pub, sizeof(pub), EC448_BIG_ENDIAN);
  425. if (ret != 0) {
  426. // error importing key
  427. }
  428. \endcode
  429. \sa wc_curve448_init
  430. \sa wc_curve448_import_public
  431. \sa wc_curve448_import_public_ex
  432. \sa wc_curve448_size
  433. */
  434. int wc_curve448_check_public(const byte* pub, word32 pubSz, int endian);
  435. /*!
  436. \ingroup Curve448
  437. \brief This function exports a public key from the given key structure and
  438. stores the result in the out buffer. Big endian only.
  439. \return 0 Returned on successfully exporting the public key from the
  440. curve448_key structure.
  441. \return ECC_BAD_ARG_E Returned if outLen is less than CURVE448_PUB_KEY_SIZE.
  442. \return BAD_FUNC_ARG Returned if any of the input parameters are NULL.
  443. \param [in] key Pointer to the curve448_key structure in from which to
  444. export the key.
  445. \param [out] out Pointer to the buffer in which to store the public key.
  446. \param [in,out] outLen On in, is the size of the out in bytes.
  447. On out, will store the bytes written to the output buffer.
  448. _Example_
  449. \code
  450. int ret;
  451. byte pub[56];
  452. int pubSz;
  453. curve448_key key;
  454. // initialize and make key
  455. ret = wc_curve448_export_public(&key, pub, &pubSz);
  456. if (ret != 0) {
  457. // error exporting key
  458. }
  459. \endcode
  460. \sa wc_curve448_init
  461. \sa wc_curve448_export_private_raw
  462. \sa wc_curve448_import_public
  463. */
  464. int wc_curve448_export_public(curve448_key* key, byte* out, word32* outLen);
  465. /*!
  466. \ingroup Curve448
  467. \brief This function exports a public key from the given key structure and
  468. stores the result in the out buffer. Supports both big and little endian.
  469. \return 0 Returned on successfully exporting the public key from the
  470. curve448_key structure.
  471. \return ECC_BAD_ARG_E Returned if outLen is less than CURVE448_PUB_KEY_SIZE.
  472. \return BAD_FUNC_ARG Returned if any of the input parameters are NULL.
  473. \param [in] key Pointer to the curve448_key structure in from which to
  474. export the key.
  475. \param [out] out Pointer to the buffer in which to store the public key.
  476. \param [in,out] outLen On in, is the size of the out in bytes.
  477. On out, will store the bytes written to the output buffer.
  478. \param [in] endian EC448_BIG_ENDIAN or EC448_LITTLE_ENDIAN to set which
  479. form to use.
  480. _Example_
  481. \code
  482. int ret;
  483. byte pub[56];
  484. int pubSz;
  485. curve448_key key;
  486. // initialize and make key
  487. ret = wc_curve448_export_public_ex(&key, pub, &pubSz, EC448_BIG_ENDIAN);
  488. if (ret != 0) {
  489. // error exporting key
  490. }
  491. \endcode
  492. \sa wc_curve448_init
  493. \sa wc_curve448_export_private_raw
  494. \sa wc_curve448_import_public
  495. */
  496. int wc_curve448_export_public_ex(curve448_key* key, byte* out,
  497. word32* outLen, int endian);
  498. /*!
  499. \ingroup Curve448
  500. \brief This function exports a key pair from the given key structure and
  501. stores the result in the out buffer. Big endian only.
  502. \return 0 Returned on successfully exporting the key pair from the
  503. curve448_key structure.
  504. \return BAD_FUNC_ARG Returned if any input parameters are NULL.
  505. \return ECC_BAD_ARG_E Returned if privSz is less than CURVE448_KEY_SIZE or
  506. pubSz is less than CURVE448_PUB_KEY_SIZE.
  507. \param [in] key Pointer to the curve448_key structure in from which to
  508. export the key pair.
  509. \param [out] priv Pointer to the buffer in which to store the private key.
  510. \param [in,out] privSz On in, is the size of the priv buffer in bytes.
  511. On out, will store the bytes written to the priv buffer.
  512. \param [out] pub Pointer to the buffer in which to store the public key.
  513. \param [in,out] pubSz On in, is the size of the pub buffer in bytes.
  514. On out, will store the bytes written to the pub buffer.
  515. _Example_
  516. \code
  517. int ret;
  518. byte pub[56];
  519. byte priv[56];
  520. int pubSz;
  521. int privSz;
  522. curve448_key key;
  523. // initialize and make key
  524. ret = wc_curve448_export_key_raw(&key, priv, &privSz, pub, &pubSz);
  525. if (ret != 0) {
  526. // error exporting key
  527. }
  528. \endcode
  529. \sa wc_curve448_export_key_raw_ex
  530. \sa wc_curve448_export_private_raw
  531. */
  532. int wc_curve448_export_key_raw(curve448_key* key,
  533. byte* priv, word32 *privSz,
  534. byte* pub, word32 *pubSz);
  535. /*!
  536. \ingroup Curve448
  537. \brief Export curve448 key pair. Big or little endian.
  538. \brief This function exports a key pair from the given key structure and
  539. stores the result in the out buffer. Big or little endian.
  540. \return 0 Success
  541. \return BAD_FUNC_ARG Returned if any input parameters are NULL.
  542. \return ECC_BAD_ARG_E Returned if privSz is less than CURVE448_KEY_SIZE or
  543. pubSz is less than CURVE448_PUB_KEY_SIZE.
  544. \param [in] key Pointer to the curve448_key structure in from which to
  545. export the key pair.
  546. \param [out] priv Pointer to the buffer in which to store the private key.
  547. \param [in,out] privSz On in, is the size of the priv buffer in bytes.
  548. On out, will store the bytes written to the priv buffer.
  549. \param [out] pub Pointer to the buffer in which to store the public key.
  550. \param [in,out] pubSz On in, is the size of the pub buffer in bytes.
  551. On out, will store the bytes written to the pub buffer.
  552. \param [in] endian EC448_BIG_ENDIAN or EC448_LITTLE_ENDIAN to set which
  553. form to use.
  554. _Example_
  555. \code
  556. int ret;
  557. byte pub[56];
  558. byte priv[56];
  559. int pubSz;
  560. int privSz;
  561. curve448_key key;
  562. // initialize and make key
  563. ret = wc_curve448_export_key_raw_ex(&key,priv, &privSz, pub, &pubSz,
  564. EC448_BIG_ENDIAN);
  565. if (ret != 0) {
  566. // error exporting key
  567. }
  568. \endcode
  569. \sa wc_curve448_export_key_raw
  570. \sa wc_curve448_export_private_raw_ex
  571. \sa wc_curve448_export_public_ex
  572. */
  573. int wc_curve448_export_key_raw_ex(curve448_key* key,
  574. byte* priv, word32 *privSz,
  575. byte* pub, word32 *pubSz,
  576. int endian);
  577. /*!
  578. \ingroup Curve448
  579. \brief This function returns the key size of the given key structure.
  580. \return Success Given a valid, initialized curve448_key structure,
  581. returns the size of the key.
  582. \return 0 Returned if key is NULL.
  583. \param [in] key Pointer to the curve448_key structure in for which to
  584. determine the key size.
  585. _Example_
  586. \code
  587. int keySz;
  588. curve448_key key;
  589. // initialize and make key
  590. keySz = wc_curve448_size(&key);
  591. \endcode
  592. \sa wc_curve448_init
  593. \sa wc_curve448_make_key
  594. */
  595. int wc_curve448_size(curve448_key* key);