Class SM9Engine.Mode

java.lang.Object
org.bouncycastle.crypto.engines.SM9Engine.Mode
Enclosing class:
SM9Engine

public static final class SM9Engine.Mode extends Object
The GM/T 0044.4-2016 data-encapsulation method. (A constants class rather than an enum so the single source also compiles for the legacy pre-Java-5 distributions.)
  • Field Details

    • STREAM

      public static final SM9Engine.Mode STREAM
      KDF-based stream cipher (XOR) encapsulation (method a).
    • SM4

      public static final SM9Engine.Mode SM4
      SM4/ECB/PKCS#7 block cipher encapsulation (method b), with no IV.

      The three texts of the standard do not agree on what this method puts on the wire, and the choice here is the one the Chinese edition's own worked example makes. GM/T 0044.4-2016 (Chinese) says only C2 = Enc(K1, M), naming no mode, IV or padding, and its companion example, GM/T 0044.5-2016 Annex D.1, is SM4-ECB with PKCS#5 padding and no IV. The official English translation adds a zero IV that is not transmitted and PKCS#7 padding, and its Annex D.1 example is SM4-CBC. GB/T 38635.2-2020 9.2 places a 16-byte IV at the front of C2 and allows any GB/T 17964 mode, and its example is CBC with a zero IV.

      A peer built from the English edition or from GB/T 38635.2 therefore does not interoperate with this mode. Agree the edition out of band.