7¤0ì�›aT>°Ò80Ã0Ã0ÃÀk”v ~‘;¶ÈŽ”o-Ü$0'¢b#IC$‹Û¶—ÝU5"ÚÿÝÄßÚØˆ\ð À3  
–KE�8(„ñ€ Œœ”Šòp,‰9£(Š‚ ¥RŠ!)   ¤—dMM2…Œ                   TX *ctx,
    pem_password_cb *cb, void *cbarg);
int OSSL_ENCODER_CTX_set_passphrase_cb(OSSL_ENCODER_CTX *ctx,
    OSSL_PASSPHRASE_CALLBACK *cb,
    void *cbarg);
int OSSL_ENCODER_CTX_set_passphrase_ui(OSSL_ENCODER_CTX *ctx,
    const UI_METHOD *ui_method,
    void *ui_data);
int OSSL_ENCODER_CTX_set_cipher(OSSL_ENCODER_CTX *ctx,
    const char *cipher_name,
    const char *propquery);
int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection);
int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx,
    const char *output_type);
int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx,
    const char *output_structure);

/* Utilities to add encoders */
int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder);
int OSSL_ENCODER_CTX_add_extra(OSSL_ENCODER_CTX *ctx,
    OSS      \
    static ossl_unused ossl_inline void                                                     \
    lh_##type##_doall_##argtype(LHASH_OF(type) *lh,                                         \
        void (*fn)(cbargtype *, argtype *),                                                 \
        argtype *arg)                                                                       \
    {                                                                                       \
        OPENSSL_LH_doall_arg_thunk((OPENSSL_LHASH *)lh,                                     \
            lh_##type##_doall_##argtype##_thunk,                                            \
            (OPENSSL_LH_DOALL_FUNCARG)fn,                                                   \
            (void *)arg);                                                                   \
    }                                                                                       \
    LHASH_OF(type)

/* clang-format off */
DEFINE_LHASH_OF_INTERNAL(OPENSSL_STRING);
#define lh_OPENSSL_STRING_new(hfn, cmp) ((LHASH_OF(OPENSSL_STRING) *)OPENSSL_LH_set_thunks(OPENSSL_LH_new(ossl_check_OPENSSL_STRING_lh_hashfunc_type(hfn), ossl_check_OPENSSL_STRING_lh_compfunc_type(cmp)), lh_OPENSSL_STRING_hash_thunk, lh_OPENSSL_STRING_comp_thunk, lh_OPENSSL_STRING_doall_thunk, lh_OPENSSL_STRING_doall_arg_thunk))
#define lh_OPENSSL_STRING_free(lh) OPENSSL_LH_free(ossl_check_OPENSSL_STRING_lh_type(lh))
#define lh_OPENSSL_STRING_flush(lh) OPENSSL_LH_flush(oss(void *, void *);
#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
    void name##_LHASH_DOALL_ARG(void *arg1, void *arg2)    \
    {                                                      \
        o_type *a = arg1;                                  \
        a_type *b = arg2;                                  \
        name##_doall_arg(a, b);                            \
    }
#define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG

#define LH_LOAD_MULT 256

int OPENSSL_LH_error(OPENSSL_LHASH *lh);
OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c);
OPENSSL_LHASH *OPENSSL_LH_set_thunks(OPENSSL_LHASH *lh,
    OPENSSL_LH_HASHFUNCTHUNK hw,
    OPENSSL_LH_COMPFUNCTHUNK cw,
    OPENSSL_LH_DOALL_FUNC_THUNK daw,
    OPENSSL_LH_DOALL_FUNCARG_THUNK daaw);
void OPENSSL_LH_free(OPENSSL_LHASH *lh);
void OPENSSL_LH_flush(OPENSSL_LHASH *lh);
void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data);
void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data);
void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data);
void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func);
void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh,
    OPENSSL_LH_DOALL_FUNCARG func, void *arg);
void OPENSSL_LH_doall_arg_thunk(OPENSSL_LHASH *lh,
    OPENSSL_LH_DOALL_FUNCARG_THUNK daaw,
    OPENSSL_LH_DOALL_FUNCARG fn, void *arg);

unsigned long OPENSSL_LH_strhash(const char *c);
unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh);
unsigned long OPENSSL_LH_get_down_load(constMP_PKISI *si);
typedef int (*OSSL_CMP_SRV_pollReq_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
    const OSSL_CMP_MSG *req, int certReqId,
    OSSL_CMP_MSG **certReq,
    int64_t *check_after);
int OSSL_CMP_SRV_CTX_init(OSSL_CMP_SRV_CTX *srv_ctx, void *custom_ctx,
    OSSL_CMP_SRV_cert_request_cb_t process_cert_request,
    OSSL_CMP_SRV_rr_cb_t process_rr,
    OSSL_CMP_SRV_genm_cb_t process_genm,
    OSSL_CMP_SRV_error_cb_t process_error,
    OSSL_CMP_SRV_certConf_cb_t process_certConf,
    OSSL_CMP_SRV_pollReq_cb_t process_pollReq);
typedef int (*OSSL_CMP_SRV_delayed_delivery_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
    const OSSL_CMP_MSG *req);
typedef int (*OSSL_CMP_SRV_clean_transaction_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
    const ASN1_OCTET_STRING *id);
int OSSL_CMP_SRV_CTX_init_trans(OSSL_CMP_SRV_CTX *srv_ctx,
    OSSL_CMP_SRV_delayed_delivery_cb_t delay,
    OSSL_CMP_SRV_clean_transaction_cb_t clean);
OSSL_CMP_CTX *OSSL_CMP_SRV_CTX_get0_cmp_ctx(const OSSL_CMP_SRV_CTX *srv_ctx);
void *OSSL_CMP_SRV_CTX_get0_custom_ctx(const OSSL_CMP_SRV_CTX *srv_ctx);
int OSSL_CMP_SRV_CTX_set_send_unprotected_errors(OSSL_CMP_SRV_CTX *srv_ctx,
    int val);
int OSSL_CMP_SRV_CTX_set_accept_unprotected(OSSL_CMP_SRV_CTX *srv_ctx, int val);
int OSSL_CMP_SRV_CTX_set_accept_raverified(OSSL_CMP_SRV_CTX *srv_ctx, int val);
int OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(OSSL_CMP_SRV_CTX *srv_ctx,
    int val);

/* from cmp_client.c */
X509 *OSSL_CMP_exec_certreq(OSSL_CMP_CTX *ctx, int req_type,
    const OSSL_CRMF_MSG *crm);
#deCERTRESPONSE_sk_type(sk), ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp)))

/* clang-format on */
typedef STACK_OF(ASN1_UTF8STRING) OSSL_CMP_PKIFREETEXT;

/*
 * function DECLARATIONS
 */

/* from cmp_asn.c */
OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value);
void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type,
    ASN1_TYPE *value);
ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav);
ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav);
int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **sk_p,
    OSSL_CMP_ITAV *itav);
void OSSL_CMP_ITAV_free(OSSL_CMP_ITAV *itav);

OSSL_CMP_ITAV *OSSL_CMP_ITAV_new0_certProfile(STACK_OF(ASN1_UTF8STRING)
        *certProfile);
int OSSL_CMP_ITAV_get0_certProfile(const OSSL_CMP_ITAV *itav,
    STACK_OF(ASN1_UTF8STRING) **out);
OSSL_CMP_ITAV *OSSL_CMP_ITAV_new_caCerts(const STACK_OF(X509) *caCerts);
int OSSL_CMP_ITAV_get0_caCerts(const OSSL_CMP_ITAV *itav, STACK_OF(X509) **out);

OSSL_CMP_ITAV *OSSL_CMP_ITAV_new_rootCaCert(const X509 *rootCaCert);
int OSSL_CMP_ITAV_get0_rootCaCert(const OSSL_CMP_ITAV *itav, X509 **out);
OSSL_CMP_ITAV *OSSL_CMP_ITAV_new_rootCaKeyUpdate(const X509 *newWithNew,
    const X509 *newWithOld,
    const X509 *oldWithNew);
int OSSL_CMP_ITAV_get0_rootCaKeyUpdate(const OSSL_CMP_ITAV *itav,
    X509 **newWithNew,
    X509 **newWithOld,
    X509 **oldWithNew);

OSSL_CMP_CRLSTATUS *OSSL_CMP_CRLSTATUS_create(const X509_CRL *crl,
    const X509 *cert, int only_DN);
OSSL sk_OSSL_CMP_CRLSTATUS_new_reserve(cmp, n) \
    ((STACK_OF(OSSL_CMP_CRLSTATUS) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_new_reserve(ossl_check_OSSL_CMP_CRLSTATUS_compfunc_type(cmp), (n)), \
                sk_OSSL_CMP_CRLSTATUS_cmpfunc_thunk), \
            sk_OSSL_CMP_CRLSTATUS_copyfunc_thunk), \
        sk_OSSL_CMP_CRLSTATUS_freefunc_thunk))
#define sk_OSSL_CMP_CRLSTATUS_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), (n))
#define sk_OSSL_CMP_CRLSTATUS_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk))
#define sk_OSSL_CMP_CRLSTATUS_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk))
#define sk_OSSL_CMP_CRLSTATUS_delete(sk, i) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), (i)))
#define sk_OSSL_CMP_CRLSTATUS_delete_ptr(sk, ptr) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr)))
#define sk_OSSL_CMP_CRLSTATUS_push(sk, ptr) OPENSSL_sk_push(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr))
#define sk_OSSL_CMP_CRLSTATUS_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk), ossl_check_OSSL_CMP_CRLSTATUS_type(ptr))
#define sk_OSSL_CMP_CRLSTATUS_pop(sk) ((OSSL_CMP_CRLSTATUS *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_CRLSTATUS_sk_type(sk)))
#define sk_OSSL_CMP_CRLSTATUS_shift(   revocationNotification (5),
 *       -- notification that a revocation has occurred
 *       keyUpdateWarning       (6)
 *       -- update already done for the oldCertId specified in
 *       -- CertReqMsg
 *   }
 */
#define OSSL_CMP_PKISTATUS_rejected_by_client -5
#define OSSL_CMP_PKISTATUS_checking_response -4
#define OSSL_CMP_PKISTATUS_request -3
#define OSSL_CMP_PKISTATUS_trans -2
#define OSSL_CMP_PKISTATUS_unspecified -1
#define OSSL_CMP_PKISTATUS_accepted 0
#define OSSL_CMP_PKISTATUS_grantedWithMods 1
#define OSSL_CMP_PKISTATUS_rejection 2
#define OSSL_CMP_PKISTATUS_waiting 3
#define OSSL_CMP_PKISTATUS_revocationWarning 4
#define OSSL_CMP_PKISTATUS_revocationNotification 5
#define OSSL_CMP_PKISTATUS_keyUpdateWarning 6
typedef ASN1_INTEGER OSSL_CMP_PKISTATUS;

DECLARE_ASN1_ITEM(OSSL_CMP_PKISTATUS)

#define OSSL_CMP_CERTORENCCERT_CERTIFICATE 0
#define OSSL_CMP_CERTORENCCERT_ENCRYPTEDCERT 1

/* data type declarations */
typedef struct ossl_cmp_ctx_st OSSL_CMP_CTX;
typedef struct ossl_cmp_pkiheader_st OSSL_CMP_PKIHEADER;
DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER)
typedef struct ossl_cmp_msg_st OSSL_CMP_MSG;
DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
DECLARE_ASN1_ENCODE_FUNCTIONS(OSSL_CMP_MSG, OSSL_CMP_MSG, OSSL_CMP_MSG)
typedef struct ossl_cmp_certstatus_st OSSL_CMP_CERTSTATUS;
/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTSTATUS, OSSL_CMP_CERTSTATUS, OSSL_CMP_CERTSTATUS)
#define sk_OSSL_CMP_CERTSTATUS_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_t_new_ex_func *asn1_ex_new_ex;
    ASN1_ex_d2i_ex *asn1_ex_d2i_ex;
} ASN1_EXTERN_FUNCS;

typedef struct ASN1_PRIMITIVE_FUNCS_st {
    void *app_data;
    unsigned long flags;
    ASN1_ex_new_func *prim_new;
    ASN1_ex_free_func *prim_free;
    ASN1_ex_free_func *prim_clear;
    ASN1_primitive_c2i *prim_c2i;
    ASN1_primitive_i2c *prim_i2c;
    ASN1_primitive_print *prim_print;
} ASN1_PRIMITIVE_FUNCS;

/*
 * This is the ASN1_AUX structure: it handles various miscellaneous
 * requirements. For example the use of reference counts and an informational
 * callback. The "informational callback" is called at various points during
 * the ASN1 encoding and decoding. It can be used to provide minor
 * customisation of the structures used. This is most useful where the
 * supplied routines *almost* do the right thing but need some extra help at
 * a few points. If the callback returns zero then it is assumed a fatal
 * error has occurred and the main operation should be abandoned. If major
 * changes in the default behaviour are required then an external type is
 * more appropriate.
 * For the operations ASN1_OP_I2D_PRE, ASN1_OP_I2D_POST, ASN1_OP_PRINT_PRE, and
 * ASN1_OP_PRINT_POST, meanwhile a variant of the callback with const parameter
 * 'in' is provided to make clear statically that its input is not modified. If
 * and only if this variant is in use the flag ASN1_AFLG_CONST_CB must be set.
 */

typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
    void *exarg);
tye ASN1_CHOICE_END_cb(stname, tname, selname)     \
    ;                                                  \
    ASN1_ITEM_start(tname)                             \
        ASN1_ITYPE_CHOICE,                             \
        offsetof(stname, selname),                     \
        tname##_ch_tt,                                 \
        sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), \
        &tname##_aux,                                  \
        sizeof(stname),                                \
        #stname ASN1_ITEM_end(tname)

/* This helps with the template wrapper form of ASN1_ITEM */

#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
    (flags), (tag), 0,                                  \
    #name, ASN1_ITEM_ref(type)                          \
}

/* These help with SEQUENCE or CHOICE components */

/* used to declare other types */

#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
    (flags), (tag), offsetof(stname, field),            \
    #field, ASN1_ITEM_ref(type)                         \
}

/* implicit and explicit helper macros */

#define ASN1_IMP_EX(stname, field, type, tag, ex) \
    ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type)

#define ASN1_EXP_EX(stname, field, type, tag, ex) \
    ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type)

/* Any defined by macros: the field used is in the table itself */

#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
#define ASN1_ADB_I * The EXTERN type uses a new style d2i/i2d.
 * The new style should be used where possible
 * because it avoids things like the d2i IMPLICIT
 * hack.
 *
 * MSTRING is a multiple string type, it is used
 * for a CHOICE of character strings where the
 * actual strings all occupy an ASN1_STRING
 * structure. In this case the 'utype' field
 * has a special meaning, it is used as a mask
 * of acceptable types using the B_ASN1 constants.
 *
 * NDEF_SEQUENCE is the same as SEQUENCE except
 * that it will use indefinite length constructed
 * encoding if requested.
 *
 */

#define ASN1_ITYPE_PRIMITIVE 0x0
#define ASN1_ITYPE_SEQUENCE 0x1
#define ASN1_ITYPE_CHOICE 0x2
/* unused value                          0x3 */
#define ASN1_ITYPE_EXTERN 0x4
#define ASN1_ITYPE_MSTRING 0x5
#define ASN1_ITYPE_NDEF_SEQUENCE 0x6

/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)()))

/* Macros for start and end of ASN1_ITEM definition */

#define ASN1_ITEM_start(itname)        \
    const ASN1_ITEM *itname##_it(void) \
    {                                  \
        static const ASN1_ITEM local_it = {

#define static_ASN1_ITEM_start(itname) \
    static ASN1_ITEM_start(itname)

#define ASN1_ITEM_end(itname) \
    }                         \
    ;                         \
    return &local_it;         \
    }

