@@ -46,6 +46,15 @@ public static byte[] encode(ECPrivateKey privateKey) {
46
46
*/
47
47
public static PublicKey loadPublicKey (String encodedPublicKey ) throws NoSuchProviderException , NoSuchAlgorithmException , InvalidKeySpecException {
48
48
byte [] decodedPublicKey = Base64Encoder .decode (encodedPublicKey );
49
+ return loadPublicKey (decodedPublicKey );
50
+ }
51
+
52
+ /**
53
+ * Load the public key from a byte array.
54
+ *
55
+ * @param decodedPublicKey
56
+ */
57
+ public static PublicKey loadPublicKey (byte [] decodedPublicKey ) throws NoSuchProviderException , NoSuchAlgorithmException , InvalidKeySpecException {
49
58
KeyFactory keyFactory = KeyFactory .getInstance (ALGORITHM , PROVIDER_NAME );
50
59
ECParameterSpec parameterSpec = ECNamedCurveTable .getParameterSpec (CURVE );
51
60
ECCurve curve = parameterSpec .getCurve ();
@@ -66,6 +75,19 @@ public static PublicKey loadPublicKey(String encodedPublicKey) throws NoSuchProv
66
75
*/
67
76
public static PrivateKey loadPrivateKey (String encodedPrivateKey ) throws NoSuchProviderException , NoSuchAlgorithmException , InvalidKeySpecException {
68
77
byte [] decodedPrivateKey = Base64Encoder .decode (encodedPrivateKey );
78
+ return loadPrivateKey (decodedPrivateKey );
79
+ }
80
+
81
+ /**
82
+ * Load the private key from a byte array
83
+ *
84
+ * @param decodedPrivateKey
85
+ * @return
86
+ * @throws NoSuchProviderException
87
+ * @throws NoSuchAlgorithmException
88
+ * @throws InvalidKeySpecException
89
+ */
90
+ public static PrivateKey loadPrivateKey (byte [] decodedPrivateKey ) throws NoSuchProviderException , NoSuchAlgorithmException , InvalidKeySpecException {
69
91
BigInteger s = BigIntegers .fromUnsignedByteArray (decodedPrivateKey );
70
92
ECParameterSpec parameterSpec = ECNamedCurveTable .getParameterSpec (CURVE );
71
93
ECPrivateKeySpec privateKeySpec = new ECPrivateKeySpec (s , parameterSpec );
0 commit comments