Bouncy Castle Cryptography Library 1.87

org.bouncycastle.jcajce.provider.asymmetric.ec
Class GMCipherSpi

java.lang.Object
  extended byjavax.crypto.CipherSpi
      extended byorg.bouncycastle.jcajce.provider.asymmetric.util.BaseCipherSpi
          extended byorg.bouncycastle.jcajce.provider.asymmetric.ec.GMCipherSpi
Direct Known Subclasses:
GMCipherSpi.SM2, GMCipherSpi.SM2withBlake2b, GMCipherSpi.SM2withBlake2s, GMCipherSpi.SM2withMD5, GMCipherSpi.SM2withRMD, GMCipherSpi.SM2withSha1, GMCipherSpi.SM2withSha224, GMCipherSpi.SM2withSha256, GMCipherSpi.SM2withSha384, GMCipherSpi.SM2withSha512, GMCipherSpi.SM2withWhirlpool

public class GMCipherSpi
extends BaseCipherSpi


Nested Class Summary
protected static class GMCipherSpi.ErasableOutputStream
          A ByteArrayOutputStream whose contents can be zeroed: reset() only rewinds the count and leaves what was written in the backing array, and a growth, left to ByteArrayOutputStream, drops the array it replaces as it stands.
static class GMCipherSpi.SM2
          Classes that inherit from us
static class GMCipherSpi.SM2withBlake2b
           
static class GMCipherSpi.SM2withBlake2s
           
static class GMCipherSpi.SM2withMD5
           
static class GMCipherSpi.SM2withRMD
           
static class GMCipherSpi.SM2withSha1
           
static class GMCipherSpi.SM2withSha224
           
static class GMCipherSpi.SM2withSha256
           
static class GMCipherSpi.SM2withSha384
           
static class GMCipherSpi.SM2withSha512
           
static class GMCipherSpi.SM2withWhirlpool
           
 
Field Summary
 
Fields inherited from class org.bouncycastle.jcajce.provider.asymmetric.util.BaseCipherSpi
engineParams, wrapEngine
 
Constructor Summary
GMCipherSpi(Digest digest)
           
 
Method Summary
 byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
           
 int engineDoFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)
           
 int engineGetBlockSize()
           
 byte[] engineGetIV()
           
 int engineGetKeySize(java.security.Key key)
          The field size of the key's curve, for any EC key init accepts - not just a BC one - so the key is converted the same way init converts it.
 int engineGetOutputSize(int inputLen)
          The size of the next doFinal's output, which takes the input update() has buffered as well as inputLen more.
 java.security.AlgorithmParameters engineGetParameters()
           
 void engineInit(int opmode, java.security.Key key, java.security.spec.AlgorithmParameterSpec engineSpec, java.security.SecureRandom random)
           
 void engineInit(int opmode, java.security.Key key, java.security.AlgorithmParameters params, java.security.SecureRandom random)
           
 void engineInit(int opmode, java.security.Key key, java.security.SecureRandom random)
           
 void engineSetMode(java.lang.String mode)
           
 void engineSetPadding(java.lang.String padding)
           
 byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
           
 int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
           
 
Methods inherited from class org.bouncycastle.jcajce.provider.asymmetric.util.BaseCipherSpi
createParametersInstance, engineUnwrap, engineWrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GMCipherSpi

public GMCipherSpi(Digest digest)
Method Detail

engineGetBlockSize

public int engineGetBlockSize()
Overrides:
engineGetBlockSize in class BaseCipherSpi

engineGetKeySize

public int engineGetKeySize(java.security.Key key)
The field size of the key's curve, for any EC key init accepts - not just a BC one - so the key is converted the same way init converts it. Cipher asks for the size before init sees the key, so a key that is not an EC key is answered as BaseCipherSpi answers it, and left for init to refuse with the InvalidKeyException it declares.

Overrides:
engineGetKeySize in class BaseCipherSpi

engineGetIV

public byte[] engineGetIV()
Overrides:
engineGetIV in class BaseCipherSpi

engineGetParameters

public java.security.AlgorithmParameters engineGetParameters()
Overrides:
engineGetParameters in class BaseCipherSpi

engineSetMode

public void engineSetMode(java.lang.String mode)
                   throws java.security.NoSuchAlgorithmException
Overrides:
engineSetMode in class BaseCipherSpi
Throws:
java.security.NoSuchAlgorithmException

engineGetOutputSize

public int engineGetOutputSize(int inputLen)
The size of the next doFinal's output, which takes the input update() has buffered as well as inputLen more. C2 is as long as the message and C1 and C3 are of fixed size, so the answer is exact: encryption adds that overhead and decryption removes it. The sum is taken in long and capped at the largest array.

Overrides:
engineGetOutputSize in class BaseCipherSpi

engineSetPadding

public void engineSetPadding(java.lang.String padding)
                      throws javax.crypto.NoSuchPaddingException
Overrides:
engineSetPadding in class BaseCipherSpi
Throws:
javax.crypto.NoSuchPaddingException

engineInit

public void engineInit(int opmode,
                       java.security.Key key,
                       java.security.AlgorithmParameters params,
                       java.security.SecureRandom random)
                throws java.security.InvalidKeyException,
                       java.security.InvalidAlgorithmParameterException
Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException

engineInit

public void engineInit(int opmode,
                       java.security.Key key,
                       java.security.spec.AlgorithmParameterSpec engineSpec,
                       java.security.SecureRandom random)
                throws java.security.InvalidAlgorithmParameterException,
                       java.security.InvalidKeyException
Throws:
java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException

engineInit

public void engineInit(int opmode,
                       java.security.Key key,
                       java.security.SecureRandom random)
                throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

engineUpdate

public byte[] engineUpdate(byte[] input,
                           int inputOffset,
                           int inputLen)

engineUpdate

public int engineUpdate(byte[] input,
                        int inputOffset,
                        int inputLen,
                        byte[] output,
                        int outputOffset)

engineDoFinal

public byte[] engineDoFinal(byte[] input,
                            int inputOffset,
                            int inputLen)
                     throws javax.crypto.IllegalBlockSizeException,
                            javax.crypto.BadPaddingException
Throws:
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException

engineDoFinal

public int engineDoFinal(byte[] input,
                         int inputOffset,
                         int inputLength,
                         byte[] output,
                         int outputOffset)
                  throws javax.crypto.ShortBufferException,
                         javax.crypto.IllegalBlockSizeException,
                         javax.crypto.BadPaddingException
Throws:
javax.crypto.ShortBufferException
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException

Bouncy Castle Cryptography Library 1.87