hc128.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*!
  2. \ingroup HC128
  3. \brief This function encrypts or decrypts a message of any size from the
  4. input buffer input, and stores the resulting plaintext/ciphertext in
  5. the output buffer output.
  6. \return 0 Returned upon successfully encrypting/decrypting the given input
  7. \return MEMORY_E Returned if the input and output buffers are not aligned
  8. along a 4-byte boundary, and there is an error allocating memory
  9. \return BAD_ALIGN_E Returned if the input or output buffers are not
  10. aligned along a 4-byte boundary, and NO_WOLFSSL_ALLOC_ALIGN is defined
  11. \param ctx pointer to a HC-128 context object with an initialized key
  12. to use for encryption or decryption
  13. \param output buffer in which to store the processed input
  14. \param input buffer containing the plaintext to encrypt or the
  15. ciphertext to decrypt
  16. \param msglen length of the plaintext to encrypt or the ciphertext
  17. to decrypt
  18. _Example_
  19. \code
  20. HC128 enc;
  21. byte key[] = { // initialize with key };
  22. byte iv[] = { // initialize with iv };
  23. wc_Hc128_SetKey(&enc, key, iv);
  24. byte msg[] = { // initialize with message };
  25. byte cipher[sizeof(msg)];
  26. if (wc_Hc128_Process(*enc, cipher, plain, sizeof(plain)) != 0) {
  27. // error encrypting msg
  28. }
  29. \endcode
  30. \sa wc_Hc128_SetKey
  31. */
  32. WOLFSSL_API int wc_Hc128_Process(HC128*, byte*, const byte*, word32);
  33. /*!
  34. \ingroup HC128
  35. \brief This function initializes an HC128 context object by
  36. setting its key and iv.
  37. \return 0 Returned upon successfully setting the key and iv
  38. for the HC128 context object
  39. \param ctx pointer to an HC-128 context object to initialize
  40. \param key pointer to the buffer containing the 16 byte key to
  41. use with encryption/decryption
  42. \param iv pointer to the buffer containing the 16 byte iv (nonce)
  43. with which to initialize the HC128 object
  44. _Example_
  45. \code
  46. HC128 enc;
  47. byte key[] = { // initialize with key };
  48. byte iv[] = { // initialize with iv };
  49. wc_Hc128_SetKey(&enc, key, iv);
  50. \endcode
  51. \sa wc_Hc128_Process
  52. */
  53. WOLFSSL_API int wc_Hc128_SetKey(HC128*, const byte* key, const byte* iv);