Files
wolfssl/doc/dox_comments/header_files/idea.h

164 lines
4.0 KiB
C
Raw Normal View History

/*!
\ingroup IDEA
2018-06-27 16:22:12 -06:00
\brief Generate the 52, 16-bit key sub-blocks from the 128 key.
2018-06-27 16:22:12 -06:00
\return 0 Success
2018-06-27 16:22:12 -06:00
\return BAD_FUNC_ARG Returns if idea or key is null, keySz is not equal to
IDEA_KEY_SIZE, or dir is not IDEA_ENCRYPTION or IDEA_DECRYPTION.
2018-06-27 16:22:12 -06:00
\param idea Pointer to Idea structure.
\param key Pointer to key in memory.
\param keySz Size of key.
\param iv Value for IV in Idea structure. Can be null.
\param dir Direction, either IDEA_ENCRYPTION or IDEA_DECRYPTION
_Example_
\code
byte v_key[IDEA_KEY_SIZE] = { }; // Some Key
Idea idea;
int ret = wc_IdeaSetKey(&idea v_key, IDEA_KEY_SIZE, NULL, IDEA_ENCRYPTION);
if (ret != 0)
{
// There was an error
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_IdeaSetIV
*/
WOLFSSL_API int wc_IdeaSetKey(Idea *idea, const byte* key, word16 keySz,
const byte *iv, int dir);
/*!
\ingroup IDEA
2018-06-27 16:22:12 -06:00
\brief Sets the IV in an Idea key structure.
\return 0 Success
\return BAD_FUNC_ARG Returns if idea is null.
\param idea Pointer to idea key structure.
\param iv The IV value to set, can be null.
2018-06-27 16:22:12 -06:00
_Example_
\code
Idea idea;
// Initialize idea
byte iv[] = { }; // Some IV
int ret = wc_IdeaSetIV(&idea, iv);
if(ret != 0)
{
// Some error occured
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_IdeaSetKey
*/
WOLFSSL_API int wc_IdeaSetIV(Idea *idea, const byte* iv);
/*!
\ingroup IDEA
2018-06-27 16:22:12 -06:00
\brief Encryption or decryption for a block (64 bits).
2018-06-27 16:22:12 -06:00
\return 0 upon success.
\return <0 an error occured
2018-06-27 16:22:12 -06:00
\param idea Pointer to idea key structure.
\param out Pointer to destination.
\param in Pointer to input data to encrypt or decrypt.
_Example_
\code
byte v_key[IDEA_KEY_SIZE] = { }; // Some Key
byte data[IDEA_BLOCK_SIZE] = { }; // Some encrypted data
Idea idea;
wc_IdeaSetKey(&idea, v_key, IDEA_KEY_SIZE, NULL, IDEA_DECRYPTION);
int ret = wc_IdeaCipher(&idea, data, data);
if (ret != 0)
{
// There was an error
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_IdeaSetKey
\sa wc_IdeaSetIV
\sa wc_IdeaCbcEncrypt
\sa wc_IdeaCbcDecrypt
*/
WOLFSSL_API int wc_IdeaCipher(Idea *idea, byte* out, const byte* in);
/*!
\ingroup IDEA
2018-06-27 16:22:12 -06:00
\brief Encrypt data using IDEA CBC mode.
2018-06-27 16:22:12 -06:00
\return 0 Success
\return BAD_FUNC_ARG Returns if any arguments are null.
\param idea Pointer to Idea key structure.
\param out Pointer to destination for encryption.
\param in Pointer to input for encryption.
\param len length of input.
2018-06-27 16:22:12 -06:00
_Example_
\code
Idea idea;
// Initialize idea structure for encryption
const char *message = "International Data Encryption Algorithm";
byte msg_enc[40], msg_dec[40];
memset(msg_enc, 0, sizeof(msg_enc));
ret = wc_IdeaCbcEncrypt(&idea, msg_enc, (byte *)message,
(word32)strlen(message)+1);
if(ret != 0)
{
// Some error occured
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_IdeaCbcDecrypt
\sa wc_IdeaCipher
\sa wc_IdeaSetKey
*/
WOLFSSL_API int wc_IdeaCbcEncrypt(Idea *idea, byte* out,
const byte* in, word32 len);
/*!
\ingroup IDEA
2018-06-27 16:22:12 -06:00
\brief Decrypt data using IDEA CBC mode.
\return 0 Success
\return BAD_FUNC_ARG Returns if any arguments are null.
2018-06-27 16:22:12 -06:00
\param idea Pointer to Idea key structure.
\param out Pointer to destination for encryption.
\param in Pointer to input for encryption.
\param len length of input.
2018-06-27 16:22:12 -06:00
_Example_
\code
Idea idea;
// Initialize idea structure for decryption
const char *message = "International Data Encryption Algorithm";
byte msg_enc[40], msg_dec[40];
memset(msg_dec, 0, sizeof(msg_dec));
ret = wc_IdeaCbcDecrypt(&idea, msg_dec, msg_enc,
(word32)strlen(message)+1);
if(ret != 0)
{
// Some error occured
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_IdeaCbcEncrypt
\sa wc_IdeaCipher
\sa wc_IdeaSetKey
*/
WOLFSSL_API int wc_IdeaCbcDecrypt(Idea *idea, byte* out,
const byte* in, word32 len);