Package org.mozilla.jss.pkcs11
Class PK11Signature
- java.lang.Object
-
- org.mozilla.jss.crypto.SignatureSpi
-
- org.mozilla.jss.pkcs11.PK11Signature
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public final class PK11Signature extends SignatureSpi implements java.lang.AutoCloseable
-
-
Field Summary
Fields Modifier and Type Field Description protected Algorithm
algorithm
protected Algorithm
digestAlgorithm
protected org.mozilla.jss.pkcs11.PK11Key
key
protected boolean
raw
protected java.io.ByteArrayOutputStream
rawInput
protected org.mozilla.jss.pkcs11.SigContextProxy
sigContext
static int
SIGN
protected int
state
protected PK11Token
token
protected TokenProxy
tokenProxy
static int
UNINITIALIZED
static int
VERIFY
-
Constructor Summary
Constructors Constructor Description PK11Signature(PK11Token token, SignatureAlgorithm algorithm)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
engineInitSign(PrivateKey privateKey)
void
engineInitSign(PrivateKey privateKey, java.security.SecureRandom random)
This is just here for JCA compliance, we don't take randoms this way.void
engineInitVerify(java.security.PublicKey publicKey)
protected static boolean
engineRawVerifyNative(PK11Token token, java.security.PublicKey key, byte[] hash, byte[] signature)
Performs raw verification of the signature of a hash using the given public key, on the given token.void
engineSetParameter(java.security.spec.AlgorithmParameterSpec params)
byte[]
engineSign()
int
engineSign(byte[] outbuf, int offset, int len)
void
engineUpdate(byte b)
void
engineUpdate(byte[] b, int off, int len)
protected void
engineUpdateNative(byte[] b, int off, int len)
boolean
engineVerify(byte[] sigBytes)
protected boolean
engineVerifyNative(byte[] sigBytes)
void
finalize()
protected void
initSigContext()
Creates a signing context, initializes it, and sets the sigContext field.protected void
initVfyContext()
-
-
-
Field Detail
-
token
protected PK11Token token
-
tokenProxy
protected TokenProxy tokenProxy
-
algorithm
protected Algorithm algorithm
-
digestAlgorithm
protected Algorithm digestAlgorithm
-
key
protected org.mozilla.jss.pkcs11.PK11Key key
-
state
protected int state
-
sigContext
protected org.mozilla.jss.pkcs11.SigContextProxy sigContext
-
raw
protected boolean raw
-
rawInput
protected java.io.ByteArrayOutputStream rawInput
-
UNINITIALIZED
public static final int UNINITIALIZED
- See Also:
- Constant Field Values
-
SIGN
public static final int SIGN
- See Also:
- Constant Field Values
-
VERIFY
public static final int VERIFY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PK11Signature
public PK11Signature(PK11Token token, SignatureAlgorithm algorithm) throws java.security.NoSuchAlgorithmException, TokenException
- Throws:
java.security.NoSuchAlgorithmException
TokenException
-
-
Method Detail
-
engineInitSign
public void engineInitSign(PrivateKey privateKey) throws java.security.InvalidKeyException, TokenException
- Specified by:
engineInitSign
in classSignatureSpi
- Throws:
java.security.InvalidKeyException
TokenException
-
engineInitSign
public void engineInitSign(PrivateKey privateKey, java.security.SecureRandom random) throws java.security.InvalidKeyException, TokenException
This is just here for JCA compliance, we don't take randoms this way.- Specified by:
engineInitSign
in classSignatureSpi
- Throws:
java.security.InvalidKeyException
TokenException
-
initSigContext
protected void initSigContext() throws TokenException
Creates a signing context, initializes it, and sets the sigContext field.- Throws:
TokenException
-
engineInitVerify
public void engineInitVerify(java.security.PublicKey publicKey) throws java.security.InvalidKeyException, TokenException
- Specified by:
engineInitVerify
in classSignatureSpi
- Throws:
java.security.InvalidKeyException
TokenException
-
initVfyContext
protected void initVfyContext() throws TokenException
- Throws:
TokenException
-
engineUpdate
public void engineUpdate(byte b) throws java.security.SignatureException, TokenException
- Specified by:
engineUpdate
in classSignatureSpi
- Throws:
java.security.SignatureException
TokenException
-
engineUpdate
public void engineUpdate(byte[] b, int off, int len) throws java.security.SignatureException, TokenException
- Specified by:
engineUpdate
in classSignatureSpi
- Throws:
java.security.SignatureException
TokenException
-
engineUpdateNative
protected void engineUpdateNative(byte[] b, int off, int len) throws TokenException
- Throws:
TokenException
-
engineSign
public byte[] engineSign() throws java.security.SignatureException, TokenException
- Specified by:
engineSign
in classSignatureSpi
- Throws:
java.security.SignatureException
TokenException
-
engineSign
public int engineSign(byte[] outbuf, int offset, int len) throws java.security.SignatureException, TokenException
- Specified by:
engineSign
in classSignatureSpi
- Throws:
java.security.SignatureException
TokenException
-
engineVerify
public boolean engineVerify(byte[] sigBytes) throws java.security.SignatureException, TokenException
- Specified by:
engineVerify
in classSignatureSpi
- Throws:
java.security.SignatureException
TokenException
-
engineRawVerifyNative
protected static boolean engineRawVerifyNative(PK11Token token, java.security.PublicKey key, byte[] hash, byte[] signature) throws java.security.SignatureException, TokenException
Performs raw verification of the signature of a hash using the given public key, on the given token.- Throws:
java.security.SignatureException
TokenException
-
engineVerifyNative
protected boolean engineVerifyNative(byte[] sigBytes) throws java.security.SignatureException, TokenException
- Throws:
java.security.SignatureException
TokenException
-
engineSetParameter
public void engineSetParameter(java.security.spec.AlgorithmParameterSpec params) throws java.security.InvalidAlgorithmParameterException, TokenException
- Specified by:
engineSetParameter
in classSignatureSpi
- Throws:
java.security.InvalidAlgorithmParameterException
TokenException
-
finalize
public void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
close
public void close() throws java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
-