You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/02/05 18:04:24 UTC
[06/21] guacamole-client git commit: GUACAMOLE-96: Include
recommended key length for each TOTP mode.
GUACAMOLE-96: Include recommended key length for each TOTP mode.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/4178a4b8
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/4178a4b8
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/4178a4b8
Branch: refs/heads/master
Commit: 4178a4b8b3f4898db4af9159ea2d3df747a01638
Parents: 78c398f
Author: Michael Jumper <mj...@apache.org>
Authored: Mon Nov 20 10:37:23 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Sun Feb 4 19:45:17 2018 -0800
----------------------------------------------------------------------
.../apache/guacamole/totp/TOTPGenerator.java | 33 +++++++++++++++++---
1 file changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/4178a4b8/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java b/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java
index b8c0d95..d075c8a 100644
--- a/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java
+++ b/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java
@@ -124,19 +124,19 @@ public class TOTPGenerator {
* TOTP mode which generates hashes using SHA1. TOTP in SHA1 mode
* requires 160-bit keys.
*/
- SHA1("HmacSHA1"),
+ SHA1("HmacSHA1", 20),
/**
* TOTP mode which generates hashes using SHA256. TOTP in SHA256 mode
* requires 256-bit keys.
*/
- SHA256("HmacSHA256"),
+ SHA256("HmacSHA256", 32),
/**
* TOTP mode which generates hashes using SHA512. TOTP in SHA512 mode
* requires 512-bit keys.
*/
- SHA512("HmacSHA512");
+ SHA512("HmacSHA512", 64);
/**
* The name of the HMAC algorithm which the TOTP implementation should
@@ -146,6 +146,13 @@ public class TOTPGenerator {
private final String algorithmName;
/**
+ * The recommended length of keys generated for TOTP in this mode, in
+ * bytes. Keys are recommended to be the same length as the hash
+ * involved.
+ */
+ private final int recommendedKeyLength;
+
+ /**
* Creates a new TOTP operating mode which is associated with the
* given HMAC algorithm.
*
@@ -153,9 +160,14 @@ public class TOTPGenerator {
* The name of the HMAC algorithm which the TOTP implementation
* should use when operating in this mode, in the format required
* by Mac.getInstance().
+ *
+ * @param recommendedKeyLength
+ * The recommended length of keys generated for TOTP in this mode,
+ * in bytes.
*/
- private Mode(String algorithmName) {
+ private Mode(String algorithmName, int recommendedKeyLength) {
this.algorithmName = algorithmName;
+ this.recommendedKeyLength = recommendedKeyLength;
}
/**
@@ -171,6 +183,19 @@ public class TOTPGenerator {
return algorithmName;
}
+ /**
+ * Returns the recommended length of keys generated for TOTP in this
+ * mode, in bytes. Keys are recommended to be the same length as the
+ * hash involved.
+ *
+ * @return
+ * The recommended length of keys generated for TOTP in this mode,
+ * in bytes.
+ */
+ public int getRecommendedKeyLength() {
+ return recommendedKeyLength;
+ }
+
}
/**