ccRTP 2.1.2
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 (uint8_t *key, int32_t key_length, int algo=SrtpEncryptionAESCM)
  Constructor that initializes key data. More...
 
 
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
key Pointer to key bytes.
key_length Number 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
input Pointer to input buffer, must be inputLen bytes.
inputLen Number of bytes to process.
output Pointer to output buffer, must be inputLen bytes.
iv The 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
data Pointer to input and output block, must be dataLen bytes.
data_length Number of bytes to process.
iv The 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
input Pointer to input block, must be 16 bytes
output Pointer to output block, must be 16 bytes

Definition at line 117 of file gcryptSrtpSymCrypto.cpp.

void SrtpSymCrypto::f8_deriveForIV ( SrtpSymCryptof8Cipher,
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
f8Cipher Pointer to the AES context that will be used to encrypt IV to IV'
key The master key
keyLen Length of the master key.
salt Master salt.
saltLen length 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,
SrtpSymCryptof8Cipher 
)

AES F8 mode encryption, in place.

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

Parameters
data Pointer to input and output block, must be dataLen bytes.
dataLen Number of bytes to process.
iv The initialization vector as input to create the cipher stream. Refer to chapter 4.1.1 in RFC 3711.
f8Cipher An 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,
SrtpSymCryptof8Cipher 
)

AES F8 mode encryption.

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

Parameters
data Pointer to input and output block, must be dataLen bytes.
dataLen Number of bytes to process.
out Pointer to output buffer, must be dataLen bytes.
iv The initialization vector as input to create the cipher stream. Refer to chapter 4.1.1 in RFC 3711.
f8Cipher An 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
output Pointer to a buffer that receives the cipher stream. Must be at least length bytes long.
length Number of cipher stream bytes to produce. Usually the same length as the data to be encrypted.
iv The 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_CTXf8ctx,
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
key Pointer to key data, must have at least a size of keyLength
keyLength Length 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:

Generated on Dec 15, 2017 for ccrtp-2.1.2 (*.h and *.cpp) and libzrtpcpp-2.3.4 (*.h), by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /