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

encr.c File Reference

#include "common.h"
#include <openssl/des.h>
#include <openssl/evp.h>
#include <string.h>
#include <assert.h>
#include "encr.h"
#include "enums.h"

Functions

void Do3DES (uint8_t *data, uint32_t dlen, uint8_t *iv, uint8_t *key, int enc)
 encrypt / decrypt data with 3DES in ECB mode
void DoEVPCrypt (const EVP_CIPHER *cipher, uint8_t *data, uint32_t dlen, uint8_t *iv, uint8_t *key, uint32_t keylen, int enc)
 encrypt/decrypt with EVP interface
const EVP_CIPHER * FindEVPCipher (uint32_t type, uint32_t keylen)
 Try to find encryption algorithm, which is supported by OpenSSL EVP interface.
uint32_t GetEncrKeyLen (uint32_t type, uint16_t keylen)
 Get encryption key length.
uint32_t GetEncrBlockLen (uint32_t type, uint32_t keylen)
 Get length of block for specific encryption algorithm.
int EncrKeyLenValid (uint32_t type, uint32_t keylen)
 Check for valid key length.
void IKEv2Crypt (uint8_t *data, uint32_t dlen, uint8_t *iv, uint8_t *key, uint32_t type, uint32_t keylen, int enc)
 Encrypt/decrypt a block of data.

Function Documentation

void Do3DES uint8_t *  data,
uint32_t  dlen,
uint8_t *  iv,
uint8_t *  key,
int  enc
 

encrypt / decrypt data with 3DES in ECB mode

Parameters:
*data ptr to buffer to be encrypted
dlen len of buffer (has to be multiple of 8)
*iv init vector (unused)
*key ptr to key (has to be 24 byte = 3 x 64bit)
enc encrypt/decrypt

void DoEVPCrypt const EVP_CIPHER *  cipher,
uint8_t *  data,
uint32_t  dlen,
uint8_t *  iv,
uint8_t *  key,
uint32_t  keylen,
int  enc
 

encrypt/decrypt with EVP interface

Parameters:
*cipher EVP cipher
*data ptr to buffer to be encrypted
dlen len of buffer (has to be multiple of 8)
*iv init vector (unused)
*key ptr to key (has to be 24 byte = 3 x 64bit)
keylen encryption key length (in bits)
enc encrypt/decrypt

int EncrKeyLenValid uint32_t  type,
uint32_t  keylen
 

Check for valid key length.

Parameters:
type encryption algorithm
keylen encryption algorithm key length in bites
Returns:
0 on success, 1 otherwise

const EVP_CIPHER * FindEVPCipher uint32_t  type,
uint32_t  keylen
 

Try to find encryption algorithm, which is supported by OpenSSL EVP interface.

Parameters:
type encryption algorithm type
keylen length of key used by this alorithm
Returns:
NULL if not found, or EVP_CIPHER struct which coresponds to algorithm

uint32_t GetEncrBlockLen uint32_t  type,
uint32_t  keylen
[inline]
 

Get length of block for specific encryption algorithm.

Parameters:
type type of the encryption algorithm
keylen key length of encryption algorithm (optional)
Returns:
block length of encryption algorithm

uint32_t GetEncrKeyLen uint32_t  type,
uint16_t  keylen
[inline]
 

Get encryption key length.

Parameters:
type type of encryption algorithm
keylen key length in bites (optional)
Returns:
the key len of crypto algo in bytes

void IKEv2Crypt uint8_t *  data,
uint32_t  dlen,
uint8_t *  iv,
uint8_t *  key,
uint32_t  type,
uint32_t  keylen,
int  enc
 

Encrypt/decrypt a block of data.

Parameters:
*data ptr to src buffer = dst buffer
dlen len of data (length should be a multiple of block len)
*iv initialization vector
*key key for cipher
type type of crypt algo
keylen key length parameter (optional)
enc IKEv2_ENCRYPT for encryption, IKEv2_DECRYPT for decryption


Project hosted by: SourceForge.net Logo