iPXE
Data Structures | Macros | Functions | Variables
asn1.h File Reference

ASN.1 encoding. More...

#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <assert.h>
#include <time.h>
#include <ipxe/tables.h>

Go to the source code of this file.

Data Structures

struct  asn1_cursor
 An ASN.1 object cursor. More...
 
struct  asn1_builder
 An ASN.1 object builder. More...
 
struct  asn1_builder_header
 An ASN.1 header. More...
 
struct  asn1_algorithm
 An ASN.1 OID-identified algorithm. More...
 

Macros

#define ASN1_MAX_LEN_LEN   ( 1 + sizeof ( size_t ) )
 Maximum (viable) length of ASN.1 length. More...
 
#define ASN1_END   0x00
 ASN.1 end. More...
 
#define ASN1_BOOLEAN   0x01
 ASN.1 boolean. More...
 
#define ASN1_INTEGER   0x02
 ASN.1 integer. More...
 
#define ASN1_BIT_STRING   0x03
 ASN.1 bit string. More...
 
#define ASN1_OCTET_STRING   0x04
 ASN.1 octet string. More...
 
#define ASN1_NULL   0x05
 ASN.1 null. More...
 
#define ASN1_OID   0x06
 ASN.1 object identifier. More...
 
#define ASN1_ENUMERATED   0x0a
 ASN.1 enumeration. More...
 
#define ASN1_UTF8_STRING   0x0c
 ASN.1 UTF-8 string. More...
 
#define ASN1_UTC_TIME   0x17
 ASN.1 UTC time. More...
 
#define ASN1_GENERALIZED_TIME   0x18
 ASN.1 generalized time. More...
 
#define ASN1_SEQUENCE   0x30
 ASN.1 sequence. More...
 
#define ASN1_SET   0x31
 ASN.1 set. More...
 
#define ASN1_IMPLICIT_TAG(number)   ( 0x80 | (number) )
 ASN.1 implicit tag. More...
 
#define ASN1_EXPLICIT_TAG(number)   ( 0xa0 | (number) )
 ASN.1 explicit tag. More...
 
#define ASN1_ANY   -1U
 ASN.1 "any tag" magic value. More...
 
#define ASN1_SHORT(tag, ...)   (tag), VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__
 Construct a short ASN.1 value. More...
 
#define ASN1_OID_INITIAL(first, second)   ( ( (first) * 40 ) + (second) )
 Initial OID byte. More...
 
#define ASN1_OID_SINGLE(value)   ( (value) & 0x7f )
 Single-byte OID value. More...
 
#define ASN1_OID_DOUBLE(value)   ( 0x80 | ( ( (value) >> 7 ) & 0x7f ) ), ASN1_OID_SINGLE ( (value) )
 Double-byte OID value. More...
 
#define ASN1_OID_TRIPLE(value)   ( 0x80 | ( ( (value) >> 14 ) & 0x7f ) ), ASN1_OID_DOUBLE ( (value) )
 Double-byte OID value. More...
 
#define ASN1_OID_ECPUBLICKEY
 ASN.1 OID for ecPublicKey (1.2.840.10045.2.1) More...
 
#define ASN1_OID_PRIME256V1
 ASN.1 OID for prime256v1 (1.2.840.10045.3.1.7) More...
 
#define ASN1_OID_ECDSA_WITH_SHA224
 ASN.1 OID for ecdsa-with-SHA224 (1.2.840.10045.4.3.1) More...
 
#define ASN1_OID_ECDSA_WITH_SHA256
 ASN.1 OID for ecdsa-with-SHA256 (1.2.840.10045.4.3.2) More...
 
#define ASN1_OID_ECDSA_WITH_SHA384
 ASN.1 OID for ecdsa-with-SHA384 (1.2.840.10045.4.3.3) More...
 
#define ASN1_OID_ECDSA_WITH_SHA512
 ASN.1 OID for ecdsa-with-SHA512 (1.2.840.10045.4.3.4) More...
 
#define ASN1_OID_RSAENCRYPTION
 ASN.1 OID for rsaEncryption (1.2.840.113549.1.1.1) More...
 
#define ASN1_OID_MD5WITHRSAENCRYPTION
 ASN.1 OID for md5WithRSAEncryption (1.2.840.113549.1.1.4) More...
 
#define ASN1_OID_SHA1WITHRSAENCRYPTION
 ASN.1 OID for sha1WithRSAEncryption (1.2.840.113549.1.1.5) More...
 
#define ASN1_OID_SHA256WITHRSAENCRYPTION
 ASN.1 OID for sha256WithRSAEncryption (1.2.840.113549.1.1.11) More...
 
#define ASN1_OID_SHA384WITHRSAENCRYPTION
 ASN.1 OID for sha384WithRSAEncryption (1.2.840.113549.1.1.12) More...
 
#define ASN1_OID_SHA512WITHRSAENCRYPTION
 ASN.1 OID for sha512WithRSAEncryption (1.2.840.113549.1.1.13) More...
 
#define ASN1_OID_SHA224WITHRSAENCRYPTION
 ASN.1 OID for sha224WithRSAEncryption (1.2.840.113549.1.1.14) More...
 
#define ASN1_OID_MD4
 ASN.1 OID for id-md4 (1.2.840.113549.2.4) More...
 
#define ASN1_OID_MD5
 ASN.1 OID for id-md5 (1.2.840.113549.2.5) More...
 
#define ASN1_OID_SHA1
 ASN.1 OID for id-sha1 (1.3.14.3.2.26) More...
 
#define ASN1_OID_X25519
 ASN.1 OID for id-x25519 (1.3.101.110) More...
 
#define ASN1_OID_SECP384R1
 ASN.1 OID for secp384r1 (1.3.132.0.34) More...
 
#define ASN1_OID_AES128_CBC
 ASN.1 OID for id-aes128-cbc (2.16.840.1.101.3.4.1.2) More...
 
#define ASN1_OID_AES128_GCM
 ASN.1 OID for id-aes128-gcm (2.16.840.1.101.3.4.1.6) More...
 
#define ASN1_OID_AES192_CBC
 ASN.1 OID for id-aes192-cbc (2.16.840.1.101.3.4.1.22) More...
 
#define ASN1_OID_AES192_GCM
 ASN.1 OID for id-aes192-gcm (2.16.840.1.101.3.4.1.26) More...
 
#define ASN1_OID_AES256_CBC
 ASN.1 OID for id-aes256-cbc (2.16.840.1.101.3.4.1.42) More...
 
#define ASN1_OID_AES256_GCM
 ASN.1 OID for id-aes256-gcm (2.16.840.1.101.3.4.1.46) More...
 
#define ASN1_OID_SHA256
 ASN.1 OID for id-sha256 (2.16.840.1.101.3.4.2.1) More...
 
#define ASN1_OID_SHA384
 ASN.1 OID for id-sha384 (2.16.840.1.101.3.4.2.2) More...
 
#define ASN1_OID_SHA512
 ASN.1 OID for id-sha512 (2.16.840.1.101.3.4.2.3) More...
 
#define ASN1_OID_SHA224
 ASN.1 OID for id-sha224 (2.16.840.1.101.3.4.2.4) More...
 
#define ASN1_OID_SHA512_224
 ASN.1 OID for id-sha512-224 (2.16.840.1.101.3.4.2.5) More...
 
#define ASN1_OID_SHA512_256
 ASN.1 OID for id-sha512-256 (2.16.840.1.101.3.4.2.6) More...
 
#define ASN1_OID_COMMON_NAME
 ASN.1 OID for commonName (2.5.4.3) More...
 
#define ASN1_OID_KEYUSAGE
 ASN.1 OID for id-ce-keyUsage (2.5.29.15) More...
 
#define ASN1_OID_BASICCONSTRAINTS
 ASN.1 OID for id-ce-basicConstraints (2.5.29.19) More...
 
#define ASN1_OID_EXTKEYUSAGE
 ASN.1 OID for id-ce-extKeyUsage (2.5.29.37) More...
 
#define ASN1_OID_CODESIGNING
 ASN.1 OID for id-kp-codeSigning (1.3.6.1.5.5.7.3.3) More...
 
#define ASN1_OID_SIGNEDDATA
 ASN.1 OID for id-signedData (1.2.840.113549.1.7.2) More...
 
#define ASN1_OID_ENVELOPEDDATA
 ASN.1 OID for id-envelopedData (1.2.840.113549.1.7.3) More...
 
#define ASN1_OID_AUTHENVELOPEDDATA
 ASN.1 OID for id-authEnvelopedData (1.2.840.113549.1.9.16.1.23) More...
 
#define ASN1_OID_AUTHORITYINFOACCESS
 ASN.1 OID for id-pe-authorityInfoAccess (1.3.6.1.5.5.7.1.1) More...
 
#define ASN1_OID_OCSP
 ASN.1 OID for id-ad-ocsp (1.3.6.1.5.5.7.48.1) More...
 
#define ASN1_OID_OCSP_BASIC
 ASN.1 OID for id-pkix-ocsp-basic ( 1.3.6.1.5.5.7.48.1.1) More...
 
#define ASN1_OID_OCSPSIGNING
 ASN.1 OID for id-kp-OCSPSigning (1.3.6.1.5.5.7.3.9) More...
 
#define ASN1_OID_SUBJECTALTNAME
 ASN.1 OID for id-ce-subjectAltName (2.5.29.17) More...
 
#define ASN1_CURSOR(value)
 Define an ASN.1 cursor for a static value. More...
 
#define ASN1_ALGORITHMS   __table ( struct asn1_algorithm, "asn1_algorithms" )
 ASN.1 OID-identified algorithms. More...
 
#define __asn1_algorithm   __table_entry ( ASN1_ALGORITHMS, 01 )
 Declare an ASN.1 OID-identified algorithm. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
static void asn1_invalidate_cursor (struct asn1_cursor *cursor)
 Invalidate ASN.1 object cursor. More...
 
static unsigned int asn1_type (const struct asn1_cursor *cursor)
 Extract ASN.1 type. More...
 
static struct asn1_cursorasn1_built (struct asn1_builder *builder)
 Get cursor for built object. More...
 
int asn1_enter (struct asn1_cursor *cursor, unsigned int type)
 Enter ASN.1 object. More...
 
int asn1_skip_if_exists (struct asn1_cursor *cursor, unsigned int type)
 Skip ASN.1 object if present. More...
 
int asn1_skip (struct asn1_cursor *cursor, unsigned int type)
 Skip ASN.1 object. More...
 
int asn1_shrink (struct asn1_cursor *cursor, unsigned int type)
 Shrink ASN.1 cursor to fit object. More...
 
int asn1_enter_any (struct asn1_cursor *cursor)
 Enter ASN.1 object of any type. More...
 
int asn1_skip_any (struct asn1_cursor *cursor)
 Skip ASN.1 object of any type. More...
 
int asn1_shrink_any (struct asn1_cursor *cursor)
 Shrink ASN.1 object of any type. More...
 
int asn1_enter_bits (struct asn1_cursor *cursor, unsigned int *unused)
 Enter ASN.1 bit string. More...
 
int asn1_enter_unsigned (struct asn1_cursor *cursor)
 Enter ASN.1 unsigned integer. More...
 
int asn1_boolean (const struct asn1_cursor *cursor)
 Parse value of ASN.1 boolean. More...
 
int asn1_integer (const struct asn1_cursor *cursor, int *value)
 Parse value of ASN.1 integer. More...
 
int asn1_compare (const struct asn1_cursor *cursor1, const struct asn1_cursor *cursor2)
 Compare two ASN.1 objects. More...
 
int asn1_algorithm (const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm, struct asn1_cursor *params)
 Parse ASN.1 OID-identified algorithm. More...
 
int asn1_pubkey_algorithm (const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
 Parse ASN.1 OID-identified public-key algorithm. More...
 
int asn1_digest_algorithm (const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
 Parse ASN.1 OID-identified digest algorithm. More...
 
int asn1_cipher_algorithm (const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm, struct asn1_cursor *params)
 Parse ASN.1 OID-identified cipher algorithm. More...
 
int asn1_signature_algorithm (const struct asn1_cursor *cursor, struct asn1_algorithm **algorithm)
 Parse ASN.1 OID-identified signature algorithm. More...
 
int asn1_curve_algorithm (const struct asn1_cursor *cursor, struct asn1_algorithm *wrapper, struct asn1_algorithm **algorithm)
 Parse ASN.1 OID-identified elliptic curve algorithm. More...
 
int asn1_check_algorithm (const struct asn1_cursor *cursor, struct asn1_algorithm *expected, struct asn1_cursor *params)
 Check ASN.1 OID-identified algorithm. More...
 
int asn1_parse_cbc (struct asn1_algorithm *algorithm, struct asn1_cursor *params)
 Parse ASN.1 CBC cipher parameters. More...
 
int asn1_parse_gcm (struct asn1_algorithm *algorithm, struct asn1_cursor *params)
 
int asn1_generalized_time (const struct asn1_cursor *cursor, time_t *time)
 Parse ASN.1 GeneralizedTime. More...
 
int asn1_grow (struct asn1_builder *builder, size_t extra)
 Grow ASN.1 builder. More...
 
int asn1_prepend_raw (struct asn1_builder *builder, const void *data, size_t len)
 Prepend raw data to ASN.1 builder. More...
 
int asn1_prepend (struct asn1_builder *builder, unsigned int type, const void *data, size_t len)
 Prepend data to ASN.1 builder. More...
 
int asn1_wrap (struct asn1_builder *builder, unsigned int type)
 Wrap ASN.1 builder. More...
 

Variables

struct asn1_algorithm rsa_encryption_algorithm __asn1_algorithm
 Generic elliptic curve container algorithm. More...
 

Detailed Description

ASN.1 encoding.

Definition in file asn1.h.

Macro Definition Documentation

◆ ASN1_MAX_LEN_LEN

#define ASN1_MAX_LEN_LEN   ( 1 + sizeof ( size_t ) )

Maximum (viable) length of ASN.1 length.

While in theory unlimited, this length is sufficient to contain a size_t.

Definition at line 46 of file asn1.h.

◆ ASN1_END

#define ASN1_END   0x00

ASN.1 end.

Definition at line 57 of file asn1.h.

◆ ASN1_BOOLEAN

#define ASN1_BOOLEAN   0x01

ASN.1 boolean.

Definition at line 60 of file asn1.h.

◆ ASN1_INTEGER

#define ASN1_INTEGER   0x02

ASN.1 integer.

Definition at line 63 of file asn1.h.

◆ ASN1_BIT_STRING

#define ASN1_BIT_STRING   0x03

ASN.1 bit string.

Definition at line 66 of file asn1.h.

◆ ASN1_OCTET_STRING

#define ASN1_OCTET_STRING   0x04

ASN.1 octet string.

Definition at line 69 of file asn1.h.

◆ ASN1_NULL

#define ASN1_NULL   0x05

ASN.1 null.

Definition at line 72 of file asn1.h.

◆ ASN1_OID

#define ASN1_OID   0x06

ASN.1 object identifier.

Definition at line 75 of file asn1.h.

◆ ASN1_ENUMERATED

#define ASN1_ENUMERATED   0x0a

ASN.1 enumeration.

Definition at line 78 of file asn1.h.

◆ ASN1_UTF8_STRING

#define ASN1_UTF8_STRING   0x0c

ASN.1 UTF-8 string.

Definition at line 81 of file asn1.h.

◆ ASN1_UTC_TIME

#define ASN1_UTC_TIME   0x17

ASN.1 UTC time.

Definition at line 84 of file asn1.h.

◆ ASN1_GENERALIZED_TIME

#define ASN1_GENERALIZED_TIME   0x18

ASN.1 generalized time.

Definition at line 87 of file asn1.h.

◆ ASN1_SEQUENCE

#define ASN1_SEQUENCE   0x30

ASN.1 sequence.

Definition at line 90 of file asn1.h.

◆ ASN1_SET

#define ASN1_SET   0x31

ASN.1 set.

Definition at line 93 of file asn1.h.

◆ ASN1_IMPLICIT_TAG

#define ASN1_IMPLICIT_TAG (   number)    ( 0x80 | (number) )

ASN.1 implicit tag.

Definition at line 96 of file asn1.h.

◆ ASN1_EXPLICIT_TAG

#define ASN1_EXPLICIT_TAG (   number)    ( 0xa0 | (number) )

ASN.1 explicit tag.

Definition at line 99 of file asn1.h.

◆ ASN1_ANY

#define ASN1_ANY   -1U

ASN.1 "any tag" magic value.

Definition at line 102 of file asn1.h.

◆ ASN1_SHORT

#define ASN1_SHORT (   tag,
  ... 
)    (tag), VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__

Construct a short ASN.1 value.

Definition at line 105 of file asn1.h.

◆ ASN1_OID_INITIAL

#define ASN1_OID_INITIAL (   first,
  second 
)    ( ( (first) * 40 ) + (second) )

Initial OID byte.

Definition at line 109 of file asn1.h.

◆ ASN1_OID_SINGLE

#define ASN1_OID_SINGLE (   value)    ( (value) & 0x7f )

Single-byte OID value.

Valid for values up to 127

Definition at line 115 of file asn1.h.

◆ ASN1_OID_DOUBLE

#define ASN1_OID_DOUBLE (   value)    ( 0x80 | ( ( (value) >> 7 ) & 0x7f ) ), ASN1_OID_SINGLE ( (value) )

Double-byte OID value.

Valid for values up to 16383

Definition at line 121 of file asn1.h.

◆ ASN1_OID_TRIPLE

#define ASN1_OID_TRIPLE (   value)    ( 0x80 | ( ( (value) >> 14 ) & 0x7f ) ), ASN1_OID_DOUBLE ( (value) )

Double-byte OID value.

Valid for values up to 2097151

Definition at line 128 of file asn1.h.

◆ ASN1_OID_ECPUBLICKEY

#define ASN1_OID_ECPUBLICKEY
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_DOUBLE ( 10045 ), ASN1_OID_SINGLE ( 2 ), \
ASN1_OID_SINGLE ( 1 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for ecPublicKey (1.2.840.10045.2.1)

Definition at line 132 of file asn1.h.

◆ ASN1_OID_PRIME256V1

#define ASN1_OID_PRIME256V1
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_DOUBLE ( 10045 ), ASN1_OID_SINGLE ( 3 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 7 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for prime256v1 (1.2.840.10045.3.1.7)

Definition at line 138 of file asn1.h.

◆ ASN1_OID_ECDSA_WITH_SHA224

#define ASN1_OID_ECDSA_WITH_SHA224
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_DOUBLE ( 10045 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 1 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for ecdsa-with-SHA224 (1.2.840.10045.4.3.1)

Definition at line 144 of file asn1.h.

◆ ASN1_OID_ECDSA_WITH_SHA256

#define ASN1_OID_ECDSA_WITH_SHA256
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_DOUBLE ( 10045 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 2 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for ecdsa-with-SHA256 (1.2.840.10045.4.3.2)

Definition at line 150 of file asn1.h.

◆ ASN1_OID_ECDSA_WITH_SHA384

#define ASN1_OID_ECDSA_WITH_SHA384
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_DOUBLE ( 10045 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 3 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for ecdsa-with-SHA384 (1.2.840.10045.4.3.3)

Definition at line 156 of file asn1.h.

◆ ASN1_OID_ECDSA_WITH_SHA512

#define ASN1_OID_ECDSA_WITH_SHA512
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_DOUBLE ( 10045 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for ecdsa-with-SHA512 (1.2.840.10045.4.3.4)

Definition at line 162 of file asn1.h.

◆ ASN1_OID_RSAENCRYPTION

#define ASN1_OID_RSAENCRYPTION
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 1 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for rsaEncryption (1.2.840.113549.1.1.1)

Definition at line 168 of file asn1.h.

◆ ASN1_OID_MD5WITHRSAENCRYPTION

#define ASN1_OID_MD5WITHRSAENCRYPTION
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 4 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for md5WithRSAEncryption (1.2.840.113549.1.1.4)

Definition at line 174 of file asn1.h.

◆ ASN1_OID_SHA1WITHRSAENCRYPTION

#define ASN1_OID_SHA1WITHRSAENCRYPTION
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for sha1WithRSAEncryption (1.2.840.113549.1.1.5)

Definition at line 180 of file asn1.h.

◆ ASN1_OID_SHA256WITHRSAENCRYPTION

#define ASN1_OID_SHA256WITHRSAENCRYPTION
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 11 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for sha256WithRSAEncryption (1.2.840.113549.1.1.11)

Definition at line 186 of file asn1.h.

◆ ASN1_OID_SHA384WITHRSAENCRYPTION

#define ASN1_OID_SHA384WITHRSAENCRYPTION
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 12 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for sha384WithRSAEncryption (1.2.840.113549.1.1.12)

Definition at line 192 of file asn1.h.

◆ ASN1_OID_SHA512WITHRSAENCRYPTION

#define ASN1_OID_SHA512WITHRSAENCRYPTION
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 13 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for sha512WithRSAEncryption (1.2.840.113549.1.1.13)

Definition at line 198 of file asn1.h.

◆ ASN1_OID_SHA224WITHRSAENCRYPTION

#define ASN1_OID_SHA224WITHRSAENCRYPTION
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 14 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for sha224WithRSAEncryption (1.2.840.113549.1.1.14)

Definition at line 204 of file asn1.h.

◆ ASN1_OID_MD4

#define ASN1_OID_MD4
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 2 ), \
ASN1_OID_SINGLE ( 4 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-md4 (1.2.840.113549.2.4)

Definition at line 210 of file asn1.h.

◆ ASN1_OID_MD5

#define ASN1_OID_MD5
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 2 ), \
ASN1_OID_SINGLE ( 5 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-md5 (1.2.840.113549.2.5)

Definition at line 216 of file asn1.h.

◆ ASN1_OID_SHA1

#define ASN1_OID_SHA1
Value:
ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 14 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 2 ), \
ASN1_OID_SINGLE ( 26 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-sha1 (1.3.14.3.2.26)

Definition at line 222 of file asn1.h.

◆ ASN1_OID_X25519

#define ASN1_OID_X25519
Value:
ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 110 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-x25519 (1.3.101.110)

Definition at line 228 of file asn1.h.

◆ ASN1_OID_SECP384R1

#define ASN1_OID_SECP384R1
Value:
ASN1_OID_INITIAL ( 1, 3 ), ASN1_OID_DOUBLE ( 132 ), \
ASN1_OID_SINGLE ( 0 ), ASN1_OID_SINGLE ( 34 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for secp384r1 (1.3.132.0.34)

Definition at line 233 of file asn1.h.

◆ ASN1_OID_AES128_CBC

#define ASN1_OID_AES128_CBC
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 2 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-aes128-cbc (2.16.840.1.101.3.4.1.2)

Definition at line 238 of file asn1.h.

◆ ASN1_OID_AES128_GCM

#define ASN1_OID_AES128_GCM
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 6 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-aes128-gcm (2.16.840.1.101.3.4.1.6)

Definition at line 245 of file asn1.h.

◆ ASN1_OID_AES192_CBC

#define ASN1_OID_AES192_CBC
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 22 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-aes192-cbc (2.16.840.1.101.3.4.1.22)

Definition at line 252 of file asn1.h.

◆ ASN1_OID_AES192_GCM

#define ASN1_OID_AES192_GCM
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 26 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-aes192-gcm (2.16.840.1.101.3.4.1.26)

Definition at line 259 of file asn1.h.

◆ ASN1_OID_AES256_CBC

#define ASN1_OID_AES256_CBC
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 42 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-aes256-cbc (2.16.840.1.101.3.4.1.42)

Definition at line 266 of file asn1.h.

◆ ASN1_OID_AES256_GCM

#define ASN1_OID_AES256_GCM
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 46 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-aes256-gcm (2.16.840.1.101.3.4.1.46)

Definition at line 273 of file asn1.h.

◆ ASN1_OID_SHA256

#define ASN1_OID_SHA256
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 1 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-sha256 (2.16.840.1.101.3.4.2.1)

Definition at line 280 of file asn1.h.

◆ ASN1_OID_SHA384

#define ASN1_OID_SHA384
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 2 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-sha384 (2.16.840.1.101.3.4.2.2)

Definition at line 287 of file asn1.h.

◆ ASN1_OID_SHA512

#define ASN1_OID_SHA512
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 3 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-sha512 (2.16.840.1.101.3.4.2.3)

Definition at line 294 of file asn1.h.

◆ ASN1_OID_SHA224

#define ASN1_OID_SHA224
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 4 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-sha224 (2.16.840.1.101.3.4.2.4)

Definition at line 301 of file asn1.h.

◆ ASN1_OID_SHA512_224

#define ASN1_OID_SHA512_224
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 5 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-sha512-224 (2.16.840.1.101.3.4.2.5)

Definition at line 308 of file asn1.h.

◆ ASN1_OID_SHA512_256

#define ASN1_OID_SHA512_256
Value:
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 6 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-sha512-256 (2.16.840.1.101.3.4.2.6)

Definition at line 315 of file asn1.h.

◆ ASN1_OID_COMMON_NAME

#define ASN1_OID_COMMON_NAME
Value:
ASN1_OID_SINGLE ( 3 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for commonName (2.5.4.3)

Definition at line 322 of file asn1.h.

◆ ASN1_OID_KEYUSAGE

#define ASN1_OID_KEYUSAGE
Value:
ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \
ASN1_OID_SINGLE ( 15 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-ce-keyUsage (2.5.29.15)

Definition at line 327 of file asn1.h.

◆ ASN1_OID_BASICCONSTRAINTS

#define ASN1_OID_BASICCONSTRAINTS
Value:
ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \
ASN1_OID_SINGLE ( 19 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-ce-basicConstraints (2.5.29.19)

Definition at line 332 of file asn1.h.

◆ ASN1_OID_EXTKEYUSAGE

#define ASN1_OID_EXTKEYUSAGE
Value:
ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \
ASN1_OID_SINGLE ( 37 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-ce-extKeyUsage (2.5.29.37)

Definition at line 337 of file asn1.h.

◆ ASN1_OID_CODESIGNING

#define ASN1_OID_CODESIGNING
Value:
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 3 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-kp-codeSigning (1.3.6.1.5.5.7.3.3)

Definition at line 342 of file asn1.h.

◆ ASN1_OID_SIGNEDDATA

#define ASN1_OID_SIGNEDDATA
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 7 ), ASN1_OID_SINGLE ( 2 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-signedData (1.2.840.113549.1.7.2)

Definition at line 349 of file asn1.h.

◆ ASN1_OID_ENVELOPEDDATA

#define ASN1_OID_ENVELOPEDDATA
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 7 ), ASN1_OID_SINGLE ( 3 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-envelopedData (1.2.840.113549.1.7.3)

Definition at line 355 of file asn1.h.

◆ ASN1_OID_AUTHENVELOPEDDATA

#define ASN1_OID_AUTHENVELOPEDDATA
Value:
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 9 ), ASN1_OID_SINGLE ( 16 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 23 )
#define ASN1_OID_DOUBLE(value)
Double-byte OID value.
Definition: asn1.h:121
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-authEnvelopedData (1.2.840.113549.1.9.16.1.23)

Definition at line 361 of file asn1.h.

◆ ASN1_OID_AUTHORITYINFOACCESS

#define ASN1_OID_AUTHORITYINFOACCESS
Value:
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 1 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-pe-authorityInfoAccess (1.3.6.1.5.5.7.1.1)

Definition at line 368 of file asn1.h.

◆ ASN1_OID_OCSP

#define ASN1_OID_OCSP
Value:
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
ASN1_OID_SINGLE ( 48 ), ASN1_OID_SINGLE ( 1 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-ad-ocsp (1.3.6.1.5.5.7.48.1)

Definition at line 375 of file asn1.h.

◆ ASN1_OID_OCSP_BASIC

#define ASN1_OID_OCSP_BASIC
Value:
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
ASN1_OID_SINGLE ( 48 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-pkix-ocsp-basic ( 1.3.6.1.5.5.7.48.1.1)

Definition at line 382 of file asn1.h.

◆ ASN1_OID_OCSPSIGNING

#define ASN1_OID_OCSPSIGNING
Value:
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 5 ), \
ASN1_OID_SINGLE ( 5 ), ASN1_OID_SINGLE ( 7 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 9 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-kp-OCSPSigning (1.3.6.1.5.5.7.3.9)

Definition at line 390 of file asn1.h.

◆ ASN1_OID_SUBJECTALTNAME

#define ASN1_OID_SUBJECTALTNAME
Value:
ASN1_OID_INITIAL ( 2, 5 ), ASN1_OID_SINGLE ( 29 ), \
ASN1_OID_SINGLE ( 17 )
#define ASN1_OID_SINGLE(value)
Single-byte OID value.
Definition: asn1.h:115
#define ASN1_OID_INITIAL(first, second)
Initial OID byte.
Definition: asn1.h:109

ASN.1 OID for id-ce-subjectAltName (2.5.29.17)

Definition at line 397 of file asn1.h.

◆ ASN1_CURSOR

#define ASN1_CURSOR (   value)
Value:
{ \
.data = value, \
.len = sizeof ( value ), \
}
pseudo_bit_t value[0x00020]
Definition: arbel.h:13

Define an ASN.1 cursor for a static value.

Definition at line 402 of file asn1.h.

◆ ASN1_ALGORITHMS

#define ASN1_ALGORITHMS   __table ( struct asn1_algorithm, "asn1_algorithms" )

ASN.1 OID-identified algorithms.

Definition at line 433 of file asn1.h.

◆ __asn1_algorithm

struct asn1_algorithm ecpubkey_algorithm __asn1_algorithm   __table_entry ( ASN1_ALGORITHMS, 01 )

Declare an ASN.1 OID-identified algorithm.

"aes256-gcm" OID-identified algorithm

"aes192-gcm" OID-identified algorithm

"aes256-cbc" OID-identified algorithm

"aes192-cbc" OID-identified algorithm

Definition at line 436 of file asn1.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ asn1_invalidate_cursor()

static void asn1_invalidate_cursor ( struct asn1_cursor cursor)
inlinestatic

Invalidate ASN.1 object cursor.

Parameters
cursorASN.1 object cursor

Definition at line 468 of file asn1.h.

468  {
469  cursor->len = 0;
470 }
size_t len
Length of data.
Definition: asn1.h:25

References asn1_cursor::len.

Referenced by asn1_enter(), asn1_enter_bits(), asn1_shrink(), asn1_skip(), asn1_start(), and ecdsa_parse_key().

◆ asn1_type()

static unsigned int asn1_type ( const struct asn1_cursor cursor)
inlinestatic

Extract ASN.1 type.

Parameters
cursorASN.1 object cursor
Return values
typeType, or ASN1_END if cursor is invalid

Definition at line 479 of file asn1.h.

479  {
480  const uint8_t *type = cursor->data;
481 
482  return ( ( cursor->len >= sizeof ( *type ) ) ? *type : ASN1_END );
483 }
#define ASN1_END
ASN.1 end.
Definition: asn1.h:57
uint32_t type
Operating system type.
Definition: ena.h:12
const void * data
Start of data.
Definition: asn1.h:23
size_t len
Length of data.
Definition: asn1.h:25
unsigned char uint8_t
Definition: stdint.h:10

References ASN1_END, asn1_cursor::data, asn1_cursor::len, and type.

Referenced by asn1_generalized_time(), asn1_start(), ecdsa_parse_key(), ocsp_parse_basic_response(), ocsp_parse_responder_id(), ocsp_parse_responses(), rsa_parse_mod_exp(), x509_check_alt_name(), x509_parse_basic_constraints(), x509_parse_extension(), and x509_parse_tbscertificate().

◆ asn1_built()

static struct asn1_cursor* asn1_built ( struct asn1_builder builder)
inlinestatic

Get cursor for built object.

Parameters
builderASN.1 object builder
Return values
cursorASN.1 object cursor

Definition at line 492 of file asn1.h.

492  {
493  union {
494  struct asn1_builder builder;
495  struct asn1_cursor cursor;
496  } *u = container_of ( builder, typeof ( *u ), builder );
497 
498  /* Sanity check */
499  build_assert ( ( ( const void * ) &u->builder.data ) ==
500  &u->cursor.data );
501  build_assert ( &u->builder.len == &u->cursor.len );
502 
503  return &u->cursor;
504 }
union @18 u
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:36
#define build_assert(condition)
Assert a condition at build time (after dead code elimination)
Definition: assert.h:77
An ASN.1 object builder.
Definition: asn1.h:29
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:48
An ASN.1 object cursor.
Definition: asn1.h:21

References build_assert, container_of, typeof(), and u.

Referenced by icert_certs(), privkey_cursor(), pubkey_okx(), and pubkey_sign_okx().

◆ asn1_enter()

int asn1_enter ( struct asn1_cursor cursor,
unsigned int  type 
)

Enter ASN.1 object.

Parameters
cursorASN.1 object cursor
typeExpected type, or ASN1_ANY
Return values
rcReturn status code

The object cursor will be updated to point to the body of the current ASN.1 object.

If any error occurs, the object cursor will be invalidated.

Definition at line 169 of file asn1.c.

169  {
170  int len;
171 
172  /* Parse current object */
173  len = asn1_start ( cursor, type );
174  if ( len < 0 ) {
175  asn1_invalidate_cursor ( cursor );
176  return len;
177  }
178 
179  /* Update cursor */
180  if ( ( ( size_t ) len ) <= cursor->len )
181  cursor->len = len;
182 
183  DBGC ( cursor, "ASN1 %p entered object type %02x (len %x)\n",
184  cursor, type, len );
185  return 0;
186 }
uint32_t type
Operating system type.
Definition: ena.h:12
#define DBGC(...)
Definition: compiler.h:505
static int asn1_start(struct asn1_cursor *cursor, unsigned int type)
Start parsing ASN.1 object.
Definition: asn1.c:103
size_t len
Length of data.
Definition: asn1.h:25
ring len
Length.
Definition: dwmac.h:231
static void asn1_invalidate_cursor(struct asn1_cursor *cursor)
Invalidate ASN.1 object cursor.
Definition: asn1.h:468

References asn1_invalidate_cursor(), asn1_start(), DBGC, asn1_cursor::len, len, and type.

Referenced by asn1_algorithm(), asn1_boolean(), asn1_curve_algorithm(), asn1_enter_any(), asn1_enter_bits(), asn1_enter_unsigned(), asn1_generalized_time(), asn1_integer(), asn1_parse_cbc(), asn1_parse_gcm(), cms_parse(), cms_parse_certificates(), cms_parse_content_type(), cms_parse_encrypted(), cms_parse_enveloped(), cms_parse_identifier(), cms_parse_mac(), cms_parse_participant(), cms_parse_participants(), cms_parse_signed(), cms_parse_value(), ecdsa_parse_key(), ecdsa_verify(), ocsp_compare_responder_key_hash(), ocsp_parse_basic_response(), ocsp_parse_cert_id(), ocsp_parse_certs(), ocsp_parse_response(), ocsp_parse_response_bytes(), ocsp_parse_response_status(), ocsp_parse_response_type(), ocsp_parse_responses(), ocsp_parse_tbs_response_data(), ocsp_request(), rsa_parse_mod_exp(), validator_append(), x509_parse(), x509_parse_access_description(), x509_parse_authority_info_access(), x509_parse_basic_constraints(), x509_parse_common_name(), x509_parse_extended_key_usage(), x509_parse_extension(), x509_parse_extensions(), x509_parse_key_purpose(), x509_parse_ocsp(), x509_parse_public_key(), x509_parse_subject_alt_name(), x509_parse_tbscertificate(), x509_parse_validity(), and x509_parse_version().

◆ asn1_skip_if_exists()

int asn1_skip_if_exists ( struct asn1_cursor cursor,
unsigned int  type 
)

Skip ASN.1 object if present.

Parameters
cursorASN.1 object cursor
typeExpected type, or ASN1_ANY
Return values
rcReturn status code

The object cursor will be updated to point to the next ASN.1 object.

If the expected type is not found, the object cursor will not be modified. If any other error occurs, the object cursor will be invalidated.

Definition at line 202 of file asn1.c.

202  {
203  int len;
204 
205  /* Parse current object */
206  len = asn1_start ( cursor, type );
207  if ( len < 0 )
208  return len;
209 
210  /* Update cursor */
211  cursor->data += len;
212  cursor->len -= len;
213 
214  DBGC ( cursor, "ASN1 %p skipped object type %02x (len %x)\n",
215  cursor, type, len );
216  return 0;
217 }
uint32_t type
Operating system type.
Definition: ena.h:12
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
static int asn1_start(struct asn1_cursor *cursor, unsigned int type)
Start parsing ASN.1 object.
Definition: asn1.c:103
size_t len
Length of data.
Definition: asn1.h:25
ring len
Length.
Definition: dwmac.h:231

References asn1_start(), asn1_cursor::data, DBGC, asn1_cursor::len, len, and type.

Referenced by asn1_skip(), cms_parse_enveloped(), cms_parse_participant(), cms_parse_signed(), and ocsp_parse_tbs_response_data().

◆ asn1_skip()

int asn1_skip ( struct asn1_cursor cursor,
unsigned int  type 
)

Skip ASN.1 object.

Parameters
cursorASN.1 object cursor
typeExpected type, or ASN1_ANY
Return values
rcReturn status code

The object cursor will be updated to point to the next ASN.1 object.

If any error occurs, the object cursor will be invalidated.

Definition at line 231 of file asn1.c.

231  {
232  int rc;
233 
234  if ( ( rc = asn1_skip_if_exists ( cursor, type ) ) != 0 ) {
235  asn1_invalidate_cursor ( cursor );
236  return rc;
237  }
238 
239  return 0;
240 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t type
Operating system type.
Definition: ena.h:12
static void asn1_invalidate_cursor(struct asn1_cursor *cursor)
Invalidate ASN.1 object cursor.
Definition: asn1.h:468
int asn1_skip_if_exists(struct asn1_cursor *cursor, unsigned int type)
Skip ASN.1 object if present.
Definition: asn1.c:202

References asn1_invalidate_cursor(), asn1_skip_if_exists(), rc, and type.

Referenced by asn1_skip_any(), cms_parse_encrypted(), cms_parse_enveloped(), cms_parse_participant(), cms_parse_signed(), der_image_probe(), ecdsa_parse_key(), ocsp_parse_cert_id(), ocsp_request(), and rsa_parse_mod_exp().

◆ asn1_shrink()

int asn1_shrink ( struct asn1_cursor cursor,
unsigned int  type 
)

Shrink ASN.1 cursor to fit object.

Parameters
cursorASN.1 object cursor
typeExpected type, or ASN1_ANY
Return values
rcReturn status code

The object cursor will be shrunk to contain only the current ASN.1 object.

If any error occurs, the object cursor will be invalidated.

Definition at line 254 of file asn1.c.

254  {
255  struct asn1_cursor temp;
256  const void *end;
257  int len;
258 
259  /* Find end of object */
260  memcpy ( &temp, cursor, sizeof ( temp ) );
261  len = asn1_start ( &temp, type );
262  if ( len < 0 ) {
263  asn1_invalidate_cursor ( cursor );
264  return len;
265  }
266  end = ( temp.data + len );
267 
268  /* Shrink original cursor to contain only its first object */
269  cursor->len = ( end - cursor->data );
270 
271  return 0;
272 }
uint32_t type
Operating system type.
Definition: ena.h:12
const void * data
Start of data.
Definition: asn1.h:23
static int asn1_start(struct asn1_cursor *cursor, unsigned int type)
Start parsing ASN.1 object.
Definition: asn1.c:103
size_t len
Length of data.
Definition: asn1.h:25
void * memcpy(void *dest, const void *src, size_t len) __nonnull
ring len
Length.
Definition: dwmac.h:231
static void asn1_invalidate_cursor(struct asn1_cursor *cursor)
Invalidate ASN.1 object cursor.
Definition: asn1.h:468
uint32_t end
Ending offset.
Definition: netvsc.h:18
An ASN.1 object cursor.
Definition: asn1.h:21

References asn1_invalidate_cursor(), asn1_start(), asn1_cursor::data, end, asn1_cursor::len, len, memcpy(), and type.

Referenced by asn1_shrink_any(), cms_parse_identifier(), ocsp_parse_cert_id(), x509_parse_issuer(), and x509_parse_serial().

◆ asn1_enter_any()

int asn1_enter_any ( struct asn1_cursor cursor)

Enter ASN.1 object of any type.

Parameters
cursorASN.1 object cursor
Return values
rcReturn status code

Definition at line 280 of file asn1.c.

280  {
281  return asn1_enter ( cursor, ASN1_ANY );
282 }
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
#define ASN1_ANY
ASN.1 "any tag" magic value.
Definition: asn1.h:102

References ASN1_ANY, and asn1_enter().

Referenced by ecdsa_parse_key(), ocsp_parse_responder_id(), x509_check_alt_name(), and x509_parse_common_name().

◆ asn1_skip_any()

int asn1_skip_any ( struct asn1_cursor cursor)

◆ asn1_shrink_any()

int asn1_shrink_any ( struct asn1_cursor cursor)

Shrink ASN.1 object of any type.

Parameters
cursorASN.1 object cursor
Return values
rcReturn status code

Definition at line 300 of file asn1.c.

300  {
301  return asn1_shrink ( cursor, ASN1_ANY );
302 }
#define ASN1_ANY
ASN.1 "any tag" magic value.
Definition: asn1.h:102
int asn1_shrink(struct asn1_cursor *cursor, unsigned int type)
Shrink ASN.1 cursor to fit object.
Definition: asn1.c:254

References ASN1_ANY, and asn1_shrink().

Referenced by cms_message(), der_asn1(), ocsp_parse_tbs_response_data(), x509_certificate(), x509_parse_public_key(), x509_parse_subject(), and x509_parse_tbscertificate().

◆ asn1_enter_bits()

int asn1_enter_bits ( struct asn1_cursor cursor,
unsigned int *  unused 
)

Enter ASN.1 bit string.

Parameters
cursorASN.1 cursor
unusedUnused bits to fill in (or NULL to require all used)
Return values
rcReturn status code

Definition at line 311 of file asn1.c.

311  {
312  const struct {
313  uint8_t unused;
314  uint8_t data[0];
315  } __attribute__ (( packed )) *bit_string;
316  const uint8_t *last;
317  unsigned int unused_bits;
318  uint8_t unused_mask;
319  int rc;
320 
321  /* Enter bit string */
322  if ( ( rc = asn1_enter ( cursor, ASN1_BIT_STRING ) ) != 0 )
323  return rc;
324 
325  /* Check that bit string header exists */
326  if ( cursor->len < sizeof ( *bit_string ) ) {
327  DBGC ( cursor, "ASN1 %p invalid bit string:\n", cursor );
328  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
329  asn1_invalidate_cursor ( cursor );
330  return -EINVAL_BIT_STRING;
331  }
332  bit_string = cursor->data;
333  cursor->data = &bit_string->data;
334  cursor->len -= offsetof ( typeof ( *bit_string ), data );
335  unused_bits = bit_string->unused;
336 
337  /* Check validity of unused bits */
338  unused_mask = ( 0xff >> ( 8 - unused_bits ) );
339  last = ( cursor->data + cursor->len - 1 );
340  if ( ( unused_bits >= 8 ) ||
341  ( ( unused_bits > 0 ) && ( cursor->len == 0 ) ) ||
342  ( ( *last & unused_mask ) != 0 ) ) {
343  DBGC ( cursor, "ASN1 %p invalid bit string:\n", cursor );
344  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
345  asn1_invalidate_cursor ( cursor );
346  return -EINVAL_BIT_STRING;
347  }
348 
349  /* Record or check number of unused bits, as applicable */
350  if ( unused ) {
351  *unused = unused_bits;
352  } else if ( unused_bits ) {
353  DBGC ( cursor, "ASN1 %p invalid integral bit string:\n",
354  cursor );
355  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
356  asn1_invalidate_cursor ( cursor );
357  return -EINVAL_BIT_STRING;
358  }
359 
360  return 0;
361 }
#define __attribute__(x)
Definition: compiler.h:10
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EINVAL_BIT_STRING
Definition: asn1.c:74
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:25
size_t len
Length of data.
Definition: asn1.h:25
#define DBGC_HDA(...)
Definition: compiler.h:506
static void asn1_invalidate_cursor(struct asn1_cursor *cursor)
Invalidate ASN.1 object cursor.
Definition: asn1.h:468
unsigned char uint8_t
Definition: stdint.h:10
uint8_t unused
Unused.
Definition: librm.h:140
uint8_t data[48]
Additional event data.
Definition: ena.h:22
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:48
#define ASN1_BIT_STRING
ASN.1 bit string.
Definition: asn1.h:66

References __attribute__, ASN1_BIT_STRING, asn1_enter(), asn1_invalidate_cursor(), data, asn1_cursor::data, DBGC, DBGC_HDA, EINVAL_BIT_STRING, asn1_cursor::len, offsetof, rc, typeof(), and unused.

Referenced by ecdsa_parse_key(), ocsp_parse_basic_response(), rsa_parse_mod_exp(), x509_parse(), x509_parse_key_usage(), and x509_parse_public_key().

◆ asn1_enter_unsigned()

int asn1_enter_unsigned ( struct asn1_cursor cursor)

Enter ASN.1 unsigned integer.

Parameters
cursorASN.1 object cursor
Return values
rcReturn status code

Definition at line 369 of file asn1.c.

369  {
370  int rc;
371 
372  /* Enter integer */
373  if ( ( rc = asn1_enter ( cursor, ASN1_INTEGER ) ) != 0 )
374  return rc;
375 
376  /* Skip initial positive sign byte if applicable */
377  if ( ( cursor->len > 1 ) &&
378  ( *( ( uint8_t * ) cursor->data ) == 0x00 ) ) {
379  cursor->data++;
380  cursor->len--;
381  }
382 
383  return 0;
384 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
const void * data
Start of data.
Definition: asn1.h:23
size_t len
Length of data.
Definition: asn1.h:25
unsigned char uint8_t
Definition: stdint.h:10
#define ASN1_INTEGER
ASN.1 integer.
Definition: asn1.h:63

References asn1_enter(), ASN1_INTEGER, asn1_cursor::data, asn1_cursor::len, and rc.

Referenced by ecdsa_parse_signature(), and rsa_parse_mod_exp().

◆ asn1_boolean()

int asn1_boolean ( const struct asn1_cursor cursor)

Parse value of ASN.1 boolean.

Parameters
cursorASN.1 object cursor
Return values
valueValue, or negative error

Definition at line 392 of file asn1.c.

392  {
393  struct asn1_cursor contents;
394  const struct {
395  uint8_t value;
396  } __attribute__ (( packed )) *boolean;
397 
398  /* Enter boolean */
399  memcpy ( &contents, cursor, sizeof ( contents ) );
400  asn1_enter ( &contents, ASN1_BOOLEAN );
401  if ( contents.len != sizeof ( *boolean ) )
402  return -EINVAL_ASN1_BOOLEAN;
403 
404  /* Extract value */
405  boolean = contents.data;
406  return boolean->value;
407 }
#define __attribute__(x)
Definition: compiler.h:10
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
#define ASN1_BOOLEAN
ASN.1 boolean.
Definition: asn1.h:60
void * memcpy(void *dest, const void *src, size_t len) __nonnull
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
unsigned char uint8_t
Definition: stdint.h:10
#define EINVAL_ASN1_BOOLEAN
Definition: asn1.c:58
An ASN.1 object cursor.
Definition: asn1.h:21

References __attribute__, ASN1_BOOLEAN, asn1_enter(), asn1_cursor::data, EINVAL_ASN1_BOOLEAN, asn1_cursor::len, memcpy(), and value.

Referenced by x509_parse_basic_constraints(), and x509_parse_extension().

◆ asn1_integer()

int asn1_integer ( const struct asn1_cursor cursor,
int *  value 
)

Parse value of ASN.1 integer.

Parameters
cursorASN.1 object cursor
valueValue to fill in
Return values
rcReturn status code

Definition at line 416 of file asn1.c.

416  {
417  struct asn1_cursor contents;
418  uint8_t high_byte;
419  int rc;
420 
421  /* Enter integer */
422  memcpy ( &contents, cursor, sizeof ( contents ) );
423  if ( ( rc = asn1_enter ( &contents, ASN1_INTEGER ) ) != 0 )
424  return rc;
425  if ( contents.len < 1 )
426  return -EINVAL_ASN1_INTEGER;
427 
428  /* Initialise value according to sign byte */
429  *value = *( ( int8_t * ) contents.data );
430  contents.data++;
431  contents.len--;
432 
433  /* Process value */
434  while ( contents.len ) {
435  high_byte = ( (*value) >> ( 8 * ( sizeof ( *value ) - 1 ) ) );
436  if ( ( high_byte != 0x00 ) && ( high_byte != 0xff ) ) {
437  DBGC ( cursor, "ASN1 %p integer overflow\n", cursor );
438  return -EINVAL_ASN1_INTEGER;
439  }
440  *value = ( ( *value << 8 ) | *( ( uint8_t * ) contents.data ) );
441  contents.data++;
442  contents.len--;
443  }
444 
445  return 0;
446 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
#define DBGC(...)
Definition: compiler.h:505
void * memcpy(void *dest, const void *src, size_t len) __nonnull
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define EINVAL_ASN1_INTEGER
Definition: asn1.c:62
signed char int8_t
Definition: stdint.h:15
unsigned char uint8_t
Definition: stdint.h:10
#define ASN1_INTEGER
ASN.1 integer.
Definition: asn1.h:63
An ASN.1 object cursor.
Definition: asn1.h:21

References asn1_enter(), ASN1_INTEGER, asn1_cursor::data, DBGC, EINVAL_ASN1_INTEGER, asn1_cursor::len, memcpy(), rc, and value.

Referenced by x509_parse_basic_constraints(), and x509_parse_version().

◆ asn1_compare()

int asn1_compare ( const struct asn1_cursor cursor1,
const struct asn1_cursor cursor2 
)

Compare two ASN.1 objects.

Parameters
cursor1ASN.1 object cursor
cursor2ASN.1 object cursor
Return values
differenceDifference as returned by memcmp()

Note that invalid and empty cursors will compare as equal with each other.

Definition at line 458 of file asn1.c.

459  {
460  int difference;
461 
462  difference = ( cursor2->len - cursor1->len );
463  return ( difference ? difference :
464  memcmp ( cursor1->data, cursor2->data, cursor1->len ) );
465 }
const void * data
Start of data.
Definition: asn1.h:23
size_t len
Length of data.
Definition: asn1.h:25
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:115

References asn1_cursor::data, asn1_cursor::len, and memcmp().

Referenced by asn1_find_algorithm(), cms_parse_content_type(), ocsp_compare_responder_name(), ocsp_parse_cert_id(), ocsp_parse_response_type(), pubkey_okx(), pubkey_sign_okx(), rsa_match(), x509_check_issuer(), x509_find(), x509_find_access_method(), x509_find_extension(), x509_find_issuer_serial(), x509_find_subject(), x509_is_self_signed(), x509_parse_common_name(), and x509_parse_key_purpose().

◆ asn1_algorithm()

int asn1_algorithm ( const struct asn1_cursor cursor,
struct asn1_algorithm **  algorithm,
struct asn1_cursor params 
)

Parse ASN.1 OID-identified algorithm.

Parameters
cursorASN.1 object cursor
Return values
algorithmAlgorithm
paramsAlgorithm parameters, or NULL
rcReturn status code

Definition at line 494 of file asn1.c.

496  {
497  struct asn1_cursor contents;
498  int rc;
499 
500  /* Enter algorithm */
501  memcpy ( &contents, cursor, sizeof ( contents ) );
502  asn1_enter ( &contents, ASN1_SEQUENCE );
503 
504  /* Get raw parameters, if applicable */
505  if ( params ) {
506  memcpy ( params, &contents, sizeof ( *params ) );
507  asn1_skip_any ( params );
508  }
509 
510  /* Enter algorithm identifier */
511  if ( ( rc = asn1_enter ( &contents, ASN1_OID ) ) != 0 ) {
512  DBGC ( cursor, "ASN1 %p cannot locate algorithm OID:\n",
513  cursor );
514  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
515  return -EINVAL_ASN1_ALGORITHM;
516  }
517 
518  /* Identify algorithm */
519  *algorithm = asn1_find_algorithm ( &contents );
520  if ( ! *algorithm ) {
521  DBGC ( cursor, "ASN1 %p unrecognised algorithm:\n", cursor );
522  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
523  return -ENOTSUP_ALGORITHM;
524  }
525 
526  /* Parse parameters, if applicable */
527  if ( params && (*algorithm)->parse &&
528  ( ( rc = (*algorithm)->parse ( *algorithm, params ) ) != 0 ) ) {
529  DBGC ( cursor, "ASN1 %p cannot parse %s parameters: %s\n",
530  cursor, (*algorithm)->name, strerror ( rc ) );
531  return rc;
532  }
533 
534  return 0;
535 }
#define EINVAL_ASN1_ALGORITHM
Definition: asn1.c:70
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
int asn1_skip_any(struct asn1_cursor *cursor)
Skip ASN.1 object of any type.
Definition: asn1.c:290
size_t len
Length of data.
Definition: asn1.h:25
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define DBGC_HDA(...)
Definition: compiler.h:506
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define ASN1_SEQUENCE
ASN.1 sequence.
Definition: asn1.h:90
u16 algorithm
Authentication algorithm (Open System or Shared Key)
Definition: ieee80211.h:1030
static struct asn1_algorithm * asn1_find_algorithm(const struct asn1_cursor *cursor)
Identify ASN.1 algorithm by OID.
Definition: asn1.c:475
#define ASN1_OID
ASN.1 object identifier.
Definition: asn1.h:75
#define ENOTSUP_ALGORITHM
Definition: asn1.c:78
An ASN.1 object cursor.
Definition: asn1.h:21

References algorithm, asn1_enter(), asn1_find_algorithm(), ASN1_OID, ASN1_SEQUENCE, asn1_skip_any(), asn1_cursor::data, DBGC, DBGC_HDA, EINVAL_ASN1_ALGORITHM, ENOTSUP_ALGORITHM, asn1_cursor::len, memcpy(), rc, and strerror().

◆ asn1_pubkey_algorithm()

int asn1_pubkey_algorithm ( const struct asn1_cursor cursor,
struct asn1_algorithm **  algorithm 
)

Parse ASN.1 OID-identified public-key algorithm.

Parameters
cursorASN.1 object cursor
Return values
algorithmAlgorithm
rcReturn status code

Definition at line 544 of file asn1.c.

545  {
546  int rc;
547 
548  /* Parse algorithm */
549  if ( ( rc = asn1_algorithm ( cursor, algorithm, NULL ) ) != 0 )
550  return rc;
551 
552  /* Check algorithm has a public key */
553  if ( ! (*algorithm)->pubkey ) {
554  DBGC ( cursor, "ASN1 %p algorithm %s is not a public-key "
555  "algorithm:\n", cursor, (*algorithm)->name );
556  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
557  return -ENOTTY_ALGORITHM;
558  }
559 
560  return 0;
561 }
An ASN.1 OID-identified algorithm.
Definition: asn1.h:408
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define ENOTTY_ALGORITHM
Definition: asn1.c:82
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
size_t len
Length of data.
Definition: asn1.h:25
#define DBGC_HDA(...)
Definition: compiler.h:506
u16 algorithm
Authentication algorithm (Open System or Shared Key)
Definition: ieee80211.h:1030
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References algorithm, asn1_cursor::data, DBGC, DBGC_HDA, ENOTTY_ALGORITHM, asn1_cursor::len, NULL, and rc.

Referenced by cms_parse_pubkey_algorithm(), and x509_parse_public_key().

◆ asn1_digest_algorithm()

int asn1_digest_algorithm ( const struct asn1_cursor cursor,
struct asn1_algorithm **  algorithm 
)

Parse ASN.1 OID-identified digest algorithm.

Parameters
cursorASN.1 object cursor
Return values
algorithmAlgorithm
rcReturn status code

Definition at line 570 of file asn1.c.

571  {
572  int rc;
573 
574  /* Parse algorithm */
575  if ( ( rc = asn1_algorithm ( cursor, algorithm, NULL ) ) != 0 )
576  return rc;
577 
578  /* Check algorithm has a digest */
579  if ( ! (*algorithm)->digest ) {
580  DBGC ( cursor, "ASN1 %p algorithm %s is not a digest "
581  "algorithm:\n", cursor, (*algorithm)->name );
582  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
583  return -ENOTTY_ALGORITHM;
584  }
585 
586  return 0;
587 }
An ASN.1 OID-identified algorithm.
Definition: asn1.h:408
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define ENOTTY_ALGORITHM
Definition: asn1.c:82
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
size_t len
Length of data.
Definition: asn1.h:25
#define DBGC_HDA(...)
Definition: compiler.h:506
u16 algorithm
Authentication algorithm (Open System or Shared Key)
Definition: ieee80211.h:1030
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References algorithm, asn1_cursor::data, DBGC, DBGC_HDA, ENOTTY_ALGORITHM, asn1_cursor::len, NULL, and rc.

Referenced by cms_parse_digest_algorithm().

◆ asn1_cipher_algorithm()

int asn1_cipher_algorithm ( const struct asn1_cursor cursor,
struct asn1_algorithm **  algorithm,
struct asn1_cursor params 
)

Parse ASN.1 OID-identified cipher algorithm.

Parameters
cursorASN.1 object cursor
Return values
algorithmAlgorithm
paramsAlgorithm parameters, or NULL
rcReturn status code

Definition at line 597 of file asn1.c.

599  {
600  int rc;
601 
602  /* Parse algorithm */
603  if ( ( rc = asn1_algorithm ( cursor, algorithm, params ) ) != 0 )
604  return rc;
605 
606  /* Check algorithm has a cipher */
607  if ( ! (*algorithm)->cipher ) {
608  DBGC ( cursor, "ASN1 %p algorithm %s is not a cipher "
609  "algorithm:\n", cursor, (*algorithm)->name );
610  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
611  return -ENOTTY_ALGORITHM;
612  }
613 
614  return 0;
615 }
An ASN.1 OID-identified algorithm.
Definition: asn1.h:408
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define ENOTTY_ALGORITHM
Definition: asn1.c:82
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
size_t len
Length of data.
Definition: asn1.h:25
#define DBGC_HDA(...)
Definition: compiler.h:506
u16 algorithm
Authentication algorithm (Open System or Shared Key)
Definition: ieee80211.h:1030

References algorithm, asn1_cursor::data, DBGC, DBGC_HDA, ENOTTY_ALGORITHM, asn1_cursor::len, and rc.

Referenced by cms_parse_cipher_algorithm().

◆ asn1_signature_algorithm()

int asn1_signature_algorithm ( const struct asn1_cursor cursor,
struct asn1_algorithm **  algorithm 
)

Parse ASN.1 OID-identified signature algorithm.

Parameters
cursorASN.1 object cursor
Return values
algorithmAlgorithm
rcReturn status code

Definition at line 624 of file asn1.c.

625  {
626  int rc;
627 
628  /* Parse algorithm */
629  if ( ( rc = asn1_algorithm ( cursor, algorithm, NULL ) ) != 0 )
630  return rc;
631 
632  /* Check algorithm has a public key */
633  if ( ! (*algorithm)->pubkey ) {
634  DBGC ( cursor, "ASN1 %p algorithm %s is not a signature "
635  "algorithm:\n", cursor, (*algorithm)->name );
636  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
637  return -ENOTTY_ALGORITHM;
638  }
639 
640  /* Check algorithm has a digest */
641  if ( ! (*algorithm)->digest ) {
642  DBGC ( cursor, "ASN1 %p algorithm %s is not a signature "
643  "algorithm:\n", cursor, (*algorithm)->name );
644  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
645  return -ENOTTY_ALGORITHM;
646  }
647 
648  return 0;
649 }
An ASN.1 OID-identified algorithm.
Definition: asn1.h:408
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define ENOTTY_ALGORITHM
Definition: asn1.c:82
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
size_t len
Length of data.
Definition: asn1.h:25
#define DBGC_HDA(...)
Definition: compiler.h:506
u16 algorithm
Authentication algorithm (Open System or Shared Key)
Definition: ieee80211.h:1030
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References algorithm, asn1_cursor::data, DBGC, DBGC_HDA, ENOTTY_ALGORITHM, asn1_cursor::len, NULL, and rc.

Referenced by ocsp_parse_basic_response(), x509_parse(), and x509_parse_tbscertificate().

◆ asn1_curve_algorithm()

int asn1_curve_algorithm ( const struct asn1_cursor cursor,
struct asn1_algorithm wrapper,
struct asn1_algorithm **  algorithm 
)

Parse ASN.1 OID-identified elliptic curve algorithm.

Parameters
cursorASN.1 object cursor
wrapperOptional wrapper algorithm, or NULL
Return values
algorithmAlgorithm
rcReturn status code

Definition at line 659 of file asn1.c.

661  {
662  struct asn1_cursor curve;
663 
664  /* Elliptic curves are identified as either:
665  *
666  * - a wrapper algorithm "id-ecPublicKey" with the actual
667  * curve specified in the algorithm parameters, or
668  *
669  * - a standalone object identifier for the curve
670  */
671  if ( ( wrapper == NULL ) ||
672  ( asn1_check_algorithm ( cursor, wrapper, &curve ) != 0 ) ) {
673  memcpy ( &curve, cursor, sizeof ( curve ) );
674  }
675 
676  /* Identify curve */
677  asn1_enter ( &curve, ASN1_OID );
678  *algorithm = asn1_find_algorithm ( &curve );
679  if ( ! *algorithm ) {
680  DBGC ( cursor, "ASN1 %p unrecognised EC algorithm:\n",
681  cursor );
682  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
683  return -ENOTSUP_ALGORITHM;
684  }
685 
686  /* Check algorithm has an elliptic curve */
687  if ( ! (*algorithm)->curve ) {
688  DBGC ( cursor, "ASN1 %p algorithm %s is not an elliptic curve "
689  "algorithm:\n", cursor, (*algorithm)->name );
690  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
691  return -ENOTTY_ALGORITHM;
692  }
693 
694  return 0;
695 }
#define ENOTTY_ALGORITHM
Definition: asn1.c:82
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
size_t len
Length of data.
Definition: asn1.h:25
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define DBGC_HDA(...)
Definition: compiler.h:506
u16 algorithm
Authentication algorithm (Open System or Shared Key)
Definition: ieee80211.h:1030
static struct asn1_algorithm * asn1_find_algorithm(const struct asn1_cursor *cursor)
Identify ASN.1 algorithm by OID.
Definition: asn1.c:475
#define ASN1_OID
ASN.1 object identifier.
Definition: asn1.h:75
#define ENOTSUP_ALGORITHM
Definition: asn1.c:78
int asn1_check_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm *expected, struct asn1_cursor *params)
Check ASN.1 OID-identified algorithm.
Definition: asn1.c:705
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
An ASN.1 object cursor.
Definition: asn1.h:21

References algorithm, asn1_check_algorithm(), asn1_enter(), asn1_find_algorithm(), ASN1_OID, asn1_cursor::data, DBGC, DBGC_HDA, ENOTSUP_ALGORITHM, ENOTTY_ALGORITHM, asn1_cursor::len, memcpy(), and NULL.

Referenced by ecdsa_parse_key().

◆ asn1_check_algorithm()

int asn1_check_algorithm ( const struct asn1_cursor cursor,
struct asn1_algorithm expected,
struct asn1_cursor params 
)

Check ASN.1 OID-identified algorithm.

Parameters
cursorASN.1 object cursor
expectedExpected algorithm
Return values
paramsAlgorithm parameters, or NULL
rcReturn status code

Definition at line 705 of file asn1.c.

707  {
708  struct asn1_algorithm *actual;
709  int rc;
710 
711  /* Parse algorithm */
712  if ( ( rc = asn1_algorithm ( cursor, &actual, params ) ) != 0 )
713  return rc;
714 
715  /* Check algorithm matches */
716  if ( actual != expected ) {
717  DBGC ( cursor, "ASN1 %p algorithm %s does not match %s\n",
718  cursor, actual->name, expected->name );
719  return -ENOTTY_ALGORITHM;
720  }
721 
722  return 0;
723 }
An ASN.1 OID-identified algorithm.
Definition: asn1.h:408
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define ENOTTY_ALGORITHM
Definition: asn1.c:82
#define DBGC(...)
Definition: compiler.h:505
const char * name
Name.
Definition: asn1.h:410

References DBGC, ENOTTY_ALGORITHM, asn1_algorithm::name, and rc.

Referenced by asn1_curve_algorithm(), and rsa_parse_mod_exp().

◆ asn1_parse_cbc()

int asn1_parse_cbc ( struct asn1_algorithm algorithm,
struct asn1_cursor params 
)

Parse ASN.1 CBC cipher parameters.

Parameters
algorithmAlgorithm
paramParameters to parse
Return values
rcReturn status code

Definition at line 732 of file asn1.c.

733  {
734  struct cipher_algorithm *cipher = algorithm->cipher;
735 
736  /* Sanity check */
737  assert ( cipher != NULL );
738 
739  /* Enter parameters */
740  asn1_enter ( params, ASN1_OCTET_STRING );
741 
742  /* Check length */
743  if ( params->len != cipher->blocksize )
744  return -EINVAL;
745 
746  return 0;
747 }
#define EINVAL
Invalid argument.
Definition: errno.h:429
size_t blocksize
Block size.
Definition: crypto.h:61
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
size_t len
Length of data.
Definition: asn1.h:25
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
u16 algorithm
Authentication algorithm (Open System or Shared Key)
Definition: ieee80211.h:1030
A cipher algorithm.
Definition: crypto.h:51
#define ASN1_OCTET_STRING
ASN.1 octet string.
Definition: asn1.h:69
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References algorithm, asn1_enter(), ASN1_OCTET_STRING, assert(), cipher_algorithm::blocksize, EINVAL, asn1_cursor::len, and NULL.

◆ asn1_parse_gcm()

int asn1_parse_gcm ( struct asn1_algorithm algorithm,
struct asn1_cursor params 
)

◆ asn1_generalized_time()

int asn1_generalized_time ( const struct asn1_cursor cursor,
time_t time 
)

Parse ASN.1 GeneralizedTime.

Parameters
cursorASN.1 cursor
timeTime to fill in
Return values
rcReturn status code

RFC 5280 section 4.1.2.5 places several restrictions on the allowed formats for UTCTime and GeneralizedTime, and mandates the interpretation of centuryless year values.

Definition at line 777 of file asn1.c.

777  {
778  struct asn1_cursor contents;
779  unsigned int have_century;
780  unsigned int type;
781  union {
782  struct {
784  uint8_t year;
785  uint8_t month;
786  uint8_t day;
787  uint8_t hour;
788  uint8_t minute;
789  uint8_t second;
790  } __attribute__ (( packed )) named;
791  uint8_t raw[7];
792  } pairs;
793  struct tm tm;
794  const uint8_t *data;
795  size_t remaining;
796  unsigned int tens;
797  unsigned int units;
798  unsigned int i;
799  int rc;
800 
801  /* Determine time format utcTime/generalizedTime */
802  memcpy ( &contents, cursor, sizeof ( contents ) );
803  type = asn1_type ( &contents );
804  switch ( type ) {
805  case ASN1_UTC_TIME:
806  have_century = 0;
807  break;
809  have_century = 1;
810  break;
811  default:
812  DBGC ( cursor, "ASN1 %p invalid time type %02x\n",
813  cursor, type );
814  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
815  return -EINVAL_ASN1_TIME;
816  }
817 
818  /* Enter utcTime/generalizedTime */
819  if ( ( rc = asn1_enter ( &contents, type ) ) != 0 ) {
820  DBGC ( cursor, "ASN1 %p cannot locate %s time:\n", cursor,
821  ( ( type == ASN1_UTC_TIME ) ? "UTC" : "generalized" ) );
822  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
823  return rc;
824  }
825 
826  /* Parse digit string a pair at a time */
827  memset ( &pairs, 0, sizeof ( pairs ) );
828  data = contents.data;
829  remaining = contents.len;
830  for ( i = ( have_century ? 0 : 1 ) ; i < sizeof ( pairs.raw ) ; i++ ) {
831  if ( remaining < 2 ) {
832  /* Some certificates violate the X.509 RFC by
833  * omitting the "seconds" value.
834  */
835  if ( i == ( sizeof ( pairs.raw ) - 1 ) )
836  break;
837  DBGC ( cursor, "ASN1 %p invalid time:\n", cursor );
838  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
839  return -EINVAL_ASN1_TIME;
840  }
841  tens = data[0];
842  units = data[1];
843  if ( ! ( isdigit ( tens ) && isdigit ( units ) ) ) {
844  DBGC ( cursor, "ASN1 %p invalid time:\n", cursor );
845  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
846  return -EINVAL_ASN1_TIME;
847  }
848  pairs.raw[i] = ( ( 10 * ( tens - '0' ) ) + ( units - '0' ) );
849  data += 2;
850  remaining -= 2;
851  }
852 
853  /* Determine century if applicable */
854  if ( ! have_century )
855  pairs.named.century = ( ( pairs.named.year >= 50 ) ? 19 : 20 );
856 
857  /* Check for trailing "Z" */
858  if ( ( remaining != 1 ) || ( data[0] != 'Z' ) ) {
859  DBGC ( cursor, "ASN1 %p invalid time:\n", cursor );
860  DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
861  return -EINVAL_ASN1_TIME;
862  }
863 
864  /* Fill in time */
865  tm.tm_year = ( ( ( pairs.named.century - 19 ) * 100 ) +
866  pairs.named.year );
867  tm.tm_mon = ( pairs.named.month - 1 );
868  tm.tm_mday = pairs.named.day;
869  tm.tm_hour = pairs.named.hour;
870  tm.tm_min = pairs.named.minute;
871  tm.tm_sec = pairs.named.second;
872 
873  /* Convert to seconds since the Epoch */
874  *time = mktime ( &tm );
875 
876  return 0;
877 }
#define __attribute__(x)
Definition: compiler.h:10
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int tm_min
Minutes [0,59].
Definition: time.h:20
#define EINVAL_ASN1_TIME
Definition: asn1.c:66
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
Definition: asn1.c:169
uint32_t type
Operating system type.
Definition: ena.h:12
int tm_mday
Day of month [1,31].
Definition: time.h:24
const void * data
Start of data.
Definition: asn1.h:23
#define DBGC(...)
Definition: compiler.h:505
uint8_t year
Year (BCD)
Definition: ucode.h:12
int tm_year
Years since 1900.
Definition: time.h:28
static unsigned int asn1_type(const struct asn1_cursor *cursor)
Extract ASN.1 type.
Definition: asn1.h:479
size_t len
Length of data.
Definition: asn1.h:25
static int isdigit(int character)
Check if character is a decimal digit.
Definition: ctype.h:30
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define DBGC_HDA(...)
Definition: compiler.h:506
int tm_mon
Month of year [0,11].
Definition: time.h:26
time_t mktime(struct tm *tm)
Calculate seconds since the Epoch.
Definition: time.c:118
#define ASN1_GENERALIZED_TIME
ASN.1 generalized time.
Definition: asn1.h:87
unsigned char uint8_t
Definition: stdint.h:10
Broken-down time.
Definition: time.h:16
uint8_t century
Century (BCD)
Definition: ucode.h:14
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint8_t day
Day (BCD)
Definition: ucode.h:16
int tm_sec
Seconds [0,60].
Definition: time.h:18
__be32 raw[7]
Definition: CIB_PRM.h:28
#define ASN1_UTC_TIME
ASN.1 UTC time.
Definition: asn1.h:84
int tm_hour
Hour [0,23].
Definition: time.h:22
uint8_t month
Month (BCD)
Definition: ucode.h:18
An ASN.1 object cursor.
Definition: asn1.h:21
void * memset(void *dest, int character, size_t len) __nonnull

References __attribute__, asn1_enter(), ASN1_GENERALIZED_TIME, asn1_type(), ASN1_UTC_TIME, century, data, asn1_cursor::data, day, DBGC, DBGC_HDA, EINVAL_ASN1_TIME, isdigit(), asn1_cursor::len, memcpy(), memset(), mktime(), month, raw, rc, tm::tm_hour, tm::tm_mday, tm::tm_min, tm::tm_mon, tm::tm_sec, tm::tm_year, type, and year.

Referenced by ocsp_parse_responses(), and x509_parse_validity().

◆ asn1_grow()

int asn1_grow ( struct asn1_builder builder,
size_t  extra 
)

Grow ASN.1 builder.

Parameters
builderASN.1 builder
extraExtra space to prepend
Return values
rcReturn status code

Definition at line 916 of file asn1.c.

916  {
917  size_t new_len;
918  void *new;
919 
920  /* As with the ASN1 parsing functions, make errors permanent */
921  if ( builder->len && ! builder->data )
922  return -ENOMEM;
923 
924  /* Reallocate data buffer */
925  new_len = ( builder->len + extra );
926  new = realloc ( builder->data, new_len );
927  if ( ! new ) {
928  free ( builder->data );
929  builder->data = NULL;
930  return -ENOMEM;
931  }
932  builder->data = new;
933 
934  /* Move existing data to end of buffer */
935  memmove ( ( builder->data + extra ), builder->data, builder->len );
936  builder->len = new_len;
937 
938  return 0;
939 }
void * data
Data.
Definition: asn1.h:36
uint8_t extra
Signature extra byte.
Definition: smbios.h:18
#define ENOMEM
Not enough space.
Definition: errno.h:535
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
void * memmove(void *dest, const void *src, size_t len) __nonnull
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
Definition: malloc.c:607
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
size_t len
Length of data.
Definition: asn1.h:38

References asn1_builder::data, ENOMEM, extra, free, asn1_builder::len, memmove(), NULL, and realloc().

Referenced by asn1_prepend(), asn1_prepend_raw(), asn1_wrap(), rsa_decrypt(), rsa_encrypt(), and rsa_sign().

◆ asn1_prepend_raw()

int asn1_prepend_raw ( struct asn1_builder builder,
const void *  data,
size_t  len 
)

Prepend raw data to ASN.1 builder.

Parameters
builderASN.1 builder
dataData to prepend
lenLength of data to prepend
Return values
rcReturn status code

Definition at line 949 of file asn1.c.

950  {
951  int rc;
952 
953  /* Grow buffer */
954  if ( ( rc = asn1_grow ( builder, len ) ) != 0 )
955  return rc;
956 
957  /* Populate data buffer */
958  memcpy ( builder->data, data, len );
959 
960  return 0;
961 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void * data
Data.
Definition: asn1.h:36
void * memcpy(void *dest, const void *src, size_t len) __nonnull
ring len
Length.
Definition: dwmac.h:231
int asn1_grow(struct asn1_builder *builder, size_t extra)
Grow ASN.1 builder.
Definition: asn1.c:916
uint8_t data[48]
Additional event data.
Definition: ena.h:22

References asn1_grow(), data, asn1_builder::data, len, memcpy(), and rc.

Referenced by icert_cert(), icert_certs(), ocsp_request(), tls_send_certificate_verify(), and tls_send_client_key_exchange_pubkey().

◆ asn1_prepend()

int asn1_prepend ( struct asn1_builder builder,
unsigned int  type,
const void *  data,
size_t  len 
)

Prepend data to ASN.1 builder.

Parameters
builderASN.1 builder
typeType
dataData to prepend
lenLength of data to prepend
Return values
rcReturn status code

Definition at line 972 of file asn1.c.

973  {
975  size_t header_len;
976  int rc;
977 
978  /* Construct header */
979  header_len = asn1_header ( &header, type, len );
980 
981  /* Grow buffer */
982  if ( ( rc = asn1_grow ( builder, header_len + len ) ) != 0 )
983  return rc;
984 
985  /* Populate data buffer */
986  memcpy ( builder->data, &header, header_len );
987  memcpy ( ( builder->data + header_len ), data, len );
988 
989  return 0;
990 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void * data
Data.
Definition: asn1.h:36
uint32_t type
Operating system type.
Definition: ena.h:12
void * memcpy(void *dest, const void *src, size_t len) __nonnull
ring len
Length.
Definition: dwmac.h:231
int asn1_grow(struct asn1_builder *builder, size_t extra)
Grow ASN.1 builder.
Definition: asn1.c:916
static size_t asn1_header(struct asn1_builder_header *header, unsigned int type, size_t len)
Construct ASN.1 header.
Definition: asn1.c:887
An ASN.1 header.
Definition: asn1.h:49
struct ena_llq_option header
Header locations.
Definition: ena.h:16
uint8_t data[48]
Additional event data.
Definition: ena.h:22

References asn1_grow(), asn1_header(), data, asn1_builder::data, header, len, memcpy(), rc, and type.

Referenced by ecdsa_prepend_signature(), icert_certs(), and ocsp_request().

◆ asn1_wrap()

int asn1_wrap ( struct asn1_builder builder,
unsigned int  type 
)

Wrap ASN.1 builder.

Parameters
builderASN.1 builder
typeType
Return values
rcReturn status code

Definition at line 999 of file asn1.c.

999  {
1000  struct asn1_builder_header header;
1001  size_t header_len;
1002  int rc;
1003 
1004  /* Construct header */
1005  header_len = asn1_header ( &header, type, builder->len );
1006 
1007  /* Grow buffer */
1008  if ( ( rc = asn1_grow ( builder, header_len ) ) != 0 )
1009  return rc;
1010 
1011  /* Populate data buffer */
1012  memcpy ( builder->data, &header, header_len );
1013 
1014  return 0;
1015 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void * data
Data.
Definition: asn1.h:36
uint32_t type
Operating system type.
Definition: ena.h:12
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int asn1_grow(struct asn1_builder *builder, size_t extra)
Grow ASN.1 builder.
Definition: asn1.c:916
static size_t asn1_header(struct asn1_builder_header *header, unsigned int type, size_t len)
Construct ASN.1 header.
Definition: asn1.c:887
An ASN.1 header.
Definition: asn1.h:49
struct ena_llq_option header
Header locations.
Definition: ena.h:16
size_t len
Length of data.
Definition: asn1.h:38

References asn1_grow(), asn1_header(), asn1_builder::data, header, asn1_builder::len, memcpy(), rc, and type.

Referenced by ecdsa_sign(), icert_cert(), icert_certs(), and ocsp_request().

Variable Documentation

◆ __asn1_algorithm

struct asn1_algorithm ecpubkey_algorithm __asn1_algorithm

Generic elliptic curve container algorithm.

The actual curve to be used is identified via the algorithm parameters, rather than the top-level OID.

Generic elliptic curve container algorithm.

Generic elliptic curve container algorithm.

"aes256-cbc" OID-identified algorithm

"aes192-cbc" OID-identified algorithm

Generic elliptic curve container algorithm.

"aes256-gcm" OID-identified algorithm

"aes192-gcm" OID-identified algorithm

Definition at line 440 of file asn1.h.