117f01e99SJung-uk Kim /* 2*b077aed3SPierre Pronchery * Copyright 2005-2021 The OpenSSL Project Authors. All Rights Reserved. 317f01e99SJung-uk Kim * 4*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use 517f01e99SJung-uk Kim * this file except in compliance with the License. You can obtain a copy 617f01e99SJung-uk Kim * in the file LICENSE in the source distribution or at 717f01e99SJung-uk Kim * https://www.openssl.org/source/license.html 817f01e99SJung-uk Kim */ 917f01e99SJung-uk Kim 1017f01e99SJung-uk Kim /* Internal ASN1 structures and functions: not for application use */ 1117f01e99SJung-uk Kim 12*b077aed3SPierre Pronchery typedef const ASN1_VALUE const_ASN1_VALUE; 13*b077aed3SPierre Pronchery SKM_DEFINE_STACK_OF(const_ASN1_VALUE, const ASN1_VALUE, ASN1_VALUE) 14*b077aed3SPierre Pronchery 15*b077aed3SPierre Pronchery int ossl_asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d); 16*b077aed3SPierre Pronchery int ossl_asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d); 1717f01e99SJung-uk Kim 1817f01e99SJung-uk Kim /* ASN1 scan context structure */ 1917f01e99SJung-uk Kim 2017f01e99SJung-uk Kim struct asn1_sctx_st { 2117f01e99SJung-uk Kim /* The ASN1_ITEM associated with this field */ 2217f01e99SJung-uk Kim const ASN1_ITEM *it; 2317f01e99SJung-uk Kim /* If ASN1_TEMPLATE associated with this field */ 2417f01e99SJung-uk Kim const ASN1_TEMPLATE *tt; 2517f01e99SJung-uk Kim /* Various flags associated with field and context */ 2617f01e99SJung-uk Kim unsigned long flags; 2717f01e99SJung-uk Kim /* If SEQUENCE OF or SET OF, field index */ 2817f01e99SJung-uk Kim int skidx; 2917f01e99SJung-uk Kim /* ASN1 depth of field */ 3017f01e99SJung-uk Kim int depth; 3117f01e99SJung-uk Kim /* Structure and field name */ 3217f01e99SJung-uk Kim const char *sname, *fname; 3317f01e99SJung-uk Kim /* If a primitive type the type of underlying field */ 3417f01e99SJung-uk Kim int prim_type; 3517f01e99SJung-uk Kim /* The field value itself */ 3617f01e99SJung-uk Kim ASN1_VALUE **field; 3717f01e99SJung-uk Kim /* Callback to pass information to */ 3817f01e99SJung-uk Kim int (*scan_cb) (ASN1_SCTX *ctx); 3917f01e99SJung-uk Kim /* Context specific application data */ 4017f01e99SJung-uk Kim void *app_data; 4117f01e99SJung-uk Kim } /* ASN1_SCTX */ ; 4217f01e99SJung-uk Kim 4317f01e99SJung-uk Kim typedef struct mime_param_st MIME_PARAM; 4417f01e99SJung-uk Kim DEFINE_STACK_OF(MIME_PARAM) 4517f01e99SJung-uk Kim typedef struct mime_header_st MIME_HEADER; 4617f01e99SJung-uk Kim DEFINE_STACK_OF(MIME_HEADER) 4717f01e99SJung-uk Kim 48*b077aed3SPierre Pronchery void ossl_asn1_string_embed_free(ASN1_STRING *a, int embed); 4917f01e99SJung-uk Kim 50*b077aed3SPierre Pronchery int ossl_asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); 51*b077aed3SPierre Pronchery int ossl_asn1_get_choice_selector_const(const ASN1_VALUE **pval, 52*b077aed3SPierre Pronchery const ASN1_ITEM *it); 53*b077aed3SPierre Pronchery int ossl_asn1_set_choice_selector(ASN1_VALUE **pval, int value, 5417f01e99SJung-uk Kim const ASN1_ITEM *it); 5517f01e99SJung-uk Kim 56*b077aed3SPierre Pronchery ASN1_VALUE **ossl_asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); 57*b077aed3SPierre Pronchery const ASN1_VALUE **ossl_asn1_get_const_field_ptr(const ASN1_VALUE **pval, 58*b077aed3SPierre Pronchery const ASN1_TEMPLATE *tt); 5917f01e99SJung-uk Kim 60*b077aed3SPierre Pronchery const ASN1_TEMPLATE *ossl_asn1_do_adb(const ASN1_VALUE *val, 61*b077aed3SPierre Pronchery const ASN1_TEMPLATE *tt, 6217f01e99SJung-uk Kim int nullerr); 6317f01e99SJung-uk Kim 64*b077aed3SPierre Pronchery int ossl_asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); 6517f01e99SJung-uk Kim 66*b077aed3SPierre Pronchery void ossl_asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); 67*b077aed3SPierre Pronchery void ossl_asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); 68*b077aed3SPierre Pronchery int ossl_asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval, 6917f01e99SJung-uk Kim const ASN1_ITEM *it); 70*b077aed3SPierre Pronchery int ossl_asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, 7117f01e99SJung-uk Kim const ASN1_ITEM *it); 7217f01e99SJung-uk Kim 73*b077aed3SPierre Pronchery void ossl_asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); 74*b077aed3SPierre Pronchery void ossl_asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); 75*b077aed3SPierre Pronchery void ossl_asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); 7617f01e99SJung-uk Kim 77*b077aed3SPierre Pronchery ASN1_OBJECT *ossl_c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, 7817f01e99SJung-uk Kim long length); 79*b077aed3SPierre Pronchery int ossl_i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); 80*b077aed3SPierre Pronchery ASN1_BIT_STRING *ossl_c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, 8117f01e99SJung-uk Kim const unsigned char **pp, long length); 82*b077aed3SPierre Pronchery int ossl_i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); 83*b077aed3SPierre Pronchery ASN1_INTEGER *ossl_c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, 8417f01e99SJung-uk Kim long length); 8517f01e99SJung-uk Kim 8617f01e99SJung-uk Kim /* Internal functions used by x_int64.c */ 87*b077aed3SPierre Pronchery int ossl_c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, 88*b077aed3SPierre Pronchery long len); 89*b077aed3SPierre Pronchery int ossl_i2c_uint64_int(unsigned char *p, uint64_t r, int neg); 9017f01e99SJung-uk Kim 91*b077aed3SPierre Pronchery ASN1_TIME *ossl_asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type); 92*b077aed3SPierre Pronchery 93*b077aed3SPierre Pronchery int ossl_asn1_item_ex_new_intern(ASN1_VALUE **pval, const ASN1_ITEM *it, 94*b077aed3SPierre Pronchery OSSL_LIB_CTX *libctx, const char *propq); 95