RSA_padding_add_PKCS1_type_1.pod 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. =pod
  2. =head1 NAME
  3. RSA_padding_add_PKCS1_type_1, RSA_padding_check_PKCS1_type_1,
  4. RSA_padding_add_PKCS1_type_2, RSA_padding_check_PKCS1_type_2,
  5. RSA_padding_add_PKCS1_OAEP, RSA_padding_check_PKCS1_OAEP,
  6. RSA_padding_add_SSLv23, RSA_padding_check_SSLv23,
  7. RSA_padding_add_none, RSA_padding_check_none - asymmetric encryption
  8. padding
  9. =head1 SYNOPSIS
  10. #include <openssl/rsa.h>
  11. int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
  12. unsigned char *f, int fl);
  13. int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
  14. unsigned char *f, int fl, int rsa_len);
  15. int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
  16. unsigned char *f, int fl);
  17. int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
  18. unsigned char *f, int fl, int rsa_len);
  19. int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
  20. unsigned char *f, int fl, unsigned char *p, int pl);
  21. int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
  22. unsigned char *f, int fl, int rsa_len,
  23. unsigned char *p, int pl);
  24. int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
  25. unsigned char *f, int fl);
  26. int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
  27. unsigned char *f, int fl, int rsa_len);
  28. int RSA_padding_add_none(unsigned char *to, int tlen,
  29. unsigned char *f, int fl);
  30. int RSA_padding_check_none(unsigned char *to, int tlen,
  31. unsigned char *f, int fl, int rsa_len);
  32. =head1 DESCRIPTION
  33. The RSA_padding_xxx_xxx() functions are called from the RSA encrypt,
  34. decrypt, sign and verify functions. Normally they should not be called
  35. from application programs.
  36. However, they can also be called directly to implement padding for other
  37. asymmetric ciphers. RSA_padding_add_PKCS1_OAEP() and
  38. RSA_padding_check_PKCS1_OAEP() may be used in an application combined
  39. with B<RSA_NO_PADDING> in order to implement OAEP with an encoding
  40. parameter.
  41. RSA_padding_add_xxx() encodes B<fl> bytes from B<f> so as to fit into
  42. B<tlen> bytes and stores the result at B<to>. An error occurs if B<fl>
  43. does not meet the size requirements of the encoding method.
  44. The following encoding methods are implemented:
  45. =over 4
  46. =item PKCS1_type_1
  47. PKCS #1 v2.0 EMSA-PKCS1-v1_5 (PKCS #1 v1.5 block type 1); used for signatures
  48. =item PKCS1_type_2
  49. PKCS #1 v2.0 EME-PKCS1-v1_5 (PKCS #1 v1.5 block type 2)
  50. =item PKCS1_OAEP
  51. PKCS #1 v2.0 EME-OAEP
  52. =item SSLv23
  53. PKCS #1 EME-PKCS1-v1_5 with SSL-specific modification
  54. =item none
  55. simply copy the data
  56. =back
  57. The random number generator must be seeded prior to calling
  58. RSA_padding_add_xxx().
  59. RSA_padding_check_xxx() verifies that the B<fl> bytes at B<f> contain
  60. a valid encoding for a B<rsa_len> byte RSA key in the respective
  61. encoding method and stores the recovered data of at most B<tlen> bytes
  62. (for B<RSA_NO_PADDING>: of size B<tlen>)
  63. at B<to>.
  64. For RSA_padding_xxx_OAEP(), B<p> points to the encoding parameter
  65. of length B<pl>. B<p> may be B<NULL> if B<pl> is 0.
  66. =head1 RETURN VALUES
  67. The RSA_padding_add_xxx() functions return 1 on success, 0 on error.
  68. The RSA_padding_check_xxx() functions return the length of the
  69. recovered data, -1 on error. Error codes can be obtained by calling
  70. L<ERR_get_error(3)>.
  71. =head1 WARNING
  72. The RSA_padding_check_PKCS1_type_2() padding check leaks timing
  73. information which can potentially be used to mount a Bleichenbacher
  74. padding oracle attack. This is an inherent weakness in the PKCS #1
  75. v1.5 padding design. Prefer PKCS1_OAEP padding.
  76. =head1 SEE ALSO
  77. L<RSA_public_encrypt(3)>,
  78. L<RSA_private_decrypt(3)>,
  79. L<RSA_sign(3)>, L<RSA_verify(3)>
  80. =head1 COPYRIGHT
  81. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  82. Licensed under the OpenSSL license (the "License"). You may not use
  83. this file except in compliance with the License. You can obtain a copy
  84. in the file LICENSE in the source distribution or at
  85. L<https://www.openssl.org/source/license.html>.
  86. =cut