public final class SigUtil extends Object
| Modifier and Type | Method | Description |
|---|---|---|
static NativeBigInteger[] |
aSN1ToBigInteger(byte[] asn,
int len) |
See above.
|
static void |
clearCaches() |
|
(package private) static byte[] |
combine(BigInteger x,
BigInteger y,
int len) |
Combine two BigIntegers of nominal length = len / 2
|
static SigningPrivateKey |
fromJavaKey(DSAPrivateKey pk) |
|
static SigningPublicKey |
fromJavaKey(DSAPublicKey pk) |
|
static SigningPrivateKey |
fromJavaKey(ECPrivateKey pk,
SigType type) |
|
static SigningPublicKey |
fromJavaKey(ECPublicKey pk,
SigType type) |
|
static SigningPrivateKey |
fromJavaKey(RSAPrivateKey pk,
SigType type) |
As of 0.9.31, if pk is a RSAPrivateCrtKey,
this will return a RSASigningPrivateCrtKey.
|
static SigningPublicKey |
fromJavaKey(RSAPublicKey pk,
SigType type) |
|
static SigningPrivateKey |
fromJavaKey(PrivateKey pk) |
Use if SigType is unknown.
|
static SigningPrivateKey |
fromJavaKey(PrivateKey pk,
SigType type) |
Use if SigType is known.
|
static SigningPublicKey |
fromJavaKey(PublicKey pk) |
Use if SigType is unknown.
|
static SigningPublicKey |
fromJavaKey(PublicKey pk,
SigType type) |
Use if SigType is known.
|
static SigningPrivateKey |
fromJavaKey(EdDSAPrivateKey pk,
SigType type) |
|
static SigningPublicKey |
fromJavaKey(EdDSAPublicKey pk,
SigType type) |
|
static Signature |
fromJavaSig(byte[] asn,
SigType type) |
|
static PrivateKey |
importJavaPrivateKey(File file,
SigType type) |
|
static PublicKey |
importJavaPublicKey(File file,
SigType type) |
|
static int |
intToASN1(byte[] d,
int idx,
int val) |
Output an length or integer value in ASN.1
Does NOT output the tag e.g.
|
static byte[] |
rectify(BigInteger bi,
int len) |
|
static byte[] |
sigBytesToASN1(BigInteger r,
BigInteger s) |
http://download.oracle.com/javase/1.5.0/docs/guide/security/CryptoSpec.html
|
static DSAPrivateKey |
toJavaDSAKey(SigningPrivateKey pk) |
|
static DSAPublicKey |
toJavaDSAKey(SigningPublicKey pk) |
|
static ECPrivateKey |
toJavaECKey(SigningPrivateKey pk) |
|
static ECPublicKey |
toJavaECKey(SigningPublicKey pk) |
|
static EdDSAPrivateKey |
toJavaEdDSAKey(SigningPrivateKey pk) |
|
static EdDSAPublicKey |
toJavaEdDSAKey(SigningPublicKey pk) |
|
static PrivateKey |
toJavaKey(SigningPrivateKey pk) |
|
static PublicKey |
toJavaKey(SigningPublicKey pk) |
|
static RSAPrivateKey |
toJavaRSAKey(SigningPrivateKey pk) |
As of 0.9.31, if pk is a RSASigningPrivateCrtKey,
this will return a RSAPrivateCrtKey.
|
static RSAPublicKey |
toJavaRSAKey(SigningPublicKey pk) |
Deprecated.
unused
|
static byte[] |
toJavaSig(Signature sig) |
public static PublicKey toJavaKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static PrivateKey toJavaKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPublicKey fromJavaKey(PublicKey pk) throws GeneralSecurityException
pk - JAVA key!IllegalArgumentException - on unknown typeGeneralSecurityExceptionpublic static SigningPublicKey fromJavaKey(PublicKey pk, SigType type) throws GeneralSecurityException
pk - JAVA key!GeneralSecurityExceptionpublic static SigningPrivateKey fromJavaKey(PrivateKey pk) throws GeneralSecurityException
pk - JAVA key!IllegalArgumentException - on unknown typeGeneralSecurityExceptionpublic static SigningPrivateKey fromJavaKey(PrivateKey pk, SigType type) throws GeneralSecurityException
pk - JAVA key!GeneralSecurityExceptionpublic static ECPublicKey toJavaECKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static ECPrivateKey toJavaECKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPublicKey fromJavaKey(ECPublicKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPrivateKey fromJavaKey(ECPrivateKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityExceptionpublic static EdDSAPublicKey toJavaEdDSAKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static EdDSAPrivateKey toJavaEdDSAKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPublicKey fromJavaKey(EdDSAPublicKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPrivateKey fromJavaKey(EdDSAPrivateKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityExceptionpublic static DSAPublicKey toJavaDSAKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static DSAPrivateKey toJavaDSAKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPublicKey fromJavaKey(DSAPublicKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPrivateKey fromJavaKey(DSAPrivateKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static RSAPublicKey toJavaRSAKey(SigningPublicKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static RSAPrivateKey toJavaRSAKey(SigningPrivateKey pk) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPublicKey fromJavaKey(RSAPublicKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityExceptionpublic static SigningPrivateKey fromJavaKey(RSAPrivateKey pk, SigType type) throws GeneralSecurityException
GeneralSecurityExceptionpublic static byte[] toJavaSig(Signature sig)
public static Signature fromJavaSig(byte[] asn, SigType type) throws SignatureException
asn - ASN.1 representationSignatureExceptionpublic static PublicKey importJavaPublicKey(File file, SigType type) throws GeneralSecurityException, IOException
GeneralSecurityExceptionIOExceptionpublic static PrivateKey importJavaPrivateKey(File file, SigType type) throws GeneralSecurityException, IOException
GeneralSecurityExceptionIOExceptionstatic byte[] combine(BigInteger x, BigInteger y, int len) throws InvalidKeyException
InvalidKeyExceptionpublic static byte[] rectify(BigInteger bi, int len) throws InvalidKeyException
bi - non-negativeInvalidKeyExceptionpublic 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 - value
r 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 BigIntegerSignatureExceptionpublic static void clearCaches()