Program: 104383
Project: 104383
Buggy source:
/** 
 * Construct a normal SRTPCryptoContext based on the given parameters.
 * @param ssrc the RTP SSRC that this SRTP cryptographic context protects.
 * @param roc the initial Roll-Over-Counter according to RFC 3711.These are the upper 32 bit of the overall 48 bit SRTP packet index. Refer to chapter 3.2.1 of the RFC.
 * @param keyDerivRate the key derivation rate defines when to recomputethe SRTP session keys. Refer to chapter 4.3.1 in the RFC.
 * @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 SRTP cryptographic 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, defined the encryption algorithm, the authentication algorithm, etc 
 */
public SRTPCryptoContext(long ssrc,int roc,long keyDerivationRate,byte[] masterKey,byte[] masterSalt,SRTPPolicy policy){
  this.ssrc=ssrc;
  this.mki=null;
  this.roc=roc;
  this.guessedROC=0;
  this.seqNum=0;
  this.keyDerivationRate=keyDerivationRate;
  this.seqNumSet=false;
  this.policy=policy;
  this.masterKey=new byte[masterKey.length];
  System.arraycopy(masterKey,0,this.masterKey,0,this.masterKey.length);
  this.masterSalt=new byte[masterSalt.length];
  System.arraycopy(masterSalt,0,this.masterSalt,0,this.masterSalt.length);
switch (policy.getEncType()) {
case SRTPPolicy.NULL_ENCRYPTION:
    this.encKey=null;
  this.saltKey=null;
break;
case SRTPPolicy.AESCM_ENCRYPTION:
case SRTPPolicy.AESF8_ENCRYPTION:
this.encKey=new byte[this.policy.getEncKeyLength()];
this.saltKey=new byte[this.policy.getSaltKeyLength()];
break;
}
switch (policy.getAuthType()) {
case SRTPPolicy.NULL_AUTHENTICATION:
this.authKey=null;
break;
case SRTPPolicy.HMACSHA1_AUTHENTICATION:
this.authKey=new byte[policy.getAuthKeyLength()];
break;
}
}

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 roc the initial Roll-Over-Counter according to RFC 3711.These are 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 to recomputethe SRTP session keys. Refer to chapter 4.3.1 in the RFC.
 * @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 SRTP cryptographic 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, defined the encryption algorithm, the authentication algorithm, etc 
 */
public SRTPCryptoContext(long ssrc,int roc,long keyDerivationRate,byte[] masterKey,byte[] masterSalt,SRTPPolicy policy){
  this.ssrc=ssrc;
  this.mki=null;
  this.roc=roc;
  this.guessedROC=0;
  this.seqNum=0;
  this.keyDerivationRate=keyDerivationRate;
  this.seqNumSet=false;
  this.policy=policy;
  this.masterKey=new byte[masterKey.length];
  System.arraycopy(masterKey,0,this.masterKey,0,this.masterKey.length);
  this.masterSalt=new byte[masterSalt.length];
  System.arraycopy(masterSalt,0,this.masterSalt,0,this.masterSalt.length);
switch (policy.getEncType()) {
case SRTPPolicy.NULL_ENCRYPTION:
    this.encKey=null;
  this.saltKey=null;
break;
case SRTPPolicy.AESCM_ENCRYPTION:
case SRTPPolicy.AESF8_ENCRYPTION:
this.encKey=new byte[this.policy.getEncKeyLength()];
this.saltKey=new byte[this.policy.getSaltKeyLength()];
break;
}
switch (policy.getAuthType()) {
case SRTPPolicy.NULL_AUTHENTICATION:
this.authKey=null;
break;
case SRTPPolicy.HMACSHA1_AUTHENTICATION:
this.authKey=new byte[policy.getAuthKeyLength()];
break;
}
}