/* Macros to aid ASN1 template writing */

#define ASN1_ITEM_TEMPLATE(tname) \
    static const ASN1_TEMPLATE tname##_item_tt

#tring of bytes with no further specification.  It is
 * expected to be printed as a hexdump.
 *
 * The difference between this and OSSL_PARAM_OCTET_STRING is that only pointers
 * are manipulated for this type.
 *
 * This is more relevant for parameter requests, where the responding
 * function doesn't need to copy the data to the provided buffer, but
 * sets the provided buffer to point at the actual data instead.
 *
 * WARNING!  Using these is FRAGILE, as it assumes that the actual
 * data and its location are constant.
 *
 * EXTRA WARNING!  If you are not completely sure you most likely want
 * to use the OSSL_PARAM_OCTET_STRING type.
 */
#define OSSL_PARAM_OCTET_PTR 7

/*
 * Typedef for the thread stop handling callback. Used both internally and by
 * providers.
 *
 * Providers may register for notifications about threads stopping by
 * registering a callback to hear about such events. Providers register the
 * callback using the OSSL_FUNC_CORE_THREAD_START function in the |in| dispatch
 * table passed to OSSL_provider_init(). The arg passed back to a provider will
 * be the provider side context object.
 */
typedef void (*OSSL_thread_stop_handler_fn)(void *arg);

/*-
 * Provider entry point
 * --------------------
 *
 * This function is expected to be present in any dynamically loadable
 * provider module.  By definition, if this function doesn't exist in a
 * module, that module is not an OpenSSL provider module.
 */
/*-
 * |handle|     pointer to opaque type OSSL_CORE_HANDLE.  Tharams, (fp), (unsigned char *)(x))
#define d2i_DSAparams_bio(bp, x) \
    ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAparams, bp, x)
#define i2d_DSAparams_bio(bp, x) \
    ASN1_i2d_bio_of(DSA, i2d_DSAparams, bp, x)

DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSAparams)
OSSL_DEPRECATEDIN_3_0 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen,
    DSA *dsa);
OSSL_DEPRECATEDIN_3_0 int DSA_do_verify(const unsigned char *dgst, int dgst_len,
    DSA_SIG *sig, DSA *dsa);

OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_OpenSSL(void);

OSSL_DEPRECATEDIN_3_0 void DSA_set_default_method(const DSA_METHOD *);
OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_get_default_method(void);
OSSL_DEPRECATEDIN_3_0 int DSA_set_method(DSA *dsa, const DSA_METHOD *);
OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_get_method(DSA *d);

OSSL_DEPRECATEDIN_3_0 DSA *DSA_new(void);
OSSL_DEPRECATEDIN_3_0 DSA *DSA_new_method(ENGINE *engine /* must be NULL */);
OSSL_DEPRECATEDIN_3_0 void DSA_free(DSA *r);
/* "up" the DSA object's reference count */
OSSL_DEPRECATEDIN_3_0 int DSA_up_ref(DSA *r);
OSSL_DEPRECATEDIN_3_0 int DSA_size(const DSA *);
OSSL_DEPRECATEDIN_3_0 int DSA_bits(const DSA *d);
OSSL_DEPRECATEDIN_3_0 int DSA_security_bits(const DSA *d);
/* next 4 return -1 on error */
OSSL_DEPRECATEDIN_3_0 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in,
    BIGNUM **kinvp, BIGNUM **rp);
OSSL_DEPRECATEDIN_3_0 int DSA_sign(int type, const unsigned char *dgst,
    int dlen, unsigned char *sig,
    unsigned int *siglen, DSA *;
int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);

int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);
ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai);
BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);

/* General */
/* given a string, return the correct type, max is the maximum length */
int ASN1_PRINTABLE_type(const unsigned char *s, int max);

unsigned long ASN1_tag2bit(int tag);

/* SPECIALS */
int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
    int *pclass, long omax);
int ASN1_check_infinite_end(unsigned char **p, long len);
int ASN1_const_check_infinite_end(const unsigned char **p, long len);
void ASN1_put_object(unsigned char **pp, int constructed, int length,
    int tag, int xclass);
int ASN1_put_eoc(unsigned char **pp);
int ASN1_object_size(int constructed, int length, int tag);

/* Used to implement other functions */
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x);

#define ASN1_dup_of(type, i2d, d2i, x)           \
    ((type *)ASN1_dup(CHECKED_I2D_OF(type, i2d), \
        CHECKED_D2I_OF(type, d2i),               \
        CHECKED_PTR_OF(const type, x)))

void *ASN1_item_dup(const ASN1_ITEM *it, const void *x);
int ASN1_item_sign_ex(const ASN1_ITEM *it, X509_ALGOR *algor1,
    X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
    const void *data, const ASN1_OCTET_STRING *id,
    EVP_PKEY *pkey, const EVP_MD *md, OSSL_EDIN_3_0 void ASN1_STRING_length_set(ASN1_STRING *x, int n);
#endif
int ASN1_STRING_type(const ASN1_STRING *x);
const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x);

DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
#ifndef OPENSSL_NO_DEPRECATED_4_1
OSSL_DEPRECATEDIN_4_1_FOR("use ASN1_BIT_STRING_set1()")
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a,
    unsigned char *d, int length);
#endif
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n);
int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,
    const unsigned char *flags, int flags_len);

#if !defined(OPENSSL_NO_DEPRECATED_4_1)
OSSL_DEPRECATEDIN_4_1 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
    BIT_STRING_BITNAME *tbl, int indent);
OSSL_DEPRECATEDIN_4_1 int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl);
OSSL_DEPRECATEDIN_4_1 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value,
    BIT_STRING_BITNAME *tbl);
#endif /* !defined(OPENSSL_NO_DEPRECATED_4_1) */
int ASN1_BIT_STRING_get_length(const ASN1_BIT_STRING *abs, size_t *length,
    int *unused_bits);
int ASN1_BIT_STRING_set1(ASN1_BIT_STRING *abs, const uint8_t *data,
    size_t length, int unused_bits);

/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(ASN1_INTEGER, ASN1_INTEGER, ASN1_INTEGER)
#define sk_ASN1_INTEGER_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_INTEGER_sk_type(sk))
#define sk_ASN1_INTEGER_value(sk, idx) ((ASN1_INTEGER *)OPEe_attr(attr, stname, fname)   \
    attr int fname##_print_ctx(BIO *out, const stname *x, int indent, \
        const ASN1_PCTX *pctx);
#define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \
    DECLARE_ASN1_PRINT_FUNCTION_fname_attr(extern, stname, fname)

#define D2I_OF(type) type *(*)(type **, const unsigned char **, long)
#define I2D_OF(type) int (*)(const type *, unsigned char **)

#define CHECKED_D2I_OF(type, d2i) \
    ((d2i_of_void *)(1 ? d2i : ((D2I_OF(type))0)))
#define CHECKED_I2D_OF(type, i2d) \
    ((i2d_of_void *)(1 ? i2d : ((I2D_OF(type))0)))
#define CHECKED_NEW_OF(type, xnew) \
    ((void *(*)(void))(1 ? xnew : ((type * (*)(void))0)))
#define CHECKED_PTR_OF(type, p) \
    ((void *)(1 ? p : (type *)0))
#define CHECKED_PPTR_OF(type, p) \
    ((void **)(1 ? p : (type **)0))

#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **, const unsigned char **, long)
#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(const type *, unsigned char **)
#define TYPEDEF_D2I2D_OF(type) \
    TYPEDEF_D2I_OF(type);      \
    TYPEDEF_I2D_OF(type)

typedef void *d2i_of_void(void **, const unsigned char **, long);
typedef int i2d_of_void(const void *, unsigned char **);
typedef int OSSL_i2d_of_void_ctx(const void *, unsigned char **, void *vctx);

/*-
 * The following macros and typedefs allow an ASN1_ITEM
 * to be embedded in a structure and referenced. Since
 * the ASN1_ITEM pointers need to be globally accessible
 * (possibly from shared libraries) they may exist in
 * di
 * NB the constants below are used internally by ASN1_INTEGER
 * and ASN1_ENUMERATED to indicate the sign. They are *not* on
 * the wire tag values.
 */

#define V_ASN1_NEG 0x100
#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)

/* For use with d2i_ASN1_type_bytes() */
#define B_ASN1_NUMERICSTRING 0x0001
#define B_ASN1_PRINTABLESTRING 0x0002
#define B_ASN1_T61STRING 0x0004
#define B_ASN1_TELETEXSTRING 0x0004
#define B_ASN1_VIDEOTEXSTRING 0x0008
#define B_ASN1_IA5STRING 0x0010
#define B_ASN1_GRAPHICSTRING 0x0020
#define B_ASN1_ISO64STRING 0x0040
#define B_ASN1_VISIBLESTRING 0x0040
#define B_ASN1_GENERALSTRING 0x0080
#define B_ASN1_UNIVERSALSTRING 0x0100
#define B_ASN1_OCTET_STRING 0x0200
#define B_ASN1_BIT_STRING 0x0400
#define B_ASN1_BMPSTRING 0x0800
#define B_ASN1_UNKNOWN 0x1000
#define B_ASN1_UTF8STRING 0x2000
#define B_ASN1_UTCTIME 0x4000
#define B_ASN1_GENERALIZEDTIME 0x8000
#define B_ASN1_SEQUENCE 0x10000
/* For use with ASN1_mbstring_copy() */
#define MBSTRING_FLAG 0x1000
#define MBSTRING_UTF8 (MBSTRING_FLAG)
#define MBSTRING_ASC (MBSTRING_FLAG | 1)
#define MBSTRING_BMP (MBSTRING_FLAG | 2)
#define MBSTRING_UNIV (MBSTRING_FLAG | 4)
#define SMIME_OLDMIME 0x400
#define SMIME_CRLFEOL 0x800
#define SMIME_STREAM 0x1000

/* Stacks for types not otherwise defined in this header */
/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(X509_ALGOR, X509_ALGOR, X509_ALGOR)
#define sk_X509_ALGOR_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ALGOR_sk_typDF_SESSION_ID "session_id"
# define OSSL_KDF_PARAM_SSHKDF_TYPE "type"
# define OSSL_KDF_PARAM_SSHKDF_XCGHASH "xcghash"
# define OSSL_KDF_PARAM_THREADS "threads"
# define OSSL_KDF_PARAM_UKM "ukm"
# define OSSL_KDF_PARAM_X942_ACVPINFO "acvp-info"
# define OSSL_KDF_PARAM_X942_PARTYUINFO "partyu-info"
# define OSSL_KDF_PARAM_X942_PARTYVINFO "partyv-info"
# define OSSL_KDF_PARAM_X942_SUPP_PRIVINFO "supp-privinfo"
# define OSSL_KDF_PARAM_X942_SUPP_PUBINFO "supp-pubinfo"
# define OSSL_KDF_PARAM_X942_USE_KEYBITS "use-keybits"
# define OSSL_KEM_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR
# define OSSL_KEM_PARAM_FIPS_KEY_CHECK OSSL_PKEY_PARAM_FIPS_KEY_CHECK
# define OSSL_KEM_PARAM_IKME "ikme"
# define OSSL_KEM_PARAM_OPERATION "operation"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_BLOCK_PADDING "block_padding"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_HS_PADDING "hs_padding"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_MAX_EARLY_DATA "max_early_data"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_MAX_FRAG_LEN "max_frag_len"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_MODE "mode"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_OPTIONS "options"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_READ_AHEAD "read_ahead"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_STREAM_MAC "stream_mac"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_TLSTREE "tlstree"
# define OSSL_LIBSSL_RECORD_LAYER_PARAM_USE_ETM "use_etm"
# define OSSL_LIBSSL_RECORD_LAYER_READ_BUFFER_LEN "read_buffer_len"
# define OSSL_MAC_PARAM_BLOCK_SIZE "block-size"
# deGROUP_CHECK_DEFAULT "default"
#define OSSL_PKEY_EC_GROUP_CHECK_NAMED "named"
#define OSSL_PKEY_EC_GROUP_CHECK_NAMED_NIST "named-nist"

/* PROV_SKEY well known key types */
#define OSSL_SKEY_TYPE_GENERIC "GENERIC-SECRET"
#define OSSL_SKEY_TYPE_AES "AES"

/* OSSL_KEM_PARAM_OPERATION values */
#define OSSL_KEM_PARAM_OPERATION_RSASVE "RSASVE"
#define OSSL_KEM_PARAM_OPERATION_DHKEM "DHKEM"

/* Parameter name definitions - generated by util/perl/OpenSSL/paramnames.pm */
/* clang-format off */
# define OSSL_ALG_PARAM_ALGORITHM_ID "algorithm-id"
# define OSSL_ALG_PARAM_ALGORITHM_ID_PARAMS "algorithm-id-params"
# define OSSL_ALG_PARAM_CIPHER "cipher"
# define OSSL_ALG_PARAM_DIGEST "digest"
# define OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR "fips-indicator"
# define OSSL_ALG_PARAM_MAC "mac"
# define OSSL_ALG_PARAM_PROPERTIES "properties"
# define OSSL_ALG_PARAM_SECURITY_CATEGORY "security-category"
# define OSSL_ASYM_CIPHER_PARAM_DIGEST OSSL_PKEY_PARAM_DIGEST
# define OSSL_ASYM_CIPHER_PARAM_FIPS_APPROVED_INDICATOR OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR
# define OSSL_ASYM_CIPHER_PARAM_FIPS_KEY_CHECK OSSL_PKEY_PARAM_FIPS_KEY_CHECK
# define OSSL_ASYM_CIPHER_PARAM_FIPS_RSA_PKCS15_PAD_DISABLED OSSL_PROV_PARAM_RSA_PKCS15_PAD_DISABLED
# define OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION "implicit-rejection"
# define OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST OSSL_PKEY_PARAM_MGF1_DIGEST
# define OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS OSSL_PKEY_PARAM_MGF1_PROPERTIES
# define OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST OSSL_AIO_get_line(BIO *bio, char *buf, int size);
int BIO_write(BIO *b, const void *data, int dlen);
int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
__owur int BIO_sendmmsg(BIO *b, BIO_MSG *msg,
    size_t stride, size_t num_msg, uint64_t flags,
    size_t *msgs_processed);
__owur int BIO_get_rpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
__owur int BIO_get_wpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
int BIO_puts(BIO *bp, const char *buf);
int BIO_indent(BIO *b, int indent, int max);
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
int BIO_eof(BIO *b);
long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);
void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
BIO *BIO_push(BIO *b, BIO *append);
BIO *BIO_pop(BIO *b);
void BIO_free_all(BIO *a);
BIO *BIO_find_type(BIO *b, int bio_type);
BIO *BIO_next(BIO *b);
void BIO_set_next(BIO *b, BIO *next);
BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
int BIO_get_retry_reason(BIO *bio);
void BIO_set_retry_reason(BIO *bio, int reason);
BIO *BIO_dup_chain(BIO *in);

int BIO_nread0(BIO *bio, char **buf);
int BIO_nread(BIO *bio, char **buf, int num);
int BIO_nwrite0(BIO *bio, char **buf);
int BIO_nwrite(BIO *bio, char **buf, int num);

const BIO_METHOD *BIO_s_mem(void);
#ifndef OPENSSL_NO_DGRAM
const BIO_METHOD *BIO_s_dgram_mem(void);
#endif
const BIO_METHOD *BIO_s_secmem(void);
BIO *BIO_new_mem_buf(const void *buf, int len);
#ifndef OPENSSL_NO_SOCK
const _DGRAM_GET_NO_TRUNC 88
#define BIO_CTRL_DGRAM_SET_NO_TRUNC 89

/*
 * internal BIO:
 * # define BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE 90
 */

