Skip to content

camellia.h

Functions

Name
int wc_CamelliaSetKey(Camellia * cam, const byte * key, word32 len, const byte * iv)
This function sets the key and initialization vector for a camellia object, initializing it for use as a cipher.
int wc_CamelliaSetIV(Camellia * cam, const byte * iv)
This function sets the initialization vector for a camellia object.
int wc_CamelliaEncryptDirect(Camellia * cam, byte * out, const byte * in)
This function does a one-block encrypt using the provided camellia object. It parses the first 16 byte block from the buffer in and stores the encrypted result in the buffer out. Before using this function, one should initialize the camellia object using wc_CamelliaSetKey.
int wc_CamelliaDecryptDirect(Camellia * cam, byte * out, const byte * in)
This function does a one-block decrypt using the provided camellia object. It parses the first 16 byte block from the buffer in, decrypts it, and stores the result in the buffer out. Before using this function, one should initialize the camellia object using wc_CamelliaSetKey.
int wc_CamelliaCbcEncrypt(Camellia * cam, byte * out, const byte * in, word32 sz)
This function encrypts the plaintext from the buffer in and stores the output in the buffer out. It performs this encryption using Camellia with Cipher Block Chaining (CBC).
int wc_CamelliaCbcDecrypt(Camellia * cam, byte * out, const byte * in, word32 sz)
This function decrypts the ciphertext from the buffer in and stores the output in the buffer out. It performs this decryption using Camellia with Cipher Block Chaining (CBC).

Functions Documentation

function wc_CamelliaSetKey

int wc_CamelliaSetKey(
    Camellia * cam,
    const byte * key,
    word32 len,
    const byte * iv
)

This function sets the key and initialization vector for a camellia object, initializing it for use as a cipher.

Parameters:

  • cam pointer to the camellia structure on which to set the key and iv
  • key pointer to the buffer containing the 16, 24, or 32 byte key to use for encryption and decryption
  • len length of the key passed in
  • iv pointer to the buffer containing the 16 byte initialization vector for use with this camellia structure

See:

Return:

  • 0 Returned upon successfully setting the key and initialization vector
  • BAD_FUNC_ARG returned if there is an error processing one of the input arguments
  • MEMORY_E returned if there is an error allocating memory with XMALLOC

Example

Camellia cam;
byte key[32];
// initialize key
byte iv[16];
// initialize iv
if( wc_CamelliaSetKey(&cam, key, sizeof(key), iv) != 0) {
    // error initializing camellia structure
}

function wc_CamelliaSetIV

int wc_CamelliaSetIV(
    Camellia * cam,
    const byte * iv
)

This function sets the initialization vector for a camellia object.

Parameters:

  • cam pointer to the camellia structure on which to set the iv
  • iv pointer to the buffer containing the 16 byte initialization vector for use with this camellia structure

See: wc_CamelliaSetKey

Return:

  • 0 Returned upon successfully setting the key and initialization vector
  • BAD_FUNC_ARG returned if there is an error processing one of the input arguments

Example

Camellia cam;
byte iv[16];
// initialize iv
if( wc_CamelliaSetIV(&cam, iv) != 0) {
// error initializing camellia structure
}

function wc_CamelliaEncryptDirect

int wc_CamelliaEncryptDirect(
    Camellia * cam,
    byte * out,
    const byte * in
)

This function does a one-block encrypt using the provided camellia object. It parses the first 16 byte block from the buffer in and stores the encrypted result in the buffer out. Before using this function, one should initialize the camellia object using wc_CamelliaSetKey.

Parameters:

  • cam pointer to the camellia structure to use for encryption
  • out pointer to the buffer in which to store the encrypted block
  • in pointer to the buffer containing the plaintext block to encrypt

See: wc_CamelliaDecryptDirect

Return: none No returns.

Example

Camellia cam;
// initialize cam structure with key and iv
byte plain[] = { // initialize with message to encrypt };
byte cipher[16];

wc_CamelliaEncryptDirect(&ca, cipher, plain);

function wc_CamelliaDecryptDirect

int wc_CamelliaDecryptDirect(
    Camellia * cam,
    byte * out,
    const byte * in
)

This function does a one-block decrypt using the provided camellia object. It parses the first 16 byte block from the buffer in, decrypts it, and stores the result in the buffer out. Before using this function, one should initialize the camellia object using wc_CamelliaSetKey.

Parameters:

  • cam pointer to the camellia structure to use for encryption
  • out pointer to the buffer in which to store the decrypted plaintext block
  • in pointer to the buffer containing the ciphertext block to decrypt

See: wc_CamelliaEncryptDirect

Return: none No returns.

Example

Camellia cam;
// initialize cam structure with key and iv
byte cipher[] = { // initialize with encrypted message to decrypt };
byte decrypted[16];

wc_CamelliaDecryptDirect(&cam, decrypted, cipher);

function wc_CamelliaCbcEncrypt

int wc_CamelliaCbcEncrypt(
    Camellia * cam,
    byte * out,
    const byte * in,
    word32 sz
)

This function encrypts the plaintext from the buffer in and stores the output in the buffer out. It performs this encryption using Camellia with Cipher Block Chaining (CBC).

Parameters:

  • cam pointer to the camellia structure to use for encryption
  • out pointer to the buffer in which to store the encrypted ciphertext
  • in pointer to the buffer containing the plaintext to encrypt
  • sz the size of the message to encrypt

See: wc_CamelliaCbcDecrypt

Return: none No returns.

Example

Camellia cam;
// initialize cam structure with key and iv
byte plain[] = { // initialize with encrypted message to decrypt };
byte cipher[sizeof(plain)];

wc_CamelliaCbcEncrypt(&cam, cipher, plain, sizeof(plain));

function wc_CamelliaCbcDecrypt

int wc_CamelliaCbcDecrypt(
    Camellia * cam,
    byte * out,
    const byte * in,
    word32 sz
)

This function decrypts the ciphertext from the buffer in and stores the output in the buffer out. It performs this decryption using Camellia with Cipher Block Chaining (CBC).

Parameters:

  • cam pointer to the camellia structure to use for encryption
  • out pointer to the buffer in which to store the decrypted message
  • in pointer to the buffer containing the encrypted ciphertext
  • sz the size of the message to encrypt

See: wc_CamelliaCbcEncrypt

Return: none No returns.

Example

Camellia cam;
// initialize cam structure with key and iv
byte cipher[] = { // initialize with encrypted message to decrypt };
byte decrypted[sizeof(cipher)];

wc_CamelliaCbcDecrypt(&cam, decrypted, cipher, sizeof(cipher));

Source code


int  wc_CamelliaSetKey(Camellia* cam,
                                   const byte* key, word32 len, const byte* iv);

int  wc_CamelliaSetIV(Camellia* cam, const byte* iv);

int  wc_CamelliaEncryptDirect(Camellia* cam, byte* out,
                                                                const byte* in);

int  wc_CamelliaDecryptDirect(Camellia* cam, byte* out,
                                                                const byte* in);

int wc_CamelliaCbcEncrypt(Camellia* cam,
                                          byte* out, const byte* in, word32 sz);

int wc_CamelliaCbcDecrypt(Camellia* cam,
                                          byte* out, const byte* in, word32 sz);

Updated on 2024-11-08 at 01:16:17 +0000