mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-22 21:23:56 +08:00
Update demos
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <gmssl/x509.h>
|
||||
#include <gmssl/x509_crl.h>
|
||||
#include <gmssl/error.h>
|
||||
|
||||
|
||||
static const char *usage =
|
||||
@@ -60,7 +61,7 @@ int certverify_main(int argc, char **argv)
|
||||
argv++;
|
||||
|
||||
if (argc < 1) {
|
||||
fprintf(stderr, "usage: %s %s\n", prog, options);
|
||||
fprintf(stderr, "usage: %s %s\n", prog, usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -171,7 +172,8 @@ bad:
|
||||
}
|
||||
|
||||
}
|
||||
x509_name_print(stdout, 0, 0, "Signed by", subject, subject_len);
|
||||
format_print(stdout, 0, 0, "Signed by\n");
|
||||
x509_name_print(stdout, 0, 0, "Certificate", subject, subject_len);
|
||||
|
||||
check_crl = 0; // only check the entity CRL
|
||||
|
||||
@@ -193,7 +195,8 @@ final:
|
||||
goto end;
|
||||
}
|
||||
printf("Verification %s\n", rv ? "success" : "failure");
|
||||
x509_name_print(stdout, 0, 0, "Signed by", subject, subject_len);
|
||||
format_print(stdout, 0, 0, "Signed by\n");
|
||||
x509_name_print(stdout, 0, 0, "Certificate", subject, subject_len);
|
||||
|
||||
if (double_certs) {
|
||||
if ((rv = x509_cert_verify_by_ca_cert(enc_cert, enc_cert_len, cacert, cacertlen, SM2_DEFAULT_ID, strlen(SM2_DEFAULT_ID))) < 0) {
|
||||
@@ -202,6 +205,7 @@ final:
|
||||
}
|
||||
printf("Verification %s\n", rv ? "success" : "failure");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
ret = 0;
|
||||
end:
|
||||
|
||||
@@ -59,6 +59,7 @@ extern int skfutil_main(int argc, char **argv);
|
||||
|
||||
static const char *options =
|
||||
"command [options]\n"
|
||||
"command -help\n"
|
||||
"\n"
|
||||
"Commands:\n"
|
||||
" help Print this help message\n"
|
||||
@@ -85,13 +86,13 @@ static const char *options =
|
||||
" reqparse Parse and print a CSR\n"
|
||||
" crlget Download the CRL of given certificate\n"
|
||||
" crlgen Sign a CRL with CA certificate and private key\n"
|
||||
" crlparse Verify a CRL with certificate\n"
|
||||
" crlverify Parse and print CRL\n"
|
||||
" crlverify Verify a CRL with issuer's certificate\n"
|
||||
" crlparse Parse and print CRL\n"
|
||||
" certgen Generate a self-signed certificate\n"
|
||||
" certparse Parse and print certificates\n"
|
||||
" certverify Verify certificate chain\n"
|
||||
" certrevoke Revoke certificate and output RevokedCertificate in DER\n"
|
||||
" cmsparse Parse cryptographic message syntax (CMS)\n"
|
||||
" certrevoke Revoke certificate and output RevokedCertificate record\n"
|
||||
" cmsparse Parse CMS (cryptographic message syntax) file\n"
|
||||
" cmsencrypt Generate CMS EnvelopedData\n"
|
||||
" cmsdecrypt Decrypt CMS EnvelopedData\n"
|
||||
" cmssign Generate CMS SignedData\n"
|
||||
@@ -103,8 +104,10 @@ static const char *options =
|
||||
" tls12_client TLS 1.2 client\n"
|
||||
" tls12_server TLS 1.2 server\n"
|
||||
" tls13_client TLS 1.3 client\n"
|
||||
" tls13_server TLS 1.3 server\n";
|
||||
|
||||
" tls13_server TLS 1.3 server\n"
|
||||
"\n"
|
||||
"run `gmssl <command> -help` to print help of the given command\n"
|
||||
"\n";
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
#include <gmssl/sm2.h>
|
||||
|
||||
|
||||
static const char *options = "-pass str [-out pem] [-pubout pem]";
|
||||
static const char *usage = "-pass str [-out pem] [-pubout pem]\n";
|
||||
|
||||
static const char *options =
|
||||
"Options\n"
|
||||
" -pass pass Password to encrypt the private key\n"
|
||||
" -out pem Output password-encrypted PKCS #8 private key in PEM format\n"
|
||||
" -pubout pem Output public key in PEM format\n"
|
||||
"\n";
|
||||
|
||||
int sm2keygen_main(int argc, char **argv)
|
||||
{
|
||||
@@ -39,7 +46,8 @@ int sm2keygen_main(int argc, char **argv)
|
||||
|
||||
while (argc > 0) {
|
||||
if (!strcmp(*argv, "-help")) {
|
||||
printf("usage: %s %s\n", prog, options);
|
||||
printf("usage: %s %s\n", prog, usage);
|
||||
printf("%s\n", options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
} else if (!strcmp(*argv, "-pass")) {
|
||||
@@ -63,7 +71,7 @@ int sm2keygen_main(int argc, char **argv)
|
||||
fprintf(stderr, "%s: illegal option '%s'\n", prog, *argv);
|
||||
goto end;
|
||||
bad:
|
||||
fprintf(stderr, "%s: '%s' option value missing\n", prog, *argv);
|
||||
fprintf(stderr, "%s: `%s` option value missing\n", prog, *argv);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -72,7 +80,7 @@ bad:
|
||||
}
|
||||
|
||||
if (!pass) {
|
||||
fprintf(stderr, "%s: '-pass' option required\n", prog);
|
||||
fprintf(stderr, "%s: `-pass` option required\n", prog);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user