From cec1ace2d4d21c85f4c8bacc2dd971721bf6b694 Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 5 May 2023 18:01:27 +0000 Subject: [PATCH] Reinstate X9.31 padding mode support in rsautl --- usr.bin/openssl/openssl.1 | 14 +++++++++----- usr.bin/openssl/rsautl.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/usr.bin/openssl/openssl.1 b/usr.bin/openssl/openssl.1 index c430e49f0f0..4c9d15b9d1d 100644 --- a/usr.bin/openssl/openssl.1 +++ b/usr.bin/openssl/openssl.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: openssl.1,v 1.143 2023/04/25 16:11:02 tb Exp $ +.\" $OpenBSD: openssl.1,v 1.144 2023/05/05 18:01:27 tb Exp $ .\" ==================================================================== .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. .\" @@ -110,7 +110,7 @@ .\" copied and put under another distribution licence .\" [including the GNU Public Licence.] .\" -.Dd $Mdocdate: April 25 2023 $ +.Dd $Mdocdate: May 5 2023 $ .Dt OPENSSL 1 .Os .Sh NAME @@ -3505,6 +3505,8 @@ for PKCS#1 padding; for no padding; .Cm oaep for OAEP mode; +.Cm x931 +for X9.31 mode; and .Cm pss for PSS. @@ -3515,6 +3517,8 @@ If a digest is set then a DigestInfo structure is used and its length must correspond to the digest type. For oeap mode only encryption and decryption is supported. +For x931 if the digest type is set it is used to format the block data; +otherwise the first byte is used to specify the X9.31 digest ID. Sign, verify, and verifyrecover can be performed in this mode. For pss mode only sign and verify are supported and the digest type must be specified. @@ -4178,7 +4182,7 @@ Print the public/private key components in plain text. .Op Fl in Ar file .Op Fl inkey Ar file .Op Fl keyform Cm der | pem -.Op Fl oaep | pkcs | raw +.Op Fl oaep | pkcs | raw | x931 .Op Fl out Ar file .Op Fl passin Ar arg .Op Fl pubin @@ -4216,9 +4220,9 @@ The input key file; by default an RSA private key. The private key format. The default is .Cm pem . -.It Fl oaep | pkcs | raw +.It Fl oaep | pkcs | raw | x931 The padding to use: -PKCS#1 OAEP, PKCS#1 v1.5 (the default), no padding, +PKCS#1 OAEP, PKCS#1 v1.5 (the default), no padding, or ANSI X9.31, respectively. For signatures, only .Fl pkcs diff --git a/usr.bin/openssl/rsautl.c b/usr.bin/openssl/rsautl.c index 4f674b0efed..d67e78807cc 100644 --- a/usr.bin/openssl/rsautl.c +++ b/usr.bin/openssl/rsautl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsautl.c,v 1.22 2023/04/09 18:33:26 tb Exp $ */ +/* $OpenBSD: rsautl.c,v 1.23 2023/05/05 18:01:27 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -206,6 +206,13 @@ static const struct option rsautl_options[] = { .value = RSA_VERIFY, .opt.value = &cfg.rsa_mode, }, + { + .name = "x931", + .desc = "Use ANSI X9.31 padding", + .type = OPTION_VALUE, + .value = RSA_X931_PADDING, + .opt.value = &cfg.pad, + }, {NULL}, }; @@ -217,7 +224,7 @@ rsautl_usage() "usage: rsautl [-asn1parse] [-certin] [-decrypt] [-encrypt] " "[-hexdump]\n" " [-in file] [-inkey file] [-keyform der | pem]\n" - " [-oaep | -pkcs | -raw] [-out file] [-passin arg]\n" + " [-oaep | -pkcs | -raw | -x931] [-out file] [-passin arg]\n" " [-pubin] [-rev] [-sign] [-verify]\n\n"); options_usage(rsautl_options); -- 2.20.1