- java.lang.Object
-
- org.shredzone.acme4j.util.KeyPairUtils
-
public class KeyPairUtils extends Object
Utility class offering convenience methods forKeyPair
.Requires
Bouncy Castle
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static KeyPair
createECKeyPair(String name)
Creates a new elliptic curveKeyPair
.static KeyPair
createKeyPair()
Creates a new standardKeyPair
.static KeyPair
createKeyPair(int keysize)
Creates a new RSAKeyPair
.static KeyPair
readKeyPair(Reader r)
Reads aKeyPair
from a PEM file.static void
writeKeyPair(KeyPair keypair, Writer w)
Writes aKeyPair
PEM file.static void
writePublicKey(PublicKey key, Writer w)
Writes aPublicKey
as PEM file.
-
-
-
Method Detail
-
createKeyPair
public static KeyPair createKeyPair()
Creates a new standardKeyPair
.This method can be used if no specific key type is required. It returns a "secp384r1" ECDSA key pair.
- Returns:
- Generated
KeyPair
- Since:
- 2.8
-
createKeyPair
public static KeyPair createKeyPair(int keysize)
Creates a new RSAKeyPair
.- Parameters:
keysize
- Key size- Returns:
- Generated
KeyPair
-
createECKeyPair
public static KeyPair createECKeyPair(String name)
Creates a new elliptic curveKeyPair
.- Parameters:
name
- ECDSA curve name (e.g. "secp256r1")- Returns:
- Generated
KeyPair
-
readKeyPair
public static KeyPair readKeyPair(Reader r) throws IOException
Reads aKeyPair
from a PEM file.- Parameters:
r
-Reader
to read the PEM file from. TheReader
is closed after use.- Returns:
KeyPair
read- Throws:
IOException
-
writeKeyPair
public static void writeKeyPair(KeyPair keypair, Writer w) throws IOException
Writes aKeyPair
PEM file.- Parameters:
keypair
-KeyPair
to writew
-Writer
to write the PEM file to. TheWriter
is closed after use.- Throws:
IOException
-
writePublicKey
public static void writePublicKey(PublicKey key, Writer w) throws IOException
Writes aPublicKey
as PEM file.- Parameters:
key
-PublicKey
w
-Writer
to write the PEM file to. TheWriter
is closed after use.- Throws:
IOException
- Since:
- 3.0.0
-
-