ccRTP 2.1.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes
SrtpSymCrypto Class Reference

Implments the SRTP encryption modes as defined in RFC3711. More...

#include <SrtpSymCrypto.h>

Collaboration diagram for SrtpSymCrypto:
Collaboration graph
[legend]

Public Member Functions

 SrtpSymCrypto (int algo=SrtpEncryptionAESCM)
 
 SrtpSymCrypto (uint8_t *key, int32_t key_length, int algo=SrtpEncryptionAESCM)
 Constructor that initializes key data. More...
 
 ~SrtpSymCrypto ()
 
void encrypt (const uint8_t *input, uint8_t *output)
 Encrypts the inpout to the output. More...
 
bool setNewKey (const uint8_t *key, int32_t keyLength)
 Set new key. More...
 
void get_ctr_cipher_stream (uint8_t *output, uint32_t length, uint8_t *iv)
 Computes the cipher stream for AES CM mode. More...
 
void ctr_encrypt (const uint8_t *input, uint32_t inputLen, uint8_t *output, uint8_t *iv)
 Counter-mode encryption. More...
 
void ctr_encrypt (uint8_t *data, uint32_t data_length, uint8_t *iv)
 Counter-mode encryption, in place. More...
 
void f8_deriveForIV (SrtpSymCrypto *f8Cipher, uint8_t *key, int32_t keyLen, uint8_t *salt, int32_t saltLen)
 Derive a AES context to compute the IV'. More...
 
void f8_encrypt (const uint8_t *data, uint32_t dataLen, uint8_t *iv, SrtpSymCrypto *f8Cipher)
 AES F8 mode encryption, in place. More...
 
void f8_encrypt (const uint8_t *data, uint32_t dataLen, uint8_t *out, uint8_t *iv, SrtpSymCrypto *f8Cipher)
 AES F8 mode encryption. More...
 

Private Member Functions

int processBlock (F8_CIPHER_CTX *f8ctx, const uint8_t *in, int32_t length, uint8_t *out)
 

Private Attributes

void * key
 
int32_t algorithm
 

Detailed Description

Implments the SRTP encryption modes as defined in RFC3711.

The SRTP specification defines two encryption modes, AES-CTR (AES Counter mode) and AES-F8 mode. The AES-CTR is required, AES-F8 is optional.

Both modes are desinged to encrypt/decrypt data of arbitrary length (with a specified upper limit, refer to RFC 3711). These modes do not require that the amount of data to encrypt is a multiple of the AES blocksize (16 bytes), no padding is necessary.

The implementation uses the openSSL library as its cryptographic backend.

Author
Erik Eliasson elias.nosp@m.son@.nosp@m.it.kt.nosp@m.h.se
Johan Bilien jobi@.nosp@m.via..nosp@m.ecp.f.nosp@m.r
Werner Dittmann Werne.nosp@m.r.Di.nosp@m.ttman.nosp@m.n@t-.nosp@m.onlin.nosp@m.e.de

Definition at line 77 of file SrtpSymCrypto.h.

Constructor & Destructor Documentation

SrtpSymCrypto::SrtpSymCrypto ( int  algo = SrtpEncryptionAESCM)

Definition at line 49 of file gcryptSrtpSymCrypto.cpp.

SrtpSymCrypto::SrtpSymCrypto ( uint8_t *  key,
int32_t  key_length,
int  algo = SrtpEncryptionAESCM 
)

Constructor that initializes key data.

Parameters
keyPointer to key bytes.
key_lengthNumber of key bytes.

Definition at line 53 of file gcryptSrtpSymCrypto.cpp.

SrtpSymCrypto::~SrtpSymCrypto ( )

Definition at line 60 of file gcryptSrtpSymCrypto.cpp.

Member Function Documentation

void SrtpSymCrypto::ctr_encrypt ( const uint8_t *  input,
uint32_t  inputLen,
uint8_t *  output,
uint8_t *  iv 
)

Counter-mode encryption.

This method performs the AES CM encryption.

Parameters
inputPointer to input buffer, must be inputLen bytes.
inputLenNumber of bytes to process.
outputPointer to output buffer, must be inputLen bytes.
ivThe initialization vector as input to create the cipher stream. Refer to chapter 4.1.1 in RFC 3711.

Definition at line 151 of file gcryptSrtpSymCrypto.cpp.