#define BIO_CTRL_GET_RPOLL_DESCRIPTOR 91
#define BIO_CTRL_GET_WPOLL_DESCRIPTOR 92
#define BIO_CTRL_DGRAM_DETECT_PEER_ADDR 93
#define BIO_CTRL_DGRAM_SET0_LOCAL_ADDR 94

#define BIO_DGRAM_CAP_NONE 0U
#define BIO_DGRAM_CAP_HANDLES_SRC_ADDR (1U << 0)
#define BIO_DGRAM_CAP_HANDLES_DST_ADDR (1U << 1)
#define BIO_DGRAM_CAP_PROVIDES_SRC_ADDR (1U << 2)
#define BIO_DGRAM_CAP_PROVIDES_DST_ADDR (1U << 3)

#ifndef OPENSSL_NO_KTLS
#define BIO_get_ktls_send(b) \
    (BIO_ctrl(b, BIO_CTRL_GET_KTLS_SEND, 0, NULL) > 0)
#define BIO_get_ktls_recv(b) \
    (BIO_ctrl(b, BIO_CTRL_GET_KTLS_RECV, 0, NULL) > 0)
#else
#define BIO_get_ktls_send(b) (0)
#define BIO_get_ktls_recv(b) (0)
#endif

/* modifiers */
#define BIO_FP_READ 0x02
#define BIO_FP_WRITE 0x04
#define BIO_FP_APPEND 0x08
#define BIO_FP_TEXT 0x10

#define BIO_FLAGS_READ 0x01
#define BIO_FLAGS_WRITE 0x02
#define BIO_FLAGS_IO_SPECIAL 0x04
#define BIO_FLAGS_RWS (BIO_FLAGS_READ | BIO_FLAGS_WRITE | BIO_FLAGS_IO_SPECIAL)
#define BIO_FLAGS_SHOULD_RETRY 0x08
#ifndef OPENSSL_NO_DEPRECATED_3_0
/* This #define was replaced by an internal constant and should not be used. */
#define BIO_FLAGS_UPLINK 0
#endif

/* the BIO FLAGS values 0x10 to 0x80 are reserved for internal use */

/*
 * BIO FLAGS in the range 0x0100..0x8000 are BIO-type specific.
 * Their meaning is defined by the particular BIO implementation and
 * is not shaMODULE_INTEGRITY_FAILURE 214
#define PROV_R_NOT_A_PRIVATE_KEY 221
#define PROV_R_NOT_A_PUBLIC_KEY 220
#define PROV_R_NOT_INSTANTIATED 193
#define PROV_R_NOT_PARAMETERS 226
#define PROV_R_NOT_SUPPORTED 136
#define PROV_R_NOT_XOF_OR_INVALID_LENGTH 113
#define PROV_R_NO_INSTANCE_ALLOWED 242
#define PROV_R_NO_KEY_SET 114
#define PROV_R_NO_PARAMETERS_SET 177
#define PROV_R_NULL_LENGTH_POINTER 247
#define PROV_R_NULL_OUTPUT_BUFFER 248
#define PROV_R_ONESHOT_CALL_OUT_OF_ORDER 239
#define PROV_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 178
#define PROV_R_OUTPUT_BUFFER_TOO_SMALL 106
#define PROV_R_PARENT_CANNOT_GENERATE_RANDOM_NUMBERS 228
#define PROV_R_PARENT_CANNOT_SUPPLY_ENTROPY_SEED 187
#define PROV_R_PARENT_LOCKING_NOT_ENABLED 182
#define PROV_R_PARENT_STRENGTH_TOO_WEAK 194
#define PROV_R_PASSWORD_STRENGTH_TOO_WEAK 254
#define PROV_R_PATH_MUST_BE_ABSOLUTE 219
#define PROV_R_PERSONALISATION_STRING_TOO_LONG 195
#define PROV_R_PSS_SALTLEN_TOO_SMALL 172
#define PROV_R_REPEATED_PARAMETER 252
#define PROV_R_REQUEST_TOO_LARGE_FOR_DRBG 196
#define PROV_R_REQUIRE_CTR_MODE_CIPHER 206
#define PROV_R_RESEED_ERROR 197
#define PROV_R_SEARCH_ONLY_SUPPORTED_FOR_DIRECTORIES 222
#define PROV_R_SEED_SOURCES_MUST_NOT_HAVE_A_PARENT 229
#define PROV_R_SELF_TEST_KAT_FAILURE 215
#define PROV_R_SELF_TEST_POST_FAILURE 216
#define PROV_R_TAG_NOT_NEEDED 120
#define PROV_R_TAG_NOT_SET 119
#define PROV_R_TOO_MANY_RECORDS 126
#define PROV_R_UNABLE_TO_FIND_CIPHERS 207
#define PROV_R_UNABLE_TO_GET_PARENT_STRENGTH 199
#defiENGINE has (or gets from through the loader) its own copy of
 * the libcrypto static data, we will need to set the callbacks. The easiest
 * way to detect this is to have a function that returns a pointer to some
 * static data and let the loading application and loaded ENGINE compare
 * their respective values.
 */
/* void *ENGINE_get_static_state(void); */
ENGINE_FUNC_NOARGS(void *, ENGINE_get_static_state, NULL)

#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
#ifndef OPENSSL_NO_DEPRECATED_1_1_0
/* OSSL_DEPRECATEDIN_1_1_0 void ENGINE_setup_bsd_cryptodev(void); */
ENGINE_VOID_FUNC_NOARGS(ENGINE_setup_bsd_cryptodev)
#endif
#endif

/*
 * Stubs for ENGINE-related API functions that were removed
 * from other headers.
 */

#ifndef OPENSSL_NO_DEPRECATED_3_0
/* int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e); */
ENGINE_FUNC(int, EVP_PKEY_set1_engine, (EVP_PKEY *pkey, ENGINE *e), 0)

/* ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey); */
ENGINE_FUNC(ENGINE *, EVP_PKEY_get0_engine, (const EVP_PKEY *pkey), NULL)

/* ENGINE *DH_get0_engine(DH *d); */
ENGINE_FUNC(ENGINE *, DH_get0_engine, (DH *d), NULL)

/* ENGINE *RSA_get0_engine(const RSA *r); */
ENGINE_FUNC(ENGINE *, RSA_get0_engine, (const RSA *r), NULL)

/* ENGINE *DSA_get0_engine(DSA *d); */
ENGINE_FUNC(ENGINE *, DSA_get0_engine, (DSA *d), NULL)

/* ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey); */
ENGINE_FUNC(ENGINE *, EC_KEY_get0_engine, (const EC_KEY *eckey), NULL)

/* const ENGINE *OSSL_STORE_LOADER_" data from an ENGINE_ctrl()
 * operation in this function will be lost - the return value is interpreted
 * as failure if the return value is zero, success otherwise, and this
 * function returns a boolean value as a result. In other words, vendors of
 * 'ENGINE'-enabled devices should write ENGINE implementations with
 * parameterisations that work in this scheme, so that compliant ENGINE-based
 * applications can work consistently with the same configuration for the
 * same ENGINE-enabled devices, across applications.
 */
#ifndef OPENSSL_NO_DEPRECATED_3_0
/*
 * OSSL_DEPRECATEDIN_3_0
 * int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
 *                            int cmd_optional);
 */
ENGINE_FUNC(int, ENGINE_ctrl_cmd_string,
    (ENGINE *e, const char *cmd_name, const char *arg, int cmd_optional), 0)
#endif

/*
 * These functions are useful for manufacturing new ENGINE structures. They
 * don't address reference counting at all - one uses them to populate an
 * ENGINE structure with personalised implementations of things prior to
 * using it directly or adding it to the builtin ENGINE list in OpenSSL.
 * These are also here so that the ENGINE structure doesn't have to be
 * exposed and break binary compatibility!
 */
#ifndef OPENSSL_NO_DEPRECATED_3_0
/* OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_new(void); */
ENGINE_FUNC_NOARGS(ENGINE *, ENGINE_new, NULL)
/* OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e); */
ENGINE_FUNC(int, ENGINE_free, (ENGINE *e), 0)
/* OSADER_ENGINE_H
#endif

#include <openssl/opensslconf.h>

/*
 * Engine support is gone. Definitions here are provided for the source code
 * compatibility only. They are meant to keep compilation working for legacy
 * projects that, for whatever reason, cannot remove/disable old legacy code.
 *
 * We deliberately keep the OPENSSL_NO_ENGINE macro around as it is supplied
 * when the build is configured with the `no-engine` option. OpenSSL 4.0 keeps
 * the `no-engine` option around.
 *
 * Note, we have to use a compile-time message to warn only if the API is really
 * used. To avoid complex macros, we kind of abuse the existing OSSL_DEPRECATED
 * macros.
 */

#ifdef OPENSSL_ENGINE_STUBS
#define ENGINE_INFO_MSG \
    " API symbol is replaced with stub to avoid linker error."

#define ENGINE_FUNC(ret_type, name, args, default_val) \
    OSSL_DEPRECATED_MESSAGE(#name ENGINE_INFO_MSG)     \
    static ossl_inline ret_type name args              \
    {                                                  \
        return default_val; /* stub return */          \
    }

#define ENGINE_FUNC_NOARGS(ret_type, name, default_val) \
    OSSL_DEPRECATED_MESSAGE(#name ENGINE_INFO_MSG)      \
    static ossl_inline ret_type name(void)              \
    {                                                   \
        return default_val; /* stub return */           \
    }

#define ENGINE_VOID_FUNC(name, args)               \
    OSSL_DEPRECATED_MESSAGE(#name ENGINE_INFO_MSG) \
    static ossl_inline void name aHE-PSK-CAMELLIA128-SHA256"
#define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-PSK-CAMELLIA256-SHA384"

/* SEED ciphersuites from RFC4162 */
#define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA"
#define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA"
#define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA"
#define TLS1_TXT_DHE_DSS_WITH_SEED_SHA "DHE-DSS-SEED-SHA"
#define TLS1_TXT_DHE_RSA_WITH_SEED_SHA "DHE-RSA-SEED-SHA"
#define TLS1_TXT_ADH_WITH_SEED_SHA "ADH-SEED-SHA"

/* TLS v1.2 ciphersuites */
#define TLS1_TXT_RSA_WITH_NULL_SHA256 "NULL-SHA256"
#define TLS1_TXT_RSA_WITH_AES_128_SHA256 "AES128-SHA256"
#define TLS1_TXT_RSA_WITH_AES_256_SHA256 "AES256-SHA256"
#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256 "DH-DSS-AES128-SHA256"
#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256 "DH-RSA-AES128-SHA256"
#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256 "DHE-DSS-AES128-SHA256"
#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256 "DHE-RSA-AES128-SHA256"
#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256 "DH-DSS-AES256-SHA256"
#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256 "DH-RSA-AES256-SHA256"
#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256 "DHE-DSS-AES256-SHA256"
#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256 "DHE-RSA-AES256-SHA256"
#define TLS1_TXT_ADH_WITH_AES_128_SHA256 "ADH-AES128-SHA256"
#define TLS1_TXT_ADH_WITH_AES_256_SHA256 "ADH-AES256-SHA256"

/* TLS v1.2 GCM ciphersuites from RFC5288 */
#define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 "AES128-GCM-SHA256"
#define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 "AES256-GCM-SHA384M_SHA384"
#define TLS1_RFC_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256"
#define TLS1_RFC_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384"
#define TLS1_RFC_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256"
#define TLS1_RFC_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384"
#define TLS1_RFC_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_PSK_WITH_ARIA_128_GCM_SHA256"
#define TLS1_RFC_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_PSK_WITH_ARIA_256_GCM_SHA384"
#define TLS1_RFC_DHE_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256"
#define TLS1_RFC_DHE_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384"
#define TLS1_RFC_RSA_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256"
#define TLS1_RFC_RSA_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384"
#define TLS1_3_RFC_SM4_GCM_SM3 "TLS_SM4_GCM_SM3"
#define TLS1_3_RFC_SM4_CCM_SM3 "TLS_SM4_CCM_SM3"

/*
 * XXX Backward compatibility alert: Older versions of OpenSSL gave some DHE
 * ciphers names with "EDH" instead of "DHE".  Going forward, we should be
 * using DHE everywhere, though we may indefinitely maintain aliases for
 * users or configurations that used "EDH"
 */
#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA"

#define TLS1_TXT_PSK_WITH_NULL_SHA "PSK-NULL-SHA"
#define TLS1_TXT_DHE_PSK_WITH_NULL_SHA "DHE-PSK-NULL-SHA"
#define TLS1_TXT_RSA_PSK_WITH_NULL_SHA "RSA-PSK-NULL-SHA"

/* AES cipher 0x0300C02F
#define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0x0300C030
#define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256 0x0300C031
#define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384 0x0300C032

/* ECDHE PSK ciphersuites from RFC5489 */
#define TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA 0x0300C033
#define TLS1_CK_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300C034
#define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA 0x0300C035
#define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA 0x0300C036

#define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0x0300C037
#define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA384 0x0300C038

/* NULL PSK ciphersuites from RFC4785 */
#define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA 0x0300C039
#define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA256 0x0300C03A
#define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA384 0x0300C03B

/* Camellia-CBC ciphersuites from RFC6367 */
#define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C072
#define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C073
#define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C074
#define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C075
#define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C076
#define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C077
#define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C078
#define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C079

#define TLS1_CK_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C094
#define TLS1_CK_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C095
#define TLS1_CK_DHE_PSKSSL_LH_node_usage_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out)
#define lh_CONF_VALUE_stats_bio(lh, out) OPENSSL_LH_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out)
#define lh_CONF_VALUE_get_down_load(lh) OPENSSL_LH_get_down_load(ossl_check_CONF_VALUE_lh_type(lh))
#define lh_CONF_VALUE_set_down_load(lh, dl) OPENSSL_LH_set_down_load(ossl_check_CONF_VALUE_lh_type(lh), dl)
#define lh_CONF_VALUE_doall(lh, dfn) OPENSSL_LH_doall(ossl_check_CONF_VALUE_lh_type(lh), ossl_check_CONF_VALUE_lh_doallfunc_type(dfn))

/* clang-format on */

struct conf_st;
struct conf_method_st;
typedef struct conf_method_st CONF_METHOD;

#ifndef OPENSSL_NO_DEPRECATED_3_0
#include <openssl/conftypes.h>
#endif

/* Module definitions */
typedef struct conf_imodule_st CONF_IMODULE;
typedef struct conf_module_st CONF_MODULE;

STACK_OF(CONF_MODULE);
STACK_OF(CONF_IMODULE);

/* DSO module function typedefs */
typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf);
typedef void conf_finish_func(CONF_IMODULE *md);

#define CONF_MFLAGS_IGNORE_ERRORS 0x1
#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2
#define CONF_MFLAGS_SILENT 0x4
#define CONF_MFLAGS_NO_DSO 0x8
#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
#define CONF_MFLAGS_DEFAULT_SECTION 0x20

int CONF_set_default_method(CONF_METHOD *meth);
void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
    long *eline);
#ifndef OPENSSL_NO_STDIO
LHASH_OF(CONF_VALUE) *CONF_load_fp(P_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
    ASN1_OCTET_STRING **pikeyHash,
    ASN1_INTEGER **pserial, OCSP_CERTID *cid);
int OCSP_request_is_signed(OCSP_REQUEST *req);
OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,
    OCSP_CERTID *cid,
    int status, int reason,
    ASN1_TIME *revtime,
    ASN1_TIME *thisupd,
    ASN1_TIME *nextupd);
int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
int OCSP_basic_sign(OCSP_BASICRESP *brsp,
    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
    const STACK_OF(X509) *certs, unsigned long flags);
int OCSP_basic_sign_ctx(OCSP_BASICRESP *brsp,
    X509 *signer, EVP_MD_CTX *ctx,
    const STACK_OF(X509) *certs, unsigned long flags);
