Class SM4Engine
- Namespace
- Org.BouncyCastle.Crypto.Engines
- Assembly
- BouncyCastle.Cryptography.dll
SM4 Block Cipher - SM4 is a 128 bit block cipher with a 128 bit key.
public class SM4Engine : IBlockCipher
- Inheritance
-
SM4Engine
- Implements
- Inherited Members
Remarks
The implementation here is based on the document http://eprint.iacr.org/2008/329.pdf by Whitfield Diffie and George Ledin, which is a translation of Prof. LU Shu-wang's original standard.
Properties
AlgorithmName
The name of the algorithm this cipher implements.
public virtual string AlgorithmName { get; }
Property Value
Methods
GetBlockSize()
public virtual int GetBlockSize()
Returns
- int
The block size for this cipher, in bytes.
Init(bool, ICipherParameters)
Initialise the cipher.
public virtual void Init(bool forEncryption, ICipherParameters parameters)
Parameters
forEncryptionboolInitialise for encryption if true, for decryption if false.
parametersICipherParametersThe key or other data required by the cipher.
ProcessBlock(byte[], int, byte[], int)
Process a block.
public virtual int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
Parameters
inputbyte[]inOffintThe offset into that the input block begins.
outputbyte[]outOffintThe offset into to write the output block.
Returns
- int
The number of bytes processed and produced.
Exceptions
- DataLengthException
If input block is wrong size, or outBuf too small.
ProcessBlock(ReadOnlySpan<byte>, Span<byte>)
Process a block.
public virtual int ProcessBlock(ReadOnlySpan<byte> input, Span<byte> output)
Parameters
inputReadOnlySpan<byte>The input block as a span.
outputSpan<byte>The output span.
Returns
- int
The number of bytes processed and produced.
Exceptions
- DataLengthException
If input block is wrong size, or output span too small.