public class CryptoUtil extends Object
Constructor and Description |
---|
CryptoUtil() |
Modifier and Type | Method and Description |
---|---|
static KeyPair |
generateEllipticCurveKeyPair()
Generates an Elliptic Curve key pair using the default elliptic curve spec.
|
static KeyPair |
generateEllipticCurveKeyPair(String inEllipticCurveSpec)
Generates an Elliptic Curve key pair.
|
static byte[] |
generateSignatureWithECDSA(PrivateKey inPrivateKey,
String inText)
Generates a signature give a private key and the text to sign.
|
static String |
getDefaultEllipticCurveSpec()
Returns the default SunEC-implemented elliptic curve spec used.
|
static PrivateKey |
readPrivateEllipticCurveKeyFile(File inPrivateKeyFile) |
static PublicKey |
readPublicEllipticCurveKeyFile(File inPublicKeyFile) |
static void |
setDefaultEllipticCurveSpec(String inValue)
Sets the default SunEC-implemented elliptic curve spec used.
|
static boolean |
verifySignatureWithECDSA(PublicKey inPublicKey,
String inText,
byte[] inSignature)
Verifies a signature give a public key, the signed text, and the signature.
|
static void |
writePrivateEllipticCurveKeyToFile(PrivateKey inPrivateKey,
File inFile) |
static void |
writePublicEllipticCurveKeyToFile(PublicKey inPublicKey,
File inFile) |
public CryptoUtil()
public static void setDefaultEllipticCurveSpec(String inValue)
inValue
- String spec for the SunEC-implemented elliptic curve to use.public static String getDefaultEllipticCurveSpec()
public static KeyPair generateEllipticCurveKeyPair() throws Exception
Exception
public static KeyPair generateEllipticCurveKeyPair(String inEllipticCurveSpec) throws Exception
inEllipticCurveSpec
- String spec for the SunEC-implemented elliptic curve to use.Exception
public static void writePrivateEllipticCurveKeyToFile(PrivateKey inPrivateKey, File inFile) throws Exception
Exception
public static PrivateKey readPrivateEllipticCurveKeyFile(File inPrivateKeyFile) throws Exception
Exception
public static void writePublicEllipticCurveKeyToFile(PublicKey inPublicKey, File inFile) throws Exception
Exception
public static PublicKey readPublicEllipticCurveKeyFile(File inPublicKeyFile) throws Exception
Exception
public static byte[] generateSignatureWithECDSA(PrivateKey inPrivateKey, String inText) throws Exception
inPrivateKey
- private Elliptic Curve keyinText
- text to signException
public static boolean verifySignatureWithECDSA(PublicKey inPublicKey, String inText, byte[] inSignature) throws Exception
inPublicKey
- public Elliptic Curve keyinText
- text that was signedinSignature
- signature as a byte[]Exception