1RSA(1)                              OpenSSL                             RSA(1)
2
3
4

NAME

6       rsa - RSA key processing tool
7

SYNOPSIS

9       openssl rsa [-inform PEM|NET|DER] [-outform PEM|NET|DER] [-in filename]
10       [-passin arg] [-out filename] [-passout arg] [-sgckey] [-aes128]
11       [-aes192] [-aes256] [-camellia128] [-camellia192] [-camellia256] [-des]
12       [-des3] [-idea] [-text] [-noout] [-modulus] [-check] [-pubin] [-pubout]
13       [-RSAPublicKey_in] [-RSAPublicKey_out] [-engine id]
14

DESCRIPTION

16       The rsa command processes RSA keys. They can be converted between
17       various forms and their components printed out. Note this command uses
18       the traditional SSLeay compatible format for private key encryption:
19       newer applications should use the more secure PKCS#8 format using the
20       pkcs8 utility.
21

COMMAND OPTIONS

23       -inform DER|NET|PEM
24           This specifies the input format. The DER option uses an ASN1 DER
25           encoded form compatible with the PKCS#1 RSAPrivateKey or
26           SubjectPublicKeyInfo format.  The PEM form is the default format:
27           it consists of the DER format base64 encoded with additional header
28           and footer lines. On input PKCS#8 format private keys are also
29           accepted. The NET form is a format is described in the NOTES
30           section.
31
32       -outform DER|NET|PEM
33           This specifies the output format, the options have the same meaning
34           as the -inform option.
35
36       -in filename
37           This specifies the input filename to read a key from or standard
38           input if this option is not specified. If the key is encrypted a
39           pass phrase will be prompted for.
40
41       -passin arg
42           the input file password source. For more information about the
43           format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
44
45       -out filename
46           This specifies the output filename to write a key to or standard
47           output if this option is not specified. If any encryption options
48           are set then a pass phrase will be prompted for. The output
49           filename should not be the same as the input filename.
50
51       -passout password
52           the output file password source. For more information about the
53           format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
54
55       -sgckey
56           use the modified NET algorithm used with some versions of Microsoft
57           IIS and SGC keys.
58
59       -aes128|-aes192|-aes256|-camellia128|-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

NOTES

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
116       The NET form is a format compatible with older Netscape servers and
117       Microsoft IIS .key files, this uses unsalted RC4 for its encryption.
118       It is not very secure and so should only be used when necessary.
119
120       Some newer version of IIS have additional data in the exported .key
121       files. To use these with the utility, view the file with a binary
122       editor and look for the string "private-key", then trace back to the
123       byte sequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data
124       from this point onwards to another file and use that as the input to
125       the rsa utility with the -inform NET option. If you get an error after
126       entering the password try the -sgckey option.
127

EXAMPLES

129       To remove the pass phrase on an RSA private key:
130
131        openssl rsa -in key.pem -out keyout.pem
132
133       To encrypt a private key using triple DES:
134
135        openssl rsa -in key.pem -des3 -out keyout.pem
136
137       To convert a private key from PEM to DER format:
138
139        openssl rsa -in key.pem -outform DER -out keyout.der
140
141       To print out the components of a private key to standard output:
142
143        openssl rsa -in key.pem -text -noout
144
145       To just output the public part of a private key:
146
147        openssl rsa -in key.pem -pubout -out pubkey.pem
148
149       Output the public part of a private key in RSAPublicKey format:
150
151        openssl rsa -in key.pem -RSAPublicKey_out -out pubkey.pem
152

BUGS

154       The command line password arguments don't currently work with NET
155       format.
156
157       There should be an option that automatically handles .key files,
158       without having to manually edit them.
159

SEE ALSO

161       pkcs8(1), dsa(1), genrsa(1), gendsa(1)
162
163
164
1651.0.2k                            2017-01-26                            RSA(1)
Impressum