mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-06 11:53:39 +08:00
Update tools help
This commit is contained in:
@@ -25,6 +25,18 @@ function(gmssl_run_capture out_var)
|
||||
set(${out_var} "${TEST_STDOUT}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(gmssl_expect_fail)
|
||||
execute_process(
|
||||
COMMAND ${GMSSL_BIN} ${ARGN}
|
||||
RESULT_VARIABLE TEST_RESULT
|
||||
ERROR_VARIABLE TEST_STDERR
|
||||
OUTPUT_VARIABLE TEST_STDOUT
|
||||
)
|
||||
if(TEST_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "command unexpectedly succeeded: ${GMSSL_BIN} ${ARGN}\nstderr: ${TEST_STDERR}\nstdout: ${TEST_STDOUT}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(gmssl_expect_stdout expected)
|
||||
gmssl_run_capture(TEST_STDOUT ${ARGN})
|
||||
if(NOT TEST_STDOUT STREQUAL "${expected}")
|
||||
|
||||
@@ -17,11 +17,29 @@ file(WRITE tool_sm4_cbc_kat.plain "0123456789abcdef")
|
||||
gmssl_run(sm4_cbc -encrypt -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
-in tool_sm4_cbc_kat.plain -out tool_sm4_cbc_kat.cipher)
|
||||
gmssl_expect_file_hex(tool_sm4_cbc_kat.cipher
|
||||
"e6887b77dbabb572ffa07fed7548b192ceaace11f2b90b94c2b7a4d9382e471e")
|
||||
"e6887b77dbabb572ffa07fed7548b192")
|
||||
gmssl_run(sm4_cbc -decrypt -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
-in tool_sm4_cbc_kat.cipher -out tool_sm4_cbc_kat.decrypt)
|
||||
gmssl_files_equal(tool_sm4_cbc_kat.plain tool_sm4_cbc_kat.decrypt)
|
||||
|
||||
file(WRITE tool_sm4_cbc_short.plain "abc")
|
||||
gmssl_expect_fail(sm4_cbc -encrypt -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
-in tool_sm4_cbc_short.plain -out tool_sm4_cbc_short.cipher)
|
||||
gmssl_run(sm4_cbc -encrypt -pkcs7_padding -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
-in tool_sm4_cbc_short.plain -out tool_sm4_cbc_short_pkcs7.cipher)
|
||||
gmssl_run(sm4_cbc -decrypt -pkcs7_padding -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
-in tool_sm4_cbc_short_pkcs7.cipher -out tool_sm4_cbc_short_pkcs7.decrypt)
|
||||
gmssl_files_equal(tool_sm4_cbc_short.plain tool_sm4_cbc_short_pkcs7.decrypt)
|
||||
|
||||
file(WRITE tool_sm4_cbc_pkcs7_kat.plain "0123456789abcdef")
|
||||
gmssl_run(sm4_cbc -encrypt -pkcs7_padding -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
-in tool_sm4_cbc_pkcs7_kat.plain -out tool_sm4_cbc_pkcs7_kat.cipher)
|
||||
gmssl_expect_file_hex(tool_sm4_cbc_pkcs7_kat.cipher
|
||||
"e6887b77dbabb572ffa07fed7548b192ceaace11f2b90b94c2b7a4d9382e471e")
|
||||
gmssl_run(sm4_cbc -decrypt -pkcs7_padding -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
-in tool_sm4_cbc_pkcs7_kat.cipher -out tool_sm4_cbc_pkcs7_kat.decrypt)
|
||||
gmssl_files_equal(tool_sm4_cbc_pkcs7_kat.plain tool_sm4_cbc_pkcs7_kat.decrypt)
|
||||
|
||||
file(WRITE tool_sm4_unified_cbc_kat.plain "0123456789abcdef")
|
||||
gmssl_run(sm4 -cbc -encrypt -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
-in tool_sm4_unified_cbc_kat.plain -out tool_sm4_unified_cbc_kat.cipher)
|
||||
@@ -32,6 +50,7 @@ gmssl_run(sm4 -cbc -decrypt -key ${SM4_KEY} -iv ${SM4_IV}
|
||||
gmssl_files_equal(tool_sm4_unified_cbc_kat.plain tool_sm4_unified_cbc_kat.decrypt)
|
||||
|
||||
gmssl_symmetric_roundtrip(tool_sm4_cbc sm4_cbc -key ${SM4_KEY} -iv ${SM4_IV})
|
||||
gmssl_symmetric_roundtrip(tool_sm4_cbc_pkcs7 sm4_cbc -pkcs7_padding -key ${SM4_KEY} -iv ${SM4_IV})
|
||||
gmssl_symmetric_roundtrip(tool_sm4_ctr sm4_ctr -key ${SM4_KEY} -iv ${SM4_IV})
|
||||
gmssl_symmetric_roundtrip(tool_sm4_gcm sm4_gcm -key ${SM4_KEY} -iv 000000000000000000000000 -aad_hex 001122 -taglen 16)
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ gmssl_files_equal(tool_zuc.plain tool_zuc.decrypt)
|
||||
gmssl_run(zuc_128_eea3
|
||||
-key 173d14ba5003731d7a60049470f00a29
|
||||
-count 0x66035492 -bearer 15 -direction 0
|
||||
-in_hex 6cf65340735552ab0c9752fa6f9025fe0bd675d9005875b2
|
||||
-in tool_zuc.plain
|
||||
-out tool_zuc_128_eea3.cipher)
|
||||
gmssl_expect_file_hex(tool_zuc_128_eea3.cipher
|
||||
"a6c85fc66afb8533aafc2518dfe784940ee1e4b030238cc8")
|
||||
gmssl_expect_stdout("390a91b7\n" zuc_128_eia3
|
||||
"fa0f3eb52d9be1af9e521680d313c40c")
|
||||
gmssl_expect_stdout("b0361765\n" zuc_128_eia3
|
||||
-key 00000000000000000000000000000000
|
||||
-count 0 -bearer 0 -direction 0 -in_hex 00)
|
||||
-count 0 -bearer 0 -direction 0 -in tool_zuc.plain)
|
||||
|
||||
gmssl_run(zuc256
|
||||
-key 0000000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
Reference in New Issue
Block a user