Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

mw_cipher.h File Reference

#include <glib.h>
#include "mw_common.h"

Go to the source code of this file.

Data Structures

struct  mwCipher
 A cipher. More...
struct  mwCipherInstance
 An instance of a cipher. More...
void mwDecrypt (const char *key, gsize keylen, char *iv, struct mwOpaque *in, struct mwOpaque *out)
 Decrypt data using an expanded form of the given key.
void mwDecryptExpanded (const int *ekey, char *iv, struct mwOpaque *in, struct mwOpaque *out)
 Decrypt data using an already expanded key.
void mwEncrypt (const char *key, gsize keylen, char *iv, struct mwOpaque *in, struct mwOpaque *out)
 Encrypt data using an expanded form of the given key.
void mwEncryptExpanded (const int *ekey, char *iv, struct mwOpaque *in, struct mwOpaque *out)
 Encrypt data using an already-expanded key.
void mwIV_init (char *iv)
 Setup an Initialization Vector.
void mwKeyExpand (int *ekey, const char *key, gsize keylen)
 Expand a variable-length key into a 128-byte key (represented as an an array of 64 ints).
void mwKeyRandom (char *key, gsize keylen)
 generate some pseudo-random bytes

Typedefs

typedef mwEncryptItem *(* mwCipherDescriptor )(struct mwCipherInstance *instance)
 Generate a descriptor for use in a channel create message to indicate the availability of this cipher.
typedef mwCipherInstance *(* mwCipherInstantiator )(struct mwCipher *cipher, struct mwChannel *chan)
 Obtain an instance of a given cipher, which can be used for the processing of a single channel.
typedef int(* mwCipherProcessor )(struct mwCipherInstance *ci, struct mwOpaque *data)
 Process (encrypt or decrypt, depending) the given data.

Enumerations

enum  mwCipherType {
  mwCipher_RC2_40 = 0x0000,
  mwCipher_RC2_128 = 0x0001
}
 Common cipher types. More...

Functions

void mwCipher_free (struct mwCipher *cipher)
 destroy a cipher
const char * mwCipher_getDesc (struct mwCipher *cipher)
const char * mwCipher_getName (struct mwCipher *cipher)
mwSession * mwCipher_getSession (struct mwCipher *cipher)
guint16 mwCipher_getType (struct mwCipher *cipher)
mwCipher * mwCipher_new_RC2_128 (struct mwSession *s)
mwCipher * mwCipher_new_RC2_40 (struct mwSession *s)
mwCipherInstance * mwCipher_newInstance (struct mwCipher *cipher, struct mwChannel *channel)
mwEncryptItem * mwCipherInstance_accept (struct mwCipherInstance *ci)
 Accept a cipher offered to our channel.
void mwCipherInstance_accepted (struct mwCipherInstance *ci, struct mwEncryptItem *item)
 Indicates an offered cipher has been accepted.
int mwCipherInstance_decrypt (struct mwCipherInstance *ci, struct mwOpaque *data)
 decrypt data
int mwCipherInstance_encrypt (struct mwCipherInstance *ci, struct mwOpaque *data)
 encrypt data
void mwCipherInstance_free (struct mwCipherInstance *ci)
 destroy a cipher instance
mwCipher * mwCipherInstance_getCipher (struct mwCipherInstance *ci)
 reference the parent cipher of an instance
mwEncryptItem * mwCipherInstance_newItem (struct mwCipherInstance *ci)
 Deprecated in favor of the methods mwCipherInstance_offer and mwCipherInstance_accept.
mwEncryptItem * mwCipherInstance_offer (struct mwCipherInstance *ci)
 Offer a cipher.
void mwCipherInstance_offered (struct mwCipherInstance *ci, struct mwEncryptItem *item)
 Indicates a cipher has been offered to our channel.


Typedef Documentation

typedef struct mwEncryptItem*(* mwCipherDescriptor)(struct mwCipherInstance *instance)
 

Generate a descriptor for use in a channel create message to indicate the availability of this cipher.

Todo:
remove for 1.0

typedef struct mwCipherInstance*(* mwCipherInstantiator)(struct mwCipher *cipher, struct mwChannel *chan)
 

