Skip to content

Commit

Permalink
Added test & updated dependencies
Browse files Browse the repository at this point in the history
- Added test/example for AEAD_AES_256_GCM
- Updated dependencies in pom.xml
  • Loading branch information
Nico Eichelmann authored and Nico Eichelmann committed Jan 30, 2024
1 parent 64953df commit 222f02f
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 50 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-failsafe-plugin.version>3.2.2</maven-failsafe-plugin.version>
<maven-compiler-plugin.version>3.12.1</maven-compiler-plugin.version>
<maven-failsafe-plugin.version>3.2.5</maven-failsafe-plugin.version>
<maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
<com.puppycrawl.tools.checkstyle.version>10.12.6</com.puppycrawl.tools.checkstyle.version>
<com.puppycrawl.tools.checkstyle.version>10.13.0</com.puppycrawl.tools.checkstyle.version>
<maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
Expand All @@ -48,10 +48,10 @@

<java-getopt.version>1.0.13</java-getopt.version>
<jakarta.xml.bind-api.version>4.0.1</jakarta.xml.bind-api.version>
<slf4j.version>2.0.9</slf4j.version>
<slf4j.version>2.0.11</slf4j.version>
<junit.version>5.10.1</junit.version>
<assertj.version>3.24.2</assertj.version>
<spotbugs.version>4.8.2</spotbugs.version>
<assertj.version>3.25.2</assertj.version>
<spotbugs.version>4.8.3</spotbugs.version>
<bouncycastle.version>1.77</bouncycastle.version>
<pkts.version>3.0.10</pkts.version>
</properties>
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/org/jitsi/srtp/SrtpContextFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,17 @@ public SrtpContextFactory(
int encKeyLength = srtpPolicy.getEncKeyLength();
if (encKeyLength != srtcpPolicy.getEncKeyLength())
{
throw new IllegalArgumentException("srtpPolicy.getEncKeyLength() != srtcpPolicy.getEncKeyLength()");
throw new IllegalArgumentException(
"srtpPolicy.getEncKeyLength() {" + srtpPolicy.getEncKeyLength() +
"}!= srtcpPolicy.getEncKeyLength() {" + srtcpPolicy.getEncKeyLength() + "}");
}

if (masterKey != null)
{
if (masterKey.length != encKeyLength)
{
throw new IllegalArgumentException("masterK.length != encKeyLength");
throw new IllegalArgumentException(
"masterK.length {" + masterKey.length + "} != encKeyLength {" + encKeyLength + "}");
}

this.masterKey = new byte[encKeyLength];
Expand All @@ -93,22 +96,25 @@ public SrtpContextFactory(
{
if (encKeyLength != 0)
{
throw new IllegalArgumentException("null masterK but encKeyLength != 0");
throw new IllegalArgumentException("null masterK but encKeyLength {" + encKeyLength + "} != 0");
}
this.masterKey = new byte[0];
}

int saltKeyLength = srtpPolicy.getSaltKeyLength();
if (saltKeyLength != srtcpPolicy.getSaltKeyLength())
{
throw new IllegalArgumentException("srtpPolicy.getSaltKeyLength() != srtcpPolicy.getSaltKeyLength()");
throw new IllegalArgumentException(
"srtpPolicy.getSaltKeyLength() {" + srtpPolicy.getSaltKeyLength() +
"} != srtcpPolicy.getSaltKeyLength() {" + srtcpPolicy.getSaltKeyLength() + "}");
}

if (masterSalt != null)
{
if (masterSalt.length != saltKeyLength)
{
throw new IllegalArgumentException("masterS.length != saltKeyLength");
throw new IllegalArgumentException(
"masterS.length {" + masterSalt.length + "} != saltKeyLength {" + saltKeyLength + "}");
}

this.masterSalt = new byte[saltKeyLength];
Expand All @@ -118,7 +124,7 @@ public SrtpContextFactory(
{
if (saltKeyLength != 0)
{
throw new IllegalArgumentException("null masterS but saltKeyLength != 0");
throw new IllegalArgumentException("null masterS but saltKeyLength {" + saltKeyLength + "} != 0");
}
this.masterSalt = new byte[0];
}
Expand Down
47 changes: 23 additions & 24 deletions src/test/java/org/jitsi/srtp/CryptoSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.jitsi.impl.neomedia.transform.srtp.SRTPTransformer;

public enum CryptoSuite {

// rfc4568
AES_CM_128_HMAC_SHA1_80(16, 14, 2 ^ 48L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 16, SrtpPolicy.HMACSHA1_AUTHENTICATION, 10, 10, 20, 20),
AES_CM_128_HMAC_SHA1_32(16, 14, 2 ^ 48L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 16, SrtpPolicy.HMACSHA1_AUTHENTICATION, 4, 10, 20, 20),
Expand All @@ -13,41 +13,40 @@ public enum CryptoSuite {
// SEED_CTR_128_HMAC_SHA1_80(),
// SEED_128_CCM_80(),
// SEED_128_GCM_96(),

// rfc6188
AES_192_CM_HMAC_SHA1_80(24, 14, 2 ^ 31L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 24, SrtpPolicy.HMACSHA1_AUTHENTICATION, 10, 10, 20, 20),
AES_192_CM_HMAC_SHA1_32(24, 14, 2 ^ 31L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 24, SrtpPolicy.HMACSHA1_AUTHENTICATION, 4, 10, 20, 20),
AES_256_CM_HMAC_SHA1_80(32, 14, 2 ^ 31L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 32, SrtpPolicy.HMACSHA1_AUTHENTICATION, 10, 10, 20, 20),
AES_256_CM_HMAC_SHA1_32(32, 14, 2 ^ 31L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 32, SrtpPolicy.HMACSHA1_AUTHENTICATION, 4, 10, 20, 20),
// // rfc7714
// AEAD_AES_128_GCM(16, 12, 2 ^ 48L, 2 ^ 31L, SrtpPolicy.AESGCM_ENCRYPTION, 16, SrtpPolicy.NULL_AUTHENTICATION, 16, 16, 0, 0),
// AEAD_AES_256_GCM(32, 12, 2 ^ 48L, 2 ^ 31L, SrtpPolicy.AESGCM_ENCRYPTION, 12, SrtpPolicy.NULL_AUTHENTICATION, 16, 16, 0, 0),

// rfc7714
AEAD_AES_128_GCM(16, 12, 2 ^ 48L, 2 ^ 31L, SrtpPolicy.AESGCM_ENCRYPTION, 16, SrtpPolicy.NULL_AUTHENTICATION, 16, 16, 0, 0),
AEAD_AES_256_GCM(32, 12, 2 ^ 48L, 2 ^ 31L, SrtpPolicy.AESGCM_ENCRYPTION, 32, SrtpPolicy.NULL_AUTHENTICATION, 16, 16, 0, 0),

// incorrect identifier
AES_CM_256_HMAC_SHA1_80(32, 14, 2 ^ 31L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 32, SrtpPolicy.HMACSHA1_AUTHENTICATION, 10, 10, 20, 20),
AES_CM_256_HMAC_SHA1_32(32, 14, 2 ^ 31L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 32, SrtpPolicy.HMACSHA1_AUTHENTICATION, 10, 10, 20, 20),
AES_CM_192_HMAC_SHA1_32(24, 14, 2 ^ 31L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 24, SrtpPolicy.HMACSHA1_AUTHENTICATION, 4, 10, 20, 20),
AES_CM_192_HMAC_SHA1_80(24, 14, 2 ^ 31L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 24, SrtpPolicy.HMACSHA1_AUTHENTICATION, 10, 10, 20, 20),

// without authentication
AES_CM_128(16, 14, 2 ^ 48L, 2 ^ 31L, SrtpPolicy.AESCM_ENCRYPTION, 16, SrtpPolicy.NULL_AUTHENTICATION, 0, 0, 0, 0);


int masterKeyLength;
int masterSaltLength;
long maxSrtpLifeTime;
long maxSrtcpLifeTime;
int encryptionMode;
int encryptionKeyByteLength;
int authenticationMode;
int srtpAuthenticationTagLength;
int srtcpAuthenticationTagLength;
int srtpAuthenticationKeyLength;
int srtcpAuthenticationKeyLength;

CryptoSuite(int masterKeyByteLength, int masterSaltByteLength, long maxSrtpLifeTime, long maxSrtcpLifeTime, int aesMode,
int encryptionKeyByteLength, int authenticationMode, int srtpAuthenticationTagByteLength,

private int masterKeyLength;
private int masterSaltLength;
private long maxSrtpLifeTime;
private long maxSrtcpLifeTime;
private int encryptionMode;
private int encryptionKeyByteLength;
private int authenticationMode;
private int srtpAuthenticationTagLength;
private int srtcpAuthenticationTagLength;
private int srtpAuthenticationKeyLength;
private int srtcpAuthenticationKeyLength;

CryptoSuite(int masterKeyByteLength, int masterSaltByteLength, long maxSrtpLifeTime, long maxSrtcpLifeTime,
int aesMode, int encryptionKeyByteLength, int authenticationMode, int srtpAuthenticationTagByteLength,
int srtcpAuthenticationTagByteLength, int srtpAuthenticationKeyByteLength,
int srtcpAuthenticationKeyByteLength) {

Expand Down
84 changes: 70 additions & 14 deletions src/test/java/org/jitsi/srtp/LiveTestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
class LiveTestIT {
private static final Logger LOGGER = System.getLogger(LiveTestIT.class.getName());

private static final String PCAP_20230801_09_20000 = Objects
.requireNonNull(LiveTestIT.class.getResource("/20230801_09_20000.pcap")).getFile();
private static final String PCAP_20000_AES_CM_128_HMAC_SHA1_80 = Objects
.requireNonNull(LiveTestIT.class.getResource("/20000_AES_CM_128_HMAC_SHA1_80.pcap")).getFile();
private static final String PCAP_20000_AEAD_AES_256_GCM = Objects
.requireNonNull(LiveTestIT.class.getResource("/20000_AEAD_AES_256_GCM.pcap")).getFile();

@Test
void decryptSinglePacket() {
void decryptSinglePacket_AES_CM_128_HMAC_SHA1_80() {
byte[] decodedKeySaltBytes = Base64.getDecoder().decode("q3BDq3ieE2aYlpPinNQClCkOWowRTO4SuQalqJgv");
byte[] key = Arrays.copyOfRange(decodedKeySaltBytes, 0, 16);
byte[] salt = Arrays.copyOfRange(decodedKeySaltBytes, 16, decodedKeySaltBytes.length);
byte[] key = Arrays.copyOfRange(decodedKeySaltBytes, 0, CryptoSuite.AES_CM_128_HMAC_SHA1_80.getMasterKeyLength());
byte[] salt = Arrays.copyOfRange(decodedKeySaltBytes, CryptoSuite.AES_CM_128_HMAC_SHA1_80.getMasterKeyLength(), decodedKeySaltBytes.length);
byte[] expectedDecryptedPayloadBytes = DatatypeConverter.parseHexBinary(
"7b7efdfd7dfefffd7d7c7e7b7d7afe7efffffcfcfefd7dfd7bfffcfdfffdfb7efefefefd7efefcfd7b7b79fffdfcfafbfbfcfe7b79ff7cfd7d7bfd7cfefeff7e7d7dfcfafdfd7c76757e7efcfa7dfd7ef8fefe7afffe7a7d7bfcfc7b7a7bfefe7b7d7dfbfdfe7b7bff7d7dfeff7efe7d7e7bfefbfdfcfcfffcfbfefdfffe7e7dfffcfb7d7e7e7efcff7d7efefcfc7c787cfe7e7b7dfffbff7d7e7dfffeff7b7efdf9fd7e7b7ef97e7e7cfe7d7e7bfefcff7d797e7d78fe7e7e7e797c7e7bfe7b7efdfbff7bfa7bff7c7efe7aff7bfdff7dfdfcf9fdfbfefffcfcfffefb7e7d7c7c7dfffe7e7d7afffffefdfffcfbfafdfafbff7b7d797e7d7bfe79fbfefafa7efc7cfbfdff7efdfbfafd7d7b787d7cff7c7c7b797c79ff7dfdffffff7c7a7efd7efbfefcfefcfe7dfdfefc7c7c797b7d7dfe7cfafbfb7d7afcfffe7b7d7e7cfffe7efffffefeffffffff7e7e7eff7e7effffff7e7effff7efffefeffffffff7eff7efffeffffffffffff7efffffeffffffff7e7e7e7efffefefffeff7e7e7effff7e7e7effff7e7e7e7eff7e7e7e7effff7efffeffffff7efffefffffefe7e7e7efffeff7e7e7efffe7e7e7e7e7e7e7e7effffff7efffeffffffff7e7e7e7efffffffeffff7e7efefeffffffffffff7effff7e7e7e7e7e7e7effffffff7e7e7e7efffffffeff7e7efefeff7e7effffffff7eff7e7eff7e7efefeffffff7e7e7e7e7e7e7e7efeff7eff7e7e7e7efefefffffffffeffffff7e7efffffffefefffefffffffffffffeffffff7eff7e7e7e7e7e7e7e7e7e7e7efffefe7e7efffeffff7e7efffeff7effffff7e7e7efffeffffff7efffefeff7e7e7e7e7e7efe7e7efffffffefeffff7e7e7e7e7e7e7efffefffffe7efffefffefeffffffff7e7effffff7e7effff7e7efffffefffefeff7effffffff7efffffffefe7eff7e7d7efffffffffefefeffff7e7efffffffeff7efffffeff7e7efffeff7efffefe7eff7e7efeff7e7e7eff7e7efe7e7e7e7e7effff7e7e78f979fb7bffff7eff7bfbfcfe7efbfafc777c7a7aff7ef97bfe7bfd7dfdf9fefb7eff7bff7dfcfbfbfd7dff7dfc7d7c79fffd797cfffd78fdfdfdfafdfbfdff7cfc7e7cfefbfefe7d7dff7dfd7cfd7efcfe7eff7bfd777d7bfffefffd7a7efe7efdfe7dfbfcf97c7afcfffafffffe77fb7afe7e79fa77fcff7c7d7df8ff777c7ef8fd7b7d797bfffdfdfefbfdfffefd7d7d7779fffefefdfbfc7efffffff77dfafefffdfef9fd7a7b7d7dfd7efd7b787c7afe7b7dff7cfc79fcfefffc7bf97b7b7c7cff7aff7cff777b7df9f6fbf9fffb7affff7dfe7e7b797c7c7d7a7cfe7bfb7bfcfe7cfa7af9fefcfe797e7e");

Expand All @@ -48,10 +50,10 @@ void decryptSinglePacket() {
}

@Test
void encryptSinglePacket() {
void encryptSinglePacket_AES_CM_128_HMAC_SHA1_80() {
byte[] decodedKeySaltBytes = Base64.getDecoder().decode("q3BDq3ieE2aYlpPinNQClCkOWowRTO4SuQalqJgv");
byte[] key = Arrays.copyOfRange(decodedKeySaltBytes, 0, 16);
byte[] salt = Arrays.copyOfRange(decodedKeySaltBytes, 16, decodedKeySaltBytes.length);
byte[] key = Arrays.copyOfRange(decodedKeySaltBytes, 0, CryptoSuite.AES_CM_128_HMAC_SHA1_80.getMasterKeyLength());
byte[] salt = Arrays.copyOfRange(decodedKeySaltBytes, CryptoSuite.AES_CM_128_HMAC_SHA1_80.getMasterKeyLength(), decodedKeySaltBytes.length);
byte[] expectedEncryptedPayloadBytes = DatatypeConverter.parseHexBinary(
"7a059abfb792b7a292dd1812682c111943942e780ddfc4fb27ba434192ae1d494b563c1fdfd0bac0c343141e379c6b719fa370861cad1b043be442f2ea362854ec2edb355e3af143cc14feeec94183d49e3218981518a47b344514dcad00ffaa31e560fd95ab39ed31025cc9c3189090d00fa98731f9141218bb14867ba4ebb794ac21a412d9d13f32a2a8392d9f98d7fa406dca78b6b01920b0283c04b6541474d4f75928fc96873202e6c695cc2b65c0df484629819249e9a7a981376750931576435c699230cadad9bb01d46654094c3547ce6bbacd2e6d5696acb2a6ed5bafe577ee25a298eef6eaf59aebbcbaff816b75b8606e34b685499211aa0aa8be0e6886f77fba5357766de8a3e63ad2ba47837d27c5214af74e0130f413796a55a6841d35924b312bf56d9592a2a8ecd9fa119296cde7e3729a3eea59eda7301b1df49c204285a163668d6259af4265cfe732b324796fccb945e5d01e4f965487bdb7bc890973279ecf1b0973d6f7d9f3cf1ffe8ac75873aa690d977b1ebad880995aad25473ddc7c079417a65dbd3bda7f3ddf11ca12bb7e5b2022a7a5ba55ff9fb9a07d6542881e1fbe98118b553791d25bafab0f304aaa476eae4902d1cc1c206432ec2f200f9dd45865387d6b6a3d80503d9584dfdda742f10fa2ad28041a360779f8294f4675d4317e2518a157fbbf83e30583159b702b9edde5911ae29278f56a2809cdee2603f9050915f630c34ded4aae9ff7f936aaa9074947ecc05c3d027f560ab77d1602c17414abc37fb48629d07323625d214af0dfb124a5869db49163a98e07cb7ed7b914498588d161296986cad72ef1658324a06524ea1fd822089f3a6ac72e6d6c7c8e6e0aba3a70aca23bf91b905236b0b0a7e012c6c67da469115f0bddd2c011dc4322d7dfe1606fb93aa844fa0774ae4853f441d36c24434ffa5c62d2e7d122eb75f832df52d50feb52c51957f981a561ff4806372ef710d1124f052b07f9786103b11db4ec658fb2a39def7b838f3983aedb3a5a6e1662cb8709ea4793fe3f947653b023ab4fa5c4d879809777adf3768a2c3882afa1907e6a4cd14c40a1766f71f8a7ce6bc421f34b93737f5a0526905c9ac5e4267a103d61d1f5be00a9d0e1947715eee541192d32b4cdeec5bf7e2fff1a4ba15ab916472515a6f5c17b03d83ceec91de7421bcde90fc602a8324f8cbcc4c932b7b37ed859705d2519f9fe97ac9efb882be5ccd187a735ac15c780f82013eb0e95686b495bfa6d1b161afd19d6dc102aa2ca296a678d45406197bf456d45e072448e8d20315b774ab674b529b7bba48f550df779043df1f4e39878e7b380643ef347c8cf77432bd988452943");

Expand All @@ -67,16 +69,18 @@ void encryptSinglePacket() {
}

@Test
void decryptWriteAndEncryptWholeStream() throws FileNotFoundException, IOException {
void decryptWriteAndEncryptWholeStream_AES_CM_128_HMAC_SHA1_80() throws FileNotFoundException, IOException {
byte[] decodedKeySaltBytes = Base64.getDecoder().decode("q3BDq3ieE2aYlpPinNQClCkOWowRTO4SuQalqJgv");
byte[] key = Arrays.copyOfRange(decodedKeySaltBytes, 0, 16);
byte[] salt = Arrays.copyOfRange(decodedKeySaltBytes, 16, decodedKeySaltBytes.length);
byte[] key = Arrays.copyOfRange(decodedKeySaltBytes, 0,
CryptoSuite.AES_CM_128_HMAC_SHA1_80.getMasterKeyLength());
byte[] salt = Arrays.copyOfRange(decodedKeySaltBytes, CryptoSuite.AES_CM_128_HMAC_SHA1_80.getMasterKeyLength(),
decodedKeySaltBytes.length);

SRTPTransformer packetTransformer = CryptoSuite.AES_CM_128_HMAC_SHA1_80.createSrtpTransformer(false, key, salt);

Pcap pcap = Pcap.openStream(PCAP_20230801_09_20000);
File parentFile = new File(PCAP_20230801_09_20000);
File outputFile = new File(parentFile.getParentFile(), "result.pcap");
Pcap pcap = Pcap.openStream(PCAP_20000_AES_CM_128_HMAC_SHA1_80);
File parentFile = new File(PCAP_20000_AES_CM_128_HMAC_SHA1_80);
File outputFile = new File(parentFile.getParentFile(), "result_AES_CM_128_HMAC_SHA1_80.pcap");

LOGGER.log(Level.INFO, "Created new pcap file: {0}", outputFile);
PcapOutputStream out = pcap.createOutputStream(new FileOutputStream(outputFile));
Expand All @@ -88,6 +92,9 @@ void decryptWriteAndEncryptWholeStream() throws FileNotFoundException, IOExcepti

// decrypt
RawPacket decrypted = packetTransformer.reverseTransform(pkt);
Assertions.assertNotNull(decrypted,
"Couldn't decrypt packet with sequence number " + pkt.getSequenceNumber() + ".");
Assertions.assertNotNull(decrypted.getBuffer());
byte[] decryptedBytes = Arrays.copyOf(decrypted.getBuffer(), decrypted.getBuffer().length);
Assertions.assertNotNull(decrypted,
"Couldn't decrypt packet with sequence number " + pkt.getSequenceNumber());
Expand All @@ -109,4 +116,53 @@ void decryptWriteAndEncryptWholeStream() throws FileNotFoundException, IOExcepti
pcap.close();
}
}

@Test
void decryptWriteAndEncryptWholeStream_AEAD_AES_256_GCM() throws FileNotFoundException, IOException {
byte[] decodedKeySaltBytes = Base64.getDecoder()
.decode("TyBfADxvPN8/JWahU4OFVGksaFwL2m6t81PE7EtnaFZoNpx3+fdq/65a3uk=");
byte[] key = Arrays.copyOfRange(decodedKeySaltBytes, 0, CryptoSuite.AEAD_AES_256_GCM.getMasterKeyLength());
byte[] salt = Arrays.copyOfRange(decodedKeySaltBytes, CryptoSuite.AEAD_AES_256_GCM.getMasterKeyLength(),
decodedKeySaltBytes.length);

SRTPTransformer packetTransformer = CryptoSuite.AEAD_AES_256_GCM.createSrtpTransformer(false, key, salt);

Pcap pcap = Pcap.openStream(PCAP_20000_AEAD_AES_256_GCM);
File parentFile = new File(PCAP_20000_AEAD_AES_256_GCM);
File outputFile = new File(parentFile.getParentFile(), "result_AEAD_AES_256_GCM.pcap");

LOGGER.log(Level.INFO, "Created new pcap file: {0}", outputFile);
PcapOutputStream out = pcap.createOutputStream(new FileOutputStream(outputFile));

try {
pcap.loop(new UdpPayloadHandler(d -> {
RawPacket pkt = new RawPacket(d, 0, d.length);
byte[] originalBytes = Arrays.copyOf(pkt.getBuffer(), pkt.getBuffer().length);

// decrypt
RawPacket decrypted = packetTransformer.reverseTransform(pkt);
Assertions.assertNotNull(decrypted,
"Couldn't decrypt packet with sequence number " + pkt.getSequenceNumber() + ".");
Assertions.assertNotNull(decrypted.getBuffer());
byte[] decryptedBytes = Arrays.copyOf(decrypted.getBuffer(), decrypted.getBuffer().length);
Assertions.assertNotNull(decrypted,
"Couldn't decrypt packet with sequence number " + pkt.getSequenceNumber());
assertThat(Arrays.equals(originalBytes, decrypted.getBuffer())).isFalse();

// encrypt
SRTPTransformer encPacketTransformer = CryptoSuite.AEAD_AES_256_GCM.createSrtpTransformer(true, key,
salt);
RawPacket reencrypted = encPacketTransformer.transform(decrypted);
Assertions.assertNotNull(reencrypted,
"Couldn't reencrypt packet with sequence number " + pkt.getSequenceNumber());
assertThat(Arrays.equals(originalBytes, reencrypted.getBuffer())).isTrue();

return decryptedBytes;
}, out, CryptoSuite.AEAD_AES_256_GCM.getSrtcpAuthenticationTagLength()));
} finally {
out.flush();
out.close();
pcap.close();
}
}
}
Binary file added src/test/resources/20000_AEAD_AES_256_GCM.pcap
Binary file not shown.
File renamed without changes.

0 comments on commit 222f02f

Please sign in to comment.