public final class SigUtil extends Object
public static PublicKey toJavaKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityException
public static PrivateKey toJavaKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityException
public static SigningPublicKey fromJavaKey(PublicKey pk) throws GeneralSecurityException
pk
- JAVA key!IllegalArgumentException
- on unknown typeGeneralSecurityException
public static SigningPublicKey fromJavaKey(PublicKey pk, SigType type) throws GeneralSecurityException
pk
- JAVA key!GeneralSecurityException
public static SigningPrivateKey fromJavaKey(PrivateKey pk) throws GeneralSecurityException
pk
- JAVA key!IllegalArgumentException
- on unknown typeGeneralSecurityException
public static SigningPrivateKey fromJavaKey(PrivateKey pk, SigType type) throws GeneralSecurityException
pk
- JAVA key!GeneralSecurityException
public static ECPublicKey toJavaECKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityException
public static ECPrivateKey toJavaECKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityException
public static SigningPublicKey fromJavaKey(ECPublicKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityException
public static SigningPrivateKey fromJavaKey(ECPrivateKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityException
public static EdDSAPublicKey toJavaEdDSAKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityException
public static EdDSAPrivateKey toJavaEdDSAKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityException
public static SigningPublicKey fromJavaKey(EdDSAPublicKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityException
public static SigningPrivateKey fromJavaKey(EdDSAPrivateKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityException
public static DSAPublicKey toJavaDSAKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityException
public static DSAPrivateKey toJavaDSAKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityException
public static SigningPublicKey fromJavaKey(DSAPublicKey pk) throws GeneralSecurityException
GeneralSecurityException
public static SigningPrivateKey fromJavaKey(DSAPrivateKey pk) throws GeneralSecurityException
GeneralSecurityException
public static RSAPublicKey toJavaRSAKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityException
public static RSAPrivateKey toJavaRSAKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityException
public static SigningPublicKey fromJavaKey(RSAPublicKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityException
public static SigningPrivateKey fromJavaKey(RSAPrivateKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityException
public static byte[] toJavaSig(Signature sig)
public static Signature fromJavaSig(byte[] asn, SigType type) throws SignatureException
asn
- ASN.1 representationSignatureException
public static PublicKey importJavaPublicKey(File file, SigType type) throws GeneralSecurityException, IOException
GeneralSecurityException
IOException
public static PrivateKey importJavaPrivateKey(File file, SigType type) throws GeneralSecurityException, IOException
GeneralSecurityException
IOException
public static byte[] rectify(BigInteger bi, int len) throws InvalidKeyException
bi
- non-negativeInvalidKeyException
public static byte[] sigBytesToASN1(BigInteger r, BigInteger s)
Signature Format: ASN.1 sequence of two INTEGER values: r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER } http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One 30 -- tag indicating SEQUENCE xx - length in octets 02 -- tag indicating INTEGER xx - length in octets xxxxxx - valuer and s are always non-negative. Only supports sigs up to about 65530 bytes. See code to fix BER encoding for this before you add a SigType with bigger signatures.
IllegalArgumentException
- if too bigpublic static int intToASN1(byte[] d, int idx, int val)
val
- 0-65535public static NativeBigInteger[] aSN1ToBigInteger(byte[] asn, int len) throws SignatureException
len
- nominal length of each BigIntegerSignatureException
public static void clearCaches()