int OCSP_RESPID_set_by_name(OCSP_RESPID *respid, X509 *cert);
int OCSP_RESPID_set_by_key_ex(OCSP_RESPID *respid, X509 *cert,
    OSSL_LIB_CTX *libctx, const char *propq);
int OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert);
int OCSP_RESPID_match_ex(OCSP_RESPID *respid, X509 *cert, OSSL_LIB_CTX *libctx,
    const char *propq);
int OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert);

X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim);

X509_EXTENSION *OCSP_accept_responses_new(char **oids);

X509_EXTENSION *OCSP_archive_cutoff_new(char *tim);

X509_EXTENSION *OCSP_url_svcloc_new(const X509_NAME *issuer, const char **urls);

int OCESPONSE, o))

#define i2d_OCSP_REQUEST_bio(bp, o)                 \
    ASN1_item_i2d_bio(ASN1_ITEM_rptr(OCSP_REQUEST), \
        (bp), CHECKED_PTR_OF(const OCSP_REQUEST, o))

#define ASN1_BIT_STRING_digest(data, type, md, len) \
    ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING), type, data, md, len)

#define OCSP_CERTSTATUS_dup(cs)                                     \
    (OCSP_CERTSTATUS *)ASN1_dup((i2d_of_void *)i2d_OCSP_CERTSTATUS, \
        (d2i_of_void *)d2i_OCSP_CERTSTATUS, (char *)(cs))

DECLARE_ASN1_DUP_FUNCTION(OCSP_CERTID)

OSSL_HTTP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path,
    const OCSP_REQUEST *req, int buf_size);
OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);

#ifndef OPENSSL_NO_DEPRECATED_3_0
typedef OSSL_HTTP_REQ_CTX OCSP_REQ_CTX;
#define OCSP_REQ_CTX_new(io, buf_size) \
    OSSL_HTTP_REQ_CTX_new(io, io, buf_size)
#define OCSP_REQ_CTX_free OSSL_HTTP_REQ_CTX_free
#define OCSP_REQ_CTX_http(rctx, op, path) \
    (OSSL_HTTP_REQ_CTX_set_expected(rctx, NULL, 1 /* asn1 */, 0, 0) && OSSL_HTTP_REQ_CTX_set_request_line(rctx, strcmp(op, "POST") == 0, NULL, NULL, path))
#define OCSP_REQ_CTX_add1_header OSSL_HTTP_REQ_CTX_add1_header
#define OCSP_REQ_CTX_i2d(r, it, req) \
    OSSL_HTTP_REQ_CTX_set1_req(r, "application/ocsp-request", it, req)
#define OCSP_REQ_CTX_set1_req(r, req) \
    OCSP_REQ_CTX_i2d(r, ASN1_ITEM_rptr(OCSP_REQUEST), (ASN1_VALUE *)(req))
#define OCSP_REQ_CTX_nbio OSSL_HTTP_REQ_CTX_nbio
#define OCSP_REQ_CTX_nbio_d2i OSSL_RL 8
#define OCSP_REVOKED_STATUS_PRIVILEGEWITHDRAWN 9
#define OCSP_REVOKED_STATUS_AACOMPROMISE 10

#ifndef OPENSSL_NO_OCSP

#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/safestack.h>
#include <openssl/ocsperr.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Various flags and values */

#define OCSP_DEFAULT_NONCE_LENGTH 16

#define OCSP_NOCERTS 0x1
#define OCSP_NOINTERN 0x2
#define OCSP_NOSIGS 0x4
#define OCSP_NOCHAIN 0x8
#define OCSP_NOVERIFY 0x10
#define OCSP_NOEXPLICIT 0x20
#define OCSP_NOCASIGN 0x40
#define OCSP_NODELEGATED 0x80
#define OCSP_NOCHECKS 0x100
#define OCSP_TRUSTOTHER 0x200
#define OCSP_RESPID_KEY 0x400
#define OCSP_NOTIME 0x800
#define OCSP_PARTIAL_CHAIN 0x1000

typedef struct ocsp_cert_id_st OCSP_CERTID;
typedef struct ocsp_one_request_st OCSP_ONEREQ;
typedef struct ocsp_req_info_st OCSP_REQINFO;
typedef struct ocsp_signature_st OCSP_SIGNATURE;
typedef struct ocsp_request_st OCSP_REQUEST;

/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(OCSP_CERTID, OCSP_CERTID, OCSP_CERTID)
#define sk_OCSP_CERTID_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_CERTID_sk_type(sk))
#define sk_OCSP_CERTID_value(sk, idx) ((OCSP_CERTID *)OPENSSL_sk_value(ossl_check_const_OCSP_CERTID_sk_type(sk), (idx)))
#define sk_OCSP_CERTID_new(cmp) \
    ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_new(ossl_check_OCSP_CERTID_compfunc_type(cmp)), \
                sk_OCSUTETYPEANDVALUE_cmpfunc_thunk), \
            sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_copyfunc_thunk), \
        sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_freefunc_thunk))
#define sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_set_cmp_func(sk, cmp) ((sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_sk_type(sk), ossl_check_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_compfunc_type(cmp)))

/* clang-format on */

typedef struct ossl_crmf_pbmparameter_st OSSL_CRMF_PBMPARAMETER;
DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PBMPARAMETER)
typedef struct ossl_crmf_poposigningkey_st OSSL_CRMF_POPOSIGNINGKEY;
typedef struct ossl_crmf_certrequest_st OSSL_CRMF_CERTREQUEST;
typedef struct ossl_crmf_certid_st OSSL_CRMF_CERTID;
DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTID)
DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID)
/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CRMF_CERTID, OSSL_CRMF_CERTID, OSSL_CRMF_CERTID)
#define sk_OSSL_CRMF_CERTID_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk))
#define sk_OSSL_CRMF_CERTID_value(sk, idx) ((OSSL_CRMF_CERTID *)OPENSSL_sk_value(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk), (idx)))
#define sk_OSSL_CRMF_CERTID_new(cmp) \
    ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_new(ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp)), \
                sk_OSSL_CRMF_CERTID_cmpfunc_thunk), \
            sk_OSSL_CRMF_CERTID_copyPE_NOT_ENVELOPED_DATA 107
#define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108
#define CMS_R_CONTENT_VERIFY_ERROR 109
#define CMS_R_CTRL_ERROR 110
#define CMS_R_CTRL_FAILURE 111
#define CMS_R_DECODE_ERROR 187
#define CMS_R_DECRYPT_ERROR 112
#define CMS_R_ERROR_GETTING_PUBLIC_KEY 113
#define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114
#define CMS_R_ERROR_SETTING_KEY 115
#define CMS_R_ERROR_SETTING_RECIPIENTINFO 116
#define CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT 196
#define CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR 183
#define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117
#define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176
#define CMS_R_INVALID_KEY_LENGTH 118
#define CMS_R_INVALID_LABEL 190
#define CMS_R_INVALID_OAEP_PARAMETERS 191
#define CMS_R_KDF_PARAMETER_ERROR 186
#define CMS_R_MD_BIO_INIT_ERROR 119
#define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120
#define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121
#define CMS_R_MSGSIGDIGEST_ERROR 172
#define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162
#define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163
#define CMS_R_NEED_ONE_SIGNER 164
#define CMS_R_NOT_A_SIGNED_RECEIPT 165
#define CMS_R_NOT_ENCRYPTED_DATA 122
#define CMS_R_NOT_KEK 123
#define CMS_R_NOT_KEM 197
#define CMS_R_NOT_KEY_AGREEMENT 181
#define CMS_R_NOT_KEY_TRANSPORT 124
#define CMS_R_NOT_PWRI 177
#define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125
#define CMS_R_NO_CIPHER 126
#define CMS_R_NO_CONTENT 127
#define CMS_R_NO_CONTENT_TYPE 173
#define CMS_R_NO_DEFAULT_DIGEST 128
#define CMS_R_NO_DIGEST_SET 129
) *bags);
PKCS7 *PKCS12_pack_p7encdata_ex(int pbe_nid, const char *pass, int passlen,
    unsigned char *salt, int saltlen, int iter,
    STACK_OF(PKCS12_SAFEBAG) *bags,
    OSSL_LIB_CTX *ctx, const char *propq);

STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,
    int passlen);

int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);
STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12);

int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, const unsigned char *name,
    int namelen);
int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
    int namelen);
int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name,
    int namelen);
int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
    int namelen);
int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,
    const unsigned char *name, int namelen);
int PKCS12_add1_attr_by_NID(PKCS12_SAFEBAG *bag, int nid, int type,
    const unsigned char *bytes, int len);
int PKCS12_add1_attr_by_txt(PKCS12_SAFEBAG *bag, const char *attrname, int type,
    const unsigned char *bytes, int len);
int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);
const ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs,
    int attr_nid);
char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);
const STACK_OF(X509_ATTRIBUTE) *
PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag);
void PKCS12_SAFEBAG_set0_attrs(PKCS12_SAFEBAG *bag, STACK_OF(X509_ATTRIBUTE) *attrs);
unsignee used in
 * FIPS mode. This is set in the validated module method. If an application
 * sets this flag in its own methods it is its responsibility to ensure the
 * result is compliant.
 */

#define RSA_FLAG_FIPS_METHOD 0x0400

/*
 * If this flag is set the operations normally disabled in FIPS mode are
 * permitted it is then the applications responsibility to ensure that the
 * usage is compliant.
 */

#define RSA_FLAG_NON_FIPS_ALLOW 0x0400
/*
 * Application has decided PRNG is good enough to generate a key: don't
 * check.
 */
#define RSA_FLAG_CHECKED 0x0800

OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_new(const char *name, int flags);
OSSL_DEPRECATEDIN_3_0 void RSA_meth_free(RSA_METHOD *meth);
OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
OSSL_DEPRECATEDIN_3_0 const char *RSA_meth_get0_name(const RSA_METHOD *meth);
OSSL_DEPRECATEDIN_3_0 int RSA_meth_set1_name(RSA_METHOD *meth,
    const char *name);
OSSL_DEPRECATEDIN_3_0 int RSA_meth_get_flags(const RSA_METHOD *meth);
OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
OSSL_DEPRECATEDIN_3_0 void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
OSSL_DEPRECATEDIN_3_0 int RSA_meth_set0_app_data(RSA_METHOD *meth,
    void *app_data);
OSSL_DEPRECATEDIN_3_0
int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen,
    const unsigned char *from,
    unsigned char *to,
    RSA *rsa, int padding);
OSSL_DEPRECATEDIN_3_0
int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
    int (*pub_enc)(int flen, co /* OPENSSL_NO_DEPRECATED_3_0 */
/*
 * Does nothing. Previously this switched off constant time behaviour.
 */
#ifndef OPENSSL_NO_DEPRECATED_1_1_0
#define RSA_FLAG_NO_CONSTTIME 0x0000
#endif
/* deprecated name for the flag*/
/*
 * new with 0.9.7h; the built-in RSA
 * implementation now uses constant time
 * modular exponentiation for secret exponents
 * by default. This flag causes the
 * faster variable sliding window method to
 * be used for all exponents.
 */
#ifndef OPENSSL_NO_DEPRECATED_0_9_8
#define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME
#endif

/*-
 * New with 3.0: use part of the flags to denote exact type of RSA key,
 * some of which are limited to specific signature and encryption schemes.
 * These different types share the same RSA structure, but indicate the
 * use of certain fields in that structure.
 * Currently known are:
 * RSA          - this is the "normal" unlimited RSA structure (typenum 0)
 * RSASSA-PSS   - indicates that the PSS parameters are used.
 * RSAES-OAEP   - no specific field used for the moment, but OAEP padding
 *                is expected.  (currently unused)
 *
 * 4 bits allow for 16 types
 */
#define RSA_FLAG_TYPE_MASK 0xF000
#define RSA_FLAG_TYPE_RSA 0x0000
#define RSA_FLAG_TYPE_RSASSAPSS 0x1000
#define RSA_FLAG_TYPE_RSAESOAEP 0x2000

int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad_mode);
int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx, int *pad_mode);

int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int saltlen);
int);

int TS_REQ_set_cert_req(TS_REQ *a, int cert_req);
int TS_REQ_get_cert_req(const TS_REQ *a);

STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);
void TS_REQ_ext_free(TS_REQ *a);
int TS_REQ_get_ext_count(TS_REQ *a);
int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);
int TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos);
int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);
const X509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);
X509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);
int TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);
void *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);

/* Function declarations for TS_REQ defined in ts/ts_req_print.c */

int TS_REQ_print_bio(BIO *bio, TS_REQ *a);

/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */

int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);
TS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);

/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */
void TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);
PKCS7 *TS_RESP_get_token(TS_RESP *a);
TS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);

int TS_TST_INFO_set_version(TS_TST_INFO *a, long version);
long TS_TST_INFO_get_version(const TS_TST_INFO *a);

int TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);
ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);

int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);
TS_MSG_define RSA_R_MGF1_DIGEST_NOT_ALLOWED 152
#define RSA_R_MISSING_PRIVATE_KEY 179
#define RSA_R_MODULUS_TOO_LARGE 105
#define RSA_R_MP_COEFFICIENT_NOT_INVERSE_OF_R 168
#define RSA_R_MP_EXPONENT_NOT_CONGRUENT_TO_D 169
#define RSA_R_MP_R_NOT_PRIME 170
#define RSA_R_NO_PUBLIC_EXPONENT 140
#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
#define RSA_R_N_DOES_NOT_EQUAL_PRODUCT_OF_PRIMES 172
#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127
#define RSA_R_OAEP_DECODING_ERROR 121
#define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148
#define RSA_R_PADDING_CHECK_FAILED 114
#define RSA_R_PAIRWISE_TEST_FAILURE 177
#define RSA_R_PKCS_DECODING_ERROR 159
#define RSA_R_PSS_SALTLEN_TOO_SMALL 164
#define RSA_R_PUB_EXPONENT_OUT_OF_RANGE 178
#define RSA_R_P_NOT_PRIME 128
#define RSA_R_Q_NOT_PRIME 129
#define RSA_R_RANDOMNESS_SOURCE_STRENGTH_INSUFFICIENT 180
#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130
#define RSA_R_SLEN_CHECK_FAILED 136
#define RSA_R_SLEN_RECOVERY_FAILED 135
#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
#define RSA_R_UNKNOWN_DIGEST 166
#define RSA_R_UNKNOWN_MASK_DIGEST 151
#define RSA_R_UNKNOWN_PADDING_TYPE 118
#define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE 162
#define RSA_R_UNSUPPORTED_LABEL_SOURCE 163
#define RSA_R_UNSUPPORTED_MASK_ALGORITHM 153
#define RSA_R_UNSUPPORTED_MASK_PARAMETER 154
#define RSA_R_UNSUPPORTED_SIGNATURE_TYPE 155
#define RSA_R_VALUE_MISSING 147
#define RSA_R_WRONG_SIGNATURE_LENGTH 119

#endif
/*
 * Copyright 2019-2021 TEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth);
OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_method(ENGINE *engine);

/** The old name for ecdh_KDF_X9_63
 *  The ECDH KDF specification has been mistakenly attributed to ANSI X9.62,
 *  it is actually specified in ANSI X9.63.
 *  This identifier is retained for backwards compatibility
 */
OSSL_DEPRECATEDIN_3_0 int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
    const unsigned char *Z, size_t Zlen,
    const unsigned char *sinfo,
    size_t sinfolen, const EVP_MD *md);

OSSL_DEPRECATEDIN_3_0 int ECDH_compute_key(void *out, size_t outlen,
    const EC_POINT *pub_key,
    const EC_KEY *ecdh,
    void *(*KDF)(const void *in,
        size_t inlen, void *out,
        size_t *outlen));
#endif /* OPENSSL_NO_DEPRECATED_3_0 */

