summaryrefslogtreecommitdiff
path: root/deps/openssl/openssl/apps/pkeyparam.c
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2018-11-22 10:39:20 -0800
committerSam Roberts <vieuxtech@gmail.com>2019-01-22 13:32:34 -0800
commit4231ad04f0b2aee5bda6be94715d4b70badaac8b (patch)
tree19f189fae6828708ebd37e466ce4a7716494b96a /deps/openssl/openssl/apps/pkeyparam.c
parent5d80f9ea6091847176fa47fb1395fdffc4af9164 (diff)
downloadandroid-node-v8-4231ad04f0b2aee5bda6be94715d4b70badaac8b.tar.gz
android-node-v8-4231ad04f0b2aee5bda6be94715d4b70badaac8b.tar.bz2
android-node-v8-4231ad04f0b2aee5bda6be94715d4b70badaac8b.zip
deps: upgrade openssl sources to 1.1.1a
This updates all sources in deps/openssl/openssl with openssl-1.1.1a. PR-URL: https://github.com/nodejs/node/pull/25381 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Shigeki Ohtsu <ohtsu@ohtsu.org>
Diffstat (limited to 'deps/openssl/openssl/apps/pkeyparam.c')
-rw-r--r--deps/openssl/openssl/apps/pkeyparam.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/deps/openssl/openssl/apps/pkeyparam.c b/deps/openssl/openssl/apps/pkeyparam.c
index 0a1b2d1283..41c3f532b3 100644
--- a/deps/openssl/openssl/apps/pkeyparam.c
+++ b/deps/openssl/openssl/apps/pkeyparam.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -10,16 +10,18 @@
#include <stdio.h>
#include <string.h>
#include "apps.h"
+#include "progs.h"
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/evp.h>
typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
- OPT_IN, OPT_OUT, OPT_TEXT, OPT_NOOUT, OPT_ENGINE
+ OPT_IN, OPT_OUT, OPT_TEXT, OPT_NOOUT,
+ OPT_ENGINE, OPT_CHECK
} OPTION_CHOICE;
-OPTIONS pkeyparam_options[] = {
+const OPTIONS pkeyparam_options[] = {
{"help", OPT_HELP, '-', "Display this summary"},
{"in", OPT_IN, '<', "Input file"},
{"out", OPT_OUT, '>', "Output file"},
@@ -28,6 +30,7 @@ OPTIONS pkeyparam_options[] = {
#ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
#endif
+ {"check", OPT_CHECK, '-', "Check key param consistency"},
{NULL}
};
@@ -36,7 +39,7 @@ int pkeyparam_main(int argc, char **argv)
ENGINE *e = NULL;
BIO *in = NULL, *out = NULL;
EVP_PKEY *pkey = NULL;
- int text = 0, noout = 0, ret = 1;
+ int text = 0, noout = 0, ret = 1, check = 0;
OPTION_CHOICE o;
char *infile = NULL, *outfile = NULL, *prog;
@@ -67,6 +70,9 @@ int pkeyparam_main(int argc, char **argv)
case OPT_NOOUT:
noout = 1;
break;
+ case OPT_CHECK:
+ check = 1;
+ break;
}
}
argc = opt_num_rest();
@@ -80,12 +86,44 @@ int pkeyparam_main(int argc, char **argv)
if (out == NULL)
goto end;
pkey = PEM_read_bio_Parameters(in, NULL);
- if (!pkey) {
+ if (pkey == NULL) {
BIO_printf(bio_err, "Error reading parameters\n");
ERR_print_errors(bio_err);
goto end;
}
+ if (check) {
+ int r;
+ EVP_PKEY_CTX *ctx;
+
+ ctx = EVP_PKEY_CTX_new(pkey, e);
+ if (ctx == NULL) {
+ ERR_print_errors(bio_err);
+ goto end;
+ }
+
+ r = EVP_PKEY_param_check(ctx);
+
+ if (r == 1) {
+ BIO_printf(out, "Parameters are valid\n");
+ } else {
+ /*
+ * Note: at least for RSA keys if this function returns
+ * -1, there will be no error reasons.
+ */
+ unsigned long err;
+
+ BIO_printf(out, "Parameters are invalid\n");
+
+ while ((err = ERR_peek_error()) != 0) {
+ BIO_printf(out, "Detailed error: %s\n",
+ ERR_reason_error_string(err));
+ ERR_get_error(); /* remove err from error stack */
+ }
+ }
+ EVP_PKEY_CTX_free(ctx);
+ }
+
if (!noout)
PEM_write_bio_Parameters(out, pkey);