My Project
Loading...
Searching...
No Matches
des3.h File Reference

Go to the source code of this file.

Data Structures

struct  Des
 
struct  Des3
 

Typedefs

typedef struct Des Des
 
typedef struct Des3 Des3
 

Enumerations

enum  {
  DES_ENC_TYPE = WC_CIPHER_DES , DES3_ENC_TYPE = WC_CIPHER_DES3 , DES_BLOCK_SIZE = 8 , DES_KS_SIZE = 32 ,
  DES_ENCRYPTION = 0 , DES_DECRYPTION = 1
}
 
enum  { DES_CBC = 0 , DES_ECB = 1 }
 

Functions

WOLFSSL_API int wc_Des_SetKey (Des *des, const byte *key, const byte *iv, int dir)
 This function sets the key and initialization vector (iv) for the Des structure given as argument. It also initializes and allocates space for the buffers needed for encryption and decryption, if these have not yet been initialized. Note: If no iv is provided (i.e. iv == NULL) the initialization vector defaults to an iv of 0.
 
WOLFSSL_API void wc_Des_SetIV (Des *des, const byte *iv)
 This function sets the initialization vector (iv) for the Des structure given as argument. When passed a NULL iv, it sets the initialization vector to 0.
 
WOLFSSL_API int wc_Des_CbcEncrypt (Des *des, byte *out, const byte *in, word32 sz)
 This function encrypts the input message, in, and stores the result in the output buffer, out. It uses DES encryption with cipher block chaining (CBC) mode.
 
WOLFSSL_API int wc_Des_CbcDecrypt (Des *des, byte *out, const byte *in, word32 sz)
 This function decrypts the input ciphertext, in, and stores the resulting plaintext in the output buffer, out. It uses DES encryption with cipher block chaining (CBC) mode.
 
WOLFSSL_API int wc_Des_EcbEncrypt (Des *des, byte *out, const byte *in, word32 sz)
 This function encrypts the input message, in, and stores the result in the output buffer, out. It uses Des encryption with Electronic Codebook (ECB) mode.
 
WOLFSSL_API int wc_Des3_EcbEncrypt (Des3 *des, byte *out, const byte *in, word32 sz)
 
WOLFSSL_API int wc_Des3_SetKey (Des3 *des, const byte *key, const byte *iv, int dir)
 This function sets the key and initialization vector (iv) for the Des3 structure given as argument. It also initializes and allocates space for the buffers needed for encryption and decryption, if these have not yet been initialized. Note: If no iv is provided (i.e. iv == NULL) the initialization vector defaults to an iv of 0.
 
WOLFSSL_API int wc_Des3_SetIV (Des3 *des, const byte *iv)
 This function sets the initialization vector (iv) for the Des3 structure given as argument. When passed a NULL iv, it sets the initialization vector to 0.
 
WOLFSSL_API int wc_Des3_CbcEncrypt (Des3 *des, byte *out, const byte *in, word32 sz)
 This function encrypts the input message, in, and stores the result in the output buffer, out. It uses Triple Des (3DES) encryption with cipher block chaining (CBC) mode.
 
WOLFSSL_API int wc_Des3_CbcDecrypt (Des3 *des, byte *out, const byte *in, word32 sz)
 This function decrypts the input ciphertext, in, and stores the resulting plaintext in the output buffer, out. It uses Triple Des (3DES) encryption with cipher block chaining (CBC) mode.
 
WOLFSSL_API int wc_Des3Init (Des3 *, void *, int)
 
WOLFSSL_API void wc_Des3Free (Des3 *)
 

Variables

 C
 

Function Documentation

◆ wc_Des3_EcbEncrypt()

WOLFSSL_API int wc_Des3_EcbEncrypt ( Des3 * des,
byte * out,
const byte * in,
word32 sz )
\ingroup 3DES

\brief This function encrypts the input message, in, and stores the
result in the output buffer, out. It uses Des3 encryption with
Electronic Codebook (ECB) mode. Warning: In nearly all use cases ECB
mode is considered to be less secure. Please avoid using ECB API’s
directly whenever possible.

\return 0 Returned upon successfully encrypting the given plaintext

\param des3 pointer to the Des3 structure to use for encryption
\param out pointer to the buffer in which to store the encrypted message
\param in pointer to the input buffer containing the plaintext to encrypt
\param sz length of the plaintext to encrypt

_Example_
/code
Des3 enc; // Des3 structure used for encryption

initialize enc with wc_Des3_SetKey, use mode DES_ENCRYPTION

byte plain[]  = { // initialize with message to encrypt };
byte cipher[sizeof(plain)];

if ( wc_Des3_EcbEncrypt(&enc,cipher, plain, sizeof(plain)) != 0) {

error encrypting message } /endcode

See also
wc_Des3_SetKey

Variable Documentation

◆ C

C
extern
Initial value:
{
#endif
enum {
DES_KEY_SIZE = 8,
DES3_KEY_SIZE = 24,
DES_IV_SIZE = 8,
}