Top Description Fields Constructors Methods
org.bouncycastle.crypto.digests

public Class SM3Digest

extends GeneralDigest
Class Inheritance
Imports
org.bouncycastle.crypto.CryptoServiceProperties, .CryptoServicePurpose, .CryptoServicesRegistrar, org.bouncycastle.util.Memoable, .Pack

Implementation of Chinese SM3 digest as described at https://tools.ietf.org/html/draft-shen-sm3-hash-01 and at .... ( Chinese PDF )

The specification says "process a bit stream", but this is written to process bytes in blocks of 4, meaning this will process 32-bit word groups. But so do also most other digest specifications, including the SHA-256 which was a origin for this specification.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private int[]
private static final int[]
T

private int[]
V

private int[]
W

private int
Inherited from org.bouncycastle.crypto.digests.GeneralDigest:
purpose

Constructor Summary

AccessConstructor and Description
public
SM3Digest()

Standard constructor

public
SM3Digest(CryptoServicePurpose purpose)

Standard constructor, with Purpose

public
SM3Digest(SM3Digest t)

Copy constructor.

Method Summary

Modifier and TypeMethod and Description
public Memoable
copy()

Implements org.bouncycastle.util.Memoable.copy.

Produce a copy of this object with its configuration and in its current state.
private void
protected CryptoServiceProperties
public int
doFinal(byte[]
the array the digest is to be copied into.
out
,
int
the offset into the out array the digest is to start at.
outOff
)

Implements org.bouncycastle.crypto.Digest.doFinal.

close the digest, producing the final digest value.
private int
FF0(final int x, final int y, final int z)

private int
FF1(final int x, final int y, final int z)

public String
public int
getDigestSize()

Implements org.bouncycastle.crypto.Digest.getDigestSize.

return the size, in bytes, of the digest produced by this message digest.
private int
GG0(final int x, final int y, final int z)

private int
GG1(final int x, final int y, final int z)

private int
P0(final int x)

private int
P1(final int x)

protected void
protected void
protected void
public void
reset(Memoable
an object originally copied from an object of the same type as this instance.
other
)

Implements org.bouncycastle.util.Memoable.reset.

Restore a copied object state into this object.
public void
Inherited from org.bouncycastle.crypto.digests.GeneralDigest:
copyInfinishgetByteLengthpopulateStateupdateupdate

Field Detail

BLOCK_SIZEback to summary
private static final int BLOCK_SIZE
DIGEST_LENGTHback to summary
private static final int DIGEST_LENGTH
inwordsback to summary
private int[] inwords
Tback to summary
private static final int[] T
Vback to summary
private int[] V
Wback to summary
private int[] W
xOffback to summary
private int xOff

Constructor Detail

SM3Digestback to summary
public SM3Digest()

Standard constructor

SM3Digestback to summary
public SM3Digest(CryptoServicePurpose purpose)

Standard constructor, with Purpose

SM3Digestback to summary
public SM3Digest(SM3Digest t)

Copy constructor. This will copy the state of the provided message digest.

Method Detail

copyback to summary
public Memoable copy()

Implements org.bouncycastle.util.Memoable.copy.

Doc from org.bouncycastle.util.Memoable.copy.

Produce a copy of this object with its configuration and in its current state.

The returned object may be used simply to store the state, or may be used as a similar object starting from the copied state.

copyInback to summary
private void copyIn(SM3Digest t)
cryptoServicePropertiesback to summary
protected CryptoServiceProperties cryptoServiceProperties()

Implements abstract org.bouncycastle.crypto.digests.GeneralDigest.cryptoServiceProperties.

doFinalback to summary
public int doFinal(byte[] out, int outOff)

Implements org.bouncycastle.crypto.Digest.doFinal.

Doc from org.bouncycastle.crypto.Digest.doFinal.

close the digest, producing the final digest value. The doFinal call leaves the digest reset.

Parameters
out:byte[]

the array the digest is to be copied into.

outOff:int

the offset into the out array the digest is to start at.

FF0back to summary
private int FF0(final int x, final int y, final int z)
FF1back to summary
private int FF1(final int x, final int y, final int z)
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.Digest.getAlgorithmName.

Doc from org.bouncycastle.crypto.Digest.getAlgorithmName.

return the algorithm name

Returns:String

the algorithm name

getDigestSizeback to summary
public int getDigestSize()

Implements org.bouncycastle.crypto.Digest.getDigestSize.

Doc from org.bouncycastle.crypto.Digest.getDigestSize.

return the size, in bytes, of the digest produced by this message digest.

Returns:int

the size, in bytes, of the digest produced by this message digest.

GG0back to summary
private int GG0(final int x, final int y, final int z)
GG1back to summary
private int GG1(final int x, final int y, final int z)
P0back to summary
private int P0(final int x)
P1back to summary
private int P1(final int x)
processBlockback to summary
protected void processBlock()

Implements abstract org.bouncycastle.crypto.digests.GeneralDigest.processBlock.

processLengthback to summary
protected void processLength(long bitLength)

Implements abstract org.bouncycastle.crypto.digests.GeneralDigest.processLength.

processWordback to summary
protected void processWord(byte[] in, int inOff)

Implements abstract org.bouncycastle.crypto.digests.GeneralDigest.processWord.

resetback to summary
public void reset(Memoable other)

Implements org.bouncycastle.util.Memoable.reset.

Doc from org.bouncycastle.util.Memoable.reset.

Restore a copied object state into this object.

Implementations of this method should try to avoid or minimise memory allocation to perform the reset.

Parameters
other:Memoable

an object originally copied from an object of the same type as this instance.

resetback to summary
public void reset()

Overrides org.bouncycastle.crypto.digests.GeneralDigest.reset.

Implements org.bouncycastle.crypto.Digest.reset.

reset the chaining variables