1RSA(1) OpenSSL RSA(1)
2
3
4
6 openssl-rsa, rsa - RSA key processing tool
7
9 openssl rsa [-help] [-inform PEM|DER] [-outform PEM|DER] [-in filename]
10 [-passin arg] [-out filename] [-passout arg] [-aes128] [-aes192]
11 [-aes256] [-aria128] [-aria192] [-aria256] [-camellia128]
12 [-camellia192] [-camellia256] [-des] [-des3] [-idea] [-text] [-noout]
13 [-modulus] [-check] [-pubin] [-pubout] [-RSAPublicKey_in]
14 [-RSAPublicKey_out] [-engine id]
15
17 The rsa command processes RSA keys. They can be converted between
18 various forms and their components printed out. Note this command uses
19 the traditional SSLeay compatible format for private key encryption:
20 newer applications should use the more secure PKCS#8 format using the
21 pkcs8 utility.
22
24 -help
25 Print out a usage message.
26
27 -inform DER|PEM
28 This specifies the input format. The DER option uses an ASN1 DER
29 encoded form compatible with the PKCS#1 RSAPrivateKey or
30 SubjectPublicKeyInfo format. The PEM form is the default format:
31 it consists of the DER format base64 encoded with additional header
32 and footer lines. On input PKCS#8 format private keys are also
33 accepted.
34
35 -outform DER|PEM
36 This specifies the output format, the options have the same meaning
37 and default as the -inform option.
38
39 -in filename
40 This specifies the input filename to read a key from or standard
41 input if this option is not specified. If the key is encrypted a
42 pass phrase will be prompted for.
43
44 -passin arg
45 The input file password source. For more information about the
46 format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
47
48 -out filename
49 This specifies the output filename to write a key to or standard
50 output if this option is not specified. If any encryption options
51 are set then a pass phrase will be prompted for. The output
52 filename should not be the same as the input filename.
53
54 -passout password
55 The output file password source. For more information about the
56 format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
57
58 -aes128, -aes192, -aes256, -aria128, -aria192, -aria256, -camellia128,
59 -camellia192, -camellia256, -des, -des3, -idea
60 These options encrypt the private key with the specified cipher
61 before outputting it. A pass phrase is prompted for. If none of
62 these options is specified the key is written in plain text. This
63 means that using the rsa utility to read in an encrypted key with
64 no encryption option can be used to remove the pass phrase from a
65 key, or by setting the encryption options it can be use to add or
66 change the pass phrase. These options can only be used with PEM
67 format output files.
68
69 -text
70 Prints out the various public or private key components in plain
71 text in addition to the encoded version.
72
73 -noout
74 This option prevents output of the encoded version of the key.
75
76 -modulus
77 This option prints out the value of the modulus of the key.
78
79 -check
80 This option checks the consistency of an RSA private key.
81
82 -pubin
83 By default a private key is read from the input file: with this
84 option a public key is read instead.
85
86 -pubout
87 By default a private key is output: with this option a public key
88 will be output instead. This option is automatically set if the
89 input is a public key.
90
91 -RSAPublicKey_in, -RSAPublicKey_out
92 Like -pubin and -pubout except RSAPublicKey format is used instead.
93
94 -engine id
95 Specifying an engine (by its unique id string) will cause rsa to
96 attempt to obtain a functional reference to the specified engine,
97 thus initialising it if needed. The engine will then be set as the
98 default for all available algorithms.
99
101 The PEM private key format uses the header and footer lines:
102
103 -----BEGIN RSA PRIVATE KEY-----
104 -----END RSA PRIVATE KEY-----
105
106 The PEM public key format uses the header and footer lines:
107
108 -----BEGIN PUBLIC KEY-----
109 -----END PUBLIC KEY-----
110
111 The PEM RSAPublicKey format uses the header and footer lines:
112
113 -----BEGIN RSA PUBLIC KEY-----
114 -----END RSA PUBLIC KEY-----
115
117 To remove the pass phrase on an RSA private key:
118
119 openssl rsa -in key.pem -out keyout.pem
120
121 To encrypt a private key using triple DES:
122
123 openssl rsa -in key.pem -des3 -out keyout.pem
124
125 To convert a private key from PEM to DER format:
126
127 openssl rsa -in key.pem -outform DER -out keyout.der
128
129 To print out the components of a private key to standard output:
130
131 openssl rsa -in key.pem -text -noout
132
133 To just output the public part of a private key:
134
135 openssl rsa -in key.pem -pubout -out pubkey.pem
136
137 Output the public part of a private key in RSAPublicKey format:
138
139 openssl rsa -in key.pem -RSAPublicKey_out -out pubkey.pem
140
142 There should be an option that automatically handles .key files,
143 without having to manually edit them.
144
146 pkcs8(1), dsa(1), genrsa(1), gendsa(1)
147
149 Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
150
151 Licensed under the OpenSSL license (the "License"). You may not use
152 this file except in compliance with the License. You can obtain a copy
153 in the file LICENSE in the source distribution or at
154 <https://www.openssl.org/source/license.html>.
155
156
157
1581.1.1g 2020-04-23 RSA(1)