Mercurial > 510Connectbot
diff src/ch/ethz/ssh2/crypto/digest/MAC.java @ 307:071eccdff8ea ganymed
fix java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 30 Jul 2014 14:16:58 -0700 |
parents | 91a31873c42a |
children | 8c1451f51a5e |
line wrap: on
line diff
--- a/src/ch/ethz/ssh2/crypto/digest/MAC.java Wed Jul 30 12:09:51 2014 -0700 +++ b/src/ch/ethz/ssh2/crypto/digest/MAC.java Wed Jul 30 14:16:58 2014 -0700 @@ -19,68 +19,75 @@ public static String[] getMacList() { // Higher priority first. Added SHA-2 algorithms as in RFC 6668 - return new String[]{"hmac-sha1-96", "hmac-sha1", "hmac-md5-96", "hmac-md5", "hmac-sha2-256", "hmac-sha2-512"}; + return new String[] {"hmac-sha1-96", "hmac-sha1", "hmac-md5-96", "hmac-md5", "hmac-sha2-256", "hmac-sha2-512"}; } public static void checkMacList(final String[] macs) { - for(String m : macs) { + for (String m : macs) { getKeyLen(m); } } public static int getKeyLen(final String type) { - if(type.equals("hmac-sha1")) { + if (type.equals("hmac-sha1")) { return 20; } - if(type.equals("hmac-sha1-96")) { + + if (type.equals("hmac-sha1-96")) { return 20; } - if(type.equals("hmac-md5")) { + + if (type.equals("hmac-md5")) { return 16; } - if(type.equals("hmac-md5-96")) { + + if (type.equals("hmac-md5-96")) { return 16; } - if(type.equals("hmac-sha2-256")) { + + if (type.equals("hmac-sha2-256")) { return 32; } - if(type.equals("hmac-sha2-512")) { + + if (type.equals("hmac-sha2-512")) { return 64; } + throw new IllegalArgumentException(String.format("Unknown algorithm %s", type)); } public MAC(final String type, final byte[] key) throws DigestException { - if(type.equals("hmac-sha1")) { + if (type.equals("hmac-sha1")) { mac = new HMAC(new SHA1(), key, 20); } - else if(type.equals("hmac-sha1-96")) { + else if (type.equals("hmac-sha1-96")) { mac = new HMAC(new SHA1(), key, 12); } - else if(type.equals("hmac-md5")) { + else if (type.equals("hmac-md5")) { mac = new HMAC(new MD5(), key, 16); } - else if(type.equals("hmac-md5-96")) { + else if (type.equals("hmac-md5-96")) { mac = new HMAC(new MD5(), key, 12); } - else if(type.equals("hmac-sha2-256")) { + else if (type.equals("hmac-sha2-256")) { mac = new HMAC(new SHA256(), key, 32); } - else if(type.equals("hmac-sha2-512")) { + else if (type.equals("hmac-sha2-512")) { mac = new HMAC(new SHA512(), key, 64); } else { throw new IllegalArgumentException(String.format("Unknown algorithm %s", type)); } + size = mac.getDigestLength(); } public final void initMac(final int seq) { mac.reset(); - mac.update((byte) (seq >> 24)); - mac.update((byte) (seq >> 16)); - mac.update((byte) (seq >> 8)); - mac.update((byte) (seq)); + mac.update((byte)(seq >> 24)); + mac.update((byte)(seq >> 16)); + mac.update((byte)(seq >> 8)); + mac.update((byte)(seq)); } public final void update(byte[] packetdata, int off, int len) { @@ -91,7 +98,7 @@ try { mac.digest(out, off); } - catch(DigestException e) { + catch (DigestException e) { throw new IOException(e); } }