1ebfedea0SLionel Sambuc 2ebfedea0SLionel Sambuc=pod 3ebfedea0SLionel Sambuc 4ebfedea0SLionel Sambuc=head1 NAME 5ebfedea0SLionel Sambuc 6ebfedea0SLionel Sambucrsa - RSA key processing tool 7ebfedea0SLionel Sambuc 8ebfedea0SLionel Sambuc=head1 SYNOPSIS 9ebfedea0SLionel Sambuc 10ebfedea0SLionel SambucB<openssl> B<rsa> 11ebfedea0SLionel Sambuc[B<-inform PEM|NET|DER>] 12ebfedea0SLionel Sambuc[B<-outform PEM|NET|DER>] 13ebfedea0SLionel Sambuc[B<-in filename>] 14ebfedea0SLionel Sambuc[B<-passin arg>] 15ebfedea0SLionel Sambuc[B<-out filename>] 16ebfedea0SLionel Sambuc[B<-passout arg>] 17ebfedea0SLionel Sambuc[B<-sgckey>] 18*0a6a1f1dSLionel Sambuc[B<-aes128>] 19*0a6a1f1dSLionel Sambuc[B<-aes192>] 20*0a6a1f1dSLionel Sambuc[B<-aes256>] 21*0a6a1f1dSLionel Sambuc[B<-camellia128>] 22*0a6a1f1dSLionel Sambuc[B<-camellia192>] 23*0a6a1f1dSLionel Sambuc[B<-camellia256>] 24ebfedea0SLionel Sambuc[B<-des>] 25ebfedea0SLionel Sambuc[B<-des3>] 26ebfedea0SLionel Sambuc[B<-idea>] 27ebfedea0SLionel Sambuc[B<-text>] 28ebfedea0SLionel Sambuc[B<-noout>] 29ebfedea0SLionel Sambuc[B<-modulus>] 30ebfedea0SLionel Sambuc[B<-check>] 31ebfedea0SLionel Sambuc[B<-pubin>] 32ebfedea0SLionel Sambuc[B<-pubout>] 33*0a6a1f1dSLionel Sambuc[B<-RSAPublicKey_in>] 34*0a6a1f1dSLionel Sambuc[B<-RSAPublicKey_out>] 35ebfedea0SLionel Sambuc[B<-engine id>] 36ebfedea0SLionel Sambuc 37ebfedea0SLionel Sambuc=head1 DESCRIPTION 38ebfedea0SLionel Sambuc 39ebfedea0SLionel SambucThe B<rsa> command processes RSA keys. They can be converted between various 40ebfedea0SLionel Sambucforms and their components printed out. B<Note> this command uses the 41ebfedea0SLionel Sambuctraditional SSLeay compatible format for private key encryption: newer 42ebfedea0SLionel Sambucapplications should use the more secure PKCS#8 format using the B<pkcs8> 43ebfedea0SLionel Sambucutility. 44ebfedea0SLionel Sambuc 45ebfedea0SLionel Sambuc=head1 COMMAND OPTIONS 46ebfedea0SLionel Sambuc 47ebfedea0SLionel Sambuc=over 4 48ebfedea0SLionel Sambuc 49ebfedea0SLionel Sambuc=item B<-inform DER|NET|PEM> 50ebfedea0SLionel Sambuc 51ebfedea0SLionel SambucThis specifies the input format. The B<DER> option uses an ASN1 DER encoded 52ebfedea0SLionel Sambucform compatible with the PKCS#1 RSAPrivateKey or SubjectPublicKeyInfo format. 53ebfedea0SLionel SambucThe B<PEM> form is the default format: it consists of the B<DER> format base64 54ebfedea0SLionel Sambucencoded with additional header and footer lines. On input PKCS#8 format private 55ebfedea0SLionel Sambuckeys are also accepted. The B<NET> form is a format is described in the B<NOTES> 56ebfedea0SLionel Sambucsection. 57ebfedea0SLionel Sambuc 58ebfedea0SLionel Sambuc=item B<-outform DER|NET|PEM> 59ebfedea0SLionel Sambuc 60ebfedea0SLionel SambucThis specifies the output format, the options have the same meaning as the 61ebfedea0SLionel SambucB<-inform> option. 62ebfedea0SLionel Sambuc 63ebfedea0SLionel Sambuc=item B<-in filename> 64ebfedea0SLionel Sambuc 65ebfedea0SLionel SambucThis specifies the input filename to read a key from or standard input if this 66ebfedea0SLionel Sambucoption is not specified. If the key is encrypted a pass phrase will be 67ebfedea0SLionel Sambucprompted for. 68ebfedea0SLionel Sambuc 69ebfedea0SLionel Sambuc=item B<-passin arg> 70ebfedea0SLionel Sambuc 71ebfedea0SLionel Sambucthe input file password source. For more information about the format of B<arg> 72ebfedea0SLionel Sambucsee the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 73ebfedea0SLionel Sambuc 74ebfedea0SLionel Sambuc=item B<-out filename> 75ebfedea0SLionel Sambuc 76ebfedea0SLionel SambucThis specifies the output filename to write a key to or standard output if this 77ebfedea0SLionel Sambucoption is not specified. If any encryption options are set then a pass phrase 78ebfedea0SLionel Sambucwill be prompted for. The output filename should B<not> be the same as the input 79ebfedea0SLionel Sambucfilename. 80ebfedea0SLionel Sambuc 81ebfedea0SLionel Sambuc=item B<-passout password> 82ebfedea0SLionel Sambuc 83ebfedea0SLionel Sambucthe output file password source. For more information about the format of B<arg> 84ebfedea0SLionel Sambucsee the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 85ebfedea0SLionel Sambuc 86ebfedea0SLionel Sambuc=item B<-sgckey> 87ebfedea0SLionel Sambuc 88ebfedea0SLionel Sambucuse the modified NET algorithm used with some versions of Microsoft IIS and SGC 89ebfedea0SLionel Sambuckeys. 90ebfedea0SLionel Sambuc 91*0a6a1f1dSLionel Sambuc=item B<-aes128|-aes192|-aes256|-camellia128|-camellia192|-camellia256|-des|-des3|-idea> 92ebfedea0SLionel Sambuc 93*0a6a1f1dSLionel SambucThese options encrypt the private key with the specified 94*0a6a1f1dSLionel Sambuccipher before outputting it. A pass phrase is prompted for. 95ebfedea0SLionel SambucIf none of these options is specified the key is written in plain text. This 96ebfedea0SLionel Sambucmeans that using the B<rsa> utility to read in an encrypted key with no 97ebfedea0SLionel Sambucencryption option can be used to remove the pass phrase from a key, or by 98ebfedea0SLionel Sambucsetting the encryption options it can be use to add or change the pass phrase. 99ebfedea0SLionel SambucThese options can only be used with PEM format output files. 100ebfedea0SLionel Sambuc 101ebfedea0SLionel Sambuc=item B<-text> 102ebfedea0SLionel Sambuc 103ebfedea0SLionel Sambucprints out the various public or private key components in 104ebfedea0SLionel Sambucplain text in addition to the encoded version. 105ebfedea0SLionel Sambuc 106ebfedea0SLionel Sambuc=item B<-noout> 107ebfedea0SLionel Sambuc 108ebfedea0SLionel Sambucthis option prevents output of the encoded version of the key. 109ebfedea0SLionel Sambuc 110ebfedea0SLionel Sambuc=item B<-modulus> 111ebfedea0SLionel Sambuc 112ebfedea0SLionel Sambucthis option prints out the value of the modulus of the key. 113ebfedea0SLionel Sambuc 114ebfedea0SLionel Sambuc=item B<-check> 115ebfedea0SLionel Sambuc 116ebfedea0SLionel Sambucthis option checks the consistency of an RSA private key. 117ebfedea0SLionel Sambuc 118ebfedea0SLionel Sambuc=item B<-pubin> 119ebfedea0SLionel Sambuc 120ebfedea0SLionel Sambucby default a private key is read from the input file: with this 121ebfedea0SLionel Sambucoption a public key is read instead. 122ebfedea0SLionel Sambuc 123ebfedea0SLionel Sambuc=item B<-pubout> 124ebfedea0SLionel Sambuc 125ebfedea0SLionel Sambucby default a private key is output: with this option a public 126ebfedea0SLionel Sambuckey will be output instead. This option is automatically set if 127ebfedea0SLionel Sambucthe input is a public key. 128ebfedea0SLionel Sambuc 129*0a6a1f1dSLionel Sambuc=item B<-RSAPublicKey_in>, B<-RSAPublicKey_out> 130*0a6a1f1dSLionel Sambuc 131*0a6a1f1dSLionel Sambuclike B<-pubin> and B<-pubout> except B<RSAPublicKey> format is used instead. 132*0a6a1f1dSLionel Sambuc 133ebfedea0SLionel Sambuc=item B<-engine id> 134ebfedea0SLionel Sambuc 135ebfedea0SLionel Sambucspecifying an engine (by its unique B<id> string) will cause B<rsa> 136ebfedea0SLionel Sambucto attempt to obtain a functional reference to the specified engine, 137ebfedea0SLionel Sambucthus initialising it if needed. The engine will then be set as the default 138ebfedea0SLionel Sambucfor all available algorithms. 139ebfedea0SLionel Sambuc 140ebfedea0SLionel Sambuc=back 141ebfedea0SLionel Sambuc 142ebfedea0SLionel Sambuc=head1 NOTES 143ebfedea0SLionel Sambuc 144ebfedea0SLionel SambucThe PEM private key format uses the header and footer lines: 145ebfedea0SLionel Sambuc 146ebfedea0SLionel Sambuc -----BEGIN RSA PRIVATE KEY----- 147ebfedea0SLionel Sambuc -----END RSA PRIVATE KEY----- 148ebfedea0SLionel Sambuc 149ebfedea0SLionel SambucThe PEM public key format uses the header and footer lines: 150ebfedea0SLionel Sambuc 151ebfedea0SLionel Sambuc -----BEGIN PUBLIC KEY----- 152ebfedea0SLionel Sambuc -----END PUBLIC KEY----- 153ebfedea0SLionel Sambuc 154*0a6a1f1dSLionel SambucThe PEM B<RSAPublicKey> format uses the header and footer lines: 155*0a6a1f1dSLionel Sambuc 156*0a6a1f1dSLionel Sambuc -----BEGIN RSA PUBLIC KEY----- 157*0a6a1f1dSLionel Sambuc -----END RSA PUBLIC KEY----- 158*0a6a1f1dSLionel Sambuc 159ebfedea0SLionel SambucThe B<NET> form is a format compatible with older Netscape servers 160ebfedea0SLionel Sambucand Microsoft IIS .key files, this uses unsalted RC4 for its encryption. 161ebfedea0SLionel SambucIt is not very secure and so should only be used when necessary. 162ebfedea0SLionel Sambuc 163ebfedea0SLionel SambucSome newer version of IIS have additional data in the exported .key 164ebfedea0SLionel Sambucfiles. To use these with the utility, view the file with a binary editor 165ebfedea0SLionel Sambucand look for the string "private-key", then trace back to the byte 166ebfedea0SLionel Sambucsequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data 167ebfedea0SLionel Sambucfrom this point onwards to another file and use that as the input 168ebfedea0SLionel Sambucto the B<rsa> utility with the B<-inform NET> option. If you get 169ebfedea0SLionel Sambucan error after entering the password try the B<-sgckey> option. 170ebfedea0SLionel Sambuc 171ebfedea0SLionel Sambuc=head1 EXAMPLES 172ebfedea0SLionel Sambuc 173ebfedea0SLionel SambucTo remove the pass phrase on an RSA private key: 174ebfedea0SLionel Sambuc 175ebfedea0SLionel Sambuc openssl rsa -in key.pem -out keyout.pem 176ebfedea0SLionel Sambuc 177ebfedea0SLionel SambucTo encrypt a private key using triple DES: 178ebfedea0SLionel Sambuc 179ebfedea0SLionel Sambuc openssl rsa -in key.pem -des3 -out keyout.pem 180ebfedea0SLionel Sambuc 181ebfedea0SLionel SambucTo convert a private key from PEM to DER format: 182ebfedea0SLionel Sambuc 183ebfedea0SLionel Sambuc openssl rsa -in key.pem -outform DER -out keyout.der 184ebfedea0SLionel Sambuc 185ebfedea0SLionel SambucTo print out the components of a private key to standard output: 186ebfedea0SLionel Sambuc 187ebfedea0SLionel Sambuc openssl rsa -in key.pem -text -noout 188ebfedea0SLionel Sambuc 189ebfedea0SLionel SambucTo just output the public part of a private key: 190ebfedea0SLionel Sambuc 191ebfedea0SLionel Sambuc openssl rsa -in key.pem -pubout -out pubkey.pem 192ebfedea0SLionel Sambuc 193*0a6a1f1dSLionel SambucOutput the public part of a private key in B<RSAPublicKey> format: 194*0a6a1f1dSLionel Sambuc 195*0a6a1f1dSLionel Sambuc openssl rsa -in key.pem -RSAPublicKey_out -out pubkey.pem 196*0a6a1f1dSLionel Sambuc 197ebfedea0SLionel Sambuc=head1 BUGS 198ebfedea0SLionel Sambuc 199ebfedea0SLionel SambucThe command line password arguments don't currently work with 200ebfedea0SLionel SambucB<NET> format. 201ebfedea0SLionel Sambuc 202ebfedea0SLionel SambucThere should be an option that automatically handles .key files, 203ebfedea0SLionel Sambucwithout having to manually edit them. 204ebfedea0SLionel Sambuc 205ebfedea0SLionel Sambuc=head1 SEE ALSO 206ebfedea0SLionel Sambuc 207ebfedea0SLionel SambucL<pkcs8(1)|pkcs8(1)>, L<dsa(1)|dsa(1)>, L<genrsa(1)|genrsa(1)>, 208ebfedea0SLionel SambucL<gendsa(1)|gendsa(1)> 209ebfedea0SLionel Sambuc 210ebfedea0SLionel Sambuc=cut 211