@@ -30,23 +30,23 @@ gmssl sm4 -gcm -decrypt -key 11223344556677881122334455667788 -iv 11223344556677
30
30
31
31
# CBC-SM3-HMAC
32
32
echo hello | gmssl sm4 -cbc_sm3_hmac -encrypt \
33
- -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
34
- -iv 11223344556677881122334455667788 -out ciphertext.bin
33
+ -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
34
+ -iv 11223344556677881122334455667788 -out ciphertext.bin
35
35
gmssl sm4 -cbc_sm3_hmac -decrypt \
36
- -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
37
- -iv 11223344556677881122334455667788 -in ciphertext.bin
36
+ -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
37
+ -iv 11223344556677881122334455667788 -in ciphertext.bin
38
38
39
39
# CTR-SM3-HMAC
40
40
echo hello | gmssl sm4 -ctr_sm3_hmac -encrypt \
41
- -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
42
- -iv 11223344556677881122334455667788 -out ciphertext.bin
41
+ -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
42
+ -iv 11223344556677881122334455667788 -out ciphertext.bin
43
43
gmssl sm4 -ctr_sm3_hmac -decrypt \
44
- -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
45
- -iv 11223344556677881122334455667788 -in ciphertext.bin
44
+ -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
45
+ -iv 11223344556677881122334455667788 -in ciphertext.bin
46
46
47
47
# encrypt/decrypt long text file
48
48
49
- cat << EOF > plaintext.txt
49
+ cat << EOF >plaintext.txt
50
50
-----BEGIN CERTIFICATE-----
51
51
MIICzzCCAnKgAwIBAgIFEzY5M3AwDAYIKoEcz1UBg3UFADAlMQswCQYDVQQGEwJD
52
52
TjEWMBQGA1UECgwNQ0ZDQSBTTTIgT0NBMTAeFw0yMTA2MTEwOTA1MjBaFw0yNjA2
67
67
-----END CERTIFICATE-----
68
68
EOF
69
69
70
-
71
70
# CBC
72
71
gmssl sm4 -cbc -encrypt -key 11223344556677881122334455667788 -iv 11223344556677881122334455667788 -in plaintext.txt -out ciphertext.bin
73
72
gmssl sm4 -cbc -decrypt -key 11223344556677881122334455667788 -iv 11223344556677881122334455667788 -in ciphertext.bin
@@ -94,22 +93,19 @@ gmssl sm4 -gcm -decrypt -key 11223344556677881122334455667788 -iv 11223344556677
94
93
95
94
# CBC-SM3-HMAC
96
95
gmssl sm4 -cbc_sm3_hmac -encrypt \
97
- -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
98
- -iv 11223344556677881122334455667788 -in plaintext.txt -out ciphertext.bin
96
+ -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
97
+ -iv 11223344556677881122334455667788 -in plaintext.txt -out ciphertext.bin
99
98
gmssl sm4 -cbc_sm3_hmac -decrypt \
100
- -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
101
- -iv 11223344556677881122334455667788 -in ciphertext.bin
99
+ -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
100
+ -iv 11223344556677881122334455667788 -in ciphertext.bin
102
101
103
102
# CTR-SM3-HMAC
104
103
gmssl sm4 -ctr_sm3_hmac -encrypt \
105
- -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
106
- -iv 11223344556677881122334455667788 -in plaintext.txt -out ciphertext.bin
104
+ -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
105
+ -iv 11223344556677881122334455667788 -in plaintext.txt -out ciphertext.bin
107
106
gmssl sm4 -ctr_sm3_hmac -decrypt \
108
- -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
109
- -iv 11223344556677881122334455667788 -in ciphertext.bin
110
-
107
+ -key 112233445566778811223344556677881122334455667788112233445566778811223344556677881122334455667788 \
108
+ -iv 11223344556677881122334455667788 -in ciphertext.bin
111
109
112
110
rm -fr plaintext.txt
113
111
rm -fr ciphertext.bin
114
-
115
-
0 commit comments