Main Page   Data Structures   File List   Data Fields   Globals  

cipher.h File Reference

Symmetric cipher support. More...

#include <cyfer/cyfer.h>

Go to the source code of this file.

Data Structures

struct  CYFER_BlockCipher_t
 A structure describing supported block ciphers. More...

struct  CYFER_BlockMode_t
 A structure describing supported block modes of operation. More...

struct  CYFER_StreamCipher_t
 A structure describing supported stream ciphers. More...


Defines

#define CYFER_CIPHER_NONE   0
#define CYFER_CIPHER_BLOWFISH   1
#define CYFER_CIPHER_DES   2
#define CYFER_CIPHER_DESX   3
#define CYFER_CIPHER_TRIPLEDES   4
#define CYFER_CIPHER_RC2   5
#define CYFER_CIPHER_RC4   6
#define CYFER_CIPHER_RC5   7
#define CYFER_CIPHER_RC6   8
#define CYFER_CIPHER_IDEA   9
#define CYFER_CIPHER_AES   10
#define CYFER_CIPHER_DEAL   11
#define CYFER_CIPHER_THREEWAY   12
#define CYFER_MODE_NONE   0
#define CYFER_MODE_ECB   1
#define CYFER_MODE_CBC   2
#define CYFER_MODE_CFB   3
#define CYFER_MODE_OFB   4

Typedefs

typedef void CYFER_BLOCK_CIPHER_CTX
 Block cipher algorithm context.

typedef void CYFER_STREAM_CIPHER_CTX
 Stream cipher algorithm context.


Functions

CYFER_BlockMode_tCYFER_BlockCipher_Get_SupportedModes (void)
 Returns a list of supported block cipher modes of operation.

CYFER_BlockCipher_tCYFER_BlockCipher_Get_Supported (void)
 Returns a list of supported block ciphers.

int CYFER_BlockCipher_Select (const char *name, size_t *keylen, size_t *minkey, size_t *length)
 Selects block cipher to use.

int CYFER_BlockCipher_SelectMode (const char *name, size_t *length)
 Selects block cipher mode of operation to use.

CYFER_BLOCK_CIPHER_CTXCYFER_BlockCipher_Init (int type, const unsigned char *key, size_t keylen, int mode, const unsigned char *ivec)
 Creates and initializes algorithm context.

void CYFER_BlockCipher_Encrypt (CYFER_BLOCK_CIPHER_CTX *ctx, const unsigned char *input, unsigned char *output)
 Encrypts a block of data.

void CYFER_BlockCipher_Decrypt (CYFER_BLOCK_CIPHER_CTX *ctx, const unsigned char *input, unsigned char *output)
 Decrypts a block of data.

void CYFER_BlockCipher_Finish (CYFER_BLOCK_CIPHER_CTX *ctx)
 Finalizes the algorithm, destroys and frees the context.

CYFER_StreamCipher_tCYFER_StreamCipher_Get_Supported (void)
 Returns a list of supported stream ciphers.

int CYFER_StreamCipher_Select (const char *name, size_t *keylen, size_t *minkey)
 Selects stream cipher to use.

CYFER_STREAM_CIPHER_CTXCYFER_StreamCipher_Init (int type, const unsigned char *key, size_t keylen)
 Creates and initializes algorithm context.

void CYFER_StreamCipher_Encrypt (CYFER_STREAM_CIPHER_CTX *ctx, const unsigned char *input, unsigned char *output, size_t length)
 Encrypts a block of data.

void CYFER_StreamCipher_Decrypt (CYFER_STREAM_CIPHER_CTX *ctx, const unsigned char *input, unsigned char *output, size_t length)
 Decrypts a block of data.

void CYFER_StreamCipher_Finish (CYFER_STREAM_CIPHER_CTX *ctx)
 Finalizes the algorithm, destroys and frees the context.


Detailed Description

Symmetric cipher support.


Define Documentation

#define CYFER_CIPHER_AES   10
 

#define CYFER_CIPHER_BLOWFISH   1
 

#define CYFER_CIPHER_DEAL   11
 

#define CYFER_CIPHER_DES   2
 

#define CYFER_CIPHER_DESX   3
 

#define CYFER_CIPHER_IDEA   9
 

#define CYFER_CIPHER_NONE   0
 

#define CYFER_CIPHER_RC2   5
 

#define CYFER_CIPHER_RC4   6
 

#define CYFER_CIPHER_RC5   7
 

#define CYFER_CIPHER_RC6   8
 

#define CYFER_CIPHER_THREEWAY   12
 

#define CYFER_CIPHER_TRIPLEDES   4
 

#define CYFER_MODE_CBC   2
 

