mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Encode algorithm recommendation in HashManager
This commit is contained in:
parent
ba323b51f9
commit
6565618840
1 changed files with 30 additions and 16 deletions
|
@ -143,26 +143,36 @@ public final class HashManager extends Manager {
|
||||||
return PREFIX_NS_ALGO + algorithm.toString();
|
return PREFIX_NS_ALGO + algorithm.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ALGORITHM { // RECOMMENDATION:
|
enum AlgorithmRecommendation {
|
||||||
MD5 ("md5"), // MUST NOT use this
|
unknown,
|
||||||
SHA_1 ("sha-1"), // SHOULD NOT use this
|
must_not,
|
||||||
SHA_224 ("sha-224"),
|
should_not,
|
||||||
SHA_256 ("sha-256"), // MUST use this
|
should,
|
||||||
SHA_384 ("sha-384"),
|
must,
|
||||||
SHA_512 ("sha-512"), // SHOULD use this
|
}
|
||||||
SHA3_224 ("sha3-224"),
|
|
||||||
SHA3_256 ("sha3-256"), // MUST use this
|
public enum ALGORITHM {
|
||||||
SHA3_384 ("sha3-384"),
|
MD5 ("md5", AlgorithmRecommendation.must_not),
|
||||||
SHA3_512 ("sha3-512"), // SHOULD use this
|
SHA_1 ("sha-1", AlgorithmRecommendation.should_not),
|
||||||
BLAKE2B160("id-blake2b160"),
|
SHA_224 ("sha-224", AlgorithmRecommendation.unknown),
|
||||||
BLAKE2B256("id-blake2b256"), // MUST use this
|
SHA_256 ("sha-256", AlgorithmRecommendation.must),
|
||||||
BLAKE2B384("id-blake2b384"),
|
SHA_384 ("sha-384", AlgorithmRecommendation.unknown),
|
||||||
BLAKE2B512("id-blake2b512"); // SHOULD use this
|
SHA_512 ("sha-512", AlgorithmRecommendation.should),
|
||||||
|
SHA3_224 ("sha3-224", AlgorithmRecommendation.unknown),
|
||||||
|
SHA3_256 ("sha3-256", AlgorithmRecommendation.must),
|
||||||
|
SHA3_384 ("sha3-384", AlgorithmRecommendation.unknown),
|
||||||
|
SHA3_512 ("sha3-512", AlgorithmRecommendation.should),
|
||||||
|
BLAKE2B160("id-blake2b160", AlgorithmRecommendation.unknown),
|
||||||
|
BLAKE2B256("id-blake2b256", AlgorithmRecommendation.must),
|
||||||
|
BLAKE2B384("id-blake2b384", AlgorithmRecommendation.unknown),
|
||||||
|
BLAKE2B512("id-blake2b512", AlgorithmRecommendation.should);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final AlgorithmRecommendation recommendation;
|
||||||
|
|
||||||
ALGORITHM(String name) {
|
ALGORITHM(String name, AlgorithmRecommendation recommendation) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.recommendation = recommendation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,6 +184,10 @@ public final class HashManager extends Manager {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AlgorithmRecommendation getRecommendation() {
|
||||||
|
return recommendation;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compensational method for static 'valueOf' function.
|
* Compensational method for static 'valueOf' function.
|
||||||
* @param s
|
* @param s
|
||||||
|
|
Loading…
Reference in a new issue