1*2175Sjp161948 2*2175Sjp161948=pod 3*2175Sjp161948 4*2175Sjp161948=head1 NAME 5*2175Sjp161948 6*2175Sjp161948rsa - RSA key processing tool 7*2175Sjp161948 8*2175Sjp161948=head1 SYNOPSIS 9*2175Sjp161948 10*2175Sjp161948B<openssl> B<rsa> 11*2175Sjp161948[B<-inform PEM|NET|DER>] 12*2175Sjp161948[B<-outform PEM|NET|DER>] 13*2175Sjp161948[B<-in filename>] 14*2175Sjp161948[B<-passin arg>] 15*2175Sjp161948[B<-out filename>] 16*2175Sjp161948[B<-passout arg>] 17*2175Sjp161948[B<-sgckey>] 18*2175Sjp161948[B<-des>] 19*2175Sjp161948[B<-des3>] 20*2175Sjp161948[B<-idea>] 21*2175Sjp161948[B<-text>] 22*2175Sjp161948[B<-noout>] 23*2175Sjp161948[B<-modulus>] 24*2175Sjp161948[B<-check>] 25*2175Sjp161948[B<-pubin>] 26*2175Sjp161948[B<-pubout>] 27*2175Sjp161948[B<-engine id>] 28*2175Sjp161948 29*2175Sjp161948=head1 DESCRIPTION 30*2175Sjp161948 31*2175Sjp161948The B<rsa> command processes RSA keys. They can be converted between various 32*2175Sjp161948forms and their components printed out. B<Note> this command uses the 33*2175Sjp161948traditional SSLeay compatible format for private key encryption: newer 34*2175Sjp161948applications should use the more secure PKCS#8 format using the B<pkcs8> 35*2175Sjp161948utility. 36*2175Sjp161948 37*2175Sjp161948=head1 COMMAND OPTIONS 38*2175Sjp161948 39*2175Sjp161948=over 4 40*2175Sjp161948 41*2175Sjp161948=item B<-inform DER|NET|PEM> 42*2175Sjp161948 43*2175Sjp161948This specifies the input format. The B<DER> option uses an ASN1 DER encoded 44*2175Sjp161948form compatible with the PKCS#1 RSAPrivateKey or SubjectPublicKeyInfo format. 45*2175Sjp161948The B<PEM> form is the default format: it consists of the B<DER> format base64 46*2175Sjp161948encoded with additional header and footer lines. On input PKCS#8 format private 47*2175Sjp161948keys are also accepted. The B<NET> form is a format is described in the B<NOTES> 48*2175Sjp161948section. 49*2175Sjp161948 50*2175Sjp161948=item B<-outform DER|NET|PEM> 51*2175Sjp161948 52*2175Sjp161948This specifies the output format, the options have the same meaning as the 53*2175Sjp161948B<-inform> option. 54*2175Sjp161948 55*2175Sjp161948=item B<-in filename> 56*2175Sjp161948 57*2175Sjp161948This specifies the input filename to read a key from or standard input if this 58*2175Sjp161948option is not specified. If the key is encrypted a pass phrase will be 59*2175Sjp161948prompted for. 60*2175Sjp161948 61*2175Sjp161948=item B<-passin arg> 62*2175Sjp161948 63*2175Sjp161948the input file password source. For more information about the format of B<arg> 64*2175Sjp161948see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 65*2175Sjp161948 66*2175Sjp161948=item B<-out filename> 67*2175Sjp161948 68*2175Sjp161948This specifies the output filename to write a key to or standard output if this 69*2175Sjp161948option is not specified. If any encryption options are set then a pass phrase 70*2175Sjp161948will be prompted for. The output filename should B<not> be the same as the input 71*2175Sjp161948filename. 72*2175Sjp161948 73*2175Sjp161948=item B<-passout password> 74*2175Sjp161948 75*2175Sjp161948the output file password source. For more information about the format of B<arg> 76*2175Sjp161948see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 77*2175Sjp161948 78*2175Sjp161948=item B<-sgckey> 79*2175Sjp161948 80*2175Sjp161948use the modified NET algorithm used with some versions of Microsoft IIS and SGC 81*2175Sjp161948keys. 82*2175Sjp161948 83*2175Sjp161948=item B<-des|-des3|-idea> 84*2175Sjp161948 85*2175Sjp161948These options encrypt the private key with the DES, triple DES, or the 86*2175Sjp161948IDEA ciphers respectively before outputting it. A pass phrase is prompted for. 87*2175Sjp161948If none of these options is specified the key is written in plain text. This 88*2175Sjp161948means that using the B<rsa> utility to read in an encrypted key with no 89*2175Sjp161948encryption option can be used to remove the pass phrase from a key, or by 90*2175Sjp161948setting the encryption options it can be use to add or change the pass phrase. 91*2175Sjp161948These options can only be used with PEM format output files. 92*2175Sjp161948 93*2175Sjp161948=item B<-text> 94*2175Sjp161948 95*2175Sjp161948prints out the various public or private key components in 96*2175Sjp161948plain text in addition to the encoded version. 97*2175Sjp161948 98*2175Sjp161948=item B<-noout> 99*2175Sjp161948 100*2175Sjp161948this option prevents output of the encoded version of the key. 101*2175Sjp161948 102*2175Sjp161948=item B<-modulus> 103*2175Sjp161948 104*2175Sjp161948this option prints out the value of the modulus of the key. 105*2175Sjp161948 106*2175Sjp161948=item B<-check> 107*2175Sjp161948 108*2175Sjp161948this option checks the consistency of an RSA private key. 109*2175Sjp161948 110*2175Sjp161948=item B<-pubin> 111*2175Sjp161948 112*2175Sjp161948by default a private key is read from the input file: with this 113*2175Sjp161948option a public key is read instead. 114*2175Sjp161948 115*2175Sjp161948=item B<-pubout> 116*2175Sjp161948 117*2175Sjp161948by default a private key is output: with this option a public 118*2175Sjp161948key will be output instead. This option is automatically set if 119*2175Sjp161948the input is a public key. 120*2175Sjp161948 121*2175Sjp161948=item B<-engine id> 122*2175Sjp161948 123*2175Sjp161948specifying an engine (by it's unique B<id> string) will cause B<req> 124*2175Sjp161948to attempt to obtain a functional reference to the specified engine, 125*2175Sjp161948thus initialising it if needed. The engine will then be set as the default 126*2175Sjp161948for all available algorithms. 127*2175Sjp161948 128*2175Sjp161948=back 129*2175Sjp161948 130*2175Sjp161948=head1 NOTES 131*2175Sjp161948 132*2175Sjp161948The PEM private key format uses the header and footer lines: 133*2175Sjp161948 134*2175Sjp161948 -----BEGIN RSA PRIVATE KEY----- 135*2175Sjp161948 -----END RSA PRIVATE KEY----- 136*2175Sjp161948 137*2175Sjp161948The PEM public key format uses the header and footer lines: 138*2175Sjp161948 139*2175Sjp161948 -----BEGIN PUBLIC KEY----- 140*2175Sjp161948 -----END PUBLIC KEY----- 141*2175Sjp161948 142*2175Sjp161948The B<NET> form is a format compatible with older Netscape servers 143*2175Sjp161948and Microsoft IIS .key files, this uses unsalted RC4 for its encryption. 144*2175Sjp161948It is not very secure and so should only be used when necessary. 145*2175Sjp161948 146*2175Sjp161948Some newer version of IIS have additional data in the exported .key 147*2175Sjp161948files. To use these with the utility, view the file with a binary editor 148*2175Sjp161948and look for the string "private-key", then trace back to the byte 149*2175Sjp161948sequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data 150*2175Sjp161948from this point onwards to another file and use that as the input 151*2175Sjp161948to the B<rsa> utility with the B<-inform NET> option. If you get 152*2175Sjp161948an error after entering the password try the B<-sgckey> option. 153*2175Sjp161948 154*2175Sjp161948=head1 EXAMPLES 155*2175Sjp161948 156*2175Sjp161948To remove the pass phrase on an RSA private key: 157*2175Sjp161948 158*2175Sjp161948 openssl rsa -in key.pem -out keyout.pem 159*2175Sjp161948 160*2175Sjp161948To encrypt a private key using triple DES: 161*2175Sjp161948 162*2175Sjp161948 openssl rsa -in key.pem -des3 -out keyout.pem 163*2175Sjp161948 164*2175Sjp161948To convert a private key from PEM to DER format: 165*2175Sjp161948 166*2175Sjp161948 openssl rsa -in key.pem -outform DER -out keyout.der 167*2175Sjp161948 168*2175Sjp161948To print out the components of a private key to standard output: 169*2175Sjp161948 170*2175Sjp161948 openssl rsa -in key.pem -text -noout 171*2175Sjp161948 172*2175Sjp161948To just output the public part of a private key: 173*2175Sjp161948 174*2175Sjp161948 openssl rsa -in key.pem -pubout -out pubkey.pem 175*2175Sjp161948 176*2175Sjp161948=head1 BUGS 177*2175Sjp161948 178*2175Sjp161948The command line password arguments don't currently work with 179*2175Sjp161948B<NET> format. 180*2175Sjp161948 181*2175Sjp161948There should be an option that automatically handles .key files, 182*2175Sjp161948without having to manually edit them. 183*2175Sjp161948 184*2175Sjp161948=head1 SEE ALSO 185*2175Sjp161948 186*2175Sjp161948L<pkcs8(1)|pkcs8(1)>, L<dsa(1)|dsa(1)>, L<genrsa(1)|genrsa(1)>, 187*2175Sjp161948L<gendsa(1)|gendsa(1)> 188*2175Sjp161948 189*2175Sjp161948=cut 190