typedef struct ECDSA_SIG_st ECDSA_SIG;

/** Allocates and initialize a ECDSA_SIG structure
 *  \return pointer to a ECDSA_SIG structure or NULL if an error occurred
 */
ECDSA_SIG *ECDSA_SIG_new(void);

/** frees a ECDSA_SIG structure
 *  \param  sig  pointer to the ECDSA_SIG structure
 */
void ECDSA_SIG_free(ECDSA_SIG *sig);

/** i2d_ECDSA_SIG encodes content of ECDSA_SIG (note: this function modifies *pp
 *  (*pp += length of the DER encoded signature)).
 *  \param  sig  pointer to the ECDSA_SIG object
 *  \param  pp   pointer to a unsigned char pointer for the output or NULL
 *  \return the length of the DER encoded ECDSA_SIG object or a negative value
 *          on error
 */
DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECt EC_KEY_check_key(const EC_KEY *key);

/** Indicates if an EC_KEY can be used for signing.
 *  \param  eckey  the EC_KEY object
 *  \return 1 if can sign and 0 otherwise.
 */
OSSL_DEPRECATEDIN_3_0 int EC_KEY_can_sign(const EC_KEY *eckey);

/** Sets a public key from affine coordinates performing
 *  necessary NIST PKV tests.
 *  \param  key  the EC_KEY object
 *  \param  x    public key x coordinate
 *  \param  y    public key y coordinate
 *  \return 1 on success and 0 otherwise.
 */
OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key,
    BIGNUM *x,
    BIGNUM *y);

/** Encodes an EC_KEY public key to an allocated octet string
 *  \param  key    key to encode
 *  \param  form   point conversion form
 *  \param  pbuf   returns pointer to allocated buffer
 *  \param  ctx    BN_CTX object (optional)
 *  \return the length of the encoded octet string or 0 if an error occurred
 */
OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_key2buf(const EC_KEY *key,
    point_conversion_form_t form,
    unsigned char **pbuf, BN_CTX *ctx);

/** Decodes a EC_KEY public key from a octet string
 *  \param  key    key to decode
 *  \param  buf    memory buffer with the encoded ec point
 *  \param  len    length of the encoded ec point
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occurred
 */

OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf,
    size_t len, BN_CTX *ctx);

/** Decodes an EC_KEY private key from an octet      BIGNUM for the x-coordinate
 *  \param  y      BIGNUM for the y-coordinate
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occurred
 */
OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *p,
    BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
#endif /* OPENSSL_NO_DEPRECATED_3_0 */

/** Sets the x9.62 compressed coordinates of a EC_POINT
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM with x-coordinate
 *  \param  y_bit  integer with the y-Bit (either 0 or 1)
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occurred
 */
int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p,
    const BIGNUM *x, int y_bit,
    BN_CTX *ctx);

#ifndef OPENSSL_NO_DEPRECATED_3_0
/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
 *  EC_POINT_set_compressed_coordinates
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM with x-coordinate
 *  \param  y_bit  integer with the y-Bit (either 0 or 1)
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occurred
 */
OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
    const BIGNUM *x, int y_bit, BN_CTX *ctx);
#ifndef OPENSSL_NO_EC2M
/** Sets the affine coordinates of an EC_POINT. A synonym of
 *  EC_POINT_set_affi_DEPRECATEDIN_3_0 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);

/** Returns the field type of the EC_METHOD.
 *  \param  meth  EC_METHOD object
 *  \return NID of the underlying field type OID.
 */
OSSL_DEPRECATEDIN_3_0 int EC_METHOD_get_field_type(const EC_METHOD *meth);
#endif /* OPENSSL_NO_DEPRECATED_3_0 */

/** Frees a EC_GROUP object
 *  \param  group  EC_GROUP object to be freed.
 */
void EC_GROUP_free(EC_GROUP *group);

/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
 *  \param  dst  destination EC_GROUP object
 *  \param  src  source EC_GROUP object
 *  \return 1 on success and 0 if an error occurred.
 */
int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);

/** Creates a new EC_GROUP object and copies the content
 *  form src to the newly created EC_KEY object
 *  \param  src  source EC_GROUP object
 *  \return newly created EC_GROUP object or NULL in case of an error.
 */
EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);

/** Sets the generator and its order/cofactor of a EC_GROUP object.
 *  \param  group      EC_GROUP object
 *  \param  generator  EC_POINT object with the generator.
 *  \param  order      the order of the group generated by the generator.
 *  \param  cofactor   the index of the sub-group generated by the generator
 *                     in the group of all points on the elliptic curve.
 *  \return 1 on success and 0 if an error occurred
 */
int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
    c others that try to do the same thing Microsoft does...
 */
/*
 * UEFI lives here because it might be built with a Microsoft toolchain and
 * we need to avoid the false positive match on Windows.
 */
#if defined(OPENSSL_SYS_UEFI)
#undef OPENSSL_SYS_UNIX
#elif defined(OPENSSL_SYS_UWIN)
#undef OPENSSL_SYS_UNIX
#define OPENSSL_SYS_WIN32_UWIN
#else
#if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN)
#define OPENSSL_SYS_WIN32_CYGWIN
#else
#if defined(_WIN32) || defined(OPENSSL_SYS_WIN32)
#undef OPENSSL_SYS_UNIX
#if !defined(OPENSSL_SYS_WIN32)
#define OPENSSL_SYS_WIN32
#endif
#endif
#if defined(_WIN64) || defined(OPENSSL_SYS_WIN64)
#undef OPENSSL_SYS_UNIX
#if !defined(OPENSSL_SYS_WIN64)
#define OPENSSL_SYS_WIN64
#endif
#endif
#if defined(OPENSSL_SYS_WINNT)
#undef OPENSSL_SYS_UNIX
#endif
#endif
#endif

/* Anything that tries to look like Microsoft is "Windows" */
#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT)
#undef OPENSSL_SYS_UNIX
#define OPENSSL_SYS_WINDOWS
#ifndef OPENSSL_SYS_MSDOS
#define OPENSSL_SYS_MSDOS
#endif
#endif

/*
 * DLL settings.  This part is a bit tough, because it's up to the
 * application implementer how he or she will link the application, so it
 * requires some macro to be used.
 */
#ifdef OPENSSL_SYS_WINDOWS
#ifndef OPENSSL_OPT_WINDLL
#if defined(_WINDLL) /* This is used when building OpenSSL to \
                      * indicate that DLL linkage should be used */
#define OPENSSL_OPT_WINDLL
#endif
#endif
#endif

/* -------- \
    (EVP_PKEY_OP_ALL & ~EVP_PKEY_OP_TYPE_GEN)

int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key,
    int keylen);

#define EVP_PKEY_CTRL_MD 1
#define EVP_PKEY_CTRL_PEER_KEY 2
#define EVP_PKEY_CTRL_SET_MAC_KEY 6
#define EVP_PKEY_CTRL_DIGESTINIT 7
/* Used by GOST key encryption in TLS */
#define EVP_PKEY_CTRL_SET_IV 8
#ifndef OPENSSL_NO_DEPRECATED_3_0
#define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3
#define EVP_PKEY_CTRL_PKCS7_DECRYPT 4
#define EVP_PKEY_CTRL_PKCS7_SIGN 5
#define EVP_PKEY_CTRL_CMS_ENCRYPT 9
#define EVP_PKEY_CTRL_CMS_DECRYPT 10
#define EVP_PKEY_CTRL_CMS_SIGN 11
#endif
#define EVP_PKEY_CTRL_CIPHER 12
#define EVP_PKEY_CTRL_GET_MD 13
#define EVP_PKEY_CTRL_SET_DIGEST_SIZE 14
#define EVP_PKEY_CTRL_SET1_ID 15
#define EVP_PKEY_CTRL_GET1_ID 16
#define EVP_PKEY_CTRL_GET1_ID_LEN 17

#define EVP_PKEY_ALG_CTRL 0x1000

#define EVP_PKEY_FLAG_AUTOARGLEN 2
/*
 * Method handles all operations: don't assume any digest related defaults.
 */
#define EVP_PKEY_FLAG_SIGCTX_CUSTOM 4

EVP_KEYMGMT *EVP_KEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
    const char *properties);
int EVP_KEYMGMT_up_ref(EVP_KEYMGMT *keymgmt);
void EVP_KEYMGMT_free(EVP_KEYMGMT *keymgmt);
const OSSL_PROVIDER *EVP_KEYMGMT_get0_provider(const EVP_KEYMGMT *keymgmt);
const char *EVP_KEYMGMT_get0_name(const EVP_KEYMGMT *keymgmt);
const char *EVP_KEYMGMT_get0_description(const EVP_KEYMGMT *keymgmt);
int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name);
void EVP_KEYMGMT_do_all_provided(OSSL_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
    size_t *siglen);

__owur int EVP_DigestVerifyInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
    const char *mdname, OSSL_LIB_CTX *libctx,
    const char *props, EVP_PKEY *pkey,
    const OSSL_PARAM params[]);
__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
    const EVP_MD *type,
    ENGINE *e /* must be NULL */,
    EVP_PKEY *pkey);
int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize);
__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
    size_t siglen);

__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
    const unsigned char *ek, int ekl,
    const unsigned char *iv, EVP_PKEY *priv);
__owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);

__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
    unsigned char **ek, int *ekl, unsigned char *iv,
    EVP_PKEY **pubk, int npubk);
__owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);

EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void);
void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx);
int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, const EVP_ENCODE_CTX *sctx);
int EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx);
void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
    const unsigned char *in, int inl);
void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);
int EVP_EncodeBle(a, b, c, d, e) EVP_DecryptUpdate(a, b, c, d, e)
#define EVP_SealUpdate(a, b, c, d, e) EVP_EncryptUpdate(a, b, c, d, e)

#ifdef CONST_STRICT
void BIO_set_md(BIO *, const EVP_MD *md);
#else
#define BIO_set_md(b, md) BIO_ctrl(b, BIO_C_SET_MD, 0, (void *)(md))
#endif
#define BIO_get_md(b, mdp) BIO_ctrl(b, BIO_C_GET_MD, 0, (mdp))
#define BIO_get_md_ctx(b, mdcp) BIO_ctrl(b, BIO_C_GET_MD_CTX, 0, (mdcp))
#define BIO_set_md_ctx(b, mdcp) BIO_ctrl(b, BIO_C_SET_MD_CTX, 0, (mdcp))
#define BIO_get_cipher_status(b) BIO_ctrl(b, BIO_C_GET_CIPHER_STATUS, 0, NULL)
#define BIO_get_cipher_ctx(b, c_pp) BIO_ctrl(b, BIO_C_GET_CIPHER_CTX, 0, (c_pp))

__owur int EVP_Cipher(EVP_CIPHER_CTX *c,
    unsigned char *out,
    const unsigned char *in, unsigned int inl);

#define EVP_add_cipher_alias(n, alias) \
    OBJ_NAME_add((alias), OBJ_NAME_TYPE_CIPHER_METH | OBJ_NAME_ALIAS, (n))
#define EVP_add_digest_alias(n, alias) \
    OBJ_NAME_add((alias), OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS, (n))
#define EVP_delete_cipher_alias(alias) \
    OBJ_NAME_remove(alias, OBJ_NAME_TYPE_CIPHER_METH | OBJ_NAME_ALIAS);
#define EVP_delete_digest_alias(alias) \
    OBJ_NAME_remove(alias, OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS);

int EVP_MD_get_params(const EVP_MD *digest, OSSL_PARAM params[]);
int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]);
int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]);
const OSSL_PARAM *EVP_MD_gettable_params(const EVP_MD *digest);
const OSSL_PARAM *EVP_MD_settable_ctx_params256S NID_SLH_DSA_SHAKE_256s
#define EVP_PKEY_SLH_DSA_SHAKE_256F NID_SLH_DSA_SHAKE_256f
#define EVP_PKEY_HSS_LMS NID_id_alg_hss_lms_hashsig

/* Special indicator that the object is uniquely provider side */
#define EVP_PKEY_KEYMGMT -1

/* Easy to use macros for EVP_PKEY related selections */
#define EVP_PKEY_KEY_PARAMETERS \
    (OSSL_KEYMGMT_SELECT_ALL_PARAMETERS)
#define EVP_PKEY_PRIVATE_KEY \
    (EVP_PKEY_KEY_PARAMETERS | OSSL_KEYMGMT_SELECT_PRIVATE_KEY)
#define EVP_PKEY_PUBLIC_KEY \
    (EVP_PKEY_KEY_PARAMETERS | OSSL_KEYMGMT_SELECT_PUBLIC_KEY)
#define EVP_PKEY_KEYPAIR \
    (EVP_PKEY_PUBLIC_KEY | OSSL_KEYMGMT_SELECT_PRIVATE_KEY)

