diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2022-06-09 10:17:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 10:17:12 +0200 |
commit | addf44cccdc9fd6d9358e617a501ea26ca6af722 (patch) | |
tree | 81a7b7dbf07b4245cac6c190d4faa9b0cab07d1a /src/main/java/org/uic/barcode/utils/SecurityUtils.java | |
parent | Merge pull request #48 from UnionInternationalCheminsdeFer/1.3.3 (diff) | |
parent | Delete DecodeDB9EuroTicketTest.java (diff) | |
download | UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.gz UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.bz2 UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.lz UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.xz UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.zst UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.zip |
Diffstat (limited to '')
-rw-r--r-- | src/main/java/org/uic/barcode/utils/SecurityUtils.java | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/src/main/java/org/uic/barcode/utils/SecurityUtils.java b/src/main/java/org/uic/barcode/utils/SecurityUtils.java index fc6a135..5fdbda7 100644 --- a/src/main/java/org/uic/barcode/utils/SecurityUtils.java +++ b/src/main/java/org/uic/barcode/utils/SecurityUtils.java @@ -24,37 +24,16 @@ public class SecurityUtils { * @return the provider
*/
public static Provider findPublicKeyProvider(String keyAlgorithmOid, byte[] keyBytes) {
-
-
- X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
-
- String name;
- try {
- name = AlgorithmNameResolver.getAlgorithmName(AlgorithmNameResolver.TYPE_KEY_GENERATOR_ALG, keyAlgorithmOid, null);
- } catch (Exception e2) {
- return null;
- }
-
- KeyFactory keyFactory = null;
-
+
Provider[] provs = Security.getProviders();
for (Provider provider : provs) {
try {
- keyFactory = KeyFactory.getInstance(name,provider);
- } catch (NoSuchAlgorithmException e1) {
+ PublicKey key = ECKeyEncoder.fromEncoded(keyBytes, keyAlgorithmOid, provider);
+ if (key != null) return provider;
+ } catch (Exception e1) {
//try next
}
- if (keyFactory != null) {
- try {
- keyFactory.generatePublic(keySpec);
- return provider;
- } catch (Exception e) {
- provider = null;
- //try next
- }
- }
}
-
return null;
}
|