Program: 107598
Project: 107598
Buggy source:
/** 
 * Constructs a normal SRTPCryptoContext based on the given parameters.
 * @param sender <tt>true</tt> if the new instance is to be used by an SRTPsender; <tt>false</tt> if the new instance is to be used by an SRTP receiver
 * @param ssrc the RTP SSRC that this SRTP cryptographic context protects.
 * @param roc the initial Roll-Over-Counter according to RFC 3711. Theseare the upper 32 bit of the overall 48 bit SRTP packet index. Refer to chapter 3.2.1 of the RFC.
 * @param keyDerivationRate the key derivation rate defines when torecompute the SRTP session keys. Refer to chapter 4.3.1 in the RFC.
 * @param masterK 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 masterS 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 SRTPCryptoContext(boolean sender,int ssrc,int roc,long keyDerivationRate,byte[] masterK,byte[] masterS,SRTPPolicy policy){
  this.sender=sender;
  this.ssrc=ssrc;
  this.roc=roc;
  this.keyDerivationRate=keyDerivationRate;
  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:
authKey=new byte[policy.getAuthKeyLength()];
mac=new HMac(new SHA1Digest());
tagStore=new byte[mac.getMacSize()];
break;
case SRTPPolicy.SKEIN_AUTHENTICATION:
authKey=new byte[policy.getAuthKeyLength()];
mac=new SkeinMac();
tagStore=new byte[policy.getAuthTagLength()];
break;
case SRTPPolicy.NULL_AUTHENTICATION:
default :
authKey=null;
mac=new HMac(new SHA1Digest());
tagStore=null;
break;
}
this.authKey=authKey;
this.mac=mac;
this.tagStore=tagStore;
readConfigurationServicePropertiesOnce();
}

Fixed version (ground truth):
/** 
 * Constructs a normal SRTPCryptoContext based on the given parameters.
 * @param sender <tt>true</tt> if the new instance is to be used by an SRTPsender; <tt>false</tt> if the new instance is to be used by an SRTP receiver
 * @param ssrc the RTP SSRC that this SRTP cryptographic context protects.
 * @param roc the initial Roll-Over-Counter according to RFC 3711. Theseare the upper 32 bit of the overall 48 bit SRTP packet index. Refer to chapter 3.2.1 of the RFC.
 * @param keyDerivationRate the key derivation rate defines when torecompute the SRTP session keys. Refer to chapter 4.3.1 in the RFC.
 * @param masterK 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 masterS 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 SRTPCryptoContext(boolean sender,int ssrc,int roc,long keyDerivationRate,byte[] masterK,byte[] masterS,SRTPPolicy policy){
  this.sender=sender;
  this.ssrc=ssrc;
  this.roc=roc;
  this.keyDerivationRate=keyDerivationRate;
  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:
authKey=new byte[policy.getAuthKeyLength()];
mac=new HMac(SHA1.createDigest());
tagStore=new byte[mac.getMacSize()];
break;
case SRTPPolicy.SKEIN_AUTHENTICATION:
authKey=new byte[policy.getAuthKeyLength()];
mac=new SkeinMac();
tagStore=new byte[policy.getAuthTagLength()];
break;
case SRTPPolicy.NULL_AUTHENTICATION:
default :
authKey=null;
mac=new HMac(SHA1.createDigest());
tagStore=null;
break;
}
this.authKey=authKey;
this.mac=mac;
this.tagStore=tagStore;
readConfigurationServicePropertiesOnce();
}