pkeyutl.pod 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. =pod
  2. =head1 NAME
  3. pkeyutl - public key algorithm utility
  4. =head1 SYNOPSIS
  5. B<openssl> B<pkeyutl>
  6. [B<-in file>]
  7. [B<-out file>]
  8. [B<-sigfile file>]
  9. [B<-inkey file>]
  10. [B<-keyform PEM|DER>]
  11. [B<-passin arg>]
  12. [B<-peerkey file>]
  13. [B<-peerform PEM|DER>]
  14. [B<-pubin>]
  15. [B<-certin>]
  16. [B<-rev>]
  17. [B<-sign>]
  18. [B<-verify>]
  19. [B<-verifyrecover>]
  20. [B<-encrypt>]
  21. [B<-decrypt>]
  22. [B<-derive>]
  23. [B<-pkeyopt opt:value>]
  24. [B<-hexdump>]
  25. [B<-asn1parse>]
  26. [B<-engine id>]
  27. =head1 DESCRIPTION
  28. The B<pkeyutl> command can be used to perform public key operations using
  29. any supported algorithm.
  30. =head1 COMMAND OPTIONS
  31. =over 4
  32. =item B<-in filename>
  33. This specifies the input filename to read data from or standard input
  34. if this option is not specified.
  35. =item B<-out filename>
  36. specifies the output filename to write to or standard output by
  37. default.
  38. =item B<-inkey file>
  39. the input key file, by default it should be a private key.
  40. =item B<-keyform PEM|DER>
  41. the key format PEM, DER or ENGINE.
  42. =item B<-passin arg>
  43. the input key password source. For more information about the format of B<arg>
  44. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
  45. =item B<-peerkey file>
  46. the peer key file, used by key derivation (agreement) operations.
  47. =item B<-peerform PEM|DER>
  48. the peer key format PEM, DER or ENGINE.
  49. =item B<-engine id>
  50. specifying an engine (by its unique B<id> string) will cause B<pkeyutl>
  51. to attempt to obtain a functional reference to the specified engine,
  52. thus initialising it if needed. The engine will then be set as the default
  53. for all available algorithms.
  54. =item B<-pubin>
  55. the input file is a public key.
  56. =item B<-certin>
  57. the input is a certificate containing a public key.
  58. =item B<-rev>
  59. reverse the order of the input buffer. This is useful for some libraries
  60. (such as CryptoAPI) which represent the buffer in little endian format.
  61. =item B<-sign>
  62. sign the input data and output the signed result. This requires
  63. a private key.
  64. =item B<-verify>
  65. verify the input data against the signature file and indicate if the
  66. verification succeeded or failed.
  67. =item B<-verifyrecover>
  68. verify the input data and output the recovered data.
  69. =item B<-encrypt>
  70. encrypt the input data using a public key.
  71. =item B<-decrypt>
  72. decrypt the input data using a private key.
  73. =item B<-derive>
  74. derive a shared secret using the peer key.
  75. =item B<-hexdump>
  76. hex dump the output data.
  77. =item B<-asn1parse>
  78. asn1parse the output data, this is useful when combined with the
  79. B<-verifyrecover> option when an ASN1 structure is signed.
  80. =back
  81. =head1 NOTES
  82. The operations and options supported vary according to the key algorithm
  83. and its implementation. The OpenSSL operations and options are indicated below.
  84. Unless otherwise mentioned all algorithms support the B<digest:alg> option
  85. which specifies the digest in use for sign, verify and verifyrecover operations.
  86. The value B<alg> should represent a digest name as used in the
  87. EVP_get_digestbyname() function for example B<sha1>.
  88. =head1 RSA ALGORITHM
  89. The RSA algorithm supports encrypt, decrypt, sign, verify and verifyrecover
  90. operations in general. Some padding modes only support some of these
  91. operations however.
  92. =over 4
  93. =item -B<rsa_padding_mode:mode>
  94. This sets the RSA padding mode. Acceptable values for B<mode> are B<pkcs1> for
  95. PKCS#1 padding, B<sslv23> for SSLv23 padding, B<none> for no padding, B<oaep>
  96. for B<OAEP> mode, B<x931> for X9.31 mode and B<pss> for PSS.
  97. In PKCS#1 padding if the message digest is not set then the supplied data is
  98. signed or verified directly instead of using a B<DigestInfo> structure. If a
  99. digest is set then the a B<DigestInfo> structure is used and its the length
  100. must correspond to the digest type.
  101. For B<oeap> mode only encryption and decryption is supported.
  102. For B<x931> if the digest type is set it is used to format the block data
  103. otherwise the first byte is used to specify the X9.31 digest ID. Sign,
  104. verify and verifyrecover are can be performed in this mode.
  105. For B<pss> mode only sign and verify are supported and the digest type must be
  106. specified.
  107. =item B<rsa_pss_saltlen:len>
  108. For B<pss> mode only this option specifies the salt length. Two special values
  109. are supported: -1 sets the salt length to the digest length. When signing -2
  110. sets the salt length to the maximum permissible value. When verifying -2 causes
  111. the salt length to be automatically determined based on the B<PSS> block
  112. structure.
  113. =back
  114. =head1 DSA ALGORITHM
  115. The DSA algorithm supports signing and verification operations only. Currently
  116. there are no additional options other than B<digest>. Only the SHA1
  117. digest can be used and this digest is assumed by default.
  118. =head1 DH ALGORITHM
  119. The DH algorithm only supports the derivation operation and no additional
  120. options.
  121. =head1 EC ALGORITHM
  122. The EC algorithm supports sign, verify and derive operations. The sign and
  123. verify operations use ECDSA and derive uses ECDH. Currently there are no
  124. additional options other than B<digest>. Only the SHA1 digest can be used and
  125. this digest is assumed by default.
  126. =head1 EXAMPLES
  127. Sign some data using a private key:
  128. openssl pkeyutl -sign -in file -inkey key.pem -out sig
  129. Recover the signed data (e.g. if an RSA key is used):
  130. openssl pkeyutl -verifyrecover -in sig -inkey key.pem
  131. Verify the signature (e.g. a DSA key):
  132. openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem
  133. Sign data using a message digest value (this is currently only valid for RSA):
  134. openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256
  135. Derive a shared secret value:
  136. openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret
  137. =head1 SEE ALSO
  138. L<genpkey(1)|genpkey(1)>, L<pkey(1)|pkey(1)>, L<rsautl(1)|rsautl(1)>
  139. L<dgst(1)|dgst(1)>, L<rsa(1)|rsa(1)>, L<genrsa(1)|genrsa(1)>