#ifdef __cplusplus
extern "C" {
#endif

int EVP_set_default_properties(OSSL_LIB_CTX *libctx, const char *propq);
char *EVP_get1_default_properties(OSSL_LIB_CTX *libctx);
int EVP_default_properties_is_fips_enabled(OSSL_LIB_CTX *libctx);
int EVP_default_properties_enable_fips(OSSL_LIB_CTX *libctx, int enable);
#define FIPS_mode() EVP_default_properties_is_fips_enabled(NULL)

#define EVP_PKEY_MO_SIGN 0x0001
#define EVP_PKEY_MO_VERIFY 0x0002
#define EVP_PKEY_MO_ENCRYPT 0x0004
#define EVP_PKEY_MO_DECRYPT 0x0008

#ifndef EVP_MD
/* digest can only handle a single block */
#define EVP_MD_FLAG_ONESHOT 0x0001

/* digest is extensible-output function, XOF */
#define EVP_MD_FLAG_XOF 0x0002

/* DigestAlgorithmIdentifier flags... */

#define EVP_MD_FLAG_DIGALGID_MASK 0x0018

/* NULL or absent parameter accepted. Use NULL */

#define EVP_MD_FLAG_DIGALGID_NULL 0x0000

/* CIPHER 0
#define EVP_F_AES_XTS_INIT_KEY 0
#define EVP_F_ALG_MODULE_INIT 0
#define EVP_F_ARIA_CCM_INIT_KEY 0
#define EVP_F_ARIA_GCM_CTRL 0
#define EVP_F_ARIA_GCM_INIT_KEY 0
#define EVP_F_ARIA_INIT_KEY 0
#define EVP_F_B64_NEW 0
#define EVP_F_CAMELLIA_INIT_KEY 0
#define EVP_F_CHACHA20_POLY1305_CTRL 0
#define EVP_F_CMLL_T4_INIT_KEY 0
#define EVP_F_DES_EDE3_WRAP_CIPHER 0
#define EVP_F_DO_SIGVER_INIT 0
#define EVP_F_ENC_NEW 0
#define EVP_F_EVP_CIPHERINIT_EX 0
#define EVP_F_EVP_CIPHER_ASN1_TO_PARAM 0
#define EVP_F_EVP_CIPHER_CTX_COPY 0
#define EVP_F_EVP_CIPHER_CTX_CTRL 0
#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 0
#define EVP_F_EVP_CIPHER_PARAM_TO_ASN1 0
#define EVP_F_EVP_DECRYPTFINAL_EX 0
#define EVP_F_EVP_DECRYPTUPDATE 0
#define EVP_F_EVP_DIGESTFINALXOF 0
#define EVP_F_EVP_DIGESTINIT_EX 0
#define EVP_F_EVP_ENCRYPTDECRYPTUPDATE 0
#define EVP_F_EVP_ENCRYPTFINAL_EX 0
#define EVP_F_EVP_ENCRYPTUPDATE 0
#define EVP_F_EVP_MD_CTX_COPY_EX 0
#define EVP_F_EVP_MD_SIZE 0
#define EVP_F_EVP_OPENINIT 0
#define EVP_F_EVP_PBE_ALG_ADD 0
#define EVP_F_EVP_PBE_ALG_ADD_TYPE 0
#define EVP_F_EVP_PBE_CIPHERINIT 0
#define EVP_F_EVP_PBE_SCRYPT 0
#define EVP_F_EVP_PKCS82PKEY 0
#define EVP_F_EVP_PKEY2PKCS8 0
#define EVP_F_EVP_PKEY_ASN1_ADD0 0
#define EVP_F_EVP_PKEY_CHECK 0
#define EVP_F_EVP_PKEY_COPY_PARAMETERS 0
#define EVP_F_EVP_PKEY_CTX_CTRL 0
#define EVP_F_EVP_PKEY_CTX_CTRL_STR 0
#define EVP_F_EVP_PKEY_CTX_DUP 0
#define EVP_F_EVP_PKEY_CTX_MD 0
#define EVP_F_EVP_PKEY_DECRYPT 0
#define EVP_F_EVP_PKEY_DECRYPT_INIT 0ATES_GF2M 0
#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 0
#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 0
#define EC_F_EC_POINT_SET_TO_INFINITY 0
#define EC_F_EC_PRE_COMP_NEW 0
#define EC_F_EC_SCALAR_MUL_LADDER 0
#define EC_F_EC_WNAF_MUL 0
#define EC_F_EC_WNAF_PRECOMPUTE_MULT 0
#define EC_F_I2D_ECPARAMETERS 0
#define EC_F_I2D_ECPKPARAMETERS 0
#define EC_F_I2D_ECPRIVATEKEY 0
#define EC_F_I2O_ECPUBLICKEY 0
#define EC_F_NISTP224_PRE_COMP_NEW 0
#define EC_F_NISTP256_PRE_COMP_NEW 0
#define EC_F_NISTP521_PRE_COMP_NEW 0
#define EC_F_O2I_ECPUBLICKEY 0
#define EC_F_OLD_EC_PRIV_DECODE 0
#define EC_F_OSSL_ECDH_COMPUTE_KEY 0
#define EC_F_OSSL_ECDSA_SIGN_SIG 0
#define EC_F_OSSL_ECDSA_VERIFY_SIG 0
#define EC_F_PKEY_ECD_CTRL 0
#define EC_F_PKEY_ECD_DIGESTSIGN 0
#define EC_F_PKEY_ECD_DIGESTSIGN25519 0
#define EC_F_PKEY_ECD_DIGESTSIGN448 0
#define EC_F_PKEY_ECX_DERIVE 0
#define EC_F_PKEY_EC_CTRL 0
#define EC_F_PKEY_EC_CTRL_STR 0
#define EC_F_PKEY_EC_DERIVE 0
#define EC_F_PKEY_EC_INIT 0
#define EC_F_PKEY_EC_KDF_DERIVE 0
#define EC_F_PKEY_EC_KEYGEN 0
#define EC_F_PKEY_EC_PARAMGEN 0
#define EC_F_PKEY_EC_SIGN 0
#define EC_F_VALIDATE_ECX_DERIVE 0
#endif

#ifdef OPENSSL_ENGINE_STUBS
/*
 * ENGINE reason codes.
 */
#define ENGINE_R_ALREADY_LOADED 0
#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 0
#define ENGINE_R_CMD_NOT_EXECUTABLE 0
#define ENGINE_R_COMMAND_TAKES_INPUT 0
#define ENGINE_R_COMMAND_TAKES_NO_INPUT 0
#define ENGINE_R_CONFLICTING_ENGINE_ID 0
#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED e OSSL_CMP_LOG_WARNING 4
#define OSSL_CMP_LOG_NOTICE 5
#define OSSL_CMP_LOG_INFO 6
#define OSSL_CMP_LOG_DEBUG 7
#define OSSL_CMP_LOG_TRACE 8
#define OSSL_CMP_LOG_MAX OSSL_CMP_LOG_TRACE
typedef int (*OSSL_CMP_log_cb_t)(const char *func, const char *file, int line,
    OSSL_CMP_severity level, const char *msg);

int OSSL_CMP_print_to_bio(BIO *bio, const char *component, const char *file,
    int line, OSSL_CMP_severity level, const char *msg);
/* use of the logging callback for outputting error queue */
void OSSL_CMP_print_errors_cb(OSSL_CMP_log_cb_t log_fn);

#ifdef __cplusplus
}
#endif
#endif /* !defined(OPENSSL_NO_CMP) */
#endif /* !defined(OPENSSL_CMP_UTIL_H) */
/*
 * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

/*
 * This header file preserves symbols from pre-3.0 OpenSSL.
 * It should never be included directly, as it's already included
 * by the public {lib}err.h headers, and since it will go away some
 * time in the future.
 */

#ifndef OPENSSL_CRYPTOERR_LEGACY_H
#define OPENSSL_CRYPTOERR_LEGACY_H
#pragma once

#include <openssl/macros.h>
#include <openssl/symhacks.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef OPENSSL_NO_DEPRECATED_3_0
OSSL_DEPRECATEDIN_3_0 int ERR_load_ASN1_strings(void);
OSSLALGOR *algorithm;
    ASN1_OCTET_STRING *enc_data; /* [ 0 ] */
    const EVP_CIPHER *cipher;
    const PKCS7_CTX *ctx;
} PKCS7_ENC_CONTENT;

typedef struct pkcs7_enveloped_st {
    ASN1_INTEGER *version; /* version 0 */
    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;
    PKCS7_ENC_CONTENT *enc_data;
} PKCS7_ENVELOPE;

typedef struct pkcs7_signedandenveloped_st {
    ASN1_INTEGER *version; /* version 1 */
    STACK_OF(X509_ALGOR) *md_algs; /* md used */
    /* untrusted certificates for chain building, may include signer certs: */
    STACK_OF(X509) *cert; /* [ 0 ] */ /* name should be 'certificates' */
    STACK_OF(X509_CRL) *crl; /* [ 1 ] */ /* name should be 'crls' */
    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;
    PKCS7_ENC_CONTENT *enc_data;
    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;
} PKCS7_SIGN_ENVELOPE;

typedef struct pkcs7_digest_st {
    ASN1_INTEGER *version; /* version 0 */
    X509_ALGOR *md; /* md used */
    struct pkcs7_st *contents;
    ASN1_OCTET_STRING *digest;
} PKCS7_DIGEST;

typedef struct pkcs7_encrypted_st {
    ASN1_INTEGER *version; /* version 0 */
    PKCS7_ENC_CONTENT *enc_data;
} PKCS7_ENCRYPT;

typedef struct pkcs7_st {
    /*
     * The following is non NULL if it contains ASN1 encoding of this
     * structure
     */
    unsigned char *asn1;
    long length;
#define PKCS7_S_HEADER 0
#define PKCS7_S_BODY 1
#define PKCS7_S_TAIL 2
    int state; /* used during processing */
    int detached;
    ASN1_OBJECT *type;
    /* content as defined by the type r *name,
    const char *value);
/*
 * Retrieves any of the requested configuration parameters for the given
 * provider that were set in the configuration file or via the above
 * OSSL_PROVIDER_add_parameter() function.
 *
 * The |params| array elements MUST have type OSSL_PARAM_UTF8_PTR, values are
 * returned by reference, not as copies.
 */
int OSSL_PROVIDER_get_conf_parameters(const OSSL_PROVIDER *prov,
    OSSL_PARAM params[]);
/*
 * Parse a provider configuration parameter as a boolean value,
 * or return a default value if unable to retrieve the parameter.
 * Values like "1", "yes", "true", ... are true (nonzero).
 * Values like "0", "no", "false", ... are false (zero).
 */
int OSSL_PROVIDER_conf_get_bool(const OSSL_PROVIDER *prov,
    const char *name, int defval);

const OSSL_ALGORITHM *OSSL_PROVIDER_query_operation(const OSSL_PROVIDER *prov,
    int operation_id,
    int *no_cache);
void OSSL_PROVIDER_unquery_operation(const OSSL_PROVIDER *prov,
    int operation_id, const OSSL_ALGORITHM *algs);
void *OSSL_PROVIDER_get0_provider_ctx(const OSSL_PROVIDER *prov);
const OSSL_DISPATCH *OSSL_PROVIDER_get0_dispatch(const OSSL_PROVIDER *prov);

/* Add a built in providers */
int OSSL_PROVIDER_add_builtin(OSSL_LIB_CTX *, const char *name,
    OSSL_provider_init_fn *init_fn);

/* Information */
const char *OSSL_PROVIDER_get0_name(const OSSL_PROVIDER *prov);

#ifdef __cplusplus
}
#endif

#endif
/*
 * WARNING: do not edit!
 * Generated by Makefile from include/openssl/pkcs7.h.in
 *
 * Core(const ERR_STATE *es);
void OSSL_ERR_STATE_free(ERR_STATE *es);

#ifdef __cplusplus
}
#endif

#endif
/*
 * Generated by util/mkerr.pl DO NOT EDIT
 * Copyright 1995-2026 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#ifndef OPENSSL_TSERR_H
#define OPENSSL_TSERR_H
#pragma once

#include <openssl/opensslconf.h>
#include <openssl/symhacks.h>
#include <openssl/cryptoerr_legacy.h>

#ifndef OPENSSL_NO_TS
/*
 * TS reason codes.
 */
#define TS_R_BAD_PKCS7_TYPE 132
#define TS_R_BAD_TYPE 133
#define TS_R_CANNOT_LOAD_CERT 137
#define TS_R_CANNOT_LOAD_KEY 138
#define TS_R_CERTIFICATE_VERIFY_ERROR 100
#define TS_R_COULD_NOT_SET_ENGINE 127
#define TS_R_COULD_NOT_SET_TIME 115
#define TS_R_DETACHED_CONTENT 134
#define TS_R_ESS_ADD_SIGNING_CERT_ERROR 116
#define TS_R_ESS_ADD_SIGNING_CERT_V2_ERROR 139
#define TS_R_ESS_SIGNING_CERTIFICATE_ERROR 101
#define TS_R_INVALID_NULL_POINTER 102
#define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE 117
#define TS_R_MESSAGE_IMPRINT_MISMATCH 103
#define TS_R_NONCE_MISMATCH 104
#define TS_R_NONCE_NOT_RETURNED 105
#define TS_R_NO_CONTENT 106
#define TS_R_NO_TIME_STAMP_TOKEN 107
#define TS_R_PKCS7_ADD_SIGNATURE_ERROR 118
#define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR 119
#define TS_R_PKCS7_TO_TS_TST_INFO_FAILED 129
#defi_LIB_DSA 10
#define ERR_LIB_X509 11
/* #define ERR_LIB_METH         12 */
#define ERR_LIB_ASN1 13
#define ERR_LIB_CONF 14
#define ERR_LIB_CRYPTO 15
#define ERR_LIB_EC 16
#define ERR_LIB_SSL 20
/* #define ERR_LIB_SSL23        21 */
/* #define ERR_LIB_SSL2         22 */
/* #define ERR_LIB_SSL3         23 */
/* #define ERR_LIB_RSAREF       30 */
/* #define ERR_LIB_PROXY        31 */
#define ERR_LIB_BIO 32
#define ERR_LIB_PKCS7 33
#define ERR_LIB_X509V3 34
#define ERR_LIB_PKCS12 35
#define ERR_LIB_RAND 36
#define ERR_LIB_DSO 37
#define ERR_LIB_ENGINE 38
#define ERR_LIB_OCSP 39
#define ERR_LIB_UI 40
#define ERR_LIB_COMP 41
#define ERR_LIB_ECDSA 42
#define ERR_LIB_ECDH 43
#define ERR_LIB_OSSL_STORE 44
#define ERR_LIB_FIPS 45
#define ERR_LIB_CMS 46
#define ERR_LIB_TS 47
#define ERR_LIB_HMAC 48
/* # define ERR_LIB_JPAKE       49 */
#define ERR_LIB_CT 50
#define ERR_LIB_ASYNC 51
#define ERR_LIB_KDF 52
#define ERR_LIB_SM2 53
#define ERR_LIB_ESS 54
#define ERR_LIB_PROP 55
#define ERR_LIB_CRMF 56
#define ERR_LIB_PROV 57
#define ERR_LIB_CMP 58
#define ERR_LIB_OSSL_ENCODER 59
#define ERR_LIB_OSSL_DECODER 60
#define ERR_LIB_HTTP 61

#define ERR_LIB_USER 128

#ifndef OPENSSL_NO_DEPRECATED_3_0
#define ASN1err(f, r) ERR_raise_data(ERR_LIB_ASN1, (r), NULL)
#define ASYNCerr(f, r) ERR_raise_data(ERR_LIB_ASYNC, (r), NULL)
#define BIOerr(f, r) ERR_raise_data(ERR_LIB_BIO, (r), NULL)
#define BNerr(f, r) ERR_raise_data(ERR_LIB_BN, (r), NULL)
#define BUFerr(f, r) ERR_raise_data(ERR_LIB_BUF, (r), NULL)
#define CMP    ossl_check_USERNOTICE_freefunc_type(freefunc)), \
                sk_USERNOTICE_cmpfunc_thunk), \
            sk_USERNOTICE_copyfunc_thunk), \
        sk_USERNOTICE_freefunc_thunk))
#define sk_USERNOTICE_set_cmp_func(sk, cmp) ((sk_USERNOTICE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_USERNOTICE_sk_type(sk), ossl_check_USERNOTICE_compfunc_type(cmp)))

/* clang-format on */

typedef struct OSSL_ROLE_SPEC_CERT_ID_st {
    GENERAL_NAME *roleName;
    GENERAL_NAME *roleCertIssuer;
    ASN1_INTEGER *roleCertSerialNumber;
    GENERAL_NAMES *roleCertLocator;
} OSSL_ROLE_SPEC_CERT_ID;

DECLARE_ASN1_FUNCTIONS(OSSL_ROLE_SPEC_CERT_ID)

/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(OSSL_ROLE_SPEC_CERT_ID, OSSL_ROLE_SPEC_CERT_ID, OSSL_ROLE_SPEC_CERT_ID)
#define sk_OSSL_ROLE_SPEC_CERT_ID_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk))
#define sk_OSSL_ROLE_SPEC_CERT_ID_value(sk, idx) ((OSSL_ROLE_SPEC_CERT_ID *)OPENSSL_sk_value(ossl_check_const_OSSL_ROLE_SPEC_CERT_ID_sk_type(sk), (idx)))
#define sk_OSSL_ROLE_SPEC_CERT_ID_new(cmp) \
    ((STACK_OF(OSSL_ROLE_SPEC_CERT_ID) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_new(ossl_check_OSSL_ROLE_SPEC_CERT_ID_compfunc_type(cmp)), \
                sk_OSSL_ROLE_SPEC_CERT_ID_cmpfunc_thunk), \
            sk_OSSL_ROLE_SPEC_CERT_ID_copyfunc_thunk), \
        sk_OSSL_ROLE_SPEC_CERT_ID_freefunc_thunk))
#define sk_OSSL_ROLE_SPEC_CERT_ID_new_nu_freefunc_type(freefunc)), \
                sk_ASN1_STRING_cmpfunc_thunk), \
            sk_ASN1_STRING_copyfunc_thunk), \
        sk_ASN1_STRING_freefunc_thunk))
#define sk_ASN1_STRING_set_cmp_func(sk, cmp) ((sk_ASN1_STRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_compfunc_type(cmp)))

/* clang-format on */

/*
 * Admission Syntax
 */
