Update QUIC/SM9/ZUC

This commit is contained in:
Zhi Guan
2026-06-24 18:21:27 +08:00
parent e5d318d1a7
commit 09c96fa2e0
21 changed files with 7702 additions and 45 deletions

View File

@@ -24,8 +24,119 @@ gmssl_run(sm9keygen -alg sm9encrypt
-in tool_sm9_enc_msk.pem -inpass ${SM9_PASS}
-id ${SM9_ID}
-out tool_sm9_enc_key.pem -outpass ${SM9_USER_PASS})
gmssl_run(sm9keygen -alg sm9keyagreement
-in tool_sm9_enc_msk.pem -inpass ${SM9_PASS}
-id Bob
-out tool_sm9_bob_exch_key.pem -outpass ${SM9_USER_PASS})
gmssl_run(sm9encrypt -pubmaster tool_sm9_enc_mpk.pem -id ${SM9_ID}
-in tool_sm9_message.txt -out tool_sm9_cipher.der)
gmssl_run(sm9decrypt -key tool_sm9_enc_key.pem -pass ${SM9_USER_PASS} -id ${SM9_ID}
-in tool_sm9_cipher.der -out tool_sm9_plain.txt)
gmssl_expect_file_text(tool_sm9_plain.txt "${SM9_TEXT}")
gmssl_run(sm9keygen -alg sm9keyagreement
-in tool_sm9_enc_msk.pem -inpass ${SM9_PASS}
-id ${SM9_ID}
-out tool_sm9_alice_exch_key.pem -outpass ${SM9_USER_PASS})
gmssl_run(sm9exch -stage init
-pubmaster tool_sm9_enc_mpk.pem -peer_id Bob
-exch_keyout tool_sm9_alice_ra.pem -out tool_sm9_ra.bin)
gmssl_run(sm9exch -stage respond
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_bob_exch_key.pem -pass ${SM9_USER_PASS} -id Bob
-peer_id ${SM9_ID} -in tool_sm9_ra.bin
-exch_keyout tool_sm9_bob_rb.pem -out tool_sm9_rb_sb.bin)
gmssl_run(sm9exch -stage confirm
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_alice_exch_key.pem -pass ${SM9_USER_PASS} -id ${SM9_ID}
-peer_id Bob -exch_key tool_sm9_alice_ra.pem
-in tool_sm9_rb_sb.bin
-keylen 48 -keyout tool_sm9_alice_shared_key.bin
-out tool_sm9_sa.bin)
gmssl_run(sm9exch -stage finish
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_bob_exch_key.pem -pass ${SM9_USER_PASS} -id Bob
-peer_id ${SM9_ID}
-exch_key tool_sm9_bob_rb.pem
-in tool_sm9_sa.bin
-keylen 48 -keyout tool_sm9_bob_shared_key.bin)
gmssl_files_equal(tool_sm9_alice_shared_key.bin tool_sm9_bob_shared_key.bin)
gmssl_run(sm9exch -stage init -bin
-pubmaster tool_sm9_enc_mpk.pem -peer_id Bob
-exch_keyout tool_sm9_bin_alice_ra.pem -out tool_sm9_bin_ra.bin)
gmssl_run(sm9exch -stage respond -bin
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_bob_exch_key.pem -pass ${SM9_USER_PASS} -id Bob
-peer_id ${SM9_ID} -in tool_sm9_bin_ra.bin
-exch_keyout tool_sm9_bin_bob_rb.pem -out tool_sm9_bin_rb_sb.bin)
gmssl_run(sm9exch -stage confirm -bin
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_alice_exch_key.pem -pass ${SM9_USER_PASS} -id ${SM9_ID}
-peer_id Bob -exch_key tool_sm9_bin_alice_ra.pem
-in tool_sm9_bin_rb_sb.bin
-keylen 48 -keyout tool_sm9_bin_alice_shared_key.bin
-out tool_sm9_bin_sa.bin)
gmssl_run(sm9exch -stage finish -bin
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_bob_exch_key.pem -pass ${SM9_USER_PASS} -id Bob
-peer_id ${SM9_ID}
-exch_key tool_sm9_bin_bob_rb.pem
-in tool_sm9_bin_sa.bin
-keylen 48 -keyout tool_sm9_bin_bob_shared_key.bin)
gmssl_files_equal(tool_sm9_bin_alice_shared_key.bin tool_sm9_bin_bob_shared_key.bin)
execute_process(
COMMAND ${GMSSL_BIN} sm9exch -stage init
-pubmaster tool_sm9_enc_mpk.pem -peer_id Bob
-exch_keyout tool_sm9_stdio_alice_ra.pem
OUTPUT_FILE tool_sm9_stdio_ra.hex
RESULT_VARIABLE TEST_RESULT
ERROR_VARIABLE TEST_STDERR
)
if(NOT TEST_RESULT EQUAL 0)
message(FATAL_ERROR "command failed: ${GMSSL_BIN} sm9exch -stage init\nstderr: ${TEST_STDERR}")
endif()
execute_process(
COMMAND ${GMSSL_BIN} sm9exch -stage respond
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_bob_exch_key.pem -pass ${SM9_USER_PASS} -id Bob
-peer_id ${SM9_ID}
-exch_keyout tool_sm9_stdio_bob_rb.pem
INPUT_FILE tool_sm9_stdio_ra.hex
OUTPUT_FILE tool_sm9_stdio_rb_sb.hex
RESULT_VARIABLE TEST_RESULT
ERROR_VARIABLE TEST_STDERR
)
if(NOT TEST_RESULT EQUAL 0)
message(FATAL_ERROR "command failed: ${GMSSL_BIN} sm9exch -stage respond\nstderr: ${TEST_STDERR}")
endif()
execute_process(
COMMAND ${GMSSL_BIN} sm9exch -stage confirm
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_alice_exch_key.pem -pass ${SM9_USER_PASS} -id ${SM9_ID}
-peer_id Bob -exch_key tool_sm9_stdio_alice_ra.pem
-keylen 48 -keyout tool_sm9_stdio_alice_shared_key.hex
INPUT_FILE tool_sm9_stdio_rb_sb.hex
OUTPUT_FILE tool_sm9_stdio_sa.hex
RESULT_VARIABLE TEST_RESULT
ERROR_VARIABLE TEST_STDERR
)
if(NOT TEST_RESULT EQUAL 0)
message(FATAL_ERROR "command failed: ${GMSSL_BIN} sm9exch -stage confirm\nstderr: ${TEST_STDERR}")
endif()
execute_process(
COMMAND ${GMSSL_BIN} sm9exch -stage finish
-pubmaster tool_sm9_enc_mpk.pem
-key tool_sm9_bob_exch_key.pem -pass ${SM9_USER_PASS} -id Bob
-peer_id ${SM9_ID}
-exch_key tool_sm9_stdio_bob_rb.pem
-keylen 48 -keyout tool_sm9_stdio_bob_shared_key.hex
INPUT_FILE tool_sm9_stdio_sa.hex
RESULT_VARIABLE TEST_RESULT
ERROR_VARIABLE TEST_STDERR
)
if(NOT TEST_RESULT EQUAL 0)
message(FATAL_ERROR "command failed: ${GMSSL_BIN} sm9exch -stage finish\nstderr: ${TEST_STDERR}")
endif()
gmssl_files_equal(tool_sm9_stdio_alice_shared_key.hex tool_sm9_stdio_bob_shared_key.hex)