1*ebfedea0SLionel Sambuc=pod 2*ebfedea0SLionel Sambuc 3*ebfedea0SLionel Sambuc=head1 NAME 4*ebfedea0SLionel Sambuc 5*ebfedea0SLionel Sambucpkeyutl - public key algorithm utility 6*ebfedea0SLionel Sambuc 7*ebfedea0SLionel Sambuc=head1 SYNOPSIS 8*ebfedea0SLionel Sambuc 9*ebfedea0SLionel SambucB<openssl> B<pkeyutl> 10*ebfedea0SLionel Sambuc[B<-in file>] 11*ebfedea0SLionel Sambuc[B<-out file>] 12*ebfedea0SLionel Sambuc[B<-sigfile file>] 13*ebfedea0SLionel Sambuc[B<-inkey file>] 14*ebfedea0SLionel Sambuc[B<-keyform PEM|DER>] 15*ebfedea0SLionel Sambuc[B<-passin arg>] 16*ebfedea0SLionel Sambuc[B<-peerkey file>] 17*ebfedea0SLionel Sambuc[B<-peerform PEM|DER>] 18*ebfedea0SLionel Sambuc[B<-pubin>] 19*ebfedea0SLionel Sambuc[B<-certin>] 20*ebfedea0SLionel Sambuc[B<-rev>] 21*ebfedea0SLionel Sambuc[B<-sign>] 22*ebfedea0SLionel Sambuc[B<-verify>] 23*ebfedea0SLionel Sambuc[B<-verifyrecover>] 24*ebfedea0SLionel Sambuc[B<-encrypt>] 25*ebfedea0SLionel Sambuc[B<-decrypt>] 26*ebfedea0SLionel Sambuc[B<-derive>] 27*ebfedea0SLionel Sambuc[B<-pkeyopt opt:value>] 28*ebfedea0SLionel Sambuc[B<-hexdump>] 29*ebfedea0SLionel Sambuc[B<-asn1parse>] 30*ebfedea0SLionel Sambuc[B<-engine id>] 31*ebfedea0SLionel Sambuc 32*ebfedea0SLionel Sambuc=head1 DESCRIPTION 33*ebfedea0SLionel Sambuc 34*ebfedea0SLionel SambucThe B<pkeyutl> command can be used to perform public key operations using 35*ebfedea0SLionel Sambucany supported algorithm. 36*ebfedea0SLionel Sambuc 37*ebfedea0SLionel Sambuc=head1 COMMAND OPTIONS 38*ebfedea0SLionel Sambuc 39*ebfedea0SLionel Sambuc=over 4 40*ebfedea0SLionel Sambuc 41*ebfedea0SLionel Sambuc=item B<-in filename> 42*ebfedea0SLionel Sambuc 43*ebfedea0SLionel SambucThis specifies the input filename to read data from or standard input 44*ebfedea0SLionel Sambucif this option is not specified. 45*ebfedea0SLionel Sambuc 46*ebfedea0SLionel Sambuc=item B<-out filename> 47*ebfedea0SLionel Sambuc 48*ebfedea0SLionel Sambucspecifies the output filename to write to or standard output by 49*ebfedea0SLionel Sambucdefault. 50*ebfedea0SLionel Sambuc 51*ebfedea0SLionel Sambuc=item B<-inkey file> 52*ebfedea0SLionel Sambuc 53*ebfedea0SLionel Sambucthe input key file, by default it should be a private key. 54*ebfedea0SLionel Sambuc 55*ebfedea0SLionel Sambuc=item B<-keyform PEM|DER> 56*ebfedea0SLionel Sambuc 57*ebfedea0SLionel Sambucthe key format PEM, DER or ENGINE. 58*ebfedea0SLionel Sambuc 59*ebfedea0SLionel Sambuc=item B<-passin arg> 60*ebfedea0SLionel Sambuc 61*ebfedea0SLionel Sambucthe input key password source. For more information about the format of B<arg> 62*ebfedea0SLionel Sambucsee the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 63*ebfedea0SLionel Sambuc 64*ebfedea0SLionel Sambuc 65*ebfedea0SLionel Sambuc=item B<-peerkey file> 66*ebfedea0SLionel Sambuc 67*ebfedea0SLionel Sambucthe peer key file, used by key derivation (agreement) operations. 68*ebfedea0SLionel Sambuc 69*ebfedea0SLionel Sambuc=item B<-peerform PEM|DER> 70*ebfedea0SLionel Sambuc 71*ebfedea0SLionel Sambucthe peer key format PEM, DER or ENGINE. 72*ebfedea0SLionel Sambuc 73*ebfedea0SLionel Sambuc=item B<-engine id> 74*ebfedea0SLionel Sambuc 75*ebfedea0SLionel Sambucspecifying an engine (by its unique B<id> string) will cause B<pkeyutl> 76*ebfedea0SLionel Sambucto attempt to obtain a functional reference to the specified engine, 77*ebfedea0SLionel Sambucthus initialising it if needed. The engine will then be set as the default 78*ebfedea0SLionel Sambucfor all available algorithms. 79*ebfedea0SLionel Sambuc 80*ebfedea0SLionel Sambuc 81*ebfedea0SLionel Sambuc=item B<-pubin> 82*ebfedea0SLionel Sambuc 83*ebfedea0SLionel Sambucthe input file is a public key. 84*ebfedea0SLionel Sambuc 85*ebfedea0SLionel Sambuc=item B<-certin> 86*ebfedea0SLionel Sambuc 87*ebfedea0SLionel Sambucthe input is a certificate containing a public key. 88*ebfedea0SLionel Sambuc 89*ebfedea0SLionel Sambuc=item B<-rev> 90*ebfedea0SLionel Sambuc 91*ebfedea0SLionel Sambucreverse the order of the input buffer. This is useful for some libraries 92*ebfedea0SLionel Sambuc(such as CryptoAPI) which represent the buffer in little endian format. 93*ebfedea0SLionel Sambuc 94*ebfedea0SLionel Sambuc=item B<-sign> 95*ebfedea0SLionel Sambuc 96*ebfedea0SLionel Sambucsign the input data and output the signed result. This requires 97*ebfedea0SLionel Sambuca private key. 98*ebfedea0SLionel Sambuc 99*ebfedea0SLionel Sambuc=item B<-verify> 100*ebfedea0SLionel Sambuc 101*ebfedea0SLionel Sambucverify the input data against the signature file and indicate if the 102*ebfedea0SLionel Sambucverification succeeded or failed. 103*ebfedea0SLionel Sambuc 104*ebfedea0SLionel Sambuc=item B<-verifyrecover> 105*ebfedea0SLionel Sambuc 106*ebfedea0SLionel Sambucverify the input data and output the recovered data. 107*ebfedea0SLionel Sambuc 108*ebfedea0SLionel Sambuc=item B<-encrypt> 109*ebfedea0SLionel Sambuc 110*ebfedea0SLionel Sambucencrypt the input data using a public key. 111*ebfedea0SLionel Sambuc 112*ebfedea0SLionel Sambuc=item B<-decrypt> 113*ebfedea0SLionel Sambuc 114*ebfedea0SLionel Sambucdecrypt the input data using a private key. 115*ebfedea0SLionel Sambuc 116*ebfedea0SLionel Sambuc=item B<-derive> 117*ebfedea0SLionel Sambuc 118*ebfedea0SLionel Sambucderive a shared secret using the peer key. 119*ebfedea0SLionel Sambuc 120*ebfedea0SLionel Sambuc=item B<-hexdump> 121*ebfedea0SLionel Sambuc 122*ebfedea0SLionel Sambuchex dump the output data. 123*ebfedea0SLionel Sambuc 124*ebfedea0SLionel Sambuc=item B<-asn1parse> 125*ebfedea0SLionel Sambuc 126*ebfedea0SLionel Sambucasn1parse the output data, this is useful when combined with the 127*ebfedea0SLionel SambucB<-verifyrecover> option when an ASN1 structure is signed. 128*ebfedea0SLionel Sambuc 129*ebfedea0SLionel Sambuc=back 130*ebfedea0SLionel Sambuc 131*ebfedea0SLionel Sambuc=head1 NOTES 132*ebfedea0SLionel Sambuc 133*ebfedea0SLionel SambucThe operations and options supported vary according to the key algorithm 134*ebfedea0SLionel Sambucand its implementation. The OpenSSL operations and options are indicated below. 135*ebfedea0SLionel Sambuc 136*ebfedea0SLionel SambucUnless otherwise mentioned all algorithms support the B<digest:alg> option 137*ebfedea0SLionel Sambucwhich specifies the digest in use for sign, verify and verifyrecover operations. 138*ebfedea0SLionel SambucThe value B<alg> should represent a digest name as used in the 139*ebfedea0SLionel SambucEVP_get_digestbyname() function for example B<sha1>. 140*ebfedea0SLionel Sambuc 141*ebfedea0SLionel Sambuc=head1 RSA ALGORITHM 142*ebfedea0SLionel Sambuc 143*ebfedea0SLionel SambucThe RSA algorithm supports encrypt, decrypt, sign, verify and verifyrecover 144*ebfedea0SLionel Sambucoperations in general. Some padding modes only support some of these 145*ebfedea0SLionel Sambucoperations however. 146*ebfedea0SLionel Sambuc 147*ebfedea0SLionel Sambuc=over 4 148*ebfedea0SLionel Sambuc 149*ebfedea0SLionel Sambuc=item -B<rsa_padding_mode:mode> 150*ebfedea0SLionel Sambuc 151*ebfedea0SLionel SambucThis sets the RSA padding mode. Acceptable values for B<mode> are B<pkcs1> for 152*ebfedea0SLionel SambucPKCS#1 padding, B<sslv23> for SSLv23 padding, B<none> for no padding, B<oaep> 153*ebfedea0SLionel Sambucfor B<OAEP> mode, B<x931> for X9.31 mode and B<pss> for PSS. 154*ebfedea0SLionel Sambuc 155*ebfedea0SLionel SambucIn PKCS#1 padding if the message digest is not set then the supplied data is 156*ebfedea0SLionel Sambucsigned or verified directly instead of using a B<DigestInfo> structure. If a 157*ebfedea0SLionel Sambucdigest is set then the a B<DigestInfo> structure is used and its the length 158*ebfedea0SLionel Sambucmust correspond to the digest type. 159*ebfedea0SLionel Sambuc 160*ebfedea0SLionel SambucFor B<oeap> mode only encryption and decryption is supported. 161*ebfedea0SLionel Sambuc 162*ebfedea0SLionel SambucFor B<x931> if the digest type is set it is used to format the block data 163*ebfedea0SLionel Sambucotherwise the first byte is used to specify the X9.31 digest ID. Sign, 164*ebfedea0SLionel Sambucverify and verifyrecover are can be performed in this mode. 165*ebfedea0SLionel Sambuc 166*ebfedea0SLionel SambucFor B<pss> mode only sign and verify are supported and the digest type must be 167*ebfedea0SLionel Sambucspecified. 168*ebfedea0SLionel Sambuc 169*ebfedea0SLionel Sambuc=item B<rsa_pss_saltlen:len> 170*ebfedea0SLionel Sambuc 171*ebfedea0SLionel SambucFor B<pss> mode only this option specifies the salt length. Two special values 172*ebfedea0SLionel Sambucare supported: -1 sets the salt length to the digest length. When signing -2 173*ebfedea0SLionel Sambucsets the salt length to the maximum permissible value. When verifying -2 causes 174*ebfedea0SLionel Sambucthe salt length to be automatically determined based on the B<PSS> block 175*ebfedea0SLionel Sambucstructure. 176*ebfedea0SLionel Sambuc 177*ebfedea0SLionel Sambuc=back 178*ebfedea0SLionel Sambuc 179*ebfedea0SLionel Sambuc=head1 DSA ALGORITHM 180*ebfedea0SLionel Sambuc 181*ebfedea0SLionel SambucThe DSA algorithm supports signing and verification operations only. Currently 182*ebfedea0SLionel Sambucthere are no additional options other than B<digest>. Only the SHA1 183*ebfedea0SLionel Sambucdigest can be used and this digest is assumed by default. 184*ebfedea0SLionel Sambuc 185*ebfedea0SLionel Sambuc=head1 DH ALGORITHM 186*ebfedea0SLionel Sambuc 187*ebfedea0SLionel SambucThe DH algorithm only supports the derivation operation and no additional 188*ebfedea0SLionel Sambucoptions. 189*ebfedea0SLionel Sambuc 190*ebfedea0SLionel Sambuc=head1 EC ALGORITHM 191*ebfedea0SLionel Sambuc 192*ebfedea0SLionel SambucThe EC algorithm supports sign, verify and derive operations. The sign and 193*ebfedea0SLionel Sambucverify operations use ECDSA and derive uses ECDH. Currently there are no 194*ebfedea0SLionel Sambucadditional options other than B<digest>. Only the SHA1 digest can be used and 195*ebfedea0SLionel Sambucthis digest is assumed by default. 196*ebfedea0SLionel Sambuc 197*ebfedea0SLionel Sambuc=head1 EXAMPLES 198*ebfedea0SLionel Sambuc 199*ebfedea0SLionel SambucSign some data using a private key: 200*ebfedea0SLionel Sambuc 201*ebfedea0SLionel Sambuc openssl pkeyutl -sign -in file -inkey key.pem -out sig 202*ebfedea0SLionel Sambuc 203*ebfedea0SLionel SambucRecover the signed data (e.g. if an RSA key is used): 204*ebfedea0SLionel Sambuc 205*ebfedea0SLionel Sambuc openssl pkeyutl -verifyrecover -in sig -inkey key.pem 206*ebfedea0SLionel Sambuc 207*ebfedea0SLionel SambucVerify the signature (e.g. a DSA key): 208*ebfedea0SLionel Sambuc 209*ebfedea0SLionel Sambuc openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem 210*ebfedea0SLionel Sambuc 211*ebfedea0SLionel SambucSign data using a message digest value (this is currently only valid for RSA): 212*ebfedea0SLionel Sambuc 213*ebfedea0SLionel Sambuc openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256 214*ebfedea0SLionel Sambuc 215*ebfedea0SLionel SambucDerive a shared secret value: 216*ebfedea0SLionel Sambuc 217*ebfedea0SLionel Sambuc openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret 218*ebfedea0SLionel Sambuc 219*ebfedea0SLionel Sambuc=head1 SEE ALSO 220*ebfedea0SLionel Sambuc 221*ebfedea0SLionel SambucL<genpkey(1)|genpkey(1)>, L<pkey(1)|pkey(1)>, L<rsautl(1)|rsautl(1)> 222*ebfedea0SLionel SambucL<dgst(1)|dgst(1)>, L<rsa(1)|rsa(1)>, L<genrsa(1)|genrsa(1)> 223