45 #define ASN1_MAX_LEN_LEN ( 1 + sizeof ( size_t ) ) 59 #define ASN1_BOOLEAN 0x01 62 #define ASN1_INTEGER 0x02 65 #define ASN1_BIT_STRING 0x03 68 #define ASN1_OCTET_STRING 0x04 71 #define ASN1_NULL 0x05 77 #define ASN1_ENUMERATED 0x0a 80 #define ASN1_UTF8_STRING 0x0c 83 #define ASN1_UTC_TIME 0x17 86 #define ASN1_GENERALIZED_TIME 0x18 89 #define ASN1_SEQUENCE 0x30 95 #define ASN1_IMPLICIT_TAG( number) ( 0x80 | (number) ) 98 #define ASN1_EXPLICIT_TAG( number) ( 0xa0 | (number) ) 104 #define ASN1_SHORT( tag, ... ) \ 105 (tag), VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__ 108 #define ASN1_OID_INITIAL( first, second ) ( ( (first) * 40 ) + (second) ) 114 #define ASN1_OID_SINGLE( value ) ( (value) & 0x7f ) 120 #define ASN1_OID_DOUBLE( value ) \ 121 ( 0x80 | ( ( (value) >> 7 ) & 0x7f ) ), ASN1_OID_SINGLE ( (value) ) 127 #define ASN1_OID_TRIPLE( value ) \ 128 ( 0x80 | ( ( (value) >> 14 ) & 0x7f ) ), ASN1_OID_DOUBLE ( (value) ) 131 #define ASN1_OID_RSAENCRYPTION \ 132 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 133 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 134 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 1 ) 137 #define ASN1_OID_MD5WITHRSAENCRYPTION \ 138 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 139 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 140 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 4 ) 143 #define ASN1_OID_SHA1WITHRSAENCRYPTION \ 144 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 145 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 146 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ) 149 #define ASN1_OID_SHA256WITHRSAENCRYPTION \ 150 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 151 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 152 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 11 ) 155 #define ASN1_OID_SHA384WITHRSAENCRYPTION \ 156 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 157 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 158 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 12 ) 161 #define ASN1_OID_SHA512WITHRSAENCRYPTION \ 162 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 163 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 164 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 13 ) 167 #define ASN1_OID_SHA224WITHRSAENCRYPTION \ 168 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 169 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 170 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 14 ) 173 #define ASN1_OID_MD4 \ 174 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 175 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 2 ), \ 176 ASN1_OID_SINGLE ( 4 ) 179 #define ASN1_OID_MD5 \ 180 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 181 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 2 ), \ 182 ASN1_OID_SINGLE ( 5 ) 185 #define ASN1_OID_SHA1 \ 186 ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 14 ), \ 187 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 2 ), \ 188 ASN1_OID_SINGLE ( 26 ) 191 #define ASN1_OID_X25519 \ 192 ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 101 ), \ 193 ASN1_OID_SINGLE ( 110 ) 196 #define ASN1_OID_AES128_CBC \ 197 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 198 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 199 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 200 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 2 ) 203 #define ASN1_OID_AES128_GCM \ 204 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 205 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 206 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 207 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 6 ) 210 #define ASN1_OID_AES192_CBC \ 211 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 212 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 213 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 214 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 22 ) 217 #define ASN1_OID_AES192_GCM \ 218 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 219 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 220 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 221 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 26 ) 224 #define ASN1_OID_AES256_CBC \ 225 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 226 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 227 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 228 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 42 ) 231 #define ASN1_OID_AES256_GCM \ 232 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 233 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 234 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 235 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 46 ) 238 #define ASN1_OID_SHA256 \ 239 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 240 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 241 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 242 ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 1 ) 245 #define ASN1_OID_SHA384 \ 246 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 247 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 248 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 249 ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 2 ) 252 #define ASN1_OID_SHA512 \ 253 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 254 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 255 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 256 ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 3 ) 259 #define ASN1_OID_SHA224 \ 260 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 261 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 262 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 263 ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 4 ) 266 #define ASN1_OID_SHA512_224 \ 267 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 268 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 269 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 270 ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 5 ) 273 #define ASN1_OID_SHA512_256 \ 274 ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \ 275 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \ 276 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \ 277 ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 6 ) 280 #define ASN1_OID_COMMON_NAME \ 281 ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 4 ), \ 282 ASN1_OID_SINGLE ( 3 ) 285 #define ASN1_OID_KEYUSAGE \ 286 ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \ 287 ASN1_OID_SINGLE ( 15 ) 290 #define ASN1_OID_BASICCONSTRAINTS \ 291 ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \ 292 ASN1_OID_SINGLE ( 19 ) 295 #define ASN1_OID_EXTKEYUSAGE \ 296 ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \ 297 ASN1_OID_SINGLE ( 37 ) 300 #define ASN1_OID_CODESIGNING \ 301 ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \ 302 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \ 303 ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \ 304 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 3 ) 307 #define ASN1_OID_SIGNEDDATA \ 308 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 309 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 310 ASN1_OID_SINGLE ( 7 ), ASN1_OID_SINGLE ( 2 ) 313 #define ASN1_OID_ENVELOPEDDATA \ 314 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 315 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 316 ASN1_OID_SINGLE ( 7 ), ASN1_OID_SINGLE ( 3 ) 319 #define ASN1_OID_AUTHENVELOPEDDATA \ 320 ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \ 321 ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \ 322 ASN1_OID_SINGLE ( 9 ), ASN1_OID_SINGLE ( 16 ), \ 323 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 23 ) 326 #define ASN1_OID_AUTHORITYINFOACCESS \ 327 ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \ 328 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \ 329 ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \ 330 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 1 ) 333 #define ASN1_OID_OCSP \ 334 ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \ 335 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \ 336 ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \ 337 ASN1_OID_SINGLE ( 48 ), ASN1_OID_SINGLE ( 1 ) 340 #define ASN1_OID_OCSP_BASIC \ 341 ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \ 342 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \ 343 ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \ 344 ASN1_OID_SINGLE ( 48 ), ASN1_OID_SINGLE ( 1 ), \ 345 ASN1_OID_SINGLE ( 1 ) 348 #define ASN1_OID_OCSPSIGNING \ 349 ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 6 ), \ 350 ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \ 351 ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \ 352 ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 9 ) 355 #define ASN1_OID_SUBJECTALTNAME \ 356 ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \ 357 ASN1_OID_SINGLE ( 17 ) 360 #define ASN1_CURSOR( value ) { \ 362 .len = sizeof ( value ), \ 391 #define ASN1_ALGORITHMS __table ( struct asn1_algorithm, "asn1_algorithms" ) 394 #define __asn1_algorithm __table_entry ( ASN1_ALGORITHMS, 01 ) 515 const void *
data,
size_t len );
int asn1_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm, struct asn1_cursor *params)
Parse ASN.1 OID-identified algorithm.
An ASN.1 OID-identified algorithm.
struct cipher_algorithm * cipher
Cipher algorithm (if applicable)
uint8_t extra
Signature extra byte.
int asn1_digest_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
Parse ASN.1 OID-identified digest algorithm.
int asn1_generalized_time(const struct asn1_cursor *cursor, time_t *time)
Parse ASN.1 GeneralizedTime.
#define ASN1_END
ASN.1 end.
int asn1_boolean(const struct asn1_cursor *cursor)
Parse value of ASN.1 boolean.
int asn1_cipher_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm, struct asn1_cursor *params)
Parse ASN.1 OID-identified cipher algorithm.
uint32_t type
Operating system type.
const void * data
Start of data.
int asn1_skip(struct asn1_cursor *cursor, unsigned int type)
Skip ASN.1 object.
#define __asn1_algorithm
Declare an ASN.1 OID-identified algorithm.
int asn1_prepend_raw(struct asn1_builder *builder, const void *data, size_t len)
Prepend raw data to ASN.1 builder.
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
static unsigned int asn1_type(const struct asn1_cursor *cursor)
Extract ASN.1 type.
int asn1_integral_bit_string(const struct asn1_cursor *cursor, struct asn1_bit_string *bits)
Parse ASN.1 bit string that must be an integral number of bytes.
int asn1_shrink(struct asn1_cursor *cursor, unsigned int type)
Shrink ASN.1 cursor to fit object.
size_t len
Length of data.
int asn1_skip_if_exists(struct asn1_cursor *cursor, unsigned int type)
Skip ASN.1 object if present.
struct pubkey_algorithm * pubkey
Public-key algorithm (if applicable)
int asn1_shrink_any(struct asn1_cursor *cursor)
Shrink ASN.1 object of any type.
int asn1_prepend(struct asn1_builder *builder, unsigned int type, const void *data, size_t len)
Prepend data to ASN.1 builder.
#define container_of(ptr, type, field)
Get containing structure.
int asn1_pubkey_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
Parse ASN.1 OID-identified public-key algorithm.
pseudo_bit_t value[0x00020]
#define build_assert(condition)
Assert a condition at build time (after dead code elimination)
int asn1_parse_gcm(struct asn1_algorithm *algorithm, struct asn1_cursor *params)
#define ASN1_MAX_LEN_LEN
Maximum (viable) length of ASN.1 length.
int asn1_compare(const struct asn1_cursor *cursor1, const struct asn1_cursor *cursor2)
Compare two ASN.1 objects.
unsigned int unused
Unused bits at end of data.
int asn1_wrap(struct asn1_builder *builder, unsigned int type)
Wrap ASN.1 builder.
int asn1_signature_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
Parse ASN.1 OID-identified signature algorithm.
static void asn1_invalidate_cursor(struct asn1_cursor *cursor)
Invalidate ASN.1 object cursor.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct elliptic_curve * curve
Elliptic curve (if applicable)
int asn1_enter_partial(struct asn1_cursor *cursor, unsigned int type, size_t *extra)
Enter ASN.1 partial object.
int asn1_bit_string(const struct asn1_cursor *cursor, struct asn1_bit_string *bits)
Parse ASN.1 bit string.
struct asn1_cursor oid
Object identifier.
int asn1_integer(const struct asn1_cursor *cursor, int *value)
Parse value of ASN.1 integer.
int asn1_check_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm *expected)
Check ASN.1 OID-identified algorithm.
int asn1_skip_any(struct asn1_cursor *cursor)
Skip ASN.1 object of any type.
u16 algorithm
Authentication algorithm (Open System or Shared Key)
static volatile void * bits
struct digest_algorithm * digest
Digest algorithm (if applicable)
int asn1_grow(struct asn1_builder *builder, size_t extra)
Grow ASN.1 builder.
A message digest algorithm.
uint8_t data[48]
Additional event data.
static struct asn1_cursor * asn1_built(struct asn1_builder *builder)
Get cursor for built object.
typeof(acpi_finder=acpi_find)
ACPI table finder.
int(* parse)(struct asn1_algorithm *algorithm, struct asn1_cursor *params)
Parse algorithm parameters (optional)
int asn1_parse_cbc(struct asn1_algorithm *algorithm, struct asn1_cursor *params)
Parse ASN.1 CBC cipher parameters.
int64_t time_t
Seconds since the Epoch.
size_t len
Length of data.
int asn1_enter_any(struct asn1_cursor *cursor)
Enter ASN.1 object of any type.