|
Bouncy Castle Cryptography Library 1.87 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.bouncycastle.asn1.ASN1Object
org.bouncycastle.asn1.gm.SM9Cipher
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, and this type represents every one of them, so that a conformant ciphertext
of any mode can be parsed and inspected. Which modes are implemented is a separate
question, answered one layer up: decrypts in the stream
(EN_TYPE_STREAM) and SM4-ECB (EN_TYPE_SM4) modes and refuses a ciphertext
whose enType is not the one it was configured for. The value is never taken as the mode to
decrypt in.
C1 and C3 have a fixed size, 65 and 32 bytes, and both constructors hold them to it; C2 is as long as the encapsulated message makes it.
| Field Summary | |
static int |
EN_TYPE_SM4
GM/T 0080-2020 data-encapsulation type 1: SM4 in ECB mode. |
static int |
EN_TYPE_SM4_CBC
GM/T 0080-2020 data-encapsulation type 2: SM4 in CBC mode (not implemented by Cipher.SM9). |
static int |
EN_TYPE_SM4_CFB
GM/T 0080-2020 data-encapsulation type 8: SM4 in CFB mode (not implemented by Cipher.SM9). |
static int |
EN_TYPE_SM4_OFB
GM/T 0080-2020 data-encapsulation type 4: SM4 in OFB mode (not implemented by Cipher.SM9). |
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 |
public static final int EN_TYPE_STREAM
public static final int EN_TYPE_SM4
public static final int EN_TYPE_SM4_CBC
public static final int EN_TYPE_SM4_OFB
public static final int EN_TYPE_SM4_CFB
| Constructor Detail |
public SM9Cipher(int enType,
byte[] c1,
byte[] c3,
byte[] c2)
| Method Detail |
public static SM9Cipher getInstance(java.lang.Object o)
public int getEnType()
public byte[] getC1()
public byte[] getC3()
public byte[] getC2()
public ASN1Primitive toASN1Primitive()
ASN1Object
toASN1Primitive in interface ASN1EncodabletoASN1Primitive in class ASN1Object
|
Bouncy Castle Cryptography Library 1.87 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||