Format help message

This commit is contained in:
Zhi Guan
2026-06-26 22:06:57 +08:00
parent a77feb2b4c
commit 4de29626b7
49 changed files with 153 additions and 149 deletions

View File

@@ -1026,7 +1026,7 @@ endif()
#
set(CPACK_PACKAGE_NAME "GmSSL")
set(CPACK_PACKAGE_VENDOR "GmSSL develop team")
set(CPACK_PACKAGE_VERSION "3.3.0-dev.1174")
set(CPACK_PACKAGE_VERSION "3.3.0-dev.1175")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${PROJECT_SOURCE_DIR}/README.md)
set(CPACK_NSIS_MODIFY_PATH ON)
include(CPack)

View File

@@ -18,7 +18,7 @@ extern "C" {
#define GMSSL_VERSION_NUM 30300
#define GMSSL_VERSION_STR "GmSSL 3.3.0-dev.1174"
#define GMSSL_VERSION_STR "GmSSL 3.3.0-dev.1175"
int gmssl_version_num(void);
const char *gmssl_version_str(void);

View File

@@ -49,6 +49,7 @@ int certparse_main(int argc, char **argv)
if (!strcmp(*argv, "-help")) {
printf("usage: gmssl %s %s\n\n", prog, options);
printf("%s\n", usage);
ret = 0;
goto end;
} else if (!strcmp(*argv, "-in")) {
if (--argc < 1) goto bad;

View File

@@ -76,6 +76,7 @@ int certrevoke_main(int argc, char **argv)
if (!strcmp(*argv, "-help")) {
printf("usage: gmssl %s %s\n\n", prog, options);
printf("%s", usage);
ret = 0;
goto end;
} else if (!strcmp(*argv, "-in")) {
if (--argc < 1) goto bad;

View File

@@ -53,6 +53,7 @@ int crlget_main(int argc, char **argv)
if (!strcmp(*argv, "-help")) {
printf("usage: gmssl %s %s\n\n", prog, usage);
printf("%s\n", options);
ret = 0;
goto end;
} else if (!strcmp(*argv, "-cert")) {
if (--argc < 1) goto bad;
@@ -156,4 +157,3 @@ end:
if (outfile && outfp) fclose(outfp);
return ret;
}

View File

@@ -44,6 +44,7 @@ int crlparse_main(int argc, char **argv)
while (argc > 0) {
if (!strcmp(*argv, "-help")) {
printf("usage: %s %s\n", prog, options);
ret = 0;
goto end;
} else if (!strcmp(*argv, "-in")) {
if (--argc < 1) goto bad;

View File

@@ -35,10 +35,10 @@ static const char *help =
"\n"
"Examples\n"
"\n"
" $ TEXT=`gmssl rand -outlen 20 -hex`\n"
" $ KEY=`gmssl rand -outlen 16 -hex`\n"
" $ AAD=\"The AAD Data\"\n"
" $ gmssl ghash -h $KEY -aad $AAD -in_str $TEXT\n"
" TEXT=`gmssl rand -outlen 20 -hex`\n"
" KEY=`gmssl rand -outlen 16 -hex`\n"
" AAD=\"The AAD Data\"\n"
" gmssl ghash -h $KEY -aad $AAD -in_str $TEXT\n"
"\n";

View File

@@ -29,8 +29,8 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl p256keygen -pass P@ssw0rd -out p256.pem\n"
" $ gmssl p256keygen -pass P@ssw0rd -out p256.pem -pubout p256pub.pem\n"
" gmssl p256keygen -pass P@ssw0rd -out p256.pem\n"
" gmssl p256keygen -pass P@ssw0rd -out p256.pem -pubout p256pub.pem\n"
"\n";
int p256keygen_main(int argc, char **argv)

View File

@@ -35,6 +35,7 @@ int reqparse_main(int argc, char **argv)
while (argc > 0) {
if (!strcmp(*argv, "-help")) {
printf("usage: %s %s\n", prog, options);
ret = 0;
goto end;
} else if(!strcmp(*argv, "-in")) {
if (--argc < 1) goto bad;

View File

@@ -36,9 +36,9 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sdfexport -encrypt -key 1 -lib libsoftsdf.so -out sm2encpub.pem\n"
" $ echo 'Secret message' | gmssl sdfencrypt -lib libsoftsdf.so -pubkey sm2encpub.pem -out sdf_ciphertext.bin\n"
" $ gmssl sdfdecrypt -lib libsoftsdf.so -key 1 -pass P@ssw0rd -in sdf_ciphertext.bin\n"
" gmssl sdfexport -encrypt -key 1 -lib libsoftsdf.so -out sm2encpub.pem\n"
" echo 'Secret message' | gmssl sdfencrypt -lib libsoftsdf.so -pubkey sm2encpub.pem -out sdf_ciphertext.bin\n"
" gmssl sdfdecrypt -lib libsoftsdf.so -key 1 -pass P@ssw0rd -in sdf_ciphertext.bin\n"
"\n";
int sdfdecrypt_main(int argc, char **argv)

View File

@@ -56,7 +56,7 @@ static const char *help =
" echo -n abc | gmssl sdfdigest\n"
"\n"
" Windows:\n"
" C:\\> echo |set/p=\"abc\" | gmssl sdfdigest\n"
" echo |set/p=\"abc\" | gmssl sdfdigest\n"
"\n";

View File

@@ -35,9 +35,9 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sdfexport -encrypt -key 1 -lib libsoftsdf.so -out sm2encpub.pem\n"
" $ echo 'Secret message' | gmssl sdfencrypt -lib libsoftsdf.so -pubkey sm2encpub.pem -out sdf_ciphertext.bin\n"
" $ gmssl sdfdecrypt -lib libsoftsdf.so -key 1 -pass P@ssw0rd -in sdf_ciphertext.bin\n"
" gmssl sdfexport -encrypt -key 1 -lib libsoftsdf.so -out sm2encpub.pem\n"
" echo 'Secret message' | gmssl sdfencrypt -lib libsoftsdf.so -pubkey sm2encpub.pem -out sdf_ciphertext.bin\n"
" gmssl sdfdecrypt -lib libsoftsdf.so -key 1 -pass P@ssw0rd -in sdf_ciphertext.bin\n"
"\n";
int sdfencrypt_main(int argc, char **argv)

View File

@@ -30,8 +30,8 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sdfexport -sign -key 1 -out sm2signpub.pem\n"
" $ gmssl sdfexport -encrypt -key 1 -out sm2signpub.pem\n"
" gmssl sdfexport -sign -key 1 -out sm2signpub.pem\n"
" gmssl sdfexport -encrypt -key 1 -out sm2signpub.pem\n"
"\n";

View File

@@ -26,7 +26,7 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sdfinfo\n"
" gmssl sdfinfo\n"
"\n";

View File

@@ -32,9 +32,9 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ echo -n 'message to be signed' | gmssl sdfsign -lib libsoftsdf.so -key 1 -pass P@ssw0rd -out sm2.sig\n"
" $ gmssl sdfexport -lib libsoftsdf.so -sign -key 1 -out sm2pub.pem\n"
" $ echo -n 'message to be signed' | gmssl sm2verify -pubkey sm2pub.pem -sig sm2.sig\n"
" echo -n 'message to be signed' | gmssl sdfsign -lib libsoftsdf.so -key 1 -pass P@ssw0rd -out sm2.sig\n"
" gmssl sdfexport -lib libsoftsdf.so -sign -key 1 -out sm2pub.pem\n"
" echo -n 'message to be signed' | gmssl sm2verify -pubkey sm2pub.pem -sig sm2.sig\n"
"\n";

View File

@@ -38,7 +38,7 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sdftest -lib soft_sdf.so -kek 1 -key 1 -pass P@ssw0rd\n"
" gmssl sdftest -lib soft_sdf.so -kek 1 -key 1 -pass P@ssw0rd\n"
"\n";

View File

@@ -80,6 +80,7 @@ int skfutil_main(int argc, char **argv)
while (argc > 0) {
if (!strcmp(*argv, "-help")) {
print_usage(stdout, prog);
ret = 0;
goto end;
} else if (!strcmp(*argv, "-lib")) {
if (--argc < 1) goto bad;

View File

@@ -30,9 +30,9 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" $ echo 'Secret message' | gmssl sm2encrypt -pubkey sm2pub.pem -out sm2.der\n"
" $ gmssl sm2decrypt -key sm2.pem -pass P@ssw0rd -in sm2.der\n"
" gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" echo 'Secret message' | gmssl sm2encrypt -pubkey sm2pub.pem -out sm2.der\n"
" gmssl sm2decrypt -key sm2.pem -pass P@ssw0rd -in sm2.der\n"
"\n";
int sm2decrypt_main(int argc, char **argv)

View File

@@ -29,9 +29,9 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" $ echo 'Secret message' | gmssl sm2encrypt -pubkey sm2pub.pem -out sm2.der\n"
" $ gmssl sm2decrypt -key sm2.pem -pass P@ssw0rd -in sm2.der\n"
" gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" echo 'Secret message' | gmssl sm2encrypt -pubkey sm2pub.pem -out sm2.der\n"
" gmssl sm2decrypt -key sm2.pem -pass P@ssw0rd -in sm2.der\n"
"\n";
int sm2encrypt_main(int argc, char **argv)

View File

@@ -28,8 +28,8 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm2keygen -pass P@ssw0rd -out sm2.pem\n"
" $ gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" gmssl sm2keygen -pass P@ssw0rd -out sm2.pem\n"
" gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
"\n";
int sm2keygen_main(int argc, char **argv)

View File

@@ -31,9 +31,9 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" $ echo -n 'message to be signed' | gmssl sm2sign -key sm2.pem -pass P@ssw0rd -out sm2.sig\n"
" $ echo -n 'message to be signed' | gmssl sm2verify -pubkey sm2pub.pem -sig sm2.sig\n"
" gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" echo -n 'message to be signed' | gmssl sm2sign -key sm2.pem -pass P@ssw0rd -out sm2.sig\n"
" echo -n 'message to be signed' | gmssl sm2verify -pubkey sm2pub.pem -sig sm2.sig\n"
"\n";

View File

@@ -30,9 +30,9 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" $ echo -n 'message to be signed' | gmssl sm2sign -key sm2.pem -pass P@ssw0rd -out sm2.sig\n"
" $ echo -n 'message to be signed' | gmssl sm2verify -pubkey sm2pub.pem -sig sm2.sig\n"
" gmssl sm2keygen -pass P@ssw0rd -out sm2.pem -pubout sm2pub.pem\n"
" echo -n 'message to be signed' | gmssl sm2sign -key sm2.pem -pass P@ssw0rd -out sm2.sig\n"
" echo -n 'message to be signed' | gmssl sm2verify -pubkey sm2pub.pem -sig sm2.sig\n"
"\n";

View File

@@ -54,7 +54,7 @@ static const char *help =
" echo -n abc | gmssl sm3\n"
"\n"
" Windows:\n"
" C:\\> echo |set/p=\"abc\" | gmssl sm3\n"
" echo |set/p=\"abc\" | gmssl sm3\n"
"\n";

View File

@@ -34,8 +34,8 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ SALT=`gmssl rand -outlen 8 -hex`\n"
" $ gmssl sm3_pbkdf2 -pass P@ssw0rd -salt $SALT -iter 10000 -outlen 16 -hex\n"
" SALT=`gmssl rand -outlen 8 -hex`\n"
" gmssl sm3_pbkdf2 -pass P@ssw0rd -salt $SALT -iter 10000 -outlen 16 -hex\n"
"\n";

View File

@@ -47,7 +47,7 @@ static const char *help =
" echo -n abc | gmssl sm3hmac -key $KEY_HEX\n"
"\n"
" Windows:\n"
" C:\\> echo |set/p=\"abc\" | gmssl sm3hmac -key 11223344556677881122334455667788\n"
" echo |set/p=\"abc\" | gmssl sm3hmac -key 11223344556677881122334455667788\n"
"\n";
int sm3hmac_main(int argc, char **argv)

View File

@@ -197,8 +197,7 @@ static const char *options =
" -in file | stdin Input data\n"
" -out file | stdout Output data\n"
"\n"
"Examples"
"\n"
"Examples\n"
" echo \"hello\" | gmssl sm4 -gcm -encrypt -key 11223344556677881122334455667788 -iv 112233445566778811223344 -out ciphertext.bin\n"
" gmssl sm4 -gcm -decrypt -key 11223344556677881122334455667788 -iv 112233445566778811223344 -in ciphertext.bin\n"
"\n";

View File

@@ -30,11 +30,11 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm9setup -alg sm9encrypt -pass P@ssw0rd -out sm9enc_msk.pem -pubout sm9enc_mpk.pem\n"
" $ gmssl sm9keygen -alg sm9encrypt -in sm9enc_msk.pem -inpass P@ssw0rd -id Alice -out sm9enc.pem -outpass 123456\n"
" gmssl sm9setup -alg sm9encrypt -pass P@ssw0rd -out sm9enc_msk.pem -pubout sm9enc_mpk.pem\n"
" gmssl sm9keygen -alg sm9encrypt -in sm9enc_msk.pem -inpass P@ssw0rd -id Alice -out sm9enc.pem -outpass 123456\n"
"\n"
" $ echo 'Secret text' | gmssl sm9encrypt -pubmaster sm9enc_mpk.pem -id Alice -out sm9_ciphertext.der\n"
" $ gmssl sm9decrypt -key sm9enc.pem -pass 123456 -id Alice -in sm9_ciphertext.der\n"
" echo 'Secret text' | gmssl sm9encrypt -pubmaster sm9enc_mpk.pem -id Alice -out sm9_ciphertext.der\n"
" gmssl sm9decrypt -key sm9enc.pem -pass 123456 -id Alice -in sm9_ciphertext.der\n"
"\n";
int sm9decrypt_main(int argc, char **argv)

View File

@@ -27,11 +27,11 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm9setup -alg sm9encrypt -pass P@ssw0rd -out sm9enc_msk.pem -pubout sm9enc_mpk.pem\n"
" $ gmssl sm9keygen -alg sm9encrypt -in sm9enc_msk.pem -inpass P@ssw0rd -id Alice -out sm9enc.pem -outpass 123456\n"
" gmssl sm9setup -alg sm9encrypt -pass P@ssw0rd -out sm9enc_msk.pem -pubout sm9enc_mpk.pem\n"
" gmssl sm9keygen -alg sm9encrypt -in sm9enc_msk.pem -inpass P@ssw0rd -id Alice -out sm9enc.pem -outpass 123456\n"
"\n"
" $ echo 'Secret text' | gmssl sm9encrypt -pubmaster sm9enc_mpk.pem -id Alice -out sm9_ciphertext.der\n"
" $ gmssl sm9decrypt -key sm9enc.pem -pass 123456 -id Alice -in sm9_ciphertext.der\n"
" echo 'Secret text' | gmssl sm9encrypt -pubmaster sm9enc_mpk.pem -id Alice -out sm9_ciphertext.der\n"
" gmssl sm9decrypt -key sm9enc.pem -pass 123456 -id Alice -in sm9_ciphertext.der\n"
"\n";
int sm9encrypt_main(int argc, char **argv)

View File

@@ -33,12 +33,12 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm9setup -alg sm9sign -pass P@ssw0rd -out sm9sign_msk.pem\n"
" $ gmssl sm9keygen -alg sm9sign -in sm9sign_msk.pem -inpass P@ssw0rd -id Alice -out sm9sign.pem -outpass 123456\n"
" gmssl sm9setup -alg sm9sign -pass P@ssw0rd -out sm9sign_msk.pem\n"
" gmssl sm9keygen -alg sm9sign -in sm9sign_msk.pem -inpass P@ssw0rd -id Alice -out sm9sign.pem -outpass 123456\n"
"\n"
" $ gmssl sm9setup -alg sm9encrypt -pass P@ssw0rd -out sm9enc_msk.pem\n"
" $ gmssl sm9keygen -alg sm9encrypt -in sm9enc_msk.pem -inpass P@ssw0rd -id Alice -out sm9enc.pem -outpass 123456\n"
" $ gmssl sm9keygen -alg sm9keyagreement -in sm9enc_msk.pem -inpass P@ssw0rd -id Alice -out sm9exch.pem -outpass 123456\n"
" gmssl sm9setup -alg sm9encrypt -pass P@ssw0rd -out sm9enc_msk.pem\n"
" gmssl sm9keygen -alg sm9encrypt -in sm9enc_msk.pem -inpass P@ssw0rd -id Alice -out sm9enc.pem -outpass 123456\n"
" gmssl sm9keygen -alg sm9keyagreement -in sm9enc_msk.pem -inpass P@ssw0rd -id Alice -out sm9exch.pem -outpass 123456\n"
"\n";
int sm9keygen_main(int argc, char **argv)

View File

@@ -30,8 +30,8 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm9setup -alg sm9sign -pass P@ssw0rd -out sm9sign_msk.pem -pubout sm9sign_mpk.pem\n"
" $ gmssl sm9setup -alg sm9encrypt -pass P@ssw0rd -out sm9enc_msk.pem -pubout sm9enc_mpk.pem\n"
" gmssl sm9setup -alg sm9sign -pass P@ssw0rd -out sm9sign_msk.pem -pubout sm9sign_mpk.pem\n"
" gmssl sm9setup -alg sm9encrypt -pass P@ssw0rd -out sm9enc_msk.pem -pubout sm9enc_mpk.pem\n"
"\n";
int sm9setup_main(int argc, char **argv)

View File

@@ -29,11 +29,11 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm9setup -alg sm9sign -pass P@ssw0rd -out sm9sign_msk.pem -pubout sm9sign_mpk.pem\n"
" $ gmssl sm9keygen -alg sm9sign -in sm9sign_msk.pem -inpass P@ssw0rd -id Alice -out sm9sign.pem -outpass 123456\n"
" gmssl sm9setup -alg sm9sign -pass P@ssw0rd -out sm9sign_msk.pem -pubout sm9sign_mpk.pem\n"
" gmssl sm9keygen -alg sm9sign -in sm9sign_msk.pem -inpass P@ssw0rd -id Alice -out sm9sign.pem -outpass 123456\n"
"\n"
" $ echo -n 'message to be signed' | gmssl sm9sign -key sm9sign.pem -pass 123456 -out sm9.sig\n"
" $ echo -n 'message to be signed' | gmssl sm9verify -pubmaster sm9sign_mpk.pem -id Alice -sig sm9.sig\n"
" echo -n 'message to be signed' | gmssl sm9sign -key sm9sign.pem -pass 123456 -out sm9.sig\n"
" echo -n 'message to be signed' | gmssl sm9verify -pubmaster sm9sign_mpk.pem -id Alice -sig sm9.sig\n"
"\n";
int sm9sign_main(int argc, char **argv)

View File

@@ -27,11 +27,11 @@ static const char *options =
"\n"
"Examples\n"
"\n"
" $ gmssl sm9setup -alg sm9sign -pass P@ssw0rd -out sm9sign_msk.pem -pubout sm9sign_mpk.pem\n"
" $ gmssl sm9keygen -alg sm9sign -in sm9sign_msk.pem -inpass P@ssw0rd -id Alice -out sm9sign.pem -outpass 123456\n"
" gmssl sm9setup -alg sm9sign -pass P@ssw0rd -out sm9sign_msk.pem -pubout sm9sign_mpk.pem\n"
" gmssl sm9keygen -alg sm9sign -in sm9sign_msk.pem -inpass P@ssw0rd -id Alice -out sm9sign.pem -outpass 123456\n"
"\n"
" $ echo -n 'message to be signed' | gmssl sm9sign -key sm9sign.pem -pass 123456 -out sm9.sig\n"
" $ echo -n 'message to be signed' | gmssl sm9verify -pubmaster sm9sign_mpk.pem -id Alice -sig sm9.sig\n"
" echo -n 'message to be signed' | gmssl sm9sign -key sm9sign.pem -pass 123456 -out sm9.sig\n"
" echo -n 'message to be signed' | gmssl sm9verify -pubmaster sm9sign_mpk.pem -id Alice -sig sm9.sig\n"
"\n";
int sm9verify_main(int argc, char **argv)