pkcs7.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # This file is dual licensed under the terms of the Apache License, Version
  2. # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3. # for complete details.
  4. from __future__ import absolute_import, division, print_function
  5. INCLUDES = """
  6. #include <openssl/pkcs7.h>
  7. """
  8. TYPES = """
  9. typedef struct {
  10. Cryptography_STACK_OF_X509 *cert;
  11. Cryptography_STACK_OF_X509_CRL *crl;
  12. ...;
  13. } PKCS7_SIGNED;
  14. typedef struct {
  15. Cryptography_STACK_OF_X509 *cert;
  16. Cryptography_STACK_OF_X509_CRL *crl;
  17. ...;
  18. } PKCS7_SIGN_ENVELOPE;
  19. typedef ... PKCS7_DIGEST;
  20. typedef ... PKCS7_ENCRYPT;
  21. typedef ... PKCS7_ENVELOPE;
  22. typedef ... PKCS7_SIGNER_INFO;
  23. typedef struct {
  24. ASN1_OBJECT *type;
  25. union {
  26. char *ptr;
  27. ASN1_OCTET_STRING *data;
  28. PKCS7_SIGNED *sign;
  29. PKCS7_ENVELOPE *enveloped;
  30. PKCS7_SIGN_ENVELOPE *signed_and_enveloped;
  31. PKCS7_DIGEST *digest;
  32. PKCS7_ENCRYPT *encrypted;
  33. ASN1_TYPE *other;
  34. } d;
  35. ...;
  36. } PKCS7;
  37. static const int PKCS7_BINARY;
  38. static const int PKCS7_DETACHED;
  39. static const int PKCS7_NOATTR;
  40. static const int PKCS7_NOCERTS;
  41. static const int PKCS7_NOCHAIN;
  42. static const int PKCS7_NOINTERN;
  43. static const int PKCS7_NOSIGS;
  44. static const int PKCS7_NOSMIMECAP;
  45. static const int PKCS7_NOVERIFY;
  46. static const int PKCS7_STREAM;
  47. static const int PKCS7_TEXT;
  48. static const int PKCS7_PARTIAL;
  49. """
  50. FUNCTIONS = """
  51. void PKCS7_free(PKCS7 *);
  52. PKCS7 *PKCS7_sign(X509 *, EVP_PKEY *, Cryptography_STACK_OF_X509 *,
  53. BIO *, int);
  54. int SMIME_write_PKCS7(BIO *, PKCS7 *, BIO *, int);
  55. int PEM_write_bio_PKCS7_stream(BIO *, PKCS7 *, BIO *, int);
  56. PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *, X509 *, EVP_PKEY *,
  57. const EVP_MD *, int);
  58. int PKCS7_final(PKCS7 *, BIO *, int);
  59. /* Included verify due to external consumer, see
  60. https://github.com/pyca/cryptography/issues/5433 */
  61. int PKCS7_verify(PKCS7 *, Cryptography_STACK_OF_X509 *, X509_STORE *, BIO *,
  62. BIO *, int);
  63. PKCS7 *SMIME_read_PKCS7(BIO *, BIO **);
  64. int PKCS7_type_is_signed(PKCS7 *);
  65. int PKCS7_type_is_enveloped(PKCS7 *);
  66. int PKCS7_type_is_signedAndEnveloped(PKCS7 *);
  67. int PKCS7_type_is_data(PKCS7 *);
  68. """
  69. CUSTOMIZATIONS = ""