You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

encoder.h 4.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef OPENSSL_ENCODER_H
  10. #define OPENSSL_ENCODER_H
  11. #pragma once
  12. #include <openssl/opensslconf.h>
  13. #ifndef OPENSSL_NO_STDIO
  14. #include <stdio.h>
  15. #endif
  16. #include <stdarg.h>
  17. #include <stddef.h>
  18. #include <openssl/encodererr.h>
  19. #include <openssl/types.h>
  20. #include <openssl/core.h>
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. OSSL_ENCODER* OSSL_ENCODER_fetch(OSSL_LIB_CTX* libctx, const char* name, const char* properties);
  26. int OSSL_ENCODER_up_ref(OSSL_ENCODER* encoder);
  27. void OSSL_ENCODER_free(OSSL_ENCODER* encoder);
  28. const OSSL_PROVIDER* OSSL_ENCODER_get0_provider(const OSSL_ENCODER* encoder);
  29. const char* OSSL_ENCODER_get0_properties(const OSSL_ENCODER* encoder);
  30. const char* OSSL_ENCODER_get0_name(const OSSL_ENCODER* kdf);
  31. const char* OSSL_ENCODER_get0_description(const OSSL_ENCODER* kdf);
  32. int OSSL_ENCODER_is_a(const OSSL_ENCODER* encoder, const char* name);
  33. void OSSL_ENCODER_do_all_provided(OSSL_LIB_CTX* libctx, void (*fn)(OSSL_ENCODER* encoder, void* arg), void* arg);
  34. int OSSL_ENCODER_names_do_all(const OSSL_ENCODER* encoder, void (*fn)(const char* name, void* data), void* data);
  35. const OSSL_PARAM* OSSL_ENCODER_gettable_params(OSSL_ENCODER* encoder);
  36. int OSSL_ENCODER_get_params(OSSL_ENCODER* encoder, OSSL_PARAM params[]);
  37. const OSSL_PARAM* OSSL_ENCODER_settable_ctx_params(OSSL_ENCODER* encoder);
  38. OSSL_ENCODER_CTX* OSSL_ENCODER_CTX_new(void);
  39. int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX* ctx, const OSSL_PARAM params[]);
  40. void OSSL_ENCODER_CTX_free(OSSL_ENCODER_CTX* ctx);
  41. /* Utilities that help set specific parameters */
  42. int OSSL_ENCODER_CTX_set_passphrase(OSSL_ENCODER_CTX* ctx, const unsigned char* kstr, size_t klen);
  43. int OSSL_ENCODER_CTX_set_pem_password_cb(OSSL_ENCODER_CTX* ctx, pem_password_cb* cb, void* cbarg);
  44. int OSSL_ENCODER_CTX_set_passphrase_cb(OSSL_ENCODER_CTX* ctx, OSSL_PASSPHRASE_CALLBACK* cb, void* cbarg);
  45. int OSSL_ENCODER_CTX_set_passphrase_ui(OSSL_ENCODER_CTX* ctx, const UI_METHOD* ui_method, void* ui_data);
  46. int OSSL_ENCODER_CTX_set_cipher(OSSL_ENCODER_CTX* ctx, const char* cipher_name, const char* propquery);
  47. int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX* ctx, int selection);
  48. int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX* ctx, const char* output_type);
  49. int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX* ctx, const char* output_structure);
  50. /* Utilities to add encoders */
  51. int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX* ctx, OSSL_ENCODER* encoder);
  52. int OSSL_ENCODER_CTX_add_extra(OSSL_ENCODER_CTX* ctx, OSSL_LIB_CTX* libctx, const char* propq);
  53. int OSSL_ENCODER_CTX_get_num_encoders(OSSL_ENCODER_CTX* ctx);
  54. typedef struct ossl_encoder_instance_st OSSL_ENCODER_INSTANCE;
  55. OSSL_ENCODER*
  56. OSSL_ENCODER_INSTANCE_get_encoder(OSSL_ENCODER_INSTANCE* encoder_inst);
  57. void*
  58. OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE* encoder_inst);
  59. const char*
  60. OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE* encoder_inst);
  61. const char*
  62. OSSL_ENCODER_INSTANCE_get_output_structure(OSSL_ENCODER_INSTANCE* encoder_inst);
  63. typedef const void* OSSL_ENCODER_CONSTRUCT(OSSL_ENCODER_INSTANCE* encoder_inst, void* construct_data);
  64. typedef void OSSL_ENCODER_CLEANUP(void* construct_data);
  65. int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX* ctx, OSSL_ENCODER_CONSTRUCT* construct);
  66. int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX* ctx, void* construct_data);
  67. int OSSL_ENCODER_CTX_set_cleanup(OSSL_ENCODER_CTX* ctx, OSSL_ENCODER_CLEANUP* cleanup);
  68. /* Utilities to output the object to encode */
  69. int OSSL_ENCODER_to_bio(OSSL_ENCODER_CTX* ctx, BIO* out);
  70. #ifndef OPENSSL_NO_STDIO
  71. int OSSL_ENCODER_to_fp(OSSL_ENCODER_CTX* ctx, FILE* fp);
  72. #endif
  73. int OSSL_ENCODER_to_data(OSSL_ENCODER_CTX* ctx, unsigned char** pdata, size_t* pdata_len);
  74. /*
  75. * Create the OSSL_ENCODER_CTX with an associated type. This will perform
  76. * an implicit OSSL_ENCODER_fetch(), suitable for the object of that type.
  77. * This is more useful than calling OSSL_ENCODER_CTX_new().
  78. */
  79. OSSL_ENCODER_CTX* OSSL_ENCODER_CTX_new_for_pkey(const EVP_PKEY* pkey, int selection, const char* output_type, const char* output_struct, const char* propquery);
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif