Package org.bouncycastle.asn1.gm
Class SM9Cipher
- java.lang.Object
-
- org.bouncycastle.asn1.ASN1Object
-
- org.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
Fields Modifier and Type Field Description static intEN_TYPE_SM4GM/T 0080-2020 data-encapsulation type 1: SM4 in ECB mode.static intEN_TYPE_STREAMGM/T 0080-2020 data-encapsulation type 0: the KDF-based stream cipher (XOR).
-
Constructor Summary
Constructors Constructor Description SM9Cipher(int enType, byte[] c1, byte[] c3, byte[] c2)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getC1()byte[]getC2()byte[]getC3()intgetEnType()static SM9CiphergetInstance(java.lang.Object o)ASN1PrimitivetoASN1Primitive()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
-
-
-
-
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
-
-
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:ASN1ObjectMethod providing a primitive representation of this object suitable for encoding.- Specified by:
toASN1Primitivein interfaceASN1Encodable- Specified by:
toASN1Primitivein classASN1Object- Returns:
- a primitive representation of this object.
-
-