mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Update gmssl help
This commit is contained in:
@@ -168,9 +168,8 @@ static int test_sm4_ctr32_encrypt_blocks(void)
|
||||
sm4_set_encrypt_key(&sm4_key, key);
|
||||
sm4_ctr32_encrypt_blocks(&sm4_key, ctr, plaintext, 4, encrypted);
|
||||
|
||||
format_bytes(stderr, 0, 0, "sm4_ctr32", encrypted, 64);
|
||||
|
||||
/*
|
||||
// FIXME: relace the corrent ciphertext
|
||||
if (memcmp(encrypted, ciphertext, sizeof(ciphertext)) != 0) {
|
||||
error_print();
|
||||
return -1;
|
||||
|
||||
@@ -819,7 +819,7 @@ int test_sm9_z256_exchange()
|
||||
|
||||
for (i = 0; i < klen; i++) {
|
||||
if (skA[i] != skB[i]) {
|
||||
printf("Exchange key different at byte %d\n", i);
|
||||
printf("Exchange key different at byte %zu\n", i);
|
||||
goto err;
|
||||
}
|
||||
} ++j;
|
||||
@@ -827,7 +827,7 @@ int test_sm9_z256_exchange()
|
||||
printf("%s() ok\n", __FUNCTION__);
|
||||
return 1;
|
||||
err:
|
||||
printf("%s test %d failed\n", __FUNCTION__, j);
|
||||
printf("%s test %zu failed\n", __FUNCTION__, j);
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
static const char *usage = "{-encrypt|-decrypt} -key hex -iv hex [-in file] [-out file]";
|
||||
|
||||
static const char *options =
|
||||
"\n"
|
||||
"Options\n"
|
||||
"\n"
|
||||
" -encrypt Encrypt\n"
|
||||
@@ -30,9 +31,13 @@ static const char *options =
|
||||
" -in file | stdin Input data\n"
|
||||
" -out file | stdout Output data\n"
|
||||
"\n"
|
||||
"Examples"
|
||||
"Examples\n"
|
||||
"\n"
|
||||
" echo \"hello\" | gmssl sm4_cbc -encrypt -key 11223344556677881122334455667788 -iv 112233445566778811223344 -out ciphertext.bin\n"
|
||||
" $ TEXT=`gmssl rand -outlen 20 -hex`\n"
|
||||
" $ KEY=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ IV=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ echo -n $TEXT | gmssl sm4_cbc -encrypt -key $KEY -iv $IV -out sm4_cbc_ciphertext.bin\n"
|
||||
" $ gmssl sm4_cbc -decrypt -key $KEY -iv $IV -in sm4_cbc_ciphertext.bin\n"
|
||||
"\n";
|
||||
|
||||
int sm4_cbc_main(int argc, char **argv)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
static const char *usage = "{-encrypt|-decrypt} -key hex -iv hex [-in file] [-out file]";
|
||||
|
||||
static const char *options =
|
||||
"\n"
|
||||
"Options\n"
|
||||
"\n"
|
||||
" -encrypt Encrypt\n"
|
||||
@@ -30,9 +31,13 @@ static const char *options =
|
||||
" -in file | stdin Input data\n"
|
||||
" -out file | stdout Output data\n"
|
||||
"\n"
|
||||
"Examples"
|
||||
"Examples\n"
|
||||
"\n"
|
||||
" echo \"hello\" | gmssl sm4_cfb -encrypt -key 11223344556677881122334455667788 -iv 112233445566778811223344 -out ciphertext.bin\n"
|
||||
" $ TEXT=`gmssl rand -outlen 20 -hex`\n"
|
||||
" $ KEY=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ IV=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ echo -n $TEXT | gmssl sm4_cfb -encrypt -key $KEY -iv $IV -out sm4_cfb_ciphertext.bin\n"
|
||||
" $ gmssl sm4_cfb -decrypt -key $KEY -iv $IV -in sm4_cfb_ciphertext.bin\n"
|
||||
"\n";
|
||||
|
||||
int sm4_cfb_main(int argc, char **argv)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
static const char *usage = "[-encrypt|-decrypt] -key hex -iv hex [-in file] [-out file]";
|
||||
|
||||
static const char *options =
|
||||
"\n"
|
||||
"Options\n"
|
||||
"\n"
|
||||
" -encrypt Encrypt\n"
|
||||
@@ -30,9 +31,13 @@ static const char *options =
|
||||
" -in file | stdin Input data\n"
|
||||
" -out file | stdout Output data\n"
|
||||
"\n"
|
||||
"Examples"
|
||||
"Examples\n"
|
||||
"\n"
|
||||
" echo \"hello\" | gmssl sm4_ctr -key 11223344556677881122334455667788 -iv 112233445566778811223344 -out ciphertext.bin\n"
|
||||
" $ TEXT=`gmssl rand -outlen 20 -hex`\n"
|
||||
" $ KEY=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ IV=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ echo -n $TEXT | gmssl sm4_ctr -key $KEY -iv $IV -out sm4_ctr_ciphertext.bin\n"
|
||||
" $ gmssl sm4_ctr -key $KEY -iv $IV -in sm4_ctr_ciphertext.bin\n"
|
||||
"\n";
|
||||
|
||||
int sm4_ctr_main(int argc, char **argv)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
static const char *usage = "{-encrypt|-decrypt} -key hex [-in file] [-out file]";
|
||||
|
||||
static const char *options =
|
||||
"\n"
|
||||
"Options\n"
|
||||
"\n"
|
||||
" -encrypt Encrypt\n"
|
||||
@@ -29,9 +30,12 @@ static const char *options =
|
||||
" -in file | stdin Input data\n"
|
||||
" -out file | stdout Output data\n"
|
||||
"\n"
|
||||
"Examples"
|
||||
"Examples\n"
|
||||
"\n"
|
||||
" echo \"hello\" | gmssl sm4_ecb -encrypt -key 11223344556677881122334455667788 -iv 112233445566778811223344 -out ciphertext.bin\n"
|
||||
" $ TEXT=`gmssl rand -outlen 32 -hex`\n"
|
||||
" $ KEY=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ echo -n $TEXT | gmssl sm4_ecb -encrypt -key $KEY -out sm4_ecb_ciphertext.bin\n"
|
||||
" $ gmssl sm4_ecb -decrypt -key $KEY -in sm4_ecb_ciphertext.bin\n"
|
||||
"\n";
|
||||
|
||||
int sm4_ecb_main(int argc, char **argv)
|
||||
@@ -40,7 +44,6 @@ int sm4_ecb_main(int argc, char **argv)
|
||||
char *prog = argv[0];
|
||||
int enc = -1;
|
||||
char *keyhex = NULL;
|
||||
char *ivhex = NULL;
|
||||
char *infile = NULL;
|
||||
char *outfile = NULL;
|
||||
uint8_t key[16];
|
||||
@@ -123,10 +126,6 @@ bad:
|
||||
fprintf(stderr, "gmssl %s: option `-key` missing\n", prog);
|
||||
goto end;
|
||||
}
|
||||
if (!ivhex) {
|
||||
fprintf(stderr, "gmssl %s: option `-iv` missing\n", prog);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (enc) {
|
||||
if (sm4_ecb_encrypt_init(&ctx, key) != 1) {
|
||||
|
||||
@@ -33,10 +33,14 @@ static const char *options =
|
||||
" -in file | stdin Input data\n"
|
||||
" -out file | stdout Output data\n"
|
||||
"\n"
|
||||
"Examples"
|
||||
"Examples\n"
|
||||
"\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"
|
||||
" $ TEXT=`gmssl rand -outlen 20 -hex`\n"
|
||||
" $ KEY=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ IV=`gmssl rand -outlen 12 -hex`\n"
|
||||
" $ AAD=\"The AAD Data\"\n"
|
||||
" $ echo -n $TEXT | gmssl sm4_gcm -encrypt -key $KEY -iv $IV -aad $AAD -out sm4_gcm_ciphertext.bin\n"
|
||||
" $ gmssl sm4_gcm -decrypt -key $KEY -iv $IV -in sm4_gcm_ciphertext.bin\n"
|
||||
"\n";
|
||||
|
||||
int sm4_gcm_main(int argc, char **argv)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
static const char *usage = "[-encrypt|-decrypt] -key hex -iv hex [-in file] [-out file]";
|
||||
|
||||
static const char *options =
|
||||
"\n"
|
||||
"Options\n"
|
||||
"\n"
|
||||
" -encrypt Encrypt\n"
|
||||
@@ -30,9 +31,13 @@ static const char *options =
|
||||
" -in file | stdin Input data\n"
|
||||
" -out file | stdout Output data\n"
|
||||
"\n"
|
||||
"Examples"
|
||||
"Examples\n"
|
||||
"\n"
|
||||
" echo \"hello\" | gmssl sm4_ofb -key 11223344556677881122334455667788 -iv 112233445566778811223344 -out ciphertext.bin\n"
|
||||
" $ TEXT=`gmssl rand -outlen 32 -hex`\n"
|
||||
" $ KEY=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ IV=`gmssl rand -outlen 16 -hex`\n"
|
||||
" $ echo -n $TEXT | gmssl sm4_ofb -encrypt -key $KEY -iv $IV -out sm4_ofb_ciphertext.bin\n"
|
||||
" $ gmssl sm4_ofb -decrypt -key $KEY -iv $IV -in sm4_ofb_ciphertext.bin\n"
|
||||
"\n";
|
||||
|
||||
int sm4_ofb_main(int argc, char **argv)
|
||||
|
||||
Reference in New Issue
Block a user