aboutsummaryrefslogtreecommitdiffstats
path: root/security-utils/src/main/java/com/yahoo/security/KeyUtils.java
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2019-05-03 14:03:42 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2019-05-03 15:19:17 +0200
commit7b9663210bd6cc087ffcd6388855048a10947fb8 (patch)
tree3ecb38a26e1df54585f36f9ddf57702d05381838 /security-utils/src/main/java/com/yahoo/security/KeyUtils.java
parent25cb895e18e9dd1f74b32896e41fe01b76ddb48e (diff)
Move Signature factories to separate class
Diffstat (limited to 'security-utils/src/main/java/com/yahoo/security/KeyUtils.java')
-rw-r--r--security-utils/src/main/java/com/yahoo/security/KeyUtils.java37
1 files changed, 0 insertions, 37 deletions
diff --git a/security-utils/src/main/java/com/yahoo/security/KeyUtils.java b/security-utils/src/main/java/com/yahoo/security/KeyUtils.java
index 7d39c0d54e0..fa999ee521a 100644
--- a/security-utils/src/main/java/com/yahoo/security/KeyUtils.java
+++ b/security-utils/src/main/java/com/yahoo/security/KeyUtils.java
@@ -3,11 +3,9 @@ package com.yahoo.security;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Primitive;
-import org.bouncycastle.asn1.eac.ECDSAPublicKey;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.jce.spec.ECParameterSpec;
import org.bouncycastle.jce.spec.ECPublicKeySpec;
import org.bouncycastle.math.ec.ECPoint;
@@ -23,18 +21,14 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.security.GeneralSecurityException;
-import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
-import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
-import java.security.Signature;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPublicKeySpec;
-import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.List;
@@ -168,35 +162,4 @@ public class KeyUtils {
return primitive.getEncoded();
}
- /** Returns a signature instance which computes a SHA-256 hash of its content, before signing with the given private key. */
- public static Signature createSigner(PrivateKey key) {
- try {
- Signature signer = Signature.getInstance(SignatureAlgorithm.SHA256_WITH_ECDSA.getAlgorithmName(),
- BouncyCastleProviderHolder.getInstance());
- signer.initSign(key);
- return signer;
- }
- catch (NoSuchAlgorithmException e) {
- throw new IllegalStateException(e);
- }
- catch (InvalidKeyException e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- /** Returns a signature instance which computes a SHA-256 hash of its content, before verifying with the given public key. */
- public static Signature createVerifier(PublicKey key) {
- try {
- Signature signer = Signature.getInstance(SignatureAlgorithm.SHA256_WITH_ECDSA.getAlgorithmName(),
- BouncyCastleProviderHolder.getInstance());
- signer.initVerify(key);
- return signer;
- }
- catch (NoSuchAlgorithmException e) {
- throw new IllegalStateException(e);
- }
- catch (InvalidKeyException e) {
- throw new IllegalArgumentException(e);
- }
- }
}