asn1_local.h 4.0 KB

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