Program: 107597
Project: 107597
Buggy source:
/** 
 * Construct a normal SRTPCryptoContext based on the given parameters.
 * @param ssrc the RTP SSRC that this SRTP cryptographic context protects.
 * @param masterKey byte array holding the master key for this SRTPcryptographic context. Refer to chapter 3.2.1 of the RFC about the role of the master key.
 * @param masterSalt byte array holding the master salt for this SRTPcryptographic context. It is used to computer the initialization vector that in turn is input to compute the session key, session authentication key and the session salt.
 * @param policy SRTP policy for this SRTP cryptographic context, definedthe encryption algorithm, the authentication algorithm, etc
 */
@SuppressWarnings("String_Node_Str") public SRTCPCryptoContext(int ssrc,byte[] masterK,byte[] masterS,SRTPPolicy policy){
  this.ssrc=ssrc;
  this.policy=policy;
  int encKeyLength=policy.getEncKeyLength();
  masterKey=new byte[encKeyLength];
  System.arraycopy(masterK,0,masterKey,0,encKeyLength);
  int saltKeyLength=policy.getSaltKeyLength();
  masterSalt=new byte[saltKeyLength];
  System.arraycopy(masterS,0,masterSalt,0,saltKeyLength);
  BlockCipher cipher=null;
  BlockCipher cipherF8=null;
  byte[] encKey=null;
  byte[] saltKey=null;
switch (policy.getEncType()) {
case SRTPPolicy.NULL_ENCRYPTION:
    break;
case SRTPPolicy.AESF8_ENCRYPTION:
  cipherF8=AES.createBlockCipher();
case SRTPPolicy.AESCM_ENCRYPTION:
cipher=AES.createBlockCipher();
encKey=new byte[encKeyLength];
saltKey=new byte[saltKeyLength];
break;
case SRTPPolicy.TWOFISHF8_ENCRYPTION:
cipherF8=new TwofishEngine();
case SRTPPolicy.TWOFISH_ENCRYPTION:
cipher=new TwofishEngine();
encKey=new byte[encKeyLength];
saltKey=new byte[saltKeyLength];
break;
}
this.cipher=cipher;
this.cipherF8=cipherF8;
this.encKey=encKey;
this.saltKey=saltKey;
byte[] authKey;
Mac mac;
byte[] tagStore;
switch (policy.getAuthType()) {
case SRTPPolicy.HMACSHA1_AUTHENTICATION:
mac=new HMac(new SHA1Digest());
authKey=new byte[policy.getAuthKeyLength()];
tagStore=new byte[mac.getMacSize()];
break;
case SRTPPolicy.SKEIN_AUTHENTICATION:
mac=new SkeinMac();
authKey=new byte[policy.getAuthKeyLength()];
tagStore=new byte[policy.getAuthTagLength()];
break;
case SRTPPolicy.NULL_AUTHENTICATION:
default :
authKey=null;
mac=null;
tagStore=null;
break;
}
this.authKey=authKey;
this.mac=mac;
this.tagStore=tagStore;
}

Fixed version (ground truth):
/** 
 * Construct a normal SRTPCryptoContext based on the given parameters.
 * @param ssrc the RTP SSRC that this SRTP cryptographic context protects.
 * @param masterKey byte array holding the master key for this SRTPcryptographic context. Refer to chapter 3.2.1 of the RFC about the role of the master key.
 * @param masterSalt byte array holding the master salt for this SRTPcryptographic context. It is used to computer the initialization vector that in turn is input to compute the session key, session authentication key and the session salt.
 * @param policy SRTP policy for this SRTP cryptographic context, definedthe encryption algorithm, the authentication algorithm, etc
 */
@SuppressWarnings("String_Node_Str") public SRTCPCryptoContext(int ssrc,byte[] masterK,byte[] masterS,SRTPPolicy policy){
  this.ssrc=ssrc;
  this.policy=policy;
  int encKeyLength=policy.getEncKeyLength();
  masterKey=new byte[encKeyLength];
  System.arraycopy(masterK,0,masterKey,0,encKeyLength);
  int saltKeyLength=policy.getSaltKeyLength();
  masterSalt=new byte[saltKeyLength];
  System.arraycopy(masterS,0,masterSalt,0,saltKeyLength);
  BlockCipher cipher=null;
  BlockCipher cipherF8=null;
  byte[] encKey=null;
  byte[] saltKey=null;
switch (policy.getEncType()) {
case SRTPPolicy.NULL_ENCRYPTION:
    break;
case SRTPPolicy.AESF8_ENCRYPTION:
  cipherF8=AES.createBlockCipher();
case SRTPPolicy.AESCM_ENCRYPTION:
cipher=AES.createBlockCipher();
encKey=new byte[encKeyLength];
saltKey=new byte[saltKeyLength];
break;
case SRTPPolicy.TWOFISHF8_ENCRYPTION:
cipherF8=new TwofishEngine();
case SRTPPolicy.TWOFISH_ENCRYPTION:
cipher=new TwofishEngine();
encKey=new byte[encKeyLength];
saltKey=new byte[saltKeyLength];
break;
}
this.cipher=cipher;
this.cipherF8=cipherF8;
this.encKey=encKey;
this.saltKey=saltKey;
byte[] authKey;
Mac mac;
byte[] tagStore;
switch (policy.getAuthType()) {
case SRTPPolicy.HMACSHA1_AUTHENTICATION:
mac=new HMac(SHA1.createDigest());
authKey=new byte[policy.getAuthKeyLength()];
tagStore=new byte[mac.getMacSize()];
break;
case SRTPPolicy.SKEIN_AUTHENTICATION:
mac=new SkeinMac();
authKey=new byte[policy.getAuthKeyLength()];
tagStore=new byte[policy.getAuthTagLength()];
break;
case SRTPPolicy.NULL_AUTHENTICATION:
default :
authKey=null;
mac=null;
tagStore=null;
break;
}
this.authKey=authKey;
this.mac=mac;
this.tagStore=tagStore;
}