Skip to content

Commit

Permalink
TEIID-2952 addressing different vm handling of dh secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed May 9, 2014
1 parent c72fce1 commit 7204ef0
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -110,7 +110,13 @@ public SymmetricCryptor getSymmetricCryptor(byte[] peerPublicKeyBytes, boolean u
ka.init(privateKey);
ka.doPhase(publicKey, true);
byte[] secret = ka.generateSecret();

//we expect a 1024-bit DH key, but vms handle leading zeros differently
if (secret.length < 128) {
byte[] temp = new byte[128];
System.arraycopy(secret, 0, temp, 128-secret.length, secret.length);
secret = temp;
}
//convert to expected bit length for AES
MessageDigest sha = MessageDigest.getInstance(DIGEST);
byte[] hash = sha.digest(secret);
byte[] symKey = new byte[keySize / 8];
Expand Down

0 comments on commit 7204ef0

Please sign in to comment.