| 1 |
/* |
| 2 |
* Copyright 2005-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 3 |
* |
| 4 |
* Licensed under the Apache License 2.0 (the "License"). You may not use |
| 5 |
* this file except in compliance with the License. You can obtain a copy |
| 6 |
* in the file LICENSE in the source distribution or at |
| 7 |
* https://www.openssl.org/source/license.html |
| 8 |
*/ |
| 9 |
|
| 10 |
/* Internal ASN1 structures and functions: not for application use */ |
| 11 |
|
| 12 |
#include "crypto/asn1.h" |
| 13 |
|
| 14 |
typedef const ASN1_VALUE const_ASN1_VALUE; |
| 15 |
SKM_DEFINE_STACK_OF(const_ASN1_VALUE, const ASN1_VALUE, ASN1_VALUE) |
| 16 |
|
| 17 |
int ossl_asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d); |
| 18 |
int ossl_asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d); |
| 19 |
|
| 20 |
/* ASN1 scan context structure */ |
| 21 |
|
| 22 |
struct asn1_sctx_st { |
| 23 |
/* The ASN1_ITEM associated with this field */ |
| 24 |
const ASN1_ITEM *it; |
| 25 |
/* If ASN1_TEMPLATE associated with this field */ |
| 26 |
const ASN1_TEMPLATE *tt; |
| 27 |
/* Various flags associated with field and context */ |
| 28 |
unsigned long flags; |
| 29 |
/* If SEQUENCE OF or SET OF, field index */ |
| 30 |
int skidx; |
| 31 |
/* ASN1 depth of field */ |
| 32 |
int depth; |
| 33 |
/* Structure and field name */ |
| 34 |
const char *sname, *fname; |
| 35 |
/* If a primitive type the type of underlying field */ |
| 36 |
int prim_type; |
| 37 |
/* The field value itself */ |
| 38 |
ASN1_VALUE **field; |
| 39 |
/* Callback to pass information to */ |
| 40 |
int (*scan_cb)(ASN1_SCTX *ctx); |
| 41 |
/* Context specific application data */ |
| 42 |
void *app_data; |
| 43 |
} /* ASN1_SCTX */; |
| 44 |
|
| 45 |
typedef struct mime_param_st MIME_PARAM; |
| 46 |
DEFINE_STACK_OF(MIME_PARAM) |
| 47 |
typedef struct mime_header_st MIME_HEADER; |
| 48 |
DEFINE_STACK_OF(MIME_HEADER) |
| 49 |
|
| 50 |
void ossl_asn1_string_embed_free(ASN1_STRING *a, int embed); |
| 51 |
|
| 52 |
int ossl_asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 53 |
int ossl_asn1_get_choice_selector_const(const ASN1_VALUE **pval, |
| 54 |
const ASN1_ITEM *it); |
| 55 |
int ossl_asn1_set_choice_selector(ASN1_VALUE **pval, int value, |
| 56 |
const ASN1_ITEM *it); |
| 57 |
|
| 58 |
ASN1_VALUE **ossl_asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); |
| 59 |
const ASN1_VALUE **ossl_asn1_get_const_field_ptr(const ASN1_VALUE **pval, |
| 60 |
const ASN1_TEMPLATE *tt); |
| 61 |
|
| 62 |
const ASN1_TEMPLATE *ossl_asn1_do_adb(const ASN1_VALUE *val, |
| 63 |
const ASN1_TEMPLATE *tt, |
| 64 |
int nullerr); |
| 65 |
|
| 66 |
int ossl_asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); |
| 67 |
|
| 68 |
void ossl_asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 69 |
void ossl_asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); |
| 70 |
int ossl_asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval, |
| 71 |
const ASN1_ITEM *it); |
| 72 |
int ossl_asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, long inlen, |
| 73 |
const ASN1_ITEM *it); |
| 74 |
|
| 75 |
void ossl_asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); |
| 76 |
void ossl_asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); |
| 77 |
void ossl_asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); |
| 78 |
|
| 79 |
ASN1_OBJECT *ossl_c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, |
| 80 |
long length); |
| 81 |
int ossl_i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); |
| 82 |
ASN1_BIT_STRING *ossl_c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, |
| 83 |
const unsigned char **pp, long length); |
| 84 |
int ossl_i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); |
| 85 |
ASN1_INTEGER *ossl_c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, |
| 86 |
long length); |
| 87 |
|
| 88 |
/* Internal functions used by x_int64.c */ |
| 89 |
int ossl_c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, |
| 90 |
long len); |
| 91 |
int ossl_i2c_uint64_int(unsigned char *p, uint64_t r, int neg); |
| 92 |
|
| 93 |
ASN1_TIME *ossl_asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type); |
| 94 |
|
| 95 |
int ossl_asn1_item_ex_new_intern(ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 96 |
OSSL_LIB_CTX *libctx, const char *propq); |