MMSCrypt Class Reference

Basic crypthographic methods based on OpenSSL functionality. More...

#include <mmscrypt.h>

List of all members.


Public Member Functions

 MMSCrypt (string keyfile=MMSCRYPT_DEFAULT_KEY_FILENAME)
 Constructor for accessing cryptographic functions.
 ~MMSCrypt ()
 Destructor of MMSCrypt class.
unsigned char * encrypt (unsigned char *in, unsigned int size=0, bool useMMSCtx=false)
 Encrypts a given buffer.
unsigned char * decrypt (unsigned char *in, unsigned int size=0, bool useMMSCtx=false)
 Decrypts a given buffer.

Private Member Functions

unsigned char * createUserKey (string keyfile)
 Creates an SSL key that will be saved in the given file.
unsigned char * getUserKey (string keyfile)
 Returns an SSL key that was stored in the given file.

Private Attributes

EVP_CIPHER_CTX mmsCtx
 private disko cipher context
EVP_CIPHER_CTX userCtx
 user cipher context

Detailed Description

Basic crypthographic methods based on OpenSSL functionality.

This class simply provides helper methods for de- and encrypting buffers.

Note:
To use MMSCrypt you have to build disko with 'enable_crypt=y' which depends on having OpenSSL development libraries installed.

Definition at line 60 of file mmscrypt.h.


Constructor & Destructor Documentation

MMSCrypt::MMSCrypt ( string  keyfile = MMSCRYPT_DEFAULT_KEY_FILENAME  ) 

Constructor for accessing cryptographic functions.

Parameters:
keyfile filename of user key
Exceptions:
MMSCryptError keyfile could not be opened or created

Definition at line 106 of file mmscrypt.cpp.

MMSCrypt::~MMSCrypt (  ) 

Destructor of MMSCrypt class.

Frees all used resources.

Definition at line 124 of file mmscrypt.cpp.


Member Function Documentation

unsigned char * MMSCrypt::encrypt ( unsigned char *  in,
unsigned int  size = 0,
bool  useMMSCtx = false 
)

Encrypts a given buffer.

Parameters:
in buffer to encrypt
size size of buffer (in) to encrypt
useMMSCtx if set to true private disko context will be used, otherwise use user key
Returns:
Encrypted buffer if the call was successful.
Exceptions:
MMSCryptError An error occured while encrypting (call MMSError::getMessage() for a detailed error message.
See also:
decrypt()

Definition at line 129 of file mmscrypt.cpp.

unsigned char * MMSCrypt::decrypt ( unsigned char *  in,
unsigned int  size = 0,
bool  useMMSCtx = false 
)

Decrypts a given buffer.

Parameters:
in buffer to decrypt
size size of buffer to decrypt
useMMSCtx if set to true private disko context will be used, otherwise use user key
Returns:
Decrypted buffer if the call was successful.
Exceptions:
MMSCryptError Not enough memory for decrypting the message.
See also:
encrypt()

Definition at line 164 of file mmscrypt.cpp.

unsigned char * MMSCrypt::createUserKey ( string  keyfile  )  [private]

Creates an SSL key that will be saved in the given file.

Parameters:
keyfile save encrypted key to this file
Note:
The memory for the returned key has to be freed.
Returns:
Unencrypted key (NULL if error occured).
See also:
getUserKey()

Definition at line 51 of file mmscrypt.cpp.

unsigned char * MMSCrypt::getUserKey ( string  keyfile  )  [private]

Returns an SSL key that was stored in the given file.

If the file doesn't exist, a new key will be generated and saved.

Parameters:
keyfile read encrypted key from this file
Note:
The memory for the returned key has to be freed.
Returns:
Unencrypted key (NULL if error occured).
See also:
createUserKey()
Exceptions:
MMSCryptError File could not be opened.

Definition at line 75 of file mmscrypt.cpp.


Member Data Documentation

EVP_CIPHER_CTX MMSCrypt::mmsCtx [private]

private disko cipher context

Definition at line 110 of file mmscrypt.h.

EVP_CIPHER_CTX MMSCrypt::userCtx [private]

user cipher context

Definition at line 110 of file mmscrypt.h.


The documentation for this class was generated from the following files: