rabbit.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*!
  2. \ingroup Rabbit
  3. \brief This function encrypts or decrypts a message of any size, storing
  4. the result in output. It requires that the Rabbit ctx structure be
  5. initialized with a key and an iv before encryption.
  6. \return 0 Returned on successfully encrypting/decrypting input
  7. \return BAD_ALIGN_E Returned if the input message is not 4-byte aligned
  8. but is required to be by XSTREAM_ALIGN, but NO_WOLFSSL_ALLOC_ALIGN is
  9. defined
  10. \return MEMORY_E Returned if there is an error allocating memory to
  11. align the message, if NO_WOLFSSL_ALLOC_ALIGN is not defined
  12. \param ctx pointer to the Rabbit structure to use for encryption/decryption
  13. \param output pointer to the buffer in which to store the processed
  14. message. Should be at least msglen long
  15. \param input pointer to the buffer containing the message to process
  16. \param msglen the length of the message to process
  17. _Example_
  18. \code
  19. int ret;
  20. Rabbit enc;
  21. byte key[] = { }; // initialize with 16 byte key
  22. byte iv[] = { }; // initialize with 8 byte iv
  23. wc_RabbitSetKey(&enc, key, iv);
  24. byte message[] = { }; // initialize with plaintext message
  25. byte ciphertext[sizeof(message)];
  26. wc_RabbitProcess(enc, ciphertext, message, sizeof(message));
  27. \endcode
  28. \sa wc_RabbitSetKey
  29. */
  30. WOLFSSL_API int wc_RabbitProcess(Rabbit*, byte*, const byte*, word32);
  31. /*!
  32. \ingroup Rabbit
  33. \brief This function initializes a Rabbit context for use with
  34. encryption or decryption by setting its iv and key.
  35. \return 0 Returned on successfully setting the key and iv
  36. \param ctx pointer to the Rabbit structure to initialize
  37. \param key pointer to the buffer containing the 16 byte key to
  38. use for encryption/decryption
  39. \param iv pointer to the buffer containing the 8 byte iv with
  40. which to initialize the Rabbit structure
  41. _Example_
  42. \code
  43. int ret;
  44. Rabbit enc;
  45. byte key[] = { }; // initialize with 16 byte key
  46. byte iv[] = { }; // initialize with 8 byte iv
  47. wc_RabbitSetKey(&enc, key, iv)
  48. \endcode
  49. \sa wc_RabbitProcess
  50. */
  51. WOLFSSL_API int wc_RabbitSetKey(Rabbit*, const byte* key, const byte* iv);