#define CYFER_MODE_CFB   3
 

#define CYFER_MODE_ECB   1
 

#define CYFER_MODE_NONE   0
 

#define CYFER_MODE_OFB   4
 


Typedef Documentation

typedef void CYFER_BLOCK_CIPHER_CTX
 

Block cipher algorithm context.

typedef void CYFER_STREAM_CIPHER_CTX
 

Stream cipher algorithm context.


Function Documentation

void CYFER_BlockCipher_Decrypt CYFER_BLOCK_CIPHER_CTX   ctx,
const unsigned char *    input,
unsigned char *    output
 

Decrypts a block of data.

Parameters:
ctx Algorithm context
input Input data block
output [output] Output data buffer

void CYFER_BlockCipher_Encrypt CYFER_BLOCK_CIPHER_CTX   ctx,
const unsigned char *    input,
unsigned char *    output
 

Encrypts a block of data.

Parameters:
ctx Algorithm context
input Input data block
output [output] Output data buffer

void CYFER_BlockCipher_Finish CYFER_BLOCK_CIPHER_CTX   ctx
 

Finalizes the algorithm, destroys and frees the context.

Parameters:
ctx Algorithm context

CYFER_BlockCipher_t* CYFER_BlockCipher_Get_Supported void   
 

Returns a list of supported block ciphers.

CYFER_BlockMode_t* CYFER_BlockCipher_Get_SupportedModes void   
 

Returns a list of supported block cipher modes of operation.

CYFER_BLOCK_CIPHER_CTX* CYFER_BlockCipher_Init int    type,
const unsigned char *    key,
size_t    keylen,
int    mode,
const unsigned char *    ivec
 

Creates and initializes algorithm context.

Parameters:
type An integer representing block cipher to use
key Key to use for encryption/decryption
keylen Key length in bytes
mode An integer representing block cipher mode to use
ivec Block cipher mode initialization vector
Note:
If the provided key is shorter than required by the algorithm, it is padded with zeroes.

If the initialization vector pointer is NULL, the default vector (filled with zeroes) is used.

Returns:
An initialized block cipher context, or NULL in case of error

int CYFER_BlockCipher_Select const char *    name,
size_t *    keylen,
size_t *    minkey,
size_t *    length
 

Selects block cipher to use.

Parameters:
name Block cipher name
keylen [output] Key length (or maximum key length)
minkey [output] Minimum key length
length [output] Data block length
Note:
If some output value is not wanted, NULL can be specified as buffer
Returns:
An integer representing the selected algorithm

int CYFER_BlockCipher_SelectMode const char *    name,
size_t *    length
 

Selects block cipher mode of operation to use.

Parameters:
name Block cipher mode name
length [output] Data block length
Note:
If the data block length is identical to the data block length of the underlying algorithm, the value returned is 0.

If some output value is not wanted, NULL can be specified as buffer

Returns:
An integer representing the selected block cipher mode

void CYFER_StreamCipher_Decrypt CYFER_STREAM_CIPHER_CTX   ctx,
const unsigned char *    input,
unsigned char *    output,
size_t    length
 

Decrypts a block of data.

Parameters:
ctx Algorithm context
input Input data block
output [output] Output data buffer
length Length of data block

void CYFER_StreamCipher_Encrypt CYFER_STREAM_CIPHER_CTX   ctx,
const unsigned char *    input,
unsigned char *    output,
size_t    length
 

Encrypts a block of data.

Parameters:
ctx Algorithm context
input Input data block
output [output] Output data buffer
length Length of data block

void CYFER_StreamCipher_Finish CYFER_STREAM_CIPHER_CTX   ctx
 

Finalizes the algorithm, destroys and frees the context.

Parameters:
ctx Algorithm context

CYFER_StreamCipher_t* CYFER_StreamCipher_Get_Supported void   
 

Returns a list of supported stream ciphers.

CYFER_STREAM_CIPHER_CTX* CYFER_StreamCipher_Init int    type,
const unsigned char *    key,
size_t    keylen
 

Creates and initializes algorithm context.

Parameters:
type An integer representing stream cipher to use
key Key to use for encryption/decryption
keylen Key length in bytes
Returns:
An initialized stream cipher context, or NULL in case of error

int CYFER_StreamCipher_Select const char *    name,
size_t *    keylen,
size_t *    minkey
 

Selects stream cipher to use.

Parameters:
name Stream cipher name
keylen [output] Key length (or maximum key length)
minkey [output] Minimum key length
Note:
If some output value is not wanted, NULL can be specified as buffer
Returns:
An integer representing the selected algorithm


Generated on Sun Sep 26 13:53:58 2004 for Cyfer by doxygen1.3-rc3