Skip to content

sm2

SM2 elliptic curve cryptography functions (Chinese National Standard GB/T 32918)

sm2 · SM2 elliptic curve cryptography functions (Chinese National Standard GB/T 32918)

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101774sm2sm21.0SECUnknownC

Usage

Sources:

sm2 — SM2 elliptic curve cryptography functions (Chinese National Standard GB/T 32918). Use it when implementing the corresponding security, audit, or access-control workflow. Use the pinned upstream revision linked above as the API boundary and test it on the target PostgreSQL build.

Core Workflow

CREATE EXTENSION sm2;

Install the extension in the intended database, run the smallest upstream example above when available, and verify the installed version and returned values before integrating it into application SQL.

Important Objects

  • sm2_c_decrypt(ciphertext bytea, private_key text) is an extension function and returns text.
  • sm2_c_decrypt_base64(ciphertext_base64 text, private_key text) is an extension function and returns text.
  • sm2_c_decrypt_hex(ciphertext_hex text, private_key text) is an extension function and returns text.
  • sm2_c_encrypt(plaintext text, public_key text) is an extension function and returns bytea.
  • sm2_c_encrypt_base64(plaintext text, public_key text) is an extension function and returns text.
  • sm2_c_encrypt_hex(plaintext text, public_key text) is an extension function and returns text.
  • sm2_c_generate_key() is an extension function and returns text[].
  • sm2_c_get_pubkey(private_key text) is an extension function and returns text.
  • sm2_c_sign(message text, private_key text, id text DEFAULT NULL) is an extension function and returns bytea.
  • sm2_c_sign_hex(message text, private_key text, id text DEFAULT NULL) is an extension function and returns text.
  • sm2_c_verify(message text, public_key text, signature bytea, id text DEFAULT NULL) is an extension function and returns boolean.
  • sm2_c_verify_hex(message text, public_key text, signature_hex text, id text DEFAULT NULL) is an extension function and returns boolean.

Requirements and Caveats

  • The reviewed control file declares default version 1.0.
  • The control file marks the extension as relocatable.
  • Confirm privileges, supported PostgreSQL versions, upgrade behavior, and failure cases against the pinned source before production use.

Table reader