typedef struct NamingAuthority_st NAMING_AUTHORITY;
typedef struct ProfessionInfo_st PROFESSION_INFO;
typedef struct Admissions_st ADMISSIONS;
typedef struct AdmissionSyntax_st ADMISSION_SYNTAX;
DECLARE_ASN1_FUNCTIONS(NAMING_AUTHORITY)
DECLARE_ASN1_FUNCTIONS(PROFESSION_INFO)
DECLARE_ASN1_FUNCTIONS(ADMISSIONS)
DECLARE_ASN1_FUNCTIONS(ADMISSION_SYNTAX)
/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(PROFESSION_INFO, PROFESSION_INFO, PROFESSION_INFO)
#define sk_PROFESSION_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PROFESSION_INFO_sk_type(sk))
#define sk_PROFESSION_INFO_value(sk, idx) ((PROFESSION_INFO *)OPENSSL_sk_value(ossl_check_const_PROFESSION_INFO_sk_type(sk), (idx)))
#define sk_PROFESSION_INFO_new(cmp) \
    ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_new(ossl_check_PROFESSION_INFO_compfunc_type(cmp)), \
                sk_PROFESSION_INFO_cmpfunc_thunk), \
            sk_PROFESSION_INFO_copyfunc_thunk), \
        sk_PROFESSION_INFO_freefunc_thunk))
#define sk_PROFESSION_INFO_new_nuSIdOrRange_freefunc_type(freefunc)), \
                sk_ASIdOrRange_cmpfunc_thunk), \
            sk_ASIdOrRange_copyfunc_thunk), \
        sk_ASIdOrRange_freefunc_thunk))
#define sk_ASIdOrRange_set_cmp_func(sk, cmp) ((sk_ASIdOrRange_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_compfunc_type(cmp)))

/* clang-format on */

typedef STACK_OF(ASIdOrRange) ASIdOrRanges;

#define ASIdentifierChoice_inherit 0
#define ASIdentifierChoice_asIdsOrRanges 1

typedef struct ASIdentifierChoice_st {
    int type;
    union {
        ASN1_NULL *inherit;
        ASIdOrRanges *asIdsOrRanges;
    } u;
} ASIdentifierChoice;

typedef struct ASIdentifiers_st {
    ASIdentifierChoice *asnum, *rdi;
} ASIdentifiers;

DECLARE_ASN1_FUNCTIONS(ASRange)
DECLARE_ASN1_FUNCTIONS(ASIdOrRange)
DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)
DECLARE_ASN1_FUNCTIONS(ASIdentifiers)

typedef struct IPAddressRange_st {
    ASN1_BIT_STRING *min, *max;
} IPAddressRange;

#define IPAddressOrRange_addressPrefix 0
#define IPAddressOrRange_addressRange 1

typedef struct IPAddressOrRange_st {
    int type;
    union {
        ASN1_BIT_STRING *addressPrefix;
        IPAddressRange *addressRange;
    } u;
} IPAddressOrRange;

/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(IPAddressOrRange, IPAddressOrRange, IPAddressOrRange)
#define sk_IPAddressOrRange_num(sk) OPENSSL_sk_num(ossl_check_const_IPAddressOrRange_sk_type(sk))
#define sk_IPAddressOrRange_value(sk, idx) ((IPAddressOrRange *)OPENNAME)
DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)

int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, const X509_NAME *iname);

int NAME_CONSTRAINTS_check(const X509 *x, NAME_CONSTRAINTS *nc);
int NAME_CONSTRAINTS_check_CN(const X509 *x, NAME_CONSTRAINTS *nc);

DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)

DECLARE_ASN1_ITEM(POLICY_MAPPING)
DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)
DECLARE_ASN1_ITEM(POLICY_MAPPINGS)

DECLARE_ASN1_ITEM(GENERAL_SUBTREE)
DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)

DECLARE_ASN1_ITEM(NAME_CONSTRAINTS)
DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)

DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)

GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
    const X509V3_EXT_METHOD *method,
    X509V3_CTX *ctx, int gen_type,
    const char *value, int is_nc);

#ifdef OPENSSL_CONF_H
GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,
    X509V3_CTX *ctx, CONF_VALUE *cnf);
GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
    const X509V3_EXT_METHOD *method,
    X509V3_CTX *ctx, CONF_VALUE *cnf,
    int is_nc);

void X509V3_conf_free(CONF_VALUE *val);

X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
    const char *value);
X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name,
    const char *value);
int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section,
    STACK_OF(X509_EXTENSION) **sk);
int         ossl_check_const_POLICY_MAPPING_sk_type(sk), \
                    ossl_check_POLICY_MAPPING_copyfunc_type(copyfunc), \
                    ossl_check_POLICY_MAPPING_freefunc_type(freefunc)), \
                sk_POLICY_MAPPING_cmpfunc_thunk), \
            sk_POLICY_MAPPING_copyfunc_thunk), \
        sk_POLICY_MAPPING_freefunc_thunk))
#define sk_POLICY_MAPPING_set_cmp_func(sk, cmp) ((sk_POLICY_MAPPING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_compfunc_type(cmp)))

/* clang-format on */

typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;

typedef struct GENERAL_SUBTREE_st {
    GENERAL_NAME *base;
    ASN1_INTEGER *minimum;
    ASN1_INTEGER *maximum;
} GENERAL_SUBTREE;

/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(GENERAL_SUBTREE, GENERAL_SUBTREE, GENERAL_SUBTREE)
#define sk_GENERAL_SUBTREE_num(sk) OPENSSL_sk_num(ossl_check_const_GENERAL_SUBTREE_sk_type(sk))
#define sk_GENERAL_SUBTREE_value(sk, idx) ((GENERAL_SUBTREE *)OPENSSL_sk_value(ossl_check_const_GENERAL_SUBTREE_sk_type(sk), (idx)))
#define sk_GENERAL_SUBTREE_new(cmp) \
    ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_new(ossl_check_GENERAL_SUBTREE_compfunc_type(cmp)), \
                sk_GENERAL_SUBTREE_cmpfunc_thunk), \
            sk_GENERAL_SUBTREE_copyfunc_thunk), \
        sk_GENERAL_SUBTREE_freefunc_thunk))
#define sk_GENERAL_SUBTREE_new_nureefunc)), \
                sk_GENERAL_NAMES_cmpfunc_thunk), \
            sk_GENERAL_NAMES_copyfunc_thunk), \
        sk_GENERAL_NAMES_freefunc_thunk))
#define sk_GENERAL_NAMES_set_cmp_func(sk, cmp) ((sk_GENERAL_NAMES_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_compfunc_type(cmp)))

/* clang-format on */

typedef struct DIST_POINT_NAME_st {
    int type;
    union {
        GENERAL_NAMES *fullname;
        STACK_OF(X509_NAME_ENTRY) *relativename;
    } name;
    /* If relativename then this contains the full distribution point name */
    X509_NAME *dpname;
} DIST_POINT_NAME;
DECLARE_ASN1_DUP_FUNCTION(DIST_POINT_NAME)
/* All existing reasons */
#define CRLDP_ALL_REASONS 0x807f

#define CRL_REASON_NONE -1
#define CRL_REASON_UNSPECIFIED 0
#define CRL_REASON_KEY_COMPROMISE 1
#define CRL_REASON_CA_COMPROMISE 2
#define CRL_REASON_AFFILIATION_CHANGED 3
#define CRL_REASON_SUPERSEDED 4
#define CRL_REASON_CESSATION_OF_OPERATION 5
#define CRL_REASON_CERTIFICATE_HOLD 6
#define CRL_REASON_REMOVE_FROM_CRL 8
#define CRL_REASON_PRIVILEGE_WITHDRAWN 9
#define CRL_REASON_AA_COMPROMISE 10

struct DIST_POINT_st {
    DIST_POINT_NAME *distpoint;
    ASN1_BIT_STRING *reasons;
    GENERAL_NAMES *CRLissuer;
    int dp_reasons;
};

/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(DIST_POINT, DIST_POINT, DIST_POINT)
#define sk_DIST_POINT_num(sk) OPENSSL_sk_num(ossl_check_const_DIST_POINT_sk_type(sk))
#define sk_DIST_POINT_value(sk, idx) ((DIST_POINT *)OPENcheck_X509V3_EXT_METHOD_sk_type(sk), ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp)))

/* clang-format on */

/* ext_flags values */
#define X509V3_EXT_DYNAMIC 0x1
#define X509V3_EXT_CTX_DEP 0x2
#define X509V3_EXT_MULTILINE 0x4

typedef BIT_STRING_BITNAME ENUMERATED_NAMES;

typedef struct BASIC_CONSTRAINTS_st {
    int ca;
    ASN1_INTEGER *pathlen;
} BASIC_CONSTRAINTS;

typedef struct OSSL_BASIC_ATTR_CONSTRAINTS_st {
    int authority;
    ASN1_INTEGER *pathlen;
} OSSL_BASIC_ATTR_CONSTRAINTS;

typedef struct PKEY_USAGE_PERIOD_st {
    ASN1_GENERALIZEDTIME *notBefore;
    ASN1_GENERALIZEDTIME *notAfter;
} PKEY_USAGE_PERIOD;

typedef struct otherName_st {
    ASN1_OBJECT *type_id;
    ASN1_TYPE *value;
} OTHERNAME;

typedef struct EDIPartyName_st {
    ASN1_STRING *nameAssigner;
    ASN1_STRING *partyName;
} EDIPARTYNAME;

typedef struct GENERAL_NAME_st {
#define GEN_OTHERNAME 0
#define GEN_EMAIL 1
#define GEN_DNS 2
#define GEN_X400 3
#define GEN_DIRNAME 4
#define GEN_EDIPARTY 5
#define GEN_URI 6
#define GEN_IPADD 7
#define GEN_RID 8
    int type;
    union {
        char *ptr;
        OTHERNAME *otherName; /* otherName */
        ASN1_IA5STRING *rfc822Name;
        ASN1_IA5STRING *dNSName;
        ASN1_STRING *x400Address;
        X509_NAME *directoryName;
        EDIPARTYNAME *ediPartyName;
        ASN1_IA5STRING *uniformResourceIdentifier;
        ASN1_OCTET_STRING *iPAddress;
        ASN1_OBJECT *registeredID;
        /* Old names */
        ASN1_OCTET_STRING *ip; /* iPAddress */
    */
void *UI_get0_user_data(UI *ui);

/* Return the result associated with a prompt given with the index i. */
const char *UI_get0_result(UI *ui, int i);
int UI_get_result_length(UI *ui, int i);

/* When all strings have been added, process the whole thing. */
int UI_process(UI *ui);

/*
 * Give a user interface parameterised control commands.  This can be used to
 * send down an integer, a data pointer or a function pointer, as well as be
 * used to get information from a UI.
 */
int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void));

/* The commands */
/*
 * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the
 * OpenSSL error stack before printing any info or added error messages and
 * before any prompting.
 */
#define UI_CTRL_PRINT_ERRORS 1
/*
 * Check if a UI_process() is possible to do again with the same instance of
 * a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0
 * if not.
 */
#define UI_CTRL_IS_REDOABLE 2

/* Some methods may use extra data */
#define UI_set_app_data(s, arg) UI_set_ex_data(s, 0, arg)
#define UI_get_app_data(s) UI_get_ex_data(s, 0)

#define UI_get_ex_new_index(l, p, newf, dupf, freef) \
    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef)
int UI_set_ex_data(UI *r, int idx, void *arg);
void *UI_get_ex_data(const UI *r, int idx);

/* Use specific methods instead of the built-in one */
void UI_set_default_method(const UI_METHOD *meth);
const UI_METHOD *UI_get_default_method(void);
consenssl.org/source/license.html
 */

/*
 * Unfortunate workaround to avoid symbol conflict with wincrypt.h
 * See https://github.com/openssl/openssl/issues/9981
 */

#ifdef _WIN32
#define WINCRYPT_USE_SYMBOL_PREFIX
#undef X509_NAME
#undef X509_EXTENSIONS
#undef PKCS7_SIGNER_INFO
#undef OCSP_REQUEST
#undef OCSP_RESPONSE
#endif

#ifndef OPENSSL_TYPES_H
#define OPENSSL_TYPES_H

#include <limits.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <openssl/e_os2.h>
#include <openssl/safestack.h>
#include <openssl/macros.h>

typedef struct ossl_provider_st OSSL_PROVIDER; /* Provider Object */

#ifdef NO_ASN1_TYPEDEFS
typedef ASN1_STRING ASN1_INTEGER;
typedef ASN1_STRING ASN1_ENUMERATED;
typedef ASN1_STRING ASN1_BIT_STRING;
typedef ASN1_STRING ASN1_OCTET_STRING;
typedef ASN1_STRING ASN1_PRINTABLESTRING;
typedef ASN1_STRING ASN1_T61STRING;
typedef ASN1_STRING ASN1_IA5STRING;
typedef ASN1_STRING ASN1_UTCTIME;
typedef ASN1_STRING ASN1_GENERALIZEDTIME;
typedef ASN1_STRING ASN1_TIME;
typedef ASN1_STRING ASN1_GENERALSTRING;
typedef ASN1_STRING ASN1_UNIVERSALSTRING;
typedef ASN1_STRING ASN1_BMPSTRING;
typedef ASN1_STRING ASN1_VISIBLESTRING;
typedef ASN1_STRING ASN1_UTF8STRING;
typedef int ASN1_BOOLEAN;
typedef int ASN1_NULL;
#else
typedef struct asn1_string_st ASN1_INTEGER;
typedef struct asn1_string_st ASN1_ENUMERATED;
typedef struct asn1_string_st ASN1_BIT_STRING;
typedef struct asn1_string_st ASN1_OCTET_STRING;
typedef struct asn1_string_st ASN1_PRINTABLESTRING;
typedef struct asn1_string_st ASN1_T_SRP_gN_cache_set_cmp_func(sk, cmp) ((sk_SRP_gN_cache_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_compfunc_type(cmp)))

/* clang-format on */

typedef struct SRP_user_pwd_st {
    /* Owned by us. */
    char *id;
    BIGNUM *s;
    BIGNUM *v;
    /* Not owned by us. */
    const BIGNUM *g;
    const BIGNUM *N;
    /* Owned by us. */
    char *info;
} SRP_user_pwd;
/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(SRP_user_pwd, SRP_user_pwd, SRP_user_pwd)
#define sk_SRP_user_pwd_num(sk) OPENSSL_sk_num(ossl_check_const_SRP_user_pwd_sk_type(sk))
#define sk_SRP_user_pwd_value(sk, idx) ((SRP_user_pwd *)OPENSSL_sk_value(ossl_check_const_SRP_user_pwd_sk_type(sk), (idx)))
#define sk_SRP_user_pwd_new(cmp) \
    ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_new(ossl_check_SRP_user_pwd_compfunc_type(cmp)), \
                sk_SRP_user_pwd_cmpfunc_thunk), \
            sk_SRP_user_pwd_copyfunc_thunk), \
        sk_SRP_user_pwd_freefunc_thunk))
#define sk_SRP_user_pwd_new_null() \
    ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_new_null(), \
                sk_SRP_user_pwd_cmpfunc_thunk), \
            sk_SRP_user_pwd_copyfunc_thunk), \
        sk_SRP_user_pwd_freefunc_thunk))
#define sk_SRP_user_pwd_new_reserve(cmp, n) \
   ACK_OF(POLICYQUALINFO)
*X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node);
const X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE *node);

#ifdef __cplusplus
}
#endif
#endif
/*
 * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#ifndef OPENSSL_MD5_H
#define OPENSSL_MD5_H
#pragma once

#include <openssl/macros.h>
#ifndef OPENSSL_NO_DEPRECATED_3_0
#define HEADER_MD5_H
#endif

#include <openssl/opensslconf.h>

#ifndef OPENSSL_NO_MD5
#include <openssl/e_os2.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

#define MD5_DIGEST_LENGTH 16

#if !defined(OPENSSL_NO_DEPRECATED_3_0)
/*
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * ! MD5_LONG has to be at least 32 bits wide.                     !
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 */
typedef unsigned int MD5_LONG;

