Mercurial > 510Connectbot
diff app/src/main/java/ch/ethz/ssh2/crypto/digest/HMAC.java @ 510:7953570e5210
update to ganymed-ssh2 tag 263 and fix hmac-sha2-512
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 01 Feb 2023 17:55:29 -0700 |
parents | d29cce60f393 |
children |
line wrap: on
line diff
--- a/app/src/main/java/ch/ethz/ssh2/crypto/digest/HMAC.java Sun Jan 29 10:25:21 2023 -0700 +++ b/app/src/main/java/ch/ethz/ssh2/crypto/digest/HMAC.java Wed Feb 01 17:55:29 2023 -0700 @@ -21,15 +21,14 @@ int size; - public HMAC(Digest md, byte[] key, int size) throws DigestException { + public HMAC(Digest md, byte[] key, int digestsize, int blocksize) throws DigestException { this.md = md; - this.size = size; + this.size = digestsize; tmp = new byte[md.getDigestLength()]; - final int BLOCKSIZE = 64; - k_xor_ipad = new byte[BLOCKSIZE]; - k_xor_opad = new byte[BLOCKSIZE]; + k_xor_ipad = new byte[blocksize]; + k_xor_opad = new byte[blocksize]; - if (key.length > BLOCKSIZE) { + if (key.length > blocksize) { md.reset(); md.update(key); md.digest(tmp); @@ -39,7 +38,7 @@ System.arraycopy(key, 0, k_xor_ipad, 0, key.length); System.arraycopy(key, 0, k_xor_opad, 0, key.length); - for (int i = 0; i < BLOCKSIZE; i++) { + for (int i = 0; i < blocksize; i++) { k_xor_ipad[i] ^= 0x36; k_xor_opad[i] ^= 0x5C; }