Obtain an instance of a given cipher, which can be used for the processing of a single channel.

typedef int(* mwCipherProcessor)(struct mwCipherInstance *ci, struct mwOpaque *data)
 

Process (encrypt or decrypt, depending) the given data.

The passed buffer may be freed in processing and be replaced with a freshly allocated buffer. The post-processed buffer must in turn be freed after use


Enumeration Type Documentation

enum mwCipherType
 

Common cipher types.

Enumerator:
mwCipher_RC2_40 
mwCipher_RC2_128 


Function Documentation

void mwCipher_free (  struct mwCipher *  cipher  ) 
 

destroy a cipher

const char* mwCipher_getDesc (  struct mwCipher *  cipher  ) 
 

const char* mwCipher_getName (  struct mwCipher *  cipher  ) 
 

struct mwSession* mwCipher_getSession (  struct mwCipher *  cipher  ) 
 

guint16 mwCipher_getType (  struct mwCipher *  cipher  ) 
 

struct mwCipher* mwCipher_new_RC2_128 (  struct mwSession *  s  ) 
 

struct mwCipher* mwCipher_new_RC2_40 (  struct mwSession *  s  ) 
 

struct mwCipherInstance* mwCipher_newInstance (  struct mwCipher *  cipher,
struct mwChannel *  channel
) 
 

struct mwEncryptItem* mwCipherInstance_accept (  struct mwCipherInstance *  ci  ) 
 

Accept a cipher offered to our channel.

void mwCipherInstance_accepted (  struct mwCipherInstance *  ci,
struct mwEncryptItem *  item
) 
 

Indicates an offered cipher has been accepted.

int mwCipherInstance_decrypt (  struct mwCipherInstance *  ci,
struct mwOpaque *  data
) 
 

decrypt data

int mwCipherInstance_encrypt (  struct mwCipherInstance *  ci,
struct mwOpaque *  data
) 
 

encrypt data

void mwCipherInstance_free (  struct mwCipherInstance *  ci  ) 
 

destroy a cipher instance

struct mwCipher* mwCipherInstance_getCipher (  struct mwCipherInstance *  ci  ) 
 

reference the parent cipher of an instance

struct mwEncryptItem* mwCipherInstance_newItem (  struct mwCipherInstance *  ci  ) 
 

Deprecated in favor of the methods mwCipherInstance_offer and mwCipherInstance_accept.

struct mwEncryptItem* mwCipherInstance_offer (  struct mwCipherInstance *  ci  ) 
 

Offer a cipher.

void mwCipherInstance_offered (  struct mwCipherInstance *  ci,
struct mwEncryptItem *  item
) 
 

Indicates a cipher has been offered to our channel.

void mwDecrypt (  const char *  key,
gsize  keylen,
char *  iv,
struct mwOpaque *  in,
struct mwOpaque *  out
) 
 

Decrypt data using an expanded form of the given key.

void mwDecryptExpanded (  const int *  ekey,
char *  iv,
struct mwOpaque *  in,
struct mwOpaque *  out
) 
 

Decrypt data using an already expanded key.

void mwEncrypt (  const char *  key,
gsize  keylen,
char *  iv,
struct mwOpaque *  in,
struct mwOpaque *  out
) 
 

Encrypt data using an expanded form of the given key.

void mwEncryptExpanded (  const int *  ekey,
char *  iv,
struct mwOpaque *  in,
struct mwOpaque *  out
) 
 

Encrypt data using an already-expanded key.

void mwIV_init (  char *  iv  ) 
 

Setup an Initialization Vector.

IV must be at least 8 bytes

void mwKeyExpand (  int *  ekey,
const char *  key,
gsize  keylen
) 
 

Expand a variable-length key into a 128-byte key (represented as an an array of 64 ints).

void mwKeyRandom (  char *  key,
gsize  keylen
) 
 

generate some pseudo-random bytes

Parameters:
keylen count of bytes to write into key
key buffer to write keys into


Generated on Tue Nov 1 15:51:53 2005 for meanwhile by  doxygen 1.4.4