ccRTP 2.1.2
|
Implments the SRTP encryption modes as defined in RFC3711. More...
#include <SrtpSymCrypto.h>
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 |
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.
Definition at line 77 of file SrtpSymCrypto.h.
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.
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.
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.
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.
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.
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 | ( | 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.
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, | ||
SrtpSymCrypto * | f8Cipher | ||
) |
AES F8 mode encryption, in place.
This method performs the AES F8 encryption, see chapter 4.1.2 in RFC 3711.
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, | ||
SrtpSymCrypto * | f8Cipher | ||
) |
AES F8 mode encryption.
This method performs the AES F8 encryption, see chapter 4.1.2 in RFC 3711.
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.
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.
|
private |
Definition at line 297 of file gcryptSrtpSymCrypto.cpp.
bool SrtpSymCrypto::setNewKey | ( | const uint8_t * | key, |
int32_t | keyLength | ||
) |
Set new key.
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 |
Definition at line 74 of file gcryptSrtpSymCrypto.cpp.
|
private |
Definition at line 248 of file SrtpSymCrypto.h.
|
private |
Definition at line 247 of file SrtpSymCrypto.h.