#define MD5_CBLOCK 64
#define MD5_LBLOCK (MD5_CBLOCK / 4)

typedef struct MD5state_st {
    MD5_LONG A, B, C, D;
    MD5_LONG Nl, Nh;
    MD5_LONG data[MD5_LBLOCK];
    unsigned int num;
} MD5_CTX;
#endif
#ifndef OPENSSL_NO_DEPRECATED_3_0
OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, sizt1_X509(X509_OBJECT *a, X509 *obj);
X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a);
int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj);
X509_STORE *X509_STORE_new(void);
void X509_STORE_free(X509_STORE *xs);
int X509_STORE_lock(X509_STORE *xs);
int X509_STORE_unlock(X509_STORE *xs);
int X509_STORE_up_ref(X509_STORE *xs);
#ifndef OPENSSL_NO_DEPRECATED_4_0
OSSL_DEPRECATEDIN_4_0_FOR("use X509_STORE_get1_objects()")
STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *xs);
#endif
STACK_OF(X509_OBJECT) *X509_STORE_get1_objects(X509_STORE *xs);
STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *xs);
STACK_OF(X509) *X509_STORE_CTX_get1_certs(const X509_STORE_CTX *xs,
    const X509_NAME *nm);
STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *st,
    const X509_NAME *nm);
int X509_STORE_set_flags(X509_STORE *xs, unsigned long flags);
int X509_STORE_set_purpose(X509_STORE *xs, int purpose);
int X509_STORE_set_trust(X509_STORE *xs, int trust);
int X509_STORE_set1_param(X509_STORE *xs, const X509_VERIFY_PARAM *pm);
X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *xs);

void X509_STORE_set_verify(X509_STORE *xs, X509_STORE_CTX_verify_fn verify);
#define X509_STORE_set_verify_func(ctx, func) \
    X509_STORE_set_verify((ctx), (func))
void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx,
    X509_STORE_CTX_verify_fn verify);
X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *xs);
void X509_STORE_set_verify_cb(X509_STORE *xs,
 EKU (1U << 4)

/* check_trust return codes */
#define X509_TRUST_TRUSTED 1
#define X509_TRUST_REJECTED 2
#define X509_TRUST_UNTRUSTED 3

int X509_TRUST_set(int *t, int trust);
int X509_TRUST_get_count(void);
X509_TRUST *X509_TRUST_get0(int idx);
int X509_TRUST_get_by_id(int id);
int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, const X509 *, int),
    const char *name, int arg1, void *arg2);
void X509_TRUST_cleanup(void);
int X509_TRUST_get_flags(const X509_TRUST *xp);
char *X509_TRUST_get0_name(const X509_TRUST *xp);
int X509_TRUST_get_trust(const X509_TRUST *xp);

int X509_trusted(const X509 *x);
int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj);
int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj);
void X509_trust_clear(X509 *x);
void X509_reject_clear(X509 *x);
const STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(const X509 *x);
const STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(const X509 *x);

int (*X509_TRUST_set_default(int (*trust)(int, const X509 *, int)))(int, const X509 *,
    int);
int X509_check_trust(const X509 *x, int id, int flags);

int X509_verify_cert(X509_STORE_CTX *ctx);
int X509_STORE_CTX_verify(X509_STORE_CTX *ctx);
STACK_OF(X509) *X509_build_chain(const X509 *target, STACK_OF(X509) *certs,
    X509_STORE *store, int with_self_signed,
    OSSL_LIB_CTX *libctx, const char *propq);

int X509_STORE_set_depth(X509_STORE *store, int depth);

typedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *);
int X509_STORE_CTX_print_verifyheck_X509_LOOKUP_type(ptr), (idx))
#define sk_X509_LOOKUP_set(sk, idx, ptr) ((X509_LOOKUP *)OPENSSL_sk_set(ossl_check_X509_LOOKUP_sk_type(sk), (idx), ossl_check_X509_LOOKUP_type(ptr)))
#define sk_X509_LOOKUP_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr))
#define sk_X509_LOOKUP_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr))
#define sk_X509_LOOKUP_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr), pnum)
#define sk_X509_LOOKUP_sort(sk) OPENSSL_sk_sort(ossl_check_X509_LOOKUP_sk_type(sk))
#define sk_X509_LOOKUP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_LOOKUP_sk_type(sk))
#define sk_X509_LOOKUP_dup(sk) \
    ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_dup(ossl_check_const_X509_LOOKUP_sk_type(sk)), \
                sk_X509_LOOKUP_cmpfunc_thunk), \
            sk_X509_LOOKUP_copyfunc_thunk), \
        sk_X509_LOOKUP_freefunc_thunk))
#define sk_X509_LOOKUP_deep_copy(sk, copyfunc, freefunc) \
    ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL_sk_set_cmp_thunks( \
                OPENSSL_sk_deep_copy( \
                    ossl_check_const_X509_LOOKUP_sk_type(sk), \
                    ossl_check_X509_LOOKUP_copyfunc_type(copyfunc), \
  
 * responsible for freeing (by calling SCT_LIST_free).
 * "**pp" and "*pp" must not be NULL.
 * Upon success, "*pp" will point to after the last bytes read, and a stack
 * will be returned.
 * Upon failure, a NULL pointer will be returned, and the position of "*pp" is
 * not defined.
 */
STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
    long len);

/*
 * Serialize (to TLS format) an |sct| and write it to |out|.
 * If |out| is null, no SCT will be output but the length will still be returned.
 * If |out| points to a null pointer, a string will be allocated to hold the
 * TLS-format SCT. It is the responsibility of the caller to free it.
 * If |out| points to an allocated string, the TLS-format SCT will be written
 * to it.
 * The length of the SCT in TLS format will be returned.
 */
__owur int i2o_SCT(const SCT *sct, unsigned char **out);

/*
 * Parses an SCT in TLS format and returns it.
 * If |psct| is not null, it will end up pointing to the parsed SCT. If it
 * already points to a non-null pointer, the pointer will be free'd.
 * |in| should be a pointer to a string containing the TLS-format SCT.
 * |in| will be advanced to the end of the SCT if parsing succeeds.
 * |len| should be the length of the SCT in |in|.
 * Returns NULL if an error occurs.
 * If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len'
 * fields will be populated (with |in| and |len| respectively).
 */
SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len);

/***
    SCT_SOURCE_X509V3_EXTENSION,
    SCT_SOURCE_OCSP_STAPLED_RESPONSE
} sct_source_t;

typedef enum {
    SCT_VALIDATION_STATUS_NOT_SET,
    SCT_VALIDATION_STATUS_UNKNOWN_LOG,
    SCT_VALIDATION_STATUS_VALID,
    SCT_VALIDATION_STATUS_INVALID,
    SCT_VALIDATION_STATUS_UNVERIFIED,
    SCT_VALIDATION_STATUS_UNKNOWN_VERSION
} sct_validation_status_t;

/******************************************
 * CT policy evaluation context functions *
 ******************************************/

/*
 * Creates a new, empty policy evaluation context associated with the given
 * library context and property query string.
 * The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished
 * with the CT_POLICY_EVAL_CTX.
 */
CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new_ex(OSSL_LIB_CTX *libctx,
    const char *propq);

/*
 * The same as CT_POLICY_EVAL_CTX_new_ex() but the default library
 * context and property query string is used.
 */
CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void);

/* Deletes a policy evaluation context and anything it owns. */
void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx);

/* Gets the peer certificate that the SCTs are for */
X509 *CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx);

/*
 * Sets the certificate associated with the received SCTs.
 * Increments the reference count of cert.
 * Returns 1 on success, 0 otherwise.
 */
int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert);

/* Gets the issuer of the aforementioned certificate */
X50ne CRMF_R_POPO_MISSING 121
#define CRMF_R_POPO_MISSING_PUBLIC_KEY 118
#define CRMF_R_POPO_MISSING_SUBJECT 119
#define CRMF_R_POPO_RAVERIFIED_NOT_ACCEPTED 120
#define CRMF_R_SETTING_MAC_ALGOR_FAILURE 110
#define CRMF_R_SETTING_OWF_ALGOR_FAILURE 111
#define CRMF_R_UNSUPPORTED_ALGORITHM 112
#define CRMF_R_UNSUPPORTED_CIPHER 114
#define CRMF_R_UNSUPPORTED_METHOD_FOR_CREATING_POPO 115
#define CRMF_R_UNSUPPORTED_POPO_METHOD 116

#endif
#endif
/*
 * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#ifndef OPENSSL_RC2_H
#define OPENSSL_RC2_H
#pragma once

#include <openssl/macros.h>
#ifndef OPENSSL_NO_DEPRECATED_3_0
#define HEADER_RC2_H
#endif

#include <openssl/opensslconf.h>

#ifndef OPENSSL_NO_RC2
#ifdef __cplusplus
extern "C" {
#endif

#define RC2_BLOCK 8
#define RC2_KEY_LENGTH 16

#ifndef OPENSSL_NO_DEPRECATED_3_0
typedef unsigned int RC2_INT;

#define RC2_ENCRYPT 1
#define RC2_DECRYPT 0

typedef struct rc2_key_st {
    RC2_INT data[64];
} RC2_KEY;
#endif
#ifndef OPENSSL_NO_DEPRECATED_3_0
OSSL_DEPRECATEDIN_3_0 void RC2_set_key(RC2_KEY *key, int len,
    const unsigned char *data, int bits);
OSSL_DEPRECATEDIN_3_0 void RC2_ecb_encrypt(const unsigned char *in,
    unsigned char *out, RC2_KEY *key,
    int enc);
OSSLE;

#define OBJ_create_and_add_object(a, b, c) OBJ_create(a, b, c)

int OBJ_NAME_init(void);
int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
    int (*cmp_func)(const char *, const char *),
    void (*free_func)(const char *, int, const char *));
const char *OBJ_NAME_get(const char *name, int type);
int OBJ_NAME_add(const char *name, int type, const char *data);
int OBJ_NAME_remove(const char *name, int type);
void OBJ_NAME_cleanup(int type); /* -1 for everything */
void OBJ_NAME_do_all(int type, void (*fn)(const OBJ_NAME *, void *arg),
    void *arg);
void OBJ_NAME_do_all_sorted(int type,
    void (*fn)(const OBJ_NAME *, void *arg),
    void *arg);

DECLARE_ASN1_DUP_FUNCTION_name(ASN1_OBJECT, OBJ)
ASN1_OBJECT *OBJ_nid2obj(int n);
const char *OBJ_nid2ln(int n);
const char *OBJ_nid2sn(int n);
int OBJ_obj2nid(const ASN1_OBJECT *o);
ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);
int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
int OBJ_txt2nid(const char *s);
int OBJ_ln2nid(const char *s);
int OBJ_sn2nid(const char *s);
int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);
const void *OBJ_bsearch_(const void *key, const void *base, int num, int size,
    int (*cmp)(const void *, const void *));
const void *OBJ_bsearch_ex_(const void *key, const void *base, int num,
    int size,
    int (*cmp)(const void *, const void *),
    int flags);

#define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm)        \
    static int nm##_cmp_BSEARCfo *ri, EVP_PKEY *pk);
EVP_CIPHER_CTX *CMS_RecipientInfo_kemri_get0_ctx(CMS_RecipientInfo *ri);
X509_ALGOR *CMS_RecipientInfo_kemri_get0_kdf_alg(CMS_RecipientInfo *ri);
int CMS_RecipientInfo_kemri_set_ukm(CMS_RecipientInfo *ri,
    const unsigned char *ukm,
    int ukmLength);

/* Backward compatibility for spelling errors. */
#define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM
#define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE \
    CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE

#ifdef __cplusplus
}
#endif
#endif
#endif
/*
 * Copyright 2021-2026 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#ifndef OPENSSL_PROV_SSL_H
#define OPENSSL_PROV_SSL_H
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

/* SSL/TLS related defines useful to providers */

#define SSL_MAX_MASTER_KEY_LENGTH 48

/* SSL/TLS uses a 2 byte unsigned version number */
#define SSL3_VERSION 0x0300
#define TLS1_VERSION 0x0301
#define TLS1_1_VERSION 0x0302
#define TLS1_2_VERSION 0x0303
#define TLS1_3_VERSION 0x0304
#define DTLS1_VERSION 0xFEFF
#define DTLS1_2_VERSION 0xFEFD
#define DTLS1_3_VERSION 0xFEFC
#define DTLS1_BAD_VER 0x0100

#define PROTO_VERSION_UNSET 0

/* QUIC uses a 4 byte unsigned version number */
#define OSSL_QUIC1_VERSION 0x0000001

/* Maximum p_CMS_RecipientInfo_cmpfunc_thunk), \
            sk_CMS_RecipientInfo_copyfunc_thunk), \
        sk_CMS_RecipientInfo_freefunc_thunk))
#define sk_CMS_RecipientInfo_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CMS_RecipientInfo_sk_type(sk), (n))
#define sk_CMS_RecipientInfo_free(sk) OPENSSL_sk_free(ossl_check_CMS_RecipientInfo_sk_type(sk))
#define sk_CMS_RecipientInfo_zero(sk) OPENSSL_sk_zero(ossl_check_CMS_RecipientInfo_sk_type(sk))
#define sk_CMS_RecipientInfo_delete(sk, i) ((CMS_RecipientInfo *)OPENSSL_sk_delete(ossl_check_CMS_RecipientInfo_sk_type(sk), (i)))
#define sk_CMS_RecipientInfo_delete_ptr(sk, ptr) ((CMS_RecipientInfo *)OPENSSL_sk_delete_ptr(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr)))
#define sk_CMS_RecipientInfo_push(sk, ptr) OPENSSL_sk_push(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr))
#define sk_CMS_RecipientInfo_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_type(ptr))
#define sk_CMS_RecipientInfo_pop(sk) ((CMS_RecipientInfo *)OPENSSL_sk_pop(ossl_check_CMS_RecipientInfo_sk_type(sk)))
#define sk_CMS_RecipientInfo_shift(sk) ((CMS_RecipientInfo *)OPENSSL_sk_shift(ossl_check_CMS_RecipientInfo_sk_type(sk)))
#define sk_CMS_RecipientInfo_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_CMS_RecipientInfo_sk_type(sk), ossl_check_CMS_RecipientInfo_freefunc_type(freefunc))
#define sk_CMS_RecipientInfo_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_l/macros.h>
#ifndef OPENSSL_NO_DEPRECATED_3_0
#define HEADER_CMS_H
#endif

#include <openssl/opensslconf.h>

#ifndef OPENSSL_NO_CMS
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/cmserr.h>
#ifdef __cplusplus
extern "C" {
#endif

typedef struct CMS_EnvelopedData_st CMS_EnvelopedData;
typedef struct CMS_ContentInfo_st CMS_ContentInfo;
typedef struct CMS_SignerInfo_st CMS_SignerInfo;
typedef struct CMS_SignedData_st CMS_SignedData;
typedef struct CMS_CertificateChoices CMS_CertificateChoices;
typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;
typedef struct CMS_RecipientInfo_st CMS_RecipientInfo;
typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;
typedef struct CMS_Receipt_st CMS_Receipt;
typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;
typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;

/* clang-format off */
SKM_DEFINE_STACK_OF_INTERNAL(CMS_SignerInfo, CMS_SignerInfo, CMS_SignerInfo)
#define sk_CMS_SignerInfo_num(sk) OPENSSL_sk_num(ossl_check_const_CMS_SignerInfo_sk_type(sk))
#define sk_CMS_SignerInfo_value(sk, idx) ((CMS_SignerInfo *)OPENSSL_sk_value(ossl_check_const_CMS_SignerInfo_sk_type(sk), (idx)))
#define sk_CMS_SignerInfo_new(cmp) \
    ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_set_thunks( \
        OPENSSL_sk_set_copy_thunks( \
            OPENSSL