Class AesFunctions
This class contains static fuctions for performing AES encryption and decryption operations for SRTP and SRTCP.
Inherited Members
Namespace: SipLib.RtpCrypto
Assembly: SipLib.dll
Syntax
public static class AesFunctions
Methods
| Edit this page View SourceAesCounterModeTransform(byte[], byte[], byte[], byte[])
Encrypts or decrypts a block of bytes using AES in Counter Mode. RFC 3711 defines the AES Counter Mode algorithm for SRTP and SRTCP.
Declaration
public static void AesCounterModeTransform(byte[] key, byte[] salt, byte[] Input, byte[] Output)
Parameters
Type | Name | Description |
---|---|---|
byte[] | key | Encryption key. The array length must be a valid length for the AES algorithm. Valid lengths are: 16 bytes (AES-128), 24 bytes (AES-192) or 32 bytes (AES-256). |
byte[] | salt | Salt value to use. This must be 16 bytes (128 bits) long. |
byte[] | Input | Input byte array to encrypt or decrypt. |
byte[] | Output | Output encrypted or decrypted byte array. Must be the same length or longer than the Input input array. |
Remarks
This function can be used to either encrypt an input array or to produce a key stream which can then be used to encrypt some data.To encrypt data, pass the data into the Input array.
To generate a key stream, pass in an array of 0s in the Input array and the Output array will contain the key stream.. Then XOR the key stream in the Output array with the data to be encrypted.
The encryption and decryption operations are symetric. To encrypt a packet, pass in the plain text as the input. To decrypt a packet, pass in the encrypted packet as the input.
AesCounterModeTransform(byte[], byte[], byte[], int, int, byte[])
Encrypts or decrypts a block of bytes using AES in Counter Mode. RFC 3711 defines the AES Counter Mode algorithm for SRTP and SRTCP.
Declaration
public static void AesCounterModeTransform(byte[] key, byte[] salt, byte[] Input, int StartIdx, int NumInputBytes, byte[] Output)
Parameters
Type | Name | Description |
---|---|---|
byte[] | key | Encryption key. The array length must be a valid length for the AES algorithm. Valid lengths are: 16 bytes (AES-128), 24 bytes (AES-192) or 32 bytes (AES-256). |
byte[] | salt | Salt value to use. This must be 16 bytes (128 bits) long. |
byte[] | Input | Input byte array to encrypt or decrypt. |
int | StartIdx | Starting index in the Input array. |
int | NumInputBytes | Number of bytes in the input array to process. |
byte[] | Output | Output encrypted or decrypted byte array. Must be the same length or longer than NumInputBytes |
Remarks
This function can be used to either encrypt an input array or to produce a key stream which can then be used to encrypt some data.To encrypt data, pass the data into the Input array.
To generate a key stream, pass in an array of 0s in the Input array and the Output array will contain the key stream.. Then XOR the key stream in the Output array with the data to be encrypted.
The encryption and decryption operations are symetric. To encrypt a packet, pass in the plain text as the input. To decrypt a packet, pass in the encrypted packet as the input.
AesF8ModeTransform(byte[], byte[], byte[], byte[], byte[])
Encrypts or Decrypts a block of bytes using the AES in F8 mode. Section 4.1.2.1 of RFC 3711 specifies the AES in F8 mode algorithm. This algorithm only supports AES-128.
Declaration
public static void AesF8ModeTransform(byte[] k_e, byte[] k_s, byte[] IV, byte[] Input, byte[] Output)
Parameters
Type | Name | Description |
---|---|---|
byte[] | k_e | Encryption key. Must be 16 bytes (128 bits) long. |
byte[] | k_s | Salt value to use. |
byte[] | IV | Initialization Vector (IV) to use. Must be the same length as the k_e input array. |
byte[] | Input | Input byte array to encrypt or decrypt. |
byte[] | Output | Output encrypted or decrypted byte array. Must be the same length or longer than the Input input array. |
Remarks
This function can be used to either encrypt an input array or to produce a key stream which can then be used to encrypt some data.To encrypt data, pass the data into the Input array.
To generate a key stream, pass in an array of 0s in the Input array and the Output array will contain the key stream.. Then XOR the key stream in the Output array with the data to be encrypted.
The encryption and decryption operations are symetric. To encrypt a packet, pass in the plain text as the input. To decrypt a packet, pass in the encrypted packet as the input.
AesF8ModeTransform(byte[], byte[], byte[], byte[], int, int, byte[])
Encrypts or Decrypts a block of bytes using the AES in F8 mode. Section 4.1.2.1 of RFC 3711 specifies the AES in F8 mode algorithm. This algorithm only supports AES-128.
Declaration
public static void AesF8ModeTransform(byte[] k_e, byte[] k_s, byte[] IV, byte[] Input, int StartIdx, int NumInputBytes, byte[] Output)
Parameters
Type | Name | Description |
---|---|---|
byte[] | k_e | Encryption key. Must be 16 bytes (128 bits) long. |
byte[] | k_s | Salt value to use. |
byte[] | IV | Initialization Vector (IV) to use. Must be the same length as the k_e input array. |
byte[] | Input | Input byte array to encrypt or decrypt. |
int | StartIdx | The index in the Input array to start processing at. |
int | NumInputBytes | The number of bytes in the Input array to process. |
byte[] | Output | Output encrypted or decrypted byte array. Must be the same length or longer than the Input input array. |
Remarks
This function can be used to either encrypt an input array or to produce a key stream which can then be used to encrypt some data.To encrypt data, pass the data into the Input array.
To generate a key stream, pass in an array of 0s in the Input array and the Output array will contain the key stream.. Then XOR the key stream in the Output array with the data to be encrypted.
The encryption and decryption operations are symetric. To encrypt a packet, pass in the plain text as the input. To decrypt a packet, pass in the encrypted packet as the input.