summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/pkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr.bin/openssl/pkey.c')
-rw-r--r--src/usr.bin/openssl/pkey.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/usr.bin/openssl/pkey.c b/src/usr.bin/openssl/pkey.c
index 06b4c01894..9134fc7192 100644
--- a/src/usr.bin/openssl/pkey.c
+++ b/src/usr.bin/openssl/pkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pkey.c,v 1.15 2019/07/14 03:30:46 guenther Exp $ */ 1/* $OpenBSD: pkey.c,v 1.16 2022/01/10 12:17:49 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006 3 * project 2006
4 */ 4 */
@@ -66,6 +66,7 @@
66#include <openssl/pem.h> 66#include <openssl/pem.h>
67 67
68static struct { 68static struct {
69 int check;
69 const EVP_CIPHER *cipher; 70 const EVP_CIPHER *cipher;
70 char *infile; 71 char *infile;
71 int informat; 72 int informat;
@@ -74,6 +75,7 @@ static struct {
74 int outformat; 75 int outformat;
75 char *passargin; 76 char *passargin;
76 char *passargout; 77 char *passargout;
78 int pubcheck;
77 int pubin; 79 int pubin;
78 int pubout; 80 int pubout;
79 int pubtext; 81 int pubtext;
@@ -99,6 +101,12 @@ pkey_opt_cipher(int argc, char **argv, int *argsused)
99 101
100static const struct option pkey_options[] = { 102static const struct option pkey_options[] = {
101 { 103 {
104 .name = "check",
105 .desc = "Check validity of key",
106 .type = OPTION_FLAG,
107 .opt.flag = &pkey_config.check,
108 },
109 {
102 .name = "in", 110 .name = "in",
103 .argname = "file", 111 .argname = "file",
104 .desc = "Input file (default stdin)", 112 .desc = "Input file (default stdin)",
@@ -147,6 +155,12 @@ static const struct option pkey_options[] = {
147 .opt.arg = &pkey_config.passargout, 155 .opt.arg = &pkey_config.passargout,
148 }, 156 },
149 { 157 {
158 .name = "pubcheck",
159 .desc = "Check validity of public key",
160 .type = OPTION_FLAG,
161 .opt.flag = &pkey_config.pubcheck,
162 },
163 {
150 .name = "pubin", 164 .name = "pubin",
151 .desc = "Expect a public key (default private key)", 165 .desc = "Expect a public key (default private key)",
152 .type = OPTION_VALUE, 166 .type = OPTION_VALUE,
@@ -186,11 +200,11 @@ pkey_usage()
186 int n = 0; 200 int n = 0;
187 201
188 fprintf(stderr, 202 fprintf(stderr,
189 "usage: pkey [-ciphername] [-in file] [-inform fmt] [-noout] " 203 "usage: pkey [-check] [-ciphername] [-in file] [-inform fmt] "
190 "[-out file]\n" 204 "[-noout] [-out file]\n"
191 " [-outform fmt] [-passin src] [-passout src] [-pubin] " 205 " [-outform fmt] [-passin src] [-passout src] [-pubcheck] "
192 "[-pubout] [-text]\n" 206 "[-pubin] [-pubout]\n"
193 " [-text_pub]\n\n"); 207 " [-text] [-text_pub]\n\n");
194 options_usage(pkey_options); 208 options_usage(pkey_options);
195 fprintf(stderr, "\n"); 209 fprintf(stderr, "\n");
196 210
@@ -252,6 +266,16 @@ pkey_main(int argc, char **argv)
252 if (!pkey) 266 if (!pkey)
253 goto end; 267 goto end;
254 268
269#if notyet
270 if (pkey_config.check) {
271 if (!pkey_check(out, pkey, EVP_PKEY_check, "Key pair"))
272 goto end;
273 } else if (pkey_config.pubcheck) {
274 if (!pkey_check(out, pkey, EVP_PKEY_public_check, "Public key"))
275 goto end;
276 }
277#endif
278
255 if (!pkey_config.noout) { 279 if (!pkey_config.noout) {
256 if (pkey_config.outformat == FORMAT_PEM) { 280 if (pkey_config.outformat == FORMAT_PEM) {
257 if (pkey_config.pubout) 281 if (pkey_config.pubout)