openssl-rsautl.pod.in 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. =pod
  2. {- OpenSSL::safe::output_do_not_edit_headers(); -}
  3. =head1 NAME
  4. openssl-rsautl - RSA command
  5. =head1 SYNOPSIS
  6. B<openssl> B<rsautl>
  7. [B<-help>]
  8. [B<-in> I<file>]
  9. [B<-passin> I<arg>]
  10. [B<-rev>]
  11. [B<-out> I<file>]
  12. [B<-inkey> I<filename>|I<uri>]
  13. [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
  14. [B<-pubin>]
  15. [B<-certin>]
  16. [B<-sign>]
  17. [B<-verify>]
  18. [B<-encrypt>]
  19. [B<-decrypt>]
  20. [B<-pkcs>]
  21. [B<-x931>]
  22. [B<-oaep>]
  23. [B<-raw>]
  24. [B<-hexdump>]
  25. [B<-asn1parse>]
  26. {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_r_synopsis -}
  27. {- $OpenSSL::safe::opt_provider_synopsis -}
  28. =head1 DESCRIPTION
  29. This command has been deprecated.
  30. The L<openssl-pkeyutl(1)> command should be used instead.
  31. This command can be used to sign, verify, encrypt and decrypt
  32. data using the RSA algorithm.
  33. =head1 OPTIONS
  34. =over 4
  35. =item B<-help>
  36. Print out a usage message.
  37. =item B<-in> I<filename>
  38. This specifies the input filename to read data from or standard input
  39. if this option is not specified.
  40. =item B<-passin> I<arg>
  41. The passphrase used in the output file.
  42. See see L<openssl-passphrase-options(1)>.
  43. =item B<-rev>
  44. Reverse the order of the input.
  45. =item B<-out> I<filename>
  46. Specifies the output filename to write to or standard output by
  47. default.
  48. =item B<-inkey> I<filename>|I<uri>
  49. The input key, by default it should be an RSA private key.
  50. =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
  51. The key format; unspecified by default.
  52. See L<openssl-format-options(1)> for details.
  53. =item B<-pubin>
  54. The input file is an RSA public key.
  55. =item B<-certin>
  56. The input is a certificate containing an RSA public key.
  57. =item B<-sign>
  58. Sign the input data and output the signed result. This requires
  59. an RSA private key.
  60. =item B<-verify>
  61. Verify the input data and output the recovered data.
  62. =item B<-encrypt>
  63. Encrypt the input data using an RSA public key.
  64. =item B<-decrypt>
  65. Decrypt the input data using an RSA private key.
  66. =item B<-pkcs>, B<-oaep>, B<-x931> B<-raw>
  67. The padding to use: PKCS#1 v1.5 (the default), PKCS#1 OAEP,
  68. ANSI X9.31, or no padding, respectively.
  69. For signatures, only B<-pkcs> and B<-raw> can be used.
  70. =item B<-hexdump>
  71. Hex dump the output data.
  72. =item B<-asn1parse>
  73. Parse the ASN.1 output data, this is useful when combined with the
  74. B<-verify> option.
  75. {- $OpenSSL::safe::opt_engine_item -}
  76. {- $OpenSSL::safe::opt_r_item -}
  77. {- $OpenSSL::safe::opt_provider_item -}
  78. =back
  79. =head1 NOTES
  80. Since this command uses the RSA algorithm directly, it can only be
  81. used to sign or verify small pieces of data.
  82. =head1 EXAMPLES
  83. Examples equivalent to these can be found in the documentation for the
  84. non-deprecated L<openssl-pkeyutl(1)> command.
  85. Sign some data using a private key:
  86. openssl rsautl -sign -in file -inkey key.pem -out sig
  87. Recover the signed data
  88. openssl rsautl -verify -in sig -inkey key.pem
  89. Examine the raw signed data:
  90. openssl rsautl -verify -in sig -inkey key.pem -raw -hexdump
  91. 0000 - 00 01 ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
  92. 0010 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
  93. 0020 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
  94. 0030 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
  95. 0040 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
  96. 0050 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
  97. 0060 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................
  98. 0070 - ff ff ff ff 00 68 65 6c-6c 6f 20 77 6f 72 6c 64 .....hello world
  99. The PKCS#1 block formatting is evident from this. If this was done using
  100. encrypt and decrypt the block would have been of type 2 (the second byte)
  101. and random padding data visible instead of the 0xff bytes.
  102. It is possible to analyse the signature of certificates using this
  103. command in conjunction with L<openssl-asn1parse(1)>. Consider the self signed
  104. example in F<certs/pca-cert.pem>. Running L<openssl-asn1parse(1)> as follows
  105. yields:
  106. openssl asn1parse -in pca-cert.pem
  107. 0:d=0 hl=4 l= 742 cons: SEQUENCE
  108. 4:d=1 hl=4 l= 591 cons: SEQUENCE
  109. 8:d=2 hl=2 l= 3 cons: cont [ 0 ]
  110. 10:d=3 hl=2 l= 1 prim: INTEGER :02
  111. 13:d=2 hl=2 l= 1 prim: INTEGER :00
  112. 16:d=2 hl=2 l= 13 cons: SEQUENCE
  113. 18:d=3 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption
  114. 29:d=3 hl=2 l= 0 prim: NULL
  115. 31:d=2 hl=2 l= 92 cons: SEQUENCE
  116. 33:d=3 hl=2 l= 11 cons: SET
  117. 35:d=4 hl=2 l= 9 cons: SEQUENCE
  118. 37:d=5 hl=2 l= 3 prim: OBJECT :countryName
  119. 42:d=5 hl=2 l= 2 prim: PRINTABLESTRING :AU
  120. ....
  121. 599:d=1 hl=2 l= 13 cons: SEQUENCE
  122. 601:d=2 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption
  123. 612:d=2 hl=2 l= 0 prim: NULL
  124. 614:d=1 hl=3 l= 129 prim: BIT STRING
  125. The final BIT STRING contains the actual signature. It can be extracted with:
  126. openssl asn1parse -in pca-cert.pem -out sig -noout -strparse 614
  127. The certificate public key can be extracted with:
  128. openssl x509 -in test/testx509.pem -pubkey -noout >pubkey.pem
  129. The signature can be analysed with:
  130. openssl rsautl -in sig -verify -asn1parse -inkey pubkey.pem -pubin
  131. 0:d=0 hl=2 l= 32 cons: SEQUENCE
  132. 2:d=1 hl=2 l= 12 cons: SEQUENCE
  133. 4:d=2 hl=2 l= 8 prim: OBJECT :md5
  134. 14:d=2 hl=2 l= 0 prim: NULL
  135. 16:d=1 hl=2 l= 16 prim: OCTET STRING
  136. 0000 - f3 46 9e aa 1a 4a 73 c9-37 ea 93 00 48 25 08 b5 .F...Js.7...H%..
  137. This is the parsed version of an ASN1 DigestInfo structure. It can be seen that
  138. the digest used was md5. The actual part of the certificate that was signed can
  139. be extracted with:
  140. openssl asn1parse -in pca-cert.pem -out tbs -noout -strparse 4
  141. and its digest computed with:
  142. openssl md5 -c tbs
  143. MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
  144. which it can be seen agrees with the recovered value above.
  145. =head1 SEE ALSO
  146. L<openssl(1)>,
  147. L<openssl-pkeyutl(1)>,
  148. L<openssl-dgst(1)>,
  149. L<openssl-rsa(1)>,
  150. L<openssl-genrsa(1)>
  151. =head1 HISTORY
  152. This command was deprecated in OpenSSL 3.0.
  153. The B<-engine> option was deprecated in OpenSSL 3.0.
  154. =head1 COPYRIGHT
  155. Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
  156. Licensed under the Apache License 2.0 (the "License"). You may not use
  157. this file except in compliance with the License. You can obtain a copy
  158. in the file LICENSE in the source distribution or at
  159. L<https://www.openssl.org/source/license.html>.
  160. =cut