1RSA(1) OpenSSL RSA(1)
2
3
4
6 rsa - RSA key processing tool
7
9 openssl rsa [-inform PEM⎪NET⎪DER] [-outform PEM⎪NET⎪DER] [-in filename]
10 [-passin arg] [-out filename] [-passout arg] [-sgckey] [-des] [-des3]
11 [-idea] [-text] [-noout] [-modulus] [-check] [-pubin] [-pubout]
12 [-engine id]
13
15 The rsa command processes RSA keys. They can be converted between vari‐
16 ous forms and their components printed out. Note this command uses the
17 traditional SSLeay compatible format for private key encryption: newer
18 applications should use the more secure PKCS#8 format using the pkcs8
19 utility.
20
22 -inform DER⎪NET⎪PEM
23 This specifies the input format. The DER option uses an ASN1 DER
24 encoded form compatible with the PKCS#1 RSAPrivateKey or Subject‐
25 PublicKeyInfo format. The PEM form is the default format: it con‐
26 sists of the DER format base64 encoded with additional header and
27 footer lines. On input PKCS#8 format private keys are also
28 accepted. The NET form is a format is described in the NOTES sec‐
29 tion.
30
31 -outform DER⎪NET⎪PEM
32 This specifies the output format, the options have the same meaning
33 as the -inform option.
34
35 -in filename
36 This specifies the input filename to read a key from or standard
37 input if this option is not specified. If the key is encrypted a
38 pass phrase will be prompted for.
39
40 -passin arg
41 the input file password source. For more information about the for‐
42 mat of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
43
44 -out filename
45 This specifies the output filename to write a key to or standard
46 output if this option is not specified. If any encryption options
47 are set then a pass phrase will be prompted for. The output file‐
48 name should not be the same as the input filename.
49
50 -passout password
51 the output file password source. For more information about the
52 format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
53
54 -sgckey
55 use the modified NET algorithm used with some versions of Microsoft
56 IIS and SGC keys.
57
58 -des⎪-des3⎪-idea
59 These options encrypt the private key with the DES, triple DES, or
60 the IDEA ciphers respectively before outputting it. A pass phrase
61 is prompted for. If none of these options is specified the key is
62 written in plain text. This means that using the rsa utility to
63 read in an encrypted key with no encryption option can be used to
64 remove the pass phrase from a key, or by setting the encryption
65 options it can be use to add or change the pass phrase. These
66 options can only be used with PEM format output files.
67
68 -text
69 prints out the various public or private key components in plain
70 text in addition to the encoded version.
71
72 -noout
73 this option prevents output of the encoded version of the key.
74
75 -modulus
76 this option prints out the value of the modulus of the key.
77
78 -check
79 this option checks the consistency of an RSA private key.
80
81 -pubin
82 by default a private key is read from the input file: with this
83 option a public key is read instead.
84
85 -pubout
86 by default a private key is output: with this option a public key
87 will be output instead. This option is automatically set if the
88 input is a public key.
89
90 -engine id
91 specifying an engine (by it's unique id string) will cause req to
92 attempt to obtain a functional reference to the specified engine,
93 thus initialising it if needed. The engine will then be set as the
94 default for all available algorithms.
95
97 The PEM private key format uses the header and footer lines:
98
99 -----BEGIN RSA PRIVATE KEY-----
100 -----END RSA PRIVATE KEY-----
101
102 The PEM public key format uses the header and footer lines:
103
104 -----BEGIN PUBLIC KEY-----
105 -----END PUBLIC KEY-----
106
107 The NET form is a format compatible with older Netscape servers and Mi‐
108 crosoft IIS .key files, this uses unsalted RC4 for its encryption. It
109 is not very secure and so should only be used when necessary.
110
111 Some newer version of IIS have additional data in the exported .key
112 files. To use these with the utility, view the file with a binary edi‐
113 tor and look for the string "private-key", then trace back to the byte
114 sequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data from
115 this point onwards to another file and use that as the input to the rsa
116 utility with the -inform NET option. If you get an error after entering
117 the password try the -sgckey option.
118
120 To remove the pass phrase on an RSA private key:
121
122 openssl rsa -in key.pem -out keyout.pem
123
124 To encrypt a private key using triple DES:
125
126 openssl rsa -in key.pem -des3 -out keyout.pem
127
128 To convert a private key from PEM to DER format:
129
130 openssl rsa -in key.pem -outform DER -out keyout.der
131
132 To print out the components of a private key to standard output:
133
134 openssl rsa -in key.pem -text -noout
135
136 To just output the public part of a private key:
137
138 openssl rsa -in key.pem -pubout -out pubkey.pem
139
141 The command line password arguments don't currently work with NET for‐
142 mat.
143
144 There should be an option that automatically handles .key files, with‐
145 out having to manually edit them.
146
148 pkcs8(1), dsa(1), genrsa(1), gendsa(1)
149
150
151
1520.9.8b 2003-01-30 RSA(1)