Class SM2Sm4HybridPayload

java.lang.Object
cn.gmkit.integration.SM2Sm4HybridPayload

public final class SM2Sm4HybridPayload extends Object
SM2 + SM4 混合加密载荷。

统一承载会话密钥密文、业务密文以及 IV、AAD、tag、模式和填充等元数据, 并对所有字节数组执行防御性复制。该类型不定义 JSON、CBOR 或二进制序列化格式; 跨进程使用时必须由调用方固定 schema 版本、字段编码和密钥标识。

  • Constructor Details

    • SM2Sm4HybridPayload

      public SM2Sm4HybridPayload(byte[] encryptedKey, byte[] ciphertext, byte[] iv, byte[] aad, byte[] tag, SM4CipherMode mode, SM4Padding padding)
      创建一个混合加密载荷。
      Parameters:
      encryptedKey - SM2 保护后的 SM4 会话密钥
      ciphertext - SM4 业务密文
      iv - IV 或 nonce;某些模式下可以为 null
      aad - AEAD 附加认证数据;无附加数据时可为 null
      tag - AEAD 认证标签;非 AEAD 模式下可为 null
      mode - SM4 工作模式
      padding - SM4 填充模式
  • Method Details

    • encryptedKey

      public byte[] encryptedKey()
      返回 SM2 保护后的会话密钥。
      Returns:
      会话密钥密文副本
    • encryptedKeyHex

      public String encryptedKeyHex()
      返回十六进制形式的会话密钥密文。
      Returns:
      十六进制会话密钥密文
    • encryptedKeyBase64

      public String encryptedKeyBase64()
      返回 Base64 形式的会话密钥密文。
      Returns:
      Base64 会话密钥密文
    • ciphertext

      public byte[] ciphertext()
      返回业务密文。
      Returns:
      业务密文副本
    • ciphertextHex

      public String ciphertextHex()
      返回十六进制形式的业务密文。
      Returns:
      十六进制业务密文
    • ciphertextBase64

      public String ciphertextBase64()
      返回 Base64 形式的业务密文。
      Returns:
      Base64 业务密文
    • iv

      public byte[] iv()
      返回 IV 或 nonce。
      Returns:
      IV 或 nonce 的副本;不存在时返回 null
    • hasIv

      public boolean hasIv()
      是否包含 IV 或 nonce。
      Returns:
      包含时返回 true
    • ivHex

      public String ivHex()
      返回十六进制形式的 IV 或 nonce。
      Returns:
      十六进制 IV 或 nonce;不存在时返回 null
    • aad

      public byte[] aad()
      返回 AEAD 附加认证数据。
      Returns:
      AAD 副本;不存在时返回 null
    • hasAad

      public boolean hasAad()
      是否包含附加认证数据。
      Returns:
      包含时返回 true
    • tag

      public byte[] tag()
      返回 AEAD 认证标签。
      Returns:
      tag 副本;不存在时返回 null
    • hasTag

      public boolean hasTag()
      是否包含 AEAD 认证标签。
      Returns:
      包含时返回 true
    • tagHex

      public String tagHex()
      返回十六进制形式的认证标签。
      Returns:
      十六进制 tag;不存在时返回 null
    • tagBase64

      public String tagBase64()
      返回 Base64 形式的认证标签。
      Returns:
      Base64 tag;不存在时返回 null
    • mode

      public SM4CipherMode mode()
      返回 SM4 工作模式。
      Returns:
      工作模式
    • padding

      public SM4Padding padding()
      返回 SM4 填充模式。
      Returns:
      填充模式