mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-19 23:06:28 +08:00
Update Public API
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2021 - 2021 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -101,7 +101,7 @@ int sm9decrypt_main(int argc, char **argv)
|
||||
} else if (!strcmp(*argv, "-in")) {
|
||||
if (--argc < 1) goto bad;
|
||||
infile = *(++argv);
|
||||
if (!(infp = fopen(outfile, "r"))) {
|
||||
if (!(infp = fopen(infile, "r"))) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -118,10 +118,14 @@ bad:
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (!mpkfile || !id) {
|
||||
if (!mpkfp || !id) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
if (sm9_enc_master_public_key_from_pem(&mpk, mpkfp) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
if ((inlen = fread(inbuf, 1, sizeof(inbuf), infp)) <= 0) {
|
||||
error_print();
|
||||
goto end;
|
||||
@@ -138,5 +142,6 @@ bad:
|
||||
end:
|
||||
if (infile && infp) fclose(infp);
|
||||
if (outfile && outfp) fclose(outfp);
|
||||
if (mpkfp) fclose(mpkfp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ int sm9sign_main(int argc, char **argv)
|
||||
SM9_SIGN_CTX ctx;
|
||||
uint8_t buf[4096];
|
||||
ssize_t len;
|
||||
uint8_t sig[SM9_MAX_SIGNATURE_SIZE];
|
||||
uint8_t sig[SM9_SIGNATURE_SIZE];
|
||||
size_t siglen;
|
||||
|
||||
argc--;
|
||||
@@ -90,14 +90,14 @@ int sm9sign_main(int argc, char **argv)
|
||||
} else if (!strcmp(*argv, "-in")) {
|
||||
if (--argc < 1) goto bad;
|
||||
infile = *(++argv);
|
||||
if (!(infp = fopen(infile, "w"))) {
|
||||
if (!(infp = fopen(infile, "r"))) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
} else if (!strcmp(*argv, "-key")) {
|
||||
if (--argc < 1) goto bad;
|
||||
keyfile = *(++argv);
|
||||
if (!(keyfp = fopen(keyfile, "w"))) {
|
||||
if (!(keyfp = fopen(keyfile, "r"))) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
@@ -145,6 +145,14 @@ bad:
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (siglen != fwrite(sig, 1, siglen, outfp)) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
end:
|
||||
|
||||
@@ -70,7 +70,7 @@ int sm9verify_main(int argc, char **argv)
|
||||
SM9_SIGN_CTX ctx;
|
||||
uint8_t buf[4096];
|
||||
ssize_t len;
|
||||
uint8_t sig[SM9_MAX_SIGNATURE_SIZE];
|
||||
uint8_t sig[SM9_SIGNATURE_SIZE];
|
||||
ssize_t siglen;
|
||||
|
||||
argc--;
|
||||
@@ -88,14 +88,14 @@ int sm9verify_main(int argc, char **argv)
|
||||
} else if (!strcmp(*argv, "-in")) {
|
||||
if (--argc < 1) goto bad;
|
||||
infile = *(++argv);
|
||||
if (!(infp = fopen(infile, "w"))) {
|
||||
if (!(infp = fopen(infile, "r"))) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
} else if (!strcmp(*argv, "-pubmaster")) {
|
||||
if (--argc < 1) goto bad;
|
||||
mpkfile = *(++argv);
|
||||
if (!(mpkfp = fopen(mpkfile, "w"))) {
|
||||
if (!(mpkfp = fopen(mpkfile, "r"))) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ int sm9verify_main(int argc, char **argv)
|
||||
} else if (!strcmp(*argv, "-sig")) {
|
||||
if (--argc < 1) goto bad;
|
||||
sigfile = *(++argv);
|
||||
if (!(sigfp = fopen(sigfile, "w"))) {
|
||||
if (!(sigfp = fopen(sigfile, "r"))) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
@@ -148,6 +148,7 @@ bad:
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
printf("%s %s\n", prog, ret ? "success" : "failure");
|
||||
|
||||
end:
|
||||
if (infile && infp) fclose(infp);
|
||||
|
||||
Reference in New Issue
Block a user