Program: 109699
Project: 109699
Buggy source:
/** 
 * Calculates the parameter M1, to be sent to the SRP server. It also updates hashes of client and server for further calculations in other methods. It uses a predefined k.
 * @param salt_bytes
 * @param Bbytes the parameter received from the server, in bytes
 * @return the parameter M1
 * @throws NoSuchAlgorithmException
 */
public byte[] response(byte[] salt_bytes,byte[] Bbytes) throws NoSuchAlgorithmException {
  byte[] xb=calculatePasswordHash(username,password,salt_bytes);
  this.x=new BigInteger(1,xb);
  String k_string="String_Node_Str";
  this.v=calculateV(k_string);
  byte[] digest_of_n=newDigest().digest(N_bytes);
  byte[] digest_of_g=newDigest().digest(params.g);
  byte[] xor_digest=xor(digest_of_n,digest_of_g,digest_of_g.length);
  clientHash.update(xor_digest);
  byte[] username_digest=newDigest().digest(Util.trim(username.getBytes()));
  username_digest=Util.trim(username_digest);
  clientHash.update(username_digest);
  clientHash.update(Util.trim(salt_bytes));
  K=null;
  byte[] Abytes=Util.trim(A.toByteArray());
  clientHash.update(Abytes);
  Bbytes=Util.trim(Bbytes);
  clientHash.update(Bbytes);
  BigInteger S=calculateS(Bbytes);
  byte[] S_bytes=Util.trim(S.toByteArray());
  String hash_algorithm=params.hashAlgorithm;
  MessageDigest sessionDigest=MessageDigest.getInstance(hash_algorithm);
  K=Util.trim(sessionDigest.digest(S_bytes));
  clientHash.update(K);
  byte[] M1=Util.trim(clientHash.digest());
  serverHash.update(Abytes);
  serverHash.update(M1);
  serverHash.update(K);
  return M1;
}

Fixed version (ground truth):
/** 
 * Calculates the parameter M1, to be sent to the SRP server. It also updates hashes of client and server for further calculations in other methods. It uses a predefined k.
 * @param salt_bytes
 * @param Bbytes the parameter received from the server, in bytes
 * @return the parameter M1
 * @throws NoSuchAlgorithmException
 */
public byte[] response(byte[] salt_bytes,byte[] Bbytes) throws NoSuchAlgorithmException {
  byte[] xb=calculatePasswordHash(username,password,Util.trim(salt_bytes));
  this.x=new BigInteger(1,xb);
  String xstr=x.toString(16);
  String k_string="String_Node_Str";
  this.v=calculateV(k_string);
  byte[] digest_of_n=newDigest().digest(N_bytes);
  byte[] digest_of_g=newDigest().digest(params.g);
  byte[] xor_digest=xor(digest_of_n,digest_of_g,digest_of_g.length);
  clientHash.update(xor_digest);
  byte[] username_digest=newDigest().digest(Util.trim(username.getBytes()));
  username_digest=Util.trim(username_digest);
  clientHash.update(username_digest);
  clientHash.update(Util.trim(salt_bytes));
  K=null;
  byte[] Abytes=Util.trim(A.toByteArray());
  clientHash.update(Abytes);
  Bbytes=Util.trim(Bbytes);
  clientHash.update(Bbytes);
  BigInteger S=calculateS(Bbytes);
  byte[] S_bytes=Util.trim(S.toByteArray());
  String Sstr=S.toString(16);
  String hash_algorithm=params.hashAlgorithm;
  MessageDigest sessionDigest=MessageDigest.getInstance(hash_algorithm);
  K=Util.trim(sessionDigest.digest(S_bytes));
  clientHash.update(K);
  String Kstr=new BigInteger(1,K).toString(16);
  byte[] M1=Util.trim(clientHash.digest());
  String M1str=new BigInteger(1,M1).toString(16);
  serverHash.update(Abytes);
  serverHash.update(M1);
  serverHash.update(K);
  return M1;
}