@@ -46,6 +46,15 @@ public static byte[] encode(ECPrivateKey privateKey) {
4646 */
4747 public static PublicKey loadPublicKey (String encodedPublicKey ) throws NoSuchProviderException , NoSuchAlgorithmException , InvalidKeySpecException {
4848 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 {
4958 KeyFactory keyFactory = KeyFactory .getInstance (ALGORITHM , PROVIDER_NAME );
5059 ECParameterSpec parameterSpec = ECNamedCurveTable .getParameterSpec (CURVE );
5160 ECCurve curve = parameterSpec .getCurve ();
@@ -66,6 +75,19 @@ public static PublicKey loadPublicKey(String encodedPublicKey) throws NoSuchProv
6675 */
6776 public static PrivateKey loadPrivateKey (String encodedPrivateKey ) throws NoSuchProviderException , NoSuchAlgorithmException , InvalidKeySpecException {
6877 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 {
6991 BigInteger s = BigIntegers .fromUnsignedByteArray (decodedPrivateKey );
7092 ECParameterSpec parameterSpec = ECNamedCurveTable .getParameterSpec (CURVE );
7193 ECPrivateKeySpec privateKeySpec = new ECPrivateKeySpec (s , parameterSpec );
0 commit comments