void SrtpSymCrypto::ctr_encrypt ( uint8_t *  data,
uint32_t  data_length,
uint8_t *  iv 
)

Counter-mode encryption, in place.

This method performs the AES CM encryption.

Parameters
dataPointer to input and output block, must be dataLen bytes.
data_lengthNumber of bytes to process.
ivThe initialization vector as input to create the cipher stream. Refer to chapter 4.1.1 in RFC 3711.

Definition at line 184 of file gcryptSrtpSymCrypto.cpp.

void SrtpSymCrypto::encrypt ( const uint8_t *  input,
uint8_t *  output 
)

Encrypts the inpout to the output.

Encrypts one input block to one output block. Each block is 16 bytes according to the AES encryption algorithm used.

Parameters
inputPointer to input block, must be 16 bytes
outputPointer to output block, must be 16 bytes

Definition at line 117 of file gcryptSrtpSymCrypto.cpp.

void SrtpSymCrypto::f8_deriveForIV ( SrtpSymCrypto f8Cipher,
uint8_t *  key,
int32_t  keyLen,
uint8_t *  salt,
int32_t  saltLen 
)

Derive a AES context to compute the IV'.

See chapter 4.1.2.1 in RFC 3711.

Parameters
f8CipherPointer to the AES context that will be used to encrypt IV to IV'
keyThe master key
keyLenLength of the master key.
saltMaster salt.
saltLenlength of master salt.

Definition at line 224 of file gcryptSrtpSymCrypto.cpp.

void SrtpSymCrypto::f8_encrypt ( const uint8_t *  data,
uint32_t  dataLen,
uint8_t *  iv,
SrtpSymCrypto f8Cipher 
)

AES F8 mode encryption, in place.

This method performs the AES F8 encryption, see chapter 4.1.2 in RFC 3711.

Parameters
dataPointer to input and output block, must be dataLen bytes.
dataLenNumber of bytes to process.
ivThe initialization vector as input to create the cipher stream. Refer to chapter 4.1.1 in RFC 3711.
f8CipherAn AES cipher context used to encrypt IV to IV'.

Definition at line 217 of file gcryptSrtpSymCrypto.cpp.

void SrtpSymCrypto::f8_encrypt ( const uint8_t *  data,
uint32_t  dataLen,
uint8_t *  out,
uint8_t *  iv,
SrtpSymCrypto f8Cipher 
)

AES F8 mode encryption.

This method performs the AES F8 encryption, see chapter 4.1.2 in RFC 3711.

Parameters
dataPointer to input and output block, must be dataLen bytes.
dataLenNumber of bytes to process.
outPointer to output buffer, must be dataLen bytes.
ivThe initialization vector as input to create the cipher stream. Refer to chapter 4.1.1 in RFC 3711.
f8CipherAn AES cipher context used to encrypt IV to IV'.

Definition at line 260 of file gcryptSrtpSymCrypto.cpp.

void SrtpSymCrypto::get_ctr_cipher_stream ( uint8_t *  output,
uint32_t  length,
uint8_t *  iv 
)

Computes the cipher stream for AES CM mode.

Parameters
outputPointer to a buffer that receives the cipher stream. Must be at least length bytes long.
lengthNumber of cipher stream bytes to produce. Usually the same length as the data to be encrypted.
ivThe initialization vector as input to create the cipher stream. Refer to chapter 4.1.1 in RFC 3711.

Definition at line 128 of file gcryptSrtpSymCrypto.cpp.

int SrtpSymCrypto::processBlock ( F8_CIPHER_CTX f8ctx,
const uint8_t *  in,
int32_t  length,
uint8_t *  out 
)
private

Definition at line 297 of file gcryptSrtpSymCrypto.cpp.

bool SrtpSymCrypto::setNewKey ( const uint8_t *  key,
int32_t  keyLength 
)

Set new key.

Parameters
keyPointer to key data, must have at least a size of keyLength
keyLengthLength of the key in bytes, must be 16, 24, or 32
Returns
false if key could not set.

Definition at line 74 of file gcryptSrtpSymCrypto.cpp.

Field Documentation

int32_t SrtpSymCrypto::algorithm
private

Definition at line 248 of file SrtpSymCrypto.h.

void* SrtpSymCrypto::key
private

Definition at line 247 of file SrtpSymCrypto.h.


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