Bouncy Castle Cryptography Library 1.86

org.bouncycastle.asn1.gm
Class SM9Cipher

java.lang.Object
  extended byorg.bouncycastle.asn1.ASN1Object
      extended byorg.bouncycastle.asn1.gm.SM9Cipher
All Implemented Interfaces:
ASN1Encodable, Encodable

public class SM9Cipher
extends ASN1Object

The SM9 public-key encryption ciphertext structure of GM/T 0080-2020 (the C1/C2/C3 values are defined by the encryption algorithm in GM/T 0044.4). SM9Cipher ::= SEQUENCE { enType INTEGER, -- data-encapsulation type (see below) C1 BIT STRING, -- the point C1 = [r]Q_B of G1, uncompressed (0x04||x||y) C3 OCTET STRING, -- the MAC value C3 (32 bytes) C2 OCTET STRING -- the encapsulated message C2 } The field order and types (enType INTEGER, C1 BIT STRING, C3/C2 OCTET STRING) have been cross-checked against the GmSSL and gmsm (emmansun) reference implementations of GM/T 0080-2020. The GM/T 0080-2020 data-encapsulation type values are 0 = KDF stream cipher (XOR), 1 = SM4-ECB, 2 = SM4-CBC, 4 = SM4-OFB, 8 = SM4-CFB; BouncyCastle implements the stream (EN_TYPE_STREAM) and SM4-ECB (EN_TYPE_SM4) modes and rejects the others as unsupported.


Field Summary
static int EN_TYPE_SM4
          GM/T 0080-2020 data-encapsulation type 1: SM4 in ECB mode.
static int EN_TYPE_STREAM
          GM/T 0080-2020 data-encapsulation type 0: the KDF-based stream cipher (XOR).
 
Constructor Summary
SM9Cipher(int enType, byte[] c1, byte[] c3, byte[] c2)
           
 
Method Summary
 byte[] getC1()
           
 byte[] getC2()
           
 byte[] getC3()
           
 int getEnType()
           
static SM9Cipher getInstance(java.lang.Object o)
           
 ASN1Primitive toASN1Primitive()
          Method providing a primitive representation of this object suitable for encoding.
 
Methods inherited from class org.bouncycastle.asn1.ASN1Object
encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EN_TYPE_STREAM

public static final int EN_TYPE_STREAM
GM/T 0080-2020 data-encapsulation type 0: the KDF-based stream cipher (XOR).

See Also:
Constant Field Values

EN_TYPE_SM4

public static final int EN_TYPE_SM4
GM/T 0080-2020 data-encapsulation type 1: SM4 in ECB mode.

See Also:
Constant Field Values
Constructor Detail

SM9Cipher

public SM9Cipher(int enType,
                 byte[] c1,
                 byte[] c3,
                 byte[] c2)
Method Detail

getInstance

public static SM9Cipher getInstance(java.lang.Object o)

getEnType

public int getEnType()

getC1

public byte[] getC1()

getC3

public byte[] getC3()

getC2

public byte[] getC2()

toASN1Primitive

public ASN1Primitive toASN1Primitive()
Description copied from class: ASN1Object
Method providing a primitive representation of this object suitable for encoding.

Specified by:
toASN1Primitive in interface ASN1Encodable
Specified by:
toASN1Primitive in class ASN1Object
Returns:
a primitive representation of this object.

Bouncy Castle Cryptography Library 1.86