Bouncy Castle Cryptography Library 1.87

org.bouncycastle.jcajce.provider.asymmetric.util
Class BaseDeterministicOrRandomSignature

java.lang.Object
  extended byjava.security.SignatureSpi
      extended byorg.bouncycastle.jcajce.provider.asymmetric.util.BaseDeterministicOrRandomSignature
Direct Known Subclasses:
HashSignatureSpi, HashSignatureSpi, SignatureSpi, SignatureSpi

public abstract class BaseDeterministicOrRandomSignature
extends java.security.SignatureSpi

Base class for the ML-DSA and SLH-DSA signature services. An with no SecureRandom signs in the deterministic form of FIPS 204 / FIPS 205; an signs in the "hedged" form, drawing the per-signature randomness from the SecureRandom given. FIPS 204 sec. 3.4 and FIPS 205 sec. 9.2 make the hedged form the default and note that it is the one to use where side-channel and fault attacks are a concern, so pass a SecureRandom unless a deterministic signature is specifically wanted.


Field Summary
protected  java.security.AlgorithmParameters engineParams
           
protected  boolean isInitState
           
protected  AsymmetricKeyParameter keyParams
           
protected  ContextParameterSpec paramSpec
           
 
Fields inherited from class java.security.SignatureSpi
appRandom
 
Constructor Summary
protected BaseDeterministicOrRandomSignature(java.lang.String name)
           
 
Method Summary
protected  java.lang.Object engineGetParameter(java.lang.String param)
          Deprecated. replaced with engineGetParameters()
protected  java.security.AlgorithmParameters engineGetParameters()
           
protected  void engineInitSign(java.security.PrivateKey privateKey)
           
protected  void engineInitSign(java.security.PrivateKey privateKey, java.security.SecureRandom random)
           
protected  void engineInitVerify(java.security.PublicKey publicKey)
           
protected  void engineSetParameter(java.security.spec.AlgorithmParameterSpec params)
          Set the signature context, either before or after engineInitSign / engineInitVerify.
protected  void engineSetParameter(java.lang.String param, java.lang.Object value)
          Deprecated. replaced with engineSetParameter(java.security.spec.AlgorithmParameterSpec)
protected  void engineUpdate(byte b)
           
protected  void engineUpdate(byte[] b, int off, int len)
           
protected abstract  void reInitialize(boolean forSigning, CipherParameters params)
           
protected abstract  void signInit(java.security.PrivateKey privateKey, java.security.SecureRandom random)
           
protected abstract  void updateEngine(byte b)
           
protected abstract  void updateEngine(byte[] buf, int off, int len)
           
protected abstract  void verifyInit(java.security.PublicKey publicKey)
           
 
Methods inherited from class java.security.SignatureSpi
clone, engineSign, engineSign, engineVerify, engineVerify
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

engineParams

protected java.security.AlgorithmParameters engineParams

paramSpec

protected ContextParameterSpec paramSpec

keyParams

protected AsymmetricKeyParameter keyParams

isInitState

protected boolean isInitState
Constructor Detail

BaseDeterministicOrRandomSignature

protected BaseDeterministicOrRandomSignature(java.lang.String name)
Method Detail

engineInitVerify

protected final void engineInitVerify(java.security.PublicKey publicKey)
                               throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

verifyInit

protected abstract void verifyInit(java.security.PublicKey publicKey)
                            throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

engineInitSign

protected final void engineInitSign(java.security.PrivateKey privateKey)
                             throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

engineInitSign

protected final void engineInitSign(java.security.PrivateKey privateKey,
                                    java.security.SecureRandom random)
                             throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

signInit

protected abstract void signInit(java.security.PrivateKey privateKey,
                                 java.security.SecureRandom random)
                          throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

engineUpdate

protected final void engineUpdate(byte b)
                           throws java.security.SignatureException
Throws:
java.security.SignatureException

updateEngine

protected abstract void updateEngine(byte b)
                              throws java.security.SignatureException
Throws:
java.security.SignatureException

engineUpdate

protected final void engineUpdate(byte[] b,
                                  int off,
                                  int len)
                           throws java.security.SignatureException
Throws:
java.security.SignatureException

updateEngine

protected abstract void updateEngine(byte[] buf,
                                     int off,
                                     int len)
                              throws java.security.SignatureException
Throws:
java.security.SignatureException

engineSetParameter

protected void engineSetParameter(java.security.spec.AlgorithmParameterSpec params)
                           throws java.security.InvalidAlgorithmParameterException
Set the signature context, either before or after engineInitSign / engineInitVerify.

Where the signature has a key already the underlying signer is re-initialised with the new context at once; where it does not the context is recorded and applied when the key arrives, as the RSASSA-PSS implementation does with its own parameters. Calling this first used to let a NullPointerException out of a method declared to throw InvalidAlgorithmParameterException, from dereferencing the key that was not there yet (see github #2396).

Throws:
java.security.InvalidAlgorithmParameterException

reInitialize

protected abstract void reInitialize(boolean forSigning,
                                     CipherParameters params)

engineGetParameters

protected final java.security.AlgorithmParameters engineGetParameters()

engineSetParameter

protected final void engineSetParameter(java.lang.String param,
                                        java.lang.Object value)
Deprecated. replaced with engineSetParameter(java.security.spec.AlgorithmParameterSpec)


engineGetParameter

protected final java.lang.Object engineGetParameter(java.lang.String param)
Deprecated. replaced with engineGetParameters()


Bouncy Castle Cryptography Library 1.87