Esempi
Example keys and passwords are public test material.
Decrypt an uppercase SM2 packet with its 04 point prefix
Input
0444BC5E4CD695B677598EC980A487C5E0477B588F4F51DF342BC87263F417F187DABBA20D4B0EC86697BE5E78F2E8A5EB24FAF3B65754D31E57DA67CD471949F68A8AEED211106B755D848F0DF1CA51C06AF306B79F00804F9DA8FA863884B80FD5D7387E6FAFF9AE984529354C9AExpected answer
UTF-8 text · exact bytesAd astra 🚀
Ad astra 🚀
- Chiave privata
84ff61118f97fd94815823a7af50eb4acdfab7ea937c51c529044ff040bf61b6- Formato di input
C1C3C2- Curva
sm2p256v1- Point encoding
Uncompressed (04 prefix)
Recover binary bytes from a C1C2C3 packet
Input
ac8e1a37b16e2b45b8c513d29e22e35525edc4b539ede4766bfd9396a6b80f2b1f0e59902484dc272221890d92e9762bfc24bcd222489984a80160925d7804017331bf925e03e7634fd269387ea2dfc0074898c79c8edbeaad7cf11ede7c2cae808d3ff4e23aExpected answer
Hexadecimal bytes| Offset | Hex bytes | ASCII |
|---|---|---|
| 00000000 | 00 01 02 7f 80 ff | ...... |
00 01 02 7f 80 ff
- Chiave privata
84ff61118f97fd94815823a7af50eb4acdfab7ea937c51c529044ff040bf61b6- Formato di input
C1C2C3- Curva
sm2p256v1- Point encoding
Coordinates only
Reject decryption with a different private scalar
Input
44bc5e4cd695b677598ec980a487c5e0477b588f4f51df342bc87263f417f187dabba20d4b0ec86697be5e78f2e8a5eb24faf3b65754d31e57da67cd471949f68a8aeed211106b755d848f0df1ca51c06af306b79f00804f9da8fa863884b80fd5d7387e6faff9ae984529354c9aExpected rejection
Message containsSM2 integrity check failed- Chiave privata
0000000000000000000000000000000000000000000000000000000000000001- Formato di input
C1C3C2- Curva
sm2p256v1- Point encoding
Coordinates only
Detect a changed encrypted payload byte
Input
44bc5e4cd695b677598ec980a487c5e0477b588f4f51df342bc87263f417f187dabba20d4b0ec86697be5e78f2e8a5eb24faf3b65754d31e57da67cd471949f68a8aeed211106b755d848f0df1ca51c06af306b79f00804f9da8fa863884b80f05d7387e6faff9ae984529354c9aExpected rejection
Message containsSM2 integrity check failed- Chiave privata
84ff61118f97fd94815823a7af50eb4acdfab7ea937c51c529044ff040bf61b6- Formato di input
C1C3C2- Curva
sm2p256v1- Point encoding
Coordinates only
Detect a changed integrity digest
Input
44bc5e4cd695b677598ec980a487c5e0477b588f4f51df342bc87263f417f187dabba20d4b0ec86697be5e78f2e8a5eb24faf3b65754d31e57da67cd471949f60a8aeed211106b755d848f0df1ca51c06af306b79f00804f9da8fa863884b80fd5d7387e6faff9ae984529354c9aExpected rejection
Message containsSM2 integrity check failed- Chiave privata
84ff61118f97fd94815823a7af50eb4acdfab7ea937c51c529044ff040bf61b6- Formato di input
C1C3C2- Curva
sm2p256v1- Point encoding
Coordinates only
Reject a C1 point that is not on the SM2 curve
Input
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a8aeed211106b755d848f0df1ca51c06af306b79f00804f9da8fa863884b80fd5d7387e6faff9ae984529354c9aExpected rejection
Message containsInvalid SM2 C1 point- Chiave privata
84ff61118f97fd94815823a7af50eb4acdfab7ea937c51c529044ff040bf61b6- Formato di input
C1C3C2- Curva
sm2p256v1- Point encoding
Coordinates only
Large Input; Format One
Reproduce this published regression case and compare the exact result. SM2 Decrypt: Large Input; Format One.
Input
d3647d68568a2e7a4f8e843286be7bf2b4d80256697d19a73df306ae1a7e6d0364d942e23d2340606e7a2502a838b132f9242587b2ea7e4c207e87242eea8cae68f5ff4da2a95a7f6d350608ae5b6777e1d925bf9c560087af84aba7befba713130106ddb4082d803811bca3864594722f3198d58257fe4ba37f4aa540adf4cb0568bddd2d8140ad3030deea0a87e3198655cc4d22bfc3d73b1c4afec2ff15d68c8d1298d97132cace922ee8a4e41ca288a7e748b77ca94aa81dc283439923ae7939e00898e16fe5111fbe1d928d152b216aExpected answer
UTF-8 text · exact bytesI am a larger plaintext, that will require the encryption KDF to generate a much larger key to properly encrypt meI am a larger plaintext, that will require the encryption KDF to generate a much larger key to properly encrypt me
- Chiave privata
e74a72505084c3269aa9b696d603e3e08c74c6740212c11a31e26cdfe08bdf6a- Formato di input
C1C3C2- Curva
sm2p256v1- Point encoding
Coordinates only
Large Input; Format Two
Reproduce this published regression case and compare the exact result. SM2 Decrypt: Large Input; Format Two.
Input
0649bac46c3f9fd7fb3b2be4bff27414d634651efd02ca67d8c802bbc5468e77d035c39b581d6b56227f5d87c0b4efbea5032c0761139295ae194b9f1fce698f2f4b51d89fa5554171a1aad2e61fe9de89831aec472ecc5ab178ebf4d2230c1fb94fca03e536b87b9eba6db71ba9939260a08ffd230ca86cb45cf754854222364231bdb8b873791d63ad57a4b3fa5b6375388dc879373f5f1be9051bc5072a8afbec5b7b034e4907aa5bb4b6b1f50e725d09cb6a02e07ce20263005f6c9157ce05d3ea739d231d4f09396fb72aa680884d78Expected answer
UTF-8 text · exact bytesI am a larger plaintext, that will require the encryption KDF to generate a much larger key to properly encrypt meI am a larger plaintext, that will require the encryption KDF to generate a much larger key to properly encrypt me
- Chiave privata
e74a72505084c3269aa9b696d603e3e08c74c6740212c11a31e26cdfe08bdf6a- Formato di input
C1C2C3- Curva
sm2p256v1- Point encoding
Coordinates only
Small Input; Format One
Reproduce this published regression case and compare the exact result. SM2 Decrypt: Small Input; Format One.
Input
9a31bc0adb4677cdc4141479e3949572a55c3e6fb52094721f741c2bd2e179aaa87be6263bc1be602e473be3d5de5dce97f8248948b3a7e15f9f67f64aef21575e0c05e6171870a10ff9ab778dbef24267ad90e1a9d47d68f757d57c4816612e9829f804025dea05a511cda39371c22a2828f976f72eExpected answer
UTF-8 text · exact bytesI am a small plaintextI am a small plaintext
- Chiave privata
e74a72505084c3269aa9b696d603e3e08c74c6740212c11a31e26cdfe08bdf6a- Formato di input
C1C3C2- Curva
sm2p256v1- Point encoding
Coordinates only
Small Input; Format Two
Reproduce this published regression case and compare the exact result. SM2 Decrypt: Small Input; Format Two.
Input
5f340eeb4398fa8950ee3408d0e3fe34bf7728c9fdb060c94b916891b5c693610274160b52a7132a2bf16ad5cdb57d1e00da2f3ddbd55350729aa9c268b53e40c05ccce9912daa14406e8c132e389484e69757350be25351755dcc6c25c94b3c1a448b2cf8c2017582125eb6cf782055b199a875e966Expected answer
UTF-8 text · exact bytesI am a small plaintextI am a small plaintext
- Chiave privata
e74a72505084c3269aa9b696d603e3e08c74c6740212c11a31e26cdfe08bdf6a- Formato di input
C1C2C3- Curva
sm2p256v1- Point encoding
Coordinates only