Class 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 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()