mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Do not explicitly select the Provider in HashManager
Note that we still setup the BouncyCastleProvider so all requested MessageDigest instances should be avaialble.
This commit is contained in:
parent
d6a90942a4
commit
9f8d13b8cd
1 changed files with 16 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2017 Paul Schaub
|
* Copyright © 2017 Paul Schaub, 2019 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -35,7 +35,6 @@ import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.SHA_512;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.NoSuchProviderException;
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -61,7 +60,6 @@ public final class HashManager extends Manager {
|
||||||
static {
|
static {
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
}
|
}
|
||||||
public static final String PROVIDER = "BC";
|
|
||||||
|
|
||||||
public static final String PREFIX_NS_ALGO = "urn:xmpp:hash-function-text-names:";
|
public static final String PREFIX_NS_ALGO = "urn:xmpp:hash-function-text-names:";
|
||||||
|
|
||||||
|
@ -224,52 +222,52 @@ public final class HashManager extends Manager {
|
||||||
try {
|
try {
|
||||||
switch (algorithm) {
|
switch (algorithm) {
|
||||||
case MD5:
|
case MD5:
|
||||||
md = MessageDigest.getInstance("MD5", PROVIDER);
|
md = MessageDigest.getInstance("MD5");
|
||||||
break;
|
break;
|
||||||
case SHA_1:
|
case SHA_1:
|
||||||
md = MessageDigest.getInstance("SHA-1", PROVIDER);
|
md = MessageDigest.getInstance("SHA-1");
|
||||||
break;
|
break;
|
||||||
case SHA_224:
|
case SHA_224:
|
||||||
md = MessageDigest.getInstance("SHA-224", PROVIDER);
|
md = MessageDigest.getInstance("SHA-224");
|
||||||
break;
|
break;
|
||||||
case SHA_256:
|
case SHA_256:
|
||||||
md = MessageDigest.getInstance("SHA-256", PROVIDER);
|
md = MessageDigest.getInstance("SHA-256");
|
||||||
break;
|
break;
|
||||||
case SHA_384:
|
case SHA_384:
|
||||||
md = MessageDigest.getInstance("SHA-384", PROVIDER);
|
md = MessageDigest.getInstance("SHA-384");
|
||||||
break;
|
break;
|
||||||
case SHA_512:
|
case SHA_512:
|
||||||
md = MessageDigest.getInstance("SHA-512", PROVIDER);
|
md = MessageDigest.getInstance("SHA-512");
|
||||||
break;
|
break;
|
||||||
case SHA3_224:
|
case SHA3_224:
|
||||||
md = MessageDigest.getInstance("SHA3-224", PROVIDER);
|
md = MessageDigest.getInstance("SHA3-224");
|
||||||
break;
|
break;
|
||||||
case SHA3_256:
|
case SHA3_256:
|
||||||
md = MessageDigest.getInstance("SHA3-256", PROVIDER);
|
md = MessageDigest.getInstance("SHA3-256");
|
||||||
break;
|
break;
|
||||||
case SHA3_384:
|
case SHA3_384:
|
||||||
md = MessageDigest.getInstance("SHA3-384", PROVIDER);
|
md = MessageDigest.getInstance("SHA3-384");
|
||||||
break;
|
break;
|
||||||
case SHA3_512:
|
case SHA3_512:
|
||||||
md = MessageDigest.getInstance("SHA3-512", PROVIDER);
|
md = MessageDigest.getInstance("SHA3-512");
|
||||||
break;
|
break;
|
||||||
case BLAKE2B160:
|
case BLAKE2B160:
|
||||||
md = MessageDigest.getInstance("BLAKE2b-160", PROVIDER);
|
md = MessageDigest.getInstance("BLAKE2b-160");
|
||||||
break;
|
break;
|
||||||
case BLAKE2B256:
|
case BLAKE2B256:
|
||||||
md = MessageDigest.getInstance("BLAKE2b-256", PROVIDER);
|
md = MessageDigest.getInstance("BLAKE2b-256");
|
||||||
break;
|
break;
|
||||||
case BLAKE2B384:
|
case BLAKE2B384:
|
||||||
md = MessageDigest.getInstance("BLAKE2b-384", PROVIDER);
|
md = MessageDigest.getInstance("BLAKE2b-384");
|
||||||
break;
|
break;
|
||||||
case BLAKE2B512:
|
case BLAKE2B512:
|
||||||
md = MessageDigest.getInstance("BLAKE2b-512", PROVIDER);
|
md = MessageDigest.getInstance("BLAKE2b-512");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new AssertionError("Invalid enum value: " + algorithm);
|
throw new AssertionError("Invalid enum value: " + algorithm);
|
||||||
}
|
}
|
||||||
return md;
|
return md;
|
||||||
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue