File indexing completed on 2025-01-18 10:02:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef NETTLE_ASN1_H_INCLUDED
0035 #define NETTLE_ASN1_H_INCLUDED
0036
0037 #include "nettle-types.h"
0038
0039 #ifdef __cplusplus
0040 extern "C" {
0041 #endif
0042
0043
0044 #define asn1_der_iterator_first nettle_asn1_der_iterator_first
0045 #define asn1_der_iterator_next nettle_asn1_der_iterator_next
0046 #define asn1_der_decode_constructed nettle_asn1_der_decode_constructed
0047 #define asn1_der_decode_constructed_last nettle_asn1_der_decode_constructed_last
0048 #define asn1_der_decode_bitstring nettle_asn1_der_decode_bitstring
0049 #define asn1_der_decode_bitstring_last nettle_asn1_der_decode_bitstring_last
0050 #define asn1_der_get_uint32 nettle_asn1_der_get_uint32
0051 #define asn1_der_get_bignum nettle_asn1_der_get_bignum
0052
0053
0054
0055
0056
0057
0058
0059 enum
0060 {
0061 ASN1_TYPE_CONSTRUCTED = 1 << 12,
0062
0063 ASN1_CLASS_UNIVERSAL = 0,
0064 ASN1_CLASS_APPLICATION = 1 << 13,
0065 ASN1_CLASS_CONTEXT_SPECIFIC = 2 << 13,
0066 ASN1_CLASS_PRIVATE = 3 << 13,
0067
0068 ASN1_CLASS_MASK = 3 << 13,
0069 ASN1_CLASS_SHIFT = 13,
0070 };
0071
0072 enum asn1_type
0073 {
0074 ASN1_BOOLEAN = 1,
0075 ASN1_INTEGER = 2,
0076 ASN1_BITSTRING = 3,
0077 ASN1_OCTETSTRING = 4,
0078 ASN1_NULL = 5,
0079 ASN1_IDENTIFIER = 6,
0080 ASN1_REAL = 9,
0081 ASN1_ENUMERATED = 10,
0082 ASN1_UTF8STRING = 12,
0083 ASN1_SEQUENCE = 16 | ASN1_TYPE_CONSTRUCTED,
0084 ASN1_SET = 17 | ASN1_TYPE_CONSTRUCTED,
0085 ASN1_PRINTABLESTRING = 19,
0086 ASN1_TELETEXSTRING = 20,
0087 ASN1_IA5STRING = 22,
0088 ASN1_UTC = 23,
0089 ASN1_UNIVERSALSTRING = 28,
0090 ASN1_BMPSTRING = 30,
0091 };
0092
0093 enum asn1_iterator_result
0094 {
0095 ASN1_ITERATOR_ERROR,
0096 ASN1_ITERATOR_PRIMITIVE,
0097 ASN1_ITERATOR_CONSTRUCTED,
0098 ASN1_ITERATOR_END,
0099 };
0100
0101
0102 struct asn1_der_iterator
0103 {
0104 size_t buffer_length;
0105 const uint8_t *buffer;
0106
0107
0108 size_t pos;
0109
0110 enum asn1_type type;
0111
0112
0113 size_t length;
0114 const uint8_t *data;
0115 };
0116
0117
0118 enum asn1_iterator_result
0119 asn1_der_iterator_first(struct asn1_der_iterator *iterator,
0120 size_t length, const uint8_t *input);
0121
0122 enum asn1_iterator_result
0123 asn1_der_iterator_next(struct asn1_der_iterator *iterator);
0124
0125
0126 enum asn1_iterator_result
0127 asn1_der_decode_constructed(struct asn1_der_iterator *i,
0128 struct asn1_der_iterator *contents);
0129
0130
0131
0132
0133 enum asn1_iterator_result
0134 asn1_der_decode_constructed_last(struct asn1_der_iterator *i);
0135
0136 enum asn1_iterator_result
0137 asn1_der_decode_bitstring(struct asn1_der_iterator *i,
0138 struct asn1_der_iterator *contents);
0139
0140 enum asn1_iterator_result
0141 asn1_der_decode_bitstring_last(struct asn1_der_iterator *i);
0142
0143
0144 int
0145 asn1_der_get_uint32(struct asn1_der_iterator *i,
0146 uint32_t *x);
0147
0148 #ifdef __cplusplus
0149 }
0150 #endif
0151
0152 #endif