1OPENSSL-RSAUTL(1ossl) OpenSSL OPENSSL-RSAUTL(1ossl)
2
3
4
6 openssl-rsautl - RSA command
7
9 openssl rsautl [-help] [-in file] [-passin arg] [-rev] [-out file]
10 [-inkey filename|uri] [-keyform DER|PEM|P12|ENGINE] [-pubin] [-certin]
11 [-sign] [-verify] [-encrypt] [-decrypt] [-pkcs] [-x931] [-oaep] [-raw]
12 [-hexdump] [-asn1parse] [-engine id] [-rand files] [-writerand file]
13 [-provider name] [-provider-path path] [-propquery propq]
14
16 This command has been deprecated. The openssl-pkeyutl(1) command
17 should be used instead.
18
19 This command can be used to sign, verify, encrypt and decrypt data
20 using the RSA algorithm.
21
23 -help
24 Print out a usage message.
25
26 -in filename
27 This specifies the input filename to read data from or standard
28 input if this option is not specified.
29
30 -passin arg
31 The passphrase used in the output file. See see
32 openssl-passphrase-options(1).
33
34 -rev
35 Reverse the order of the input.
36
37 -out filename
38 Specifies the output filename to write to or standard output by
39 default.
40
41 -inkey filename|uri
42 The input key, by default it should be an RSA private key.
43
44 -keyform DER|PEM|P12|ENGINE
45 The key format; unspecified by default. See
46 openssl-format-options(1) for details.
47
48 -pubin
49 The input file is an RSA public key.
50
51 -certin
52 The input is a certificate containing an RSA public key.
53
54 -sign
55 Sign the input data and output the signed result. This requires an
56 RSA private key.
57
58 -verify
59 Verify the input data and output the recovered data.
60
61 -encrypt
62 Encrypt the input data using an RSA public key.
63
64 -decrypt
65 Decrypt the input data using an RSA private key.
66
67 -pkcs, -oaep, -x931 -raw
68 The padding to use: PKCS#1 v1.5 (the default), PKCS#1 OAEP, ANSI
69 X9.31, or no padding, respectively. For signatures, only -pkcs and
70 -raw can be used.
71
72 -hexdump
73 Hex dump the output data.
74
75 -asn1parse
76 Parse the ASN.1 output data, this is useful when combined with the
77 -verify option.
78
79 -engine id
80 See "Engine Options" in openssl(1). This option is deprecated.
81
82 -rand files, -writerand file
83 See "Random State Options" in openssl(1) for details.
84
85 -provider name
86 -provider-path path
87 -propquery propq
88 See "Provider Options" in openssl(1), provider(7), and property(7).
89
91 Since this command uses the RSA algorithm directly, it can only be used
92 to sign or verify small pieces of data.
93
95 Examples equivalent to these can be found in the documentation for the
96 non-deprecated openssl-pkeyutl(1) command.
97
98 Sign some data using a private key:
99
100 openssl rsautl -sign -in file -inkey key.pem -out sig
101
102 Recover the signed data
103
104 openssl rsautl -verify -in sig -inkey key.pem
105
106 Examine the raw signed data:
107
108 openssl rsautl -verify -in sig -inkey key.pem -raw -hexdump
109
110 0000 - 00 01 ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
111 0010 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
112 0020 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
113 0030 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
114 0040 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
115 0050 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
116 0060 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
117 0070 - ff ff ff ff 00 68 65 6c-6c 6f 20 77 6f 72 6c 64 .....hello world
118
119 The PKCS#1 block formatting is evident from this. If this was done
120 using encrypt and decrypt the block would have been of type 2 (the
121 second byte) and random padding data visible instead of the 0xff bytes.
122
123 It is possible to analyse the signature of certificates using this
124 command in conjunction with openssl-asn1parse(1). Consider the self
125 signed example in certs/pca-cert.pem. Running openssl-asn1parse(1) as
126 follows yields:
127
128 openssl asn1parse -in pca-cert.pem
129
130 0:d=0 hl=4 l= 742 cons: SEQUENCE
131 4:d=1 hl=4 l= 591 cons: SEQUENCE
132 8:d=2 hl=2 l= 3 cons: cont [ 0 ]
133 10:d=3 hl=2 l= 1 prim: INTEGER :02
134 13:d=2 hl=2 l= 1 prim: INTEGER :00
135 16:d=2 hl=2 l= 13 cons: SEQUENCE
136 18:d=3 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption
137 29:d=3 hl=2 l= 0 prim: NULL
138 31:d=2 hl=2 l= 92 cons: SEQUENCE
139 33:d=3 hl=2 l= 11 cons: SET
140 35:d=4 hl=2 l= 9 cons: SEQUENCE
141 37:d=5 hl=2 l= 3 prim: OBJECT :countryName
142 42:d=5 hl=2 l= 2 prim: PRINTABLESTRING :AU
143 ....
144 599:d=1 hl=2 l= 13 cons: SEQUENCE
145 601:d=2 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption
146 612:d=2 hl=2 l= 0 prim: NULL
147 614:d=1 hl=3 l= 129 prim: BIT STRING
148
149 The final BIT STRING contains the actual signature. It can be extracted
150 with:
151
152 openssl asn1parse -in pca-cert.pem -out sig -noout -strparse 614
153
154 The certificate public key can be extracted with:
155
156 openssl x509 -in test/testx509.pem -pubkey -noout >pubkey.pem
157
158 The signature can be analysed with:
159
160 openssl rsautl -in sig -verify -asn1parse -inkey pubkey.pem -pubin
161
162 0:d=0 hl=2 l= 32 cons: SEQUENCE
163 2:d=1 hl=2 l= 12 cons: SEQUENCE
164 4:d=2 hl=2 l= 8 prim: OBJECT :md5
165 14:d=2 hl=2 l= 0 prim: NULL
166 16:d=1 hl=2 l= 16 prim: OCTET STRING
167 0000 - f3 46 9e aa 1a 4a 73 c9-37 ea 93 00 48 25 08 b5 .F...Js.7...H%..
168
169 This is the parsed version of an ASN1 DigestInfo structure. It can be
170 seen that the digest used was md5. The actual part of the certificate
171 that was signed can be extracted with:
172
173 openssl asn1parse -in pca-cert.pem -out tbs -noout -strparse 4
174
175 and its digest computed with:
176
177 openssl md5 -c tbs
178 MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
179
180 which it can be seen agrees with the recovered value above.
181
183 openssl(1), openssl-pkeyutl(1), openssl-dgst(1), openssl-rsa(1),
184 openssl-genrsa(1)
185
187 This command was deprecated in OpenSSL 3.0.
188
189 The -engine option was deprecated in OpenSSL 3.0.
190
192 Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
193
194 Licensed under the Apache License 2.0 (the "License"). You may not use
195 this file except in compliance with the License. You can obtain a copy
196 in the file LICENSE in the source distribution or at
197 <https://www.openssl.org/source/license.html>.
198
199
200
2013.0.5 2022-07-05 OPENSSL-RSAUTL(1ossl)