mirror of https://github.com/shred/acme4j
Add method that returns a standard keypair
parent
b9b7bda342
commit
3ce5b8bd4f
|
@ -46,6 +46,19 @@ public class KeyPairUtils {
|
||||||
// utility class without constructor
|
// utility class without constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new standard {@link KeyPair}.
|
||||||
|
* <p>
|
||||||
|
* This method can be used if no specific key type is required. It returns a
|
||||||
|
* "secp384r1" ECDSA key pair.
|
||||||
|
*
|
||||||
|
* @return Generated {@link KeyPair}
|
||||||
|
* @since 2.8
|
||||||
|
*/
|
||||||
|
public static KeyPair createKeyPair() {
|
||||||
|
return createECKeyPair("secp384r1");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new RSA {@link KeyPair}.
|
* Creates a new RSA {@link KeyPair}.
|
||||||
*
|
*
|
||||||
|
|
|
@ -42,6 +42,19 @@ public class KeyPairUtilsTest {
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that standard keypair generates a secure key pair.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCreateStandardKeyPair() {
|
||||||
|
KeyPair pair = KeyPairUtils.createKeyPair();
|
||||||
|
assertThat(pair, is(notNullValue()));
|
||||||
|
assertThat(pair.getPublic(), is(instanceOf(ECPublicKey.class)));
|
||||||
|
ECPublicKey pk = (ECPublicKey) pair.getPublic();
|
||||||
|
assertThat(pk.getAlgorithm(), is("ECDSA"));
|
||||||
|
assertThat(pk.getParams().getCurve().getField().getFieldSize(), is(384));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that RSA keypairs of the correct size are generated.
|
* Test that RSA keypairs of the correct size are generated.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue