1
0

arc4.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*!
  2. \ingroup ARC4
  3. \brief This function encrypts an input message from the buffer in, placing
  4. the ciphertext in the output buffer out, or decrypts a ciphertext from the
  5. buffer in, placing the plaintext in the output buffer out, using ARC4
  6. encryption. This function is used for both encryption and decryption.
  7. Before this method may be called, one must first initialize the ARC4
  8. structure using wc_Arc4SetKey.
  9. \return none
  10. \param arc4 pointer to the ARC4 structure used to process the message
  11. \param out pointer to the output buffer in which to store the
  12. processed message
  13. \param in pointer to the input buffer containing the message to process
  14. \param length length of the message to process
  15. _Example_
  16. \code
  17. Arc4 enc;
  18. byte key[] = { key to use for encryption };
  19. wc_Arc4SetKey(&enc, key, sizeof(key));
  20. byte plain[] = { plain text to encode };
  21. byte cipher[sizeof(plain)];
  22. byte decrypted[sizeof(plain)];
  23. // encrypt the plain into cipher
  24. wc_Arc4Process(&enc, cipher, plain, sizeof(plain));
  25. // decrypt the cipher
  26. wc_Arc4Process(&enc, decrypted, cipher, sizeof(cipher));
  27. \endcode
  28. \sa wc_Arc4SetKey
  29. */
  30. int wc_Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length);
  31. /*!
  32. \ingroup ARC4
  33. \brief This function sets the key for a ARC4 object, initializing it for
  34. use as a cipher. It should be called before using it for encryption
  35. with wc_Arc4Process.
  36. \return none
  37. \param arc4 pointer to an arc4 structure to be used for encryption
  38. \param key key with which to initialize the arc4 structure
  39. \param length length of the key used to initialize the arc4 structure
  40. _Example_
  41. \code
  42. Arc4 enc;
  43. byte key[] = { initialize with key to use for encryption };
  44. wc_Arc4SetKey(&enc, key, sizeof(key));
  45. \endcode
  46. \sa wc_Arc4Process
  47. */
  48. int wc_Arc4SetKey(Arc4* arc4, const byte* key, word32 length);