gmssl Command Examples

GmSSL is a cryptographic toolkit that provides support for various cryptographic algorithms and protocols. It is designed to meet the cryptographic standards established by China, known as the SM (Chinese National Cryptographic Standards) series. The toolkit includes implementations for several algorithms, such as SM1, SM2, SM3, SM4, SM9, and ZUC/ZUC256.

Here’s a brief overview of the mentioned algorithms:

  • SM1: A symmetric key block cipher used for encryption and decryption.
  • SM2: A public key cryptography algorithm, including both key exchange and digital signature schemes.
  • SM3: A hash function designed for generating fixed-size hash values from variable-sized messages.
  • SM4: A symmetric key block cipher similar to the Advanced Encryption Standard (AES), widely used for encryption and decryption.
  • SM9: A pair of cryptographic algorithms for identity-based encryption and digital signature.
  • ZUC/ZUC256: A stream cipher and hash function designed for use in mobile communications, particularly in 3G and 4G networks.

gmssl Command Examples

1. Generate an SM3 hash for a file:

# gmssl sm3 /path/to/file

2. Encrypt a file using the SM4 cipher:

# gmssl sms4 -e -in /path/to/file -out path/to/file.sms4

3. Decrypt a file using the SM4 cipher:

# gmssl sms4 -d -in /path/to/file.sms4

4. Generate an SM2 private key:

# gmssl sm2 -genkey -out /path/to/file.pem

5. Generate an SM2 public key from an existing private key:

# gmssl sm2 -pubout -in /path/to/file.pem -out /path/to/file.pem.pub

6. Encrypt a file using the ZUC cipher:

# gmssl zuc -e -in path/to/file -out /path/to/file.zuc

7. Decrypt a file using the ZUC cipher:

# gmssl zuc -d -in /path/to/file.zuc

8. Print version:

# gmssl version
Related Post