Path: blob/main/contrib/bearssl/src/x509/x509_minimal.c
39507 views
/* Automatically generated code; do not modify directly. */12#include <stddef.h>3#include <stdint.h>45typedef struct {6uint32_t *dp;7uint32_t *rp;8const unsigned char *ip;9} t0_context;1011static uint32_t12t0_parse7E_unsigned(const unsigned char **p)13{14uint32_t x;1516x = 0;17for (;;) {18unsigned y;1920y = *(*p) ++;21x = (x << 7) | (uint32_t)(y & 0x7F);22if (y < 0x80) {23return x;24}25}26}2728static int32_t29t0_parse7E_signed(const unsigned char **p)30{31int neg;32uint32_t x;3334neg = ((**p) >> 6) & 1;35x = (uint32_t)-neg;36for (;;) {37unsigned y;3839y = *(*p) ++;40x = (x << 7) | (uint32_t)(y & 0x7F);41if (y < 0x80) {42if (neg) {43return -(int32_t)~x - 1;44} else {45return (int32_t)x;46}47}48}49}5051#define T0_VBYTE(x, n) (unsigned char)((((uint32_t)(x) >> (n)) & 0x7F) | 0x80)52#define T0_FBYTE(x, n) (unsigned char)(((uint32_t)(x) >> (n)) & 0x7F)53#define T0_SBYTE(x) (unsigned char)((((uint32_t)(x) >> 28) + 0xF8) ^ 0xF8)54#define T0_INT1(x) T0_FBYTE(x, 0)55#define T0_INT2(x) T0_VBYTE(x, 7), T0_FBYTE(x, 0)56#define T0_INT3(x) T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0)57#define T0_INT4(x) T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0)58#define T0_INT5(x) T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0)5960/* static const unsigned char t0_datablock[]; */616263void br_x509_minimal_init_main(void *t0ctx);6465void br_x509_minimal_run(void *t0ctx);66676869#include "inner.h"707172737475#include "inner.h"7677/*78* Implementation Notes79* --------------------80*81* The C code pushes the data by chunks; all decoding is done in the82* T0 code. The cert_length value is set to the certificate length when83* a new certificate is started; the T0 code picks it up as outer limit,84* and decoding functions use it to ensure that no attempt is made at85* reading past it. The T0 code also checks that once the certificate is86* decoded, there are no trailing bytes.87*88* The T0 code sets cert_length to 0 when the certificate is fully89* decoded.90*91* The C code must still perform two checks:92*93* -- If the certificate length is 0, then the T0 code will not be94* invoked at all. This invalid condition must thus be reported by the95* C code.96*97* -- When reaching the end of certificate, the C code must verify that98* the certificate length has been set to 0, thereby signaling that99* the T0 code properly decoded a certificate.100*101* Processing of a chain works in the following way:102*103* -- The error flag is set to a non-zero value when validation is104* finished. The value is either BR_ERR_X509_OK (validation is105* successful) or another non-zero error code. When a non-zero error106* code is obtained, the remaining bytes in the current certificate and107* the subsequent certificates (if any) are completely ignored.108*109* -- Each certificate is decoded in due course, with the following110* "interesting points":111*112* -- Start of the TBS: the multihash engine is reset and activated.113*114* -- Start of the issuer DN: the secondary hash engine is started,115* to process the encoded issuer DN.116*117* -- End of the issuer DN: the secondary hash engine is stopped. The118* resulting hash value is computed and then copied into the119* next_dn_hash[] buffer.120*121* -- Start of the subject DN: the secondary hash engine is started,122* to process the encoded subject DN.123*124* -- For the EE certificate only: the Common Name, if any, is matched125* against the expected server name.126*127* -- End of the subject DN: the secondary hash engine is stopped. The128* resulting hash value is computed into the pad. It is then processed:129*130* -- If this is the EE certificate, then the hash is ignored131* (except for direct trust processing, see later; the hash is132* simply left in current_dn_hash[]).133*134* -- Otherwise, the hashed subject DN is compared with the saved135* hash value (in saved_dn_hash[]). They must match.136*137* Either way, the next_dn_hash[] value is then copied into the138* saved_dn_hash[] value. Thus, at that point, saved_dn_hash[]139* contains the hash of the issuer DN for the current certificate,140* and current_dn_hash[] contains the hash of the subject DN for the141* current certificate.142*143* -- Public key: it is decoded into the cert_pkey[] buffer. Unknown144* key types are reported at that point.145*146* -- If this is the EE certificate, then the key type is compared147* with the expected key type (initialization parameter). The public148* key data is copied to ee_pkey_data[]. The key and hashed subject149* DN are also compared with the "direct trust" keys; if the key150* and DN are matched, then validation ends with a success.151*152* -- Otherwise, the saved signature (cert_sig[]) is verified153* against the saved TBS hash (tbs_hash[]) and that freshly154* decoded public key. Failure here ends validation with an error.155*156* -- Extensions: extension values are processed in due order.157*158* -- Basic Constraints: for all certificates except EE, must be159* present, indicate a CA, and have a path length compatible with160* the chain length so far.161*162* -- Key Usage: for the EE, if present, must allow signatures163* or encryption/key exchange, as required for the cipher suite.164* For non-EE, if present, must have the "certificate sign" bit.165*166* -- Subject Alt Name: for the EE, dNSName names are matched167* against the server name. Ignored for non-EE.168*169* -- Authority Key Identifier, Subject Key Identifier, Issuer170* Alt Name, Subject Directory Attributes, CRL Distribution Points171* Freshest CRL, Authority Info Access and Subject Info Access172* extensions are always ignored: they either contain only173* informative data, or they relate to revocation processing, which174* we explicitly do not support.175*176* -- All other extensions are ignored if non-critical. If a177* critical extension other than the ones above is encountered,178* then a failure is reported.179*180* -- End of the TBS: the multihash engine is stopped.181*182* -- Signature algorithm: the signature algorithm on the183* certificate is decoded. A failure is reported if that algorithm184* is unknown. The hashed TBS corresponding to the signature hash185* function is computed and stored in tbs_hash[] (if not supported,186* then a failure is reported). The hash OID and length are stored187* in cert_sig_hash_oid and cert_sig_hash_len.188*189* -- Signature value: the signature value is copied into the190* cert_sig[] array.191*192* -- Certificate end: the hashed issuer DN (saved_dn_hash[]) is193* looked up in the trust store (CA trust anchors only); for all194* that match, the signature (cert_sig[]) is verified against the195* anchor public key (hashed TBS is in tbs_hash[]). If one of these196* signatures is valid, then validation ends with a success.197*198* -- If the chain end is reached without obtaining a validation success,199* then validation is reported as failed.200*/201202#if BR_USE_UNIX_TIME203#include <time.h>204#endif205206#if BR_USE_WIN32_TIME207#include <windows.h>208#endif209210/*211* The T0 compiler will produce these prototypes declarations in the212* header.213*214void br_x509_minimal_init_main(void *ctx);215void br_x509_minimal_run(void *ctx);216*/217218/* see bearssl_x509.h */219void220br_x509_minimal_init(br_x509_minimal_context *ctx,221const br_hash_class *dn_hash_impl,222const br_x509_trust_anchor *trust_anchors, size_t trust_anchors_num)223{224memset(ctx, 0, sizeof *ctx);225ctx->vtable = &br_x509_minimal_vtable;226ctx->dn_hash_impl = dn_hash_impl;227ctx->trust_anchors = trust_anchors;228ctx->trust_anchors_num = trust_anchors_num;229}230231static void232xm_start_chain(const br_x509_class **ctx, const char *server_name)233{234br_x509_minimal_context *cc;235size_t u;236237cc = (br_x509_minimal_context *)(void *)ctx;238for (u = 0; u < cc->num_name_elts; u ++) {239cc->name_elts[u].status = 0;240cc->name_elts[u].buf[0] = 0;241}242memset(&cc->pkey, 0, sizeof cc->pkey);243cc->num_certs = 0;244cc->err = 0;245cc->cpu.dp = cc->dp_stack;246cc->cpu.rp = cc->rp_stack;247br_x509_minimal_init_main(&cc->cpu);248if (server_name == NULL || *server_name == 0) {249cc->server_name = NULL;250} else {251cc->server_name = server_name;252}253}254255static void256xm_start_cert(const br_x509_class **ctx, uint32_t length)257{258br_x509_minimal_context *cc;259260cc = (br_x509_minimal_context *)(void *)ctx;261if (cc->err != 0) {262return;263}264if (length == 0) {265cc->err = BR_ERR_X509_TRUNCATED;266return;267}268cc->cert_length = length;269}270271static void272xm_append(const br_x509_class **ctx, const unsigned char *buf, size_t len)273{274br_x509_minimal_context *cc;275276cc = (br_x509_minimal_context *)(void *)ctx;277if (cc->err != 0) {278return;279}280cc->hbuf = buf;281cc->hlen = len;282br_x509_minimal_run(&cc->cpu);283}284285static void286xm_end_cert(const br_x509_class **ctx)287{288br_x509_minimal_context *cc;289290cc = (br_x509_minimal_context *)(void *)ctx;291if (cc->err == 0 && cc->cert_length != 0) {292cc->err = BR_ERR_X509_TRUNCATED;293}294cc->num_certs ++;295}296297static unsigned298xm_end_chain(const br_x509_class **ctx)299{300br_x509_minimal_context *cc;301302cc = (br_x509_minimal_context *)(void *)ctx;303if (cc->err == 0) {304if (cc->num_certs == 0) {305cc->err = BR_ERR_X509_EMPTY_CHAIN;306} else {307cc->err = BR_ERR_X509_NOT_TRUSTED;308}309} else if (cc->err == BR_ERR_X509_OK) {310return 0;311}312return (unsigned)cc->err;313}314315static const br_x509_pkey *316xm_get_pkey(const br_x509_class *const *ctx, unsigned *usages)317{318br_x509_minimal_context *cc;319320cc = (br_x509_minimal_context *)(void *)ctx;321if (cc->err == BR_ERR_X509_OK322|| cc->err == BR_ERR_X509_NOT_TRUSTED)323{324if (usages != NULL) {325*usages = cc->key_usages;326}327return &((br_x509_minimal_context *)(void *)ctx)->pkey;328} else {329return NULL;330}331}332333/* see bearssl_x509.h */334const br_x509_class br_x509_minimal_vtable = {335sizeof(br_x509_minimal_context),336xm_start_chain,337xm_start_cert,338xm_append,339xm_end_cert,340xm_end_chain,341xm_get_pkey342};343344#define CTX ((br_x509_minimal_context *)(void *)((unsigned char *)t0ctx - offsetof(br_x509_minimal_context, cpu)))345#define CONTEXT_NAME br_x509_minimal_context346347#define DNHASH_LEN ((CTX->dn_hash_impl->desc >> BR_HASHDESC_OUT_OFF) & BR_HASHDESC_OUT_MASK)348349/*350* Hash a DN (from a trust anchor) into the provided buffer. This uses the351* DN hash implementation and context structure from the X.509 engine352* context.353*/354static void355hash_dn(br_x509_minimal_context *ctx, const void *dn, size_t len,356unsigned char *out)357{358ctx->dn_hash_impl->init(&ctx->dn_hash.vtable);359ctx->dn_hash_impl->update(&ctx->dn_hash.vtable, dn, len);360ctx->dn_hash_impl->out(&ctx->dn_hash.vtable, out);361}362363/*364* Compare two big integers for equality. The integers use unsigned big-endian365* encoding; extra leading bytes (of value 0) are allowed.366*/367static int368eqbigint(const unsigned char *b1, size_t len1,369const unsigned char *b2, size_t len2)370{371while (len1 > 0 && *b1 == 0) {372b1 ++;373len1 --;374}375while (len2 > 0 && *b2 == 0) {376b2 ++;377len2 --;378}379if (len1 != len2) {380return 0;381}382return memcmp(b1, b2, len1) == 0;383}384385/*386* Compare two strings for equality, in a case-insensitive way. This387* function handles casing only for ASCII letters.388*/389static int390eqnocase(const void *s1, const void *s2, size_t len)391{392const unsigned char *buf1, *buf2;393394buf1 = s1;395buf2 = s2;396while (len -- > 0) {397int x1, x2;398399x1 = *buf1 ++;400x2 = *buf2 ++;401if (x1 >= 'A' && x1 <= 'Z') {402x1 += 'a' - 'A';403}404if (x2 >= 'A' && x2 <= 'Z') {405x2 += 'a' - 'A';406}407if (x1 != x2) {408return 0;409}410}411return 1;412}413414static int verify_signature(br_x509_minimal_context *ctx,415const br_x509_pkey *pk);416417418419static const unsigned char t0_datablock[] = {4200x00, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x09,4210x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x09, 0x2A, 0x86,4220x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0E, 0x09, 0x2A, 0x86, 0x48, 0x86,4230xF7, 0x0D, 0x01, 0x01, 0x0B, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D,4240x01, 0x01, 0x0C, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01,4250x0D, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x09, 0x60, 0x86, 0x48, 0x01,4260x65, 0x03, 0x04, 0x02, 0x04, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,4270x04, 0x02, 0x01, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02,4280x02, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x07,4290x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x08, 0x2A, 0x86, 0x48, 0xCE,4300x3D, 0x03, 0x01, 0x07, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x22, 0x05, 0x2B,4310x81, 0x04, 0x00, 0x23, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x01,4320x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x01, 0x08, 0x2A, 0x86,4330x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,4340x04, 0x03, 0x03, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x04,4350x03, 0x55, 0x04, 0x03, 0x00, 0x1F, 0x03, 0xFC, 0x07, 0x7F, 0x0B, 0x5E,4360x0F, 0x1F, 0x12, 0xFE, 0x16, 0xBF, 0x1A, 0x9F, 0x1E, 0x7E, 0x22, 0x3F,4370x26, 0x1E, 0x29, 0xDF, 0x00, 0x1F, 0x03, 0xFD, 0x07, 0x9F, 0x0B, 0x7E,4380x0F, 0x3F, 0x13, 0x1E, 0x16, 0xDF, 0x1A, 0xBF, 0x1E, 0x9E, 0x22, 0x5F,4390x26, 0x3E, 0x29, 0xFF, 0x03, 0x55, 0x1D, 0x13, 0x03, 0x55, 0x1D, 0x0F,4400x03, 0x55, 0x1D, 0x11, 0x03, 0x55, 0x1D, 0x20, 0x08, 0x2B, 0x06, 0x01,4410x05, 0x05, 0x07, 0x02, 0x01, 0x03, 0x55, 0x1D, 0x23, 0x03, 0x55, 0x1D,4420x0E, 0x03, 0x55, 0x1D, 0x12, 0x03, 0x55, 0x1D, 0x09, 0x03, 0x55, 0x1D,4430x1F, 0x03, 0x55, 0x1D, 0x2E, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07,4440x01, 0x01, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x0B445};446447static const unsigned char t0_codeblock[] = {4480x00, 0x01, 0x00, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x01,4490x00, 0x11, 0x00, 0x00, 0x01, 0x01, 0x09, 0x00, 0x00, 0x01, 0x01, 0x0A,4500x00, 0x00, 0x25, 0x25, 0x00, 0x00, 0x01,451T0_INT1(BR_ERR_X509_BAD_BOOLEAN), 0x00, 0x00, 0x01,452T0_INT1(BR_ERR_X509_BAD_DN), 0x00, 0x00, 0x01,453T0_INT1(BR_ERR_X509_BAD_SERVER_NAME), 0x00, 0x00, 0x01,454T0_INT1(BR_ERR_X509_BAD_TAG_CLASS), 0x00, 0x00, 0x01,455T0_INT1(BR_ERR_X509_BAD_TAG_VALUE), 0x00, 0x00, 0x01,456T0_INT1(BR_ERR_X509_BAD_TIME), 0x00, 0x00, 0x01,457T0_INT1(BR_ERR_X509_CRITICAL_EXTENSION), 0x00, 0x00, 0x01,458T0_INT1(BR_ERR_X509_DN_MISMATCH), 0x00, 0x00, 0x01,459T0_INT1(BR_ERR_X509_EXPIRED), 0x00, 0x00, 0x01,460T0_INT1(BR_ERR_X509_EXTRA_ELEMENT), 0x00, 0x00, 0x01,461T0_INT1(BR_ERR_X509_FORBIDDEN_KEY_USAGE), 0x00, 0x00, 0x01,462T0_INT1(BR_ERR_X509_INDEFINITE_LENGTH), 0x00, 0x00, 0x01,463T0_INT1(BR_ERR_X509_INNER_TRUNC), 0x00, 0x00, 0x01,464T0_INT1(BR_ERR_X509_LIMIT_EXCEEDED), 0x00, 0x00, 0x01,465T0_INT1(BR_ERR_X509_NOT_CA), 0x00, 0x00, 0x01,466T0_INT1(BR_ERR_X509_NOT_CONSTRUCTED), 0x00, 0x00, 0x01,467T0_INT1(BR_ERR_X509_NOT_PRIMITIVE), 0x00, 0x00, 0x01,468T0_INT1(BR_ERR_X509_OVERFLOW), 0x00, 0x00, 0x01,469T0_INT1(BR_ERR_X509_PARTIAL_BYTE), 0x00, 0x00, 0x01,470T0_INT1(BR_ERR_X509_UNEXPECTED), 0x00, 0x00, 0x01,471T0_INT1(BR_ERR_X509_UNSUPPORTED), 0x00, 0x00, 0x01,472T0_INT1(BR_ERR_X509_WEAK_PUBLIC_KEY), 0x00, 0x00, 0x01,473T0_INT1(BR_KEYTYPE_EC), 0x00, 0x00, 0x01, T0_INT1(BR_KEYTYPE_RSA),4740x00, 0x00, 0x01, T0_INT2(offsetof(CONTEXT_NAME, cert_length)), 0x00,4750x00, 0x01, T0_INT2(offsetof(CONTEXT_NAME, cert_sig)), 0x00, 0x00,4760x01, T0_INT2(offsetof(CONTEXT_NAME, cert_sig_hash_len)), 0x00, 0x00,4770x01, T0_INT2(offsetof(CONTEXT_NAME, cert_sig_hash_oid)), 0x00, 0x00,4780x01, T0_INT2(offsetof(CONTEXT_NAME, cert_sig_len)), 0x00, 0x00, 0x01,479T0_INT2(offsetof(CONTEXT_NAME, cert_signer_key_type)), 0x00, 0x00,4800x01, T0_INT2(offsetof(CONTEXT_NAME, current_dn_hash)), 0x00, 0x00,4810x01, T0_INT2(offsetof(CONTEXT_NAME, key_usages)), 0x00, 0x00, 0x01,482T0_INT2(offsetof(br_x509_minimal_context, pkey_data)), 0x01,483T0_INT2(BR_X509_BUFSIZE_KEY), 0x00, 0x00, 0x01,484T0_INT2(offsetof(CONTEXT_NAME, min_rsa_size)), 0x00, 0x00, 0x01,485T0_INT2(offsetof(CONTEXT_NAME, next_dn_hash)), 0x00, 0x00, 0x01,486T0_INT2(offsetof(CONTEXT_NAME, num_certs)), 0x00, 0x00, 0x01,487T0_INT2(offsetof(CONTEXT_NAME, pad)), 0x00, 0x00, 0x01,488T0_INT2(offsetof(CONTEXT_NAME, saved_dn_hash)), 0x00, 0x00, 0x01, 0x80,4890x73, 0x00, 0x00, 0x01, 0x80, 0x7C, 0x00, 0x00, 0x01, 0x81, 0x02, 0x00,4900x00, 0x8F, 0x05, 0x05, 0x33, 0x41, 0x01, 0x00, 0x00, 0x33, 0x01, 0x0A,4910x0E, 0x09, 0x01, 0x9A, 0xFF, 0xB8, 0x00, 0x0A, 0x00, 0x00, 0x01, 0x82,4920x19, 0x00, 0x00, 0x01, 0x82, 0x01, 0x00, 0x00, 0x01, 0x81, 0x68, 0x00,4930x02, 0x03, 0x00, 0x03, 0x01, 0x26, 0x02, 0x01, 0x13, 0x3A, 0x02, 0x00,4940x0F, 0x15, 0x00, 0x00, 0x01, 0x81, 0x74, 0x00, 0x00, 0x05, 0x02, 0x51,4950x29, 0x00, 0x00, 0x06, 0x02, 0x52, 0x29, 0x00, 0x00, 0x01, 0x10, 0x74,4960x00, 0x00, 0x11, 0x05, 0x02, 0x55, 0x29, 0x71, 0x00, 0x00, 0x11, 0x05,4970x02, 0x55, 0x29, 0x72, 0x00, 0x00, 0x06, 0x02, 0x4B, 0x29, 0x00, 0x00,4980x01, 0x82, 0x11, 0x00, 0x00, 0x26, 0x21, 0x01, 0x08, 0x0E, 0x3A, 0x3F,4990x21, 0x09, 0x00, 0x0B, 0x03, 0x00, 0x5A, 0x2B, 0xAC, 0x38, 0xAC, 0xB0,5000x26, 0x01, 0x20, 0x11, 0x06, 0x11, 0x25, 0x71, 0xAA, 0xB0, 0x01, 0x02,5010x75, 0xAD, 0x01, 0x02, 0x12, 0x06, 0x02, 0x56, 0x29, 0x76, 0xB0, 0x01,5020x02, 0x75, 0xAB, 0xAC, 0xBF, 0x99, 0x64, 0x60, 0x22, 0x16, 0xAC, 0xA4,5030x03, 0x01, 0x03, 0x02, 0xA4, 0x02, 0x02, 0x02, 0x01, 0x19, 0x06, 0x02,5040x4A, 0x29, 0x76, 0x02, 0x00, 0x06, 0x05, 0x9A, 0x03, 0x03, 0x04, 0x09,5050x99, 0x60, 0x67, 0x22, 0x28, 0x05, 0x02, 0x49, 0x29, 0x67, 0x64, 0x22,5060x16, 0xAC, 0xAC, 0x9B, 0x05, 0x02, 0x56, 0x29, 0xB9, 0x27, 0x06, 0x27,5070xBF, 0xA1, 0xAC, 0x62, 0xA7, 0x03, 0x05, 0x62, 0x3A, 0x02, 0x05, 0x09,5080x3A, 0x02, 0x05, 0x0A, 0xA7, 0x03, 0x06, 0x76, 0x63, 0x2A, 0x01, 0x81,5090x00, 0x09, 0x02, 0x05, 0x12, 0x06, 0x02, 0x57, 0x29, 0x76, 0x59, 0x03,5100x04, 0x04, 0x3A, 0x85, 0x27, 0x06, 0x34, 0x9B, 0x05, 0x02, 0x56, 0x29,5110x68, 0x27, 0x06, 0x04, 0x01, 0x17, 0x04, 0x12, 0x69, 0x27, 0x06, 0x04,5120x01, 0x18, 0x04, 0x0A, 0x6A, 0x27, 0x06, 0x04, 0x01, 0x19, 0x04, 0x02,5130x56, 0x29, 0x03, 0x07, 0x76, 0xA1, 0x26, 0x03, 0x08, 0x26, 0x62, 0x33,5140x0D, 0x06, 0x02, 0x4F, 0x29, 0xA2, 0x58, 0x03, 0x04, 0x04, 0x02, 0x56,5150x29, 0x76, 0x02, 0x00, 0x06, 0x21, 0x02, 0x04, 0x59, 0x30, 0x11, 0x06,5160x08, 0x25, 0x02, 0x05, 0x02, 0x06, 0x1E, 0x04, 0x10, 0x58, 0x30, 0x11,5170x06, 0x08, 0x25, 0x02, 0x07, 0x02, 0x08, 0x1D, 0x04, 0x03, 0x56, 0x29,5180x25, 0x04, 0x24, 0x02, 0x04, 0x59, 0x30, 0x11, 0x06, 0x08, 0x25, 0x02,5190x05, 0x02, 0x06, 0x24, 0x04, 0x10, 0x58, 0x30, 0x11, 0x06, 0x08, 0x25,5200x02, 0x07, 0x02, 0x08, 0x23, 0x04, 0x03, 0x56, 0x29, 0x25, 0x26, 0x06,5210x01, 0x29, 0x25, 0x01, 0x00, 0x03, 0x09, 0xB1, 0x01, 0x21, 0x8C, 0x01,5220x22, 0x8C, 0x26, 0x01, 0x23, 0x11, 0x06, 0x81, 0x26, 0x25, 0x71, 0xAA,5230xAC, 0x26, 0x06, 0x81, 0x1A, 0x01, 0x00, 0x03, 0x0A, 0xAC, 0x9B, 0x25,5240xB0, 0x26, 0x01, 0x01, 0x11, 0x06, 0x04, 0xA3, 0x03, 0x0A, 0xB0, 0x01,5250x04, 0x75, 0xAA, 0x6E, 0x27, 0x06, 0x0F, 0x02, 0x00, 0x06, 0x03, 0xC0,5260x04, 0x05, 0x96, 0x01, 0x7F, 0x03, 0x09, 0x04, 0x80, 0x6C, 0x8E, 0x27,5270x06, 0x06, 0x02, 0x00, 0x98, 0x04, 0x80, 0x62, 0xC2, 0x27, 0x06, 0x11,5280x02, 0x00, 0x06, 0x09, 0x01, 0x00, 0x03, 0x03, 0x95, 0x03, 0x03, 0x04,5290x01, 0xC0, 0x04, 0x80, 0x4D, 0x70, 0x27, 0x06, 0x0A, 0x02, 0x0A, 0x06,5300x03, 0x97, 0x04, 0x01, 0xC0, 0x04, 0x3F, 0x6D, 0x27, 0x06, 0x03, 0xC0,5310x04, 0x38, 0xC5, 0x27, 0x06, 0x03, 0xC0, 0x04, 0x31, 0x8D, 0x27, 0x06,5320x03, 0xC0, 0x04, 0x2A, 0xC3, 0x27, 0x06, 0x03, 0xC0, 0x04, 0x23, 0x77,5330x27, 0x06, 0x03, 0xC0, 0x04, 0x1C, 0x82, 0x27, 0x06, 0x03, 0xC0, 0x04,5340x15, 0x6C, 0x27, 0x06, 0x03, 0xC0, 0x04, 0x0E, 0xC4, 0x27, 0x06, 0x03,5350xC0, 0x04, 0x07, 0x02, 0x0A, 0x06, 0x02, 0x48, 0x29, 0xC0, 0x76, 0x76,5360x04, 0xFE, 0x62, 0x76, 0x76, 0x04, 0x08, 0x01, 0x7F, 0x11, 0x05, 0x02,5370x55, 0x29, 0x25, 0x76, 0x39, 0x02, 0x00, 0x06, 0x08, 0x02, 0x03, 0x3B,5380x2F, 0x05, 0x02, 0x44, 0x29, 0x02, 0x00, 0x06, 0x01, 0x17, 0x02, 0x00,5390x02, 0x09, 0x2F, 0x05, 0x02, 0x50, 0x29, 0xB0, 0x73, 0xAA, 0x9B, 0x06,5400x80, 0x77, 0xBA, 0x27, 0x06, 0x07, 0x01, 0x02, 0x59, 0x87, 0x04, 0x80,5410x5E, 0xBB, 0x27, 0x06, 0x07, 0x01, 0x03, 0x59, 0x88, 0x04, 0x80, 0x53,5420xBC, 0x27, 0x06, 0x07, 0x01, 0x04, 0x59, 0x89, 0x04, 0x80, 0x48, 0xBD,5430x27, 0x06, 0x06, 0x01, 0x05, 0x59, 0x8A, 0x04, 0x3E, 0xBE, 0x27, 0x06,5440x06, 0x01, 0x06, 0x59, 0x8B, 0x04, 0x34, 0x7C, 0x27, 0x06, 0x06, 0x01,5450x02, 0x58, 0x87, 0x04, 0x2A, 0x7D, 0x27, 0x06, 0x06, 0x01, 0x03, 0x58,5460x88, 0x04, 0x20, 0x7E, 0x27, 0x06, 0x06, 0x01, 0x04, 0x58, 0x89, 0x04,5470x16, 0x7F, 0x27, 0x06, 0x06, 0x01, 0x05, 0x58, 0x8A, 0x04, 0x0C, 0x80,5480x27, 0x06, 0x06, 0x01, 0x06, 0x58, 0x8B, 0x04, 0x02, 0x56, 0x29, 0x5D,5490x34, 0x5F, 0x36, 0x1C, 0x26, 0x05, 0x02, 0x56, 0x29, 0x5C, 0x36, 0x04,5500x02, 0x56, 0x29, 0xBF, 0xA1, 0x26, 0x01, T0_INT2(BR_X509_BUFSIZE_SIG),5510x12, 0x06, 0x02, 0x4F, 0x29, 0x26, 0x5E, 0x34, 0x5B, 0xA2, 0x76, 0x76,5520x01, 0x00, 0x5A, 0x35, 0x18, 0x00, 0x00, 0x01, 0x30, 0x0A, 0x26, 0x01,5530x00, 0x01, 0x09, 0x6F, 0x05, 0x02, 0x47, 0x29, 0x00, 0x00, 0x30, 0x30,5540x00, 0x00, 0x01, 0x81, 0x08, 0x00, 0x00, 0x01, 0x81, 0x10, 0x00, 0x00,5550x01, 0x81, 0x19, 0x00, 0x00, 0x01, 0x81, 0x22, 0x00, 0x00, 0x01, 0x81,5560x2B, 0x00, 0x01, 0x7B, 0x01, 0x01, 0x11, 0x3A, 0x01, 0x83, 0xFD, 0x7F,5570x11, 0x15, 0x06, 0x03, 0x3A, 0x25, 0x00, 0x3A, 0x26, 0x03, 0x00, 0x26,5580xC6, 0x05, 0x04, 0x41, 0x01, 0x00, 0x00, 0x26, 0x01, 0x81, 0x00, 0x0D,5590x06, 0x04, 0x93, 0x04, 0x80, 0x49, 0x26, 0x01, 0x90, 0x00, 0x0D, 0x06,5600x0F, 0x01, 0x06, 0x14, 0x01, 0x81, 0x40, 0x2F, 0x93, 0x02, 0x00, 0x01,5610x00, 0x94, 0x04, 0x33, 0x26, 0x01, 0x83, 0xFF, 0x7F, 0x0D, 0x06, 0x14,5620x01, 0x0C, 0x14, 0x01, 0x81, 0x60, 0x2F, 0x93, 0x02, 0x00, 0x01, 0x06,5630x94, 0x02, 0x00, 0x01, 0x00, 0x94, 0x04, 0x17, 0x01, 0x12, 0x14, 0x01,5640x81, 0x70, 0x2F, 0x93, 0x02, 0x00, 0x01, 0x0C, 0x94, 0x02, 0x00, 0x01,5650x06, 0x94, 0x02, 0x00, 0x01, 0x00, 0x94, 0x00, 0x00, 0x01, 0x82, 0x15,5660x00, 0x00, 0x26, 0x01, 0x83, 0xB0, 0x00, 0x01, 0x83, 0xB7, 0x7F, 0x6F,5670x00, 0x00, 0x01, 0x81, 0x34, 0x00, 0x00, 0x01, 0x80, 0x6B, 0x00, 0x00,5680x01, 0x81, 0x78, 0x00, 0x00, 0x01, 0x3D, 0x00, 0x00, 0x01, 0x80, 0x43,5690x00, 0x00, 0x01, 0x80, 0x4D, 0x00, 0x00, 0x01, 0x80, 0x57, 0x00, 0x00,5700x01, 0x80, 0x61, 0x00, 0x00, 0x30, 0x11, 0x06, 0x04, 0x41, 0xAA, 0xBF,5710xB1, 0x00, 0x00, 0x01, 0x82, 0x09, 0x00, 0x00, 0x01, 0x81, 0x6C, 0x00,5720x00, 0x26, 0x01, 0x83, 0xB8, 0x00, 0x01, 0x83, 0xBF, 0x7F, 0x6F, 0x00,5730x00, 0x01, 0x30, 0x61, 0x36, 0x01, 0x7F, 0x79, 0x1A, 0x01, 0x00, 0x79,5740x1A, 0x04, 0x7A, 0x00, 0x01, 0x81, 0x38, 0x00, 0x01, 0x7B, 0x0D, 0x06,5750x02, 0x4E, 0x29, 0x26, 0x03, 0x00, 0x0A, 0x02, 0x00, 0x00, 0x00, 0x30,5760x26, 0x3E, 0x3A, 0x01, 0x82, 0x00, 0x13, 0x2F, 0x06, 0x04, 0x41, 0x01,5770x00, 0x00, 0x30, 0x66, 0x09, 0x36, 0x3F, 0x00, 0x00, 0x14, 0x01, 0x3F,5780x15, 0x01, 0x81, 0x00, 0x2F, 0x93, 0x00, 0x02, 0x01, 0x00, 0x03, 0x00,5790xAC, 0x26, 0x06, 0x80, 0x59, 0xB0, 0x01, 0x20, 0x30, 0x11, 0x06, 0x17,5800x25, 0x71, 0xAA, 0x9B, 0x25, 0x01, 0x7F, 0x2E, 0x03, 0x01, 0xB0, 0x01,5810x20, 0x74, 0xAA, 0xAF, 0x02, 0x01, 0x20, 0x76, 0x76, 0x04, 0x38, 0x01,5820x21, 0x30, 0x11, 0x06, 0x08, 0x25, 0x72, 0xB3, 0x01, 0x01, 0x1F, 0x04,5830x2A, 0x01, 0x22, 0x30, 0x11, 0x06, 0x11, 0x25, 0x72, 0xB3, 0x26, 0x06,5840x06, 0x2C, 0x02, 0x00, 0x2F, 0x03, 0x00, 0x01, 0x02, 0x1F, 0x04, 0x13,5850x01, 0x26, 0x30, 0x11, 0x06, 0x08, 0x25, 0x72, 0xB3, 0x01, 0x06, 0x1F,5860x04, 0x05, 0x41, 0xAB, 0x01, 0x00, 0x25, 0x04, 0xFF, 0x23, 0x76, 0x02,5870x00, 0x00, 0x00, 0xAC, 0xB1, 0x26, 0x01, 0x01, 0x11, 0x06, 0x08, 0xA3,5880x05, 0x02, 0x50, 0x29, 0xB1, 0x04, 0x02, 0x50, 0x29, 0x26, 0x01, 0x02,5890x11, 0x06, 0x0C, 0x25, 0x72, 0xAD, 0x65, 0x2B, 0x40, 0x0D, 0x06, 0x02,5900x50, 0x29, 0xB1, 0x01, 0x7F, 0x10, 0x06, 0x02, 0x55, 0x29, 0x25, 0x76,5910x00, 0x00, 0xAC, 0x26, 0x06, 0x1A, 0xAC, 0x9B, 0x25, 0x26, 0x06, 0x11,5920xAC, 0x26, 0x06, 0x0C, 0xAC, 0x9B, 0x25, 0x86, 0x27, 0x05, 0x02, 0x48,5930x29, 0xBF, 0x04, 0x71, 0x76, 0x76, 0x04, 0x63, 0x76, 0x00, 0x02, 0x03,5940x00, 0xB0, 0x01, 0x03, 0x75, 0xAA, 0xB7, 0x03, 0x01, 0x02, 0x01, 0x01,5950x07, 0x12, 0x06, 0x02, 0x55, 0x29, 0x26, 0x01, 0x00, 0x30, 0x11, 0x06,5960x05, 0x25, 0x4C, 0x29, 0x04, 0x15, 0x01, 0x01, 0x30, 0x11, 0x06, 0x0A,5970x25, 0xB7, 0x02, 0x01, 0x14, 0x02, 0x01, 0x0E, 0x04, 0x05, 0x25, 0xB7,5980x01, 0x00, 0x25, 0x02, 0x00, 0x06, 0x19, 0x01, 0x00, 0x30, 0x01, 0x38,5990x15, 0x06, 0x03, 0x01, 0x10, 0x2F, 0x3A, 0x01, 0x81, 0x40, 0x15, 0x06,6000x03, 0x01, 0x20, 0x2F, 0x61, 0x36, 0x04, 0x07, 0x01, 0x04, 0x15, 0x05,6010x02, 0x4C, 0x29, 0xBF, 0x00, 0x00, 0x37, 0xAC, 0xBF, 0x1B, 0x00, 0x03,6020x01, 0x00, 0x03, 0x00, 0x37, 0xAC, 0x26, 0x06, 0x30, 0xB0, 0x01, 0x11,6030x74, 0xAA, 0x26, 0x05, 0x02, 0x43, 0x29, 0x26, 0x06, 0x20, 0xAC, 0x9B,6040x25, 0x84, 0x27, 0x03, 0x01, 0x01, 0x00, 0x2E, 0x03, 0x02, 0xAF, 0x26,6050x02, 0x01, 0x15, 0x06, 0x07, 0x2C, 0x06, 0x04, 0x01, 0x7F, 0x03, 0x00,6060x02, 0x02, 0x20, 0x76, 0x04, 0x5D, 0x76, 0x04, 0x4D, 0x76, 0x1B, 0x02,6070x00, 0x00, 0x00, 0xB0, 0x01, 0x06, 0x75, 0xAE, 0x00, 0x00, 0xB5, 0x83,6080x06, 0x0E, 0x3A, 0x26, 0x05, 0x06, 0x41, 0x01, 0x00, 0x01, 0x00, 0x00,6090xB5, 0x6B, 0x04, 0x08, 0x8F, 0x06, 0x05, 0x25, 0x01, 0x00, 0x04, 0x00,6100x00, 0x00, 0xB6, 0x83, 0x06, 0x0E, 0x3A, 0x26, 0x05, 0x06, 0x41, 0x01,6110x00, 0x01, 0x00, 0x00, 0xB6, 0x6B, 0x04, 0x08, 0x8F, 0x06, 0x05, 0x25,6120x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0xB7, 0x26, 0x01, 0x81, 0x00, 0x0D,6130x06, 0x04, 0x00, 0x04, 0x80, 0x55, 0x26, 0x01, 0x81, 0x40, 0x0D, 0x06,6140x07, 0x25, 0x01, 0x00, 0x00, 0x04, 0x80, 0x47, 0x26, 0x01, 0x81, 0x60,6150x0D, 0x06, 0x0E, 0x01, 0x1F, 0x15, 0x01, 0x01, 0xA0, 0x01, 0x81, 0x00,6160x01, 0x8F, 0x7F, 0x04, 0x32, 0x26, 0x01, 0x81, 0x70, 0x0D, 0x06, 0x0F,6170x01, 0x0F, 0x15, 0x01, 0x02, 0xA0, 0x01, 0x90, 0x00, 0x01, 0x83, 0xFF,6180x7F, 0x04, 0x1C, 0x26, 0x01, 0x81, 0x78, 0x0D, 0x06, 0x11, 0x01, 0x07,6190x15, 0x01, 0x03, 0xA0, 0x01, 0x84, 0x80, 0x00, 0x01, 0x80, 0xC3, 0xFF,6200x7F, 0x04, 0x04, 0x25, 0x01, 0x00, 0x00, 0x6F, 0x05, 0x03, 0x25, 0x01,6210x00, 0x00, 0x00, 0x3A, 0x26, 0x05, 0x06, 0x41, 0x01, 0x00, 0x01, 0x7F,6220x00, 0xB7, 0x33, 0x26, 0x3C, 0x06, 0x03, 0x3A, 0x25, 0x00, 0x01, 0x06,6230x0E, 0x3A, 0x26, 0x01, 0x06, 0x14, 0x01, 0x02, 0x10, 0x06, 0x04, 0x41,6240x01, 0x7F, 0x00, 0x01, 0x3F, 0x15, 0x09, 0x00, 0x00, 0x26, 0x06, 0x06,6250x0B, 0x9F, 0x33, 0x40, 0x04, 0x77, 0x25, 0x26, 0x00, 0x00, 0xB0, 0x01,6260x03, 0x75, 0xAA, 0xB7, 0x06, 0x02, 0x54, 0x29, 0x00, 0x00, 0x3A, 0x26,6270x06, 0x07, 0x31, 0x26, 0x06, 0x01, 0x1A, 0x04, 0x76, 0x41, 0x00, 0x00,6280x01, 0x01, 0x75, 0xA9, 0x01, 0x01, 0x10, 0x06, 0x02, 0x42, 0x29, 0xB7,6290x3D, 0x00, 0x04, 0xB0, 0x26, 0x01, 0x17, 0x01, 0x18, 0x6F, 0x05, 0x02,6300x47, 0x29, 0x01, 0x18, 0x11, 0x03, 0x00, 0x72, 0xAA, 0xA5, 0x02, 0x00,6310x06, 0x0C, 0x01, 0x80, 0x64, 0x08, 0x03, 0x01, 0xA5, 0x02, 0x01, 0x09,6320x04, 0x0E, 0x26, 0x01, 0x32, 0x0D, 0x06, 0x04, 0x01, 0x80, 0x64, 0x09,6330x01, 0x8E, 0x6C, 0x09, 0x03, 0x01, 0x02, 0x01, 0x01, 0x82, 0x6D, 0x08,6340x02, 0x01, 0x01, 0x03, 0x09, 0x01, 0x04, 0x0C, 0x09, 0x02, 0x01, 0x01,6350x80, 0x63, 0x09, 0x01, 0x80, 0x64, 0x0C, 0x0A, 0x02, 0x01, 0x01, 0x83,6360x0F, 0x09, 0x01, 0x83, 0x10, 0x0C, 0x09, 0x03, 0x03, 0x01, 0x01, 0x01,6370x0C, 0xA6, 0x40, 0x01, 0x01, 0x0E, 0x02, 0x01, 0x01, 0x04, 0x07, 0x3E,6380x02, 0x01, 0x01, 0x80, 0x64, 0x07, 0x3D, 0x02, 0x01, 0x01, 0x83, 0x10,6390x07, 0x3E, 0x2F, 0x15, 0x06, 0x03, 0x01, 0x18, 0x09, 0x91, 0x09, 0x78,6400x26, 0x01, 0x05, 0x14, 0x02, 0x03, 0x09, 0x03, 0x03, 0x01, 0x1F, 0x15,6410x01, 0x01, 0x3A, 0xA6, 0x02, 0x03, 0x09, 0x40, 0x03, 0x03, 0x01, 0x00,6420x01, 0x17, 0xA6, 0x01, 0x9C, 0x10, 0x08, 0x03, 0x02, 0x01, 0x00, 0x01,6430x3B, 0xA6, 0x01, 0x3C, 0x08, 0x02, 0x02, 0x09, 0x03, 0x02, 0x01, 0x00,6440x01, 0x3C, 0xA6, 0x02, 0x02, 0x09, 0x03, 0x02, 0xB7, 0x26, 0x01, 0x2E,6450x11, 0x06, 0x0D, 0x25, 0xB7, 0x26, 0x01, 0x30, 0x01, 0x39, 0x6F, 0x06,6460x03, 0x25, 0x04, 0x74, 0x01, 0x80, 0x5A, 0x10, 0x06, 0x02, 0x47, 0x29,6470x76, 0x02, 0x03, 0x02, 0x02, 0x00, 0x01, 0xB7, 0x7A, 0x01, 0x0A, 0x08,6480x03, 0x00, 0xB7, 0x7A, 0x02, 0x00, 0x09, 0x00, 0x02, 0x03, 0x00, 0x03,6490x01, 0xA5, 0x26, 0x02, 0x01, 0x02, 0x00, 0x6F, 0x05, 0x02, 0x47, 0x29,6500x00, 0x00, 0x33, 0xB0, 0x01, 0x02, 0x75, 0x0B, 0xA8, 0x00, 0x03, 0x26,6510x03, 0x00, 0x03, 0x01, 0x03, 0x02, 0xAA, 0xB7, 0x26, 0x01, 0x81, 0x00,6520x13, 0x06, 0x02, 0x53, 0x29, 0x26, 0x01, 0x00, 0x11, 0x06, 0x0B, 0x25,6530x26, 0x05, 0x04, 0x25, 0x01, 0x00, 0x00, 0xB7, 0x04, 0x6F, 0x02, 0x01,6540x26, 0x05, 0x02, 0x4F, 0x29, 0x40, 0x03, 0x01, 0x02, 0x02, 0x36, 0x02,6550x02, 0x3F, 0x03, 0x02, 0x26, 0x06, 0x03, 0xB7, 0x04, 0x68, 0x25, 0x02,6560x00, 0x02, 0x01, 0x0A, 0x00, 0x01, 0xB7, 0x26, 0x01, 0x81, 0x00, 0x0D,6570x06, 0x01, 0x00, 0x01, 0x81, 0x00, 0x0A, 0x26, 0x05, 0x02, 0x4D, 0x29,6580x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x12, 0x06, 0x19, 0x02,6590x00, 0x40, 0x03, 0x00, 0x26, 0x01, 0x83, 0xFF, 0xFF, 0x7F, 0x12, 0x06,6600x02, 0x4E, 0x29, 0x01, 0x08, 0x0E, 0x3A, 0xB7, 0x33, 0x09, 0x04, 0x60,6610x00, 0x00, 0xA9, 0x92, 0x00, 0x00, 0xAA, 0xBF, 0x00, 0x00, 0xB0, 0x73,6620xAA, 0x00, 0x01, 0xAA, 0x26, 0x05, 0x02, 0x53, 0x29, 0xB7, 0x26, 0x01,6630x81, 0x00, 0x13, 0x06, 0x02, 0x53, 0x29, 0x03, 0x00, 0x26, 0x06, 0x16,6640xB7, 0x02, 0x00, 0x26, 0x01, 0x87, 0xFF, 0xFF, 0x7F, 0x13, 0x06, 0x02,6650x53, 0x29, 0x01, 0x08, 0x0E, 0x09, 0x03, 0x00, 0x04, 0x67, 0x25, 0x02,6660x00, 0x00, 0x00, 0xAA, 0x26, 0x01, 0x81, 0x7F, 0x12, 0x06, 0x08, 0xBF,6670x01, 0x00, 0x66, 0x36, 0x01, 0x00, 0x00, 0x26, 0x66, 0x36, 0x66, 0x3F,6680xA2, 0x01, 0x7F, 0x00, 0x00, 0xB0, 0x01, 0x0C, 0x30, 0x11, 0x06, 0x05,6690x25, 0x72, 0xB3, 0x04, 0x3E, 0x01, 0x12, 0x30, 0x11, 0x06, 0x05, 0x25,6700x72, 0xB4, 0x04, 0x33, 0x01, 0x13, 0x30, 0x11, 0x06, 0x05, 0x25, 0x72,6710xB4, 0x04, 0x28, 0x01, 0x14, 0x30, 0x11, 0x06, 0x05, 0x25, 0x72, 0xB4,6720x04, 0x1D, 0x01, 0x16, 0x30, 0x11, 0x06, 0x05, 0x25, 0x72, 0xB4, 0x04,6730x12, 0x01, 0x1E, 0x30, 0x11, 0x06, 0x05, 0x25, 0x72, 0xB2, 0x04, 0x07,6740x41, 0xAB, 0x01, 0x00, 0x01, 0x00, 0x25, 0x00, 0x01, 0xB7, 0x03, 0x00,6750x02, 0x00, 0x01, 0x05, 0x14, 0x01, 0x01, 0x15, 0x2D, 0x02, 0x00, 0x01,6760x06, 0x14, 0x26, 0x01, 0x01, 0x15, 0x06, 0x02, 0x45, 0x29, 0x01, 0x04,6770x0E, 0x02, 0x00, 0x01, 0x1F, 0x15, 0x26, 0x01, 0x1F, 0x11, 0x06, 0x02,6780x46, 0x29, 0x09, 0x00, 0x00, 0x26, 0x05, 0x05, 0x01, 0x00, 0x01, 0x7F,6790x00, 0xB0, 0x00, 0x01, 0xAA, 0x26, 0x05, 0x05, 0x66, 0x36, 0x01, 0x7F,6800x00, 0x01, 0x01, 0x03, 0x00, 0x9C, 0x26, 0x01, 0x83, 0xFF, 0x7E, 0x11,6810x06, 0x16, 0x25, 0x26, 0x06, 0x10, 0x9D, 0x26, 0x05, 0x05, 0x25, 0xBF,6820x01, 0x00, 0x00, 0x02, 0x00, 0x81, 0x03, 0x00, 0x04, 0x6D, 0x04, 0x1B,6830x26, 0x05, 0x05, 0x25, 0xBF, 0x01, 0x00, 0x00, 0x02, 0x00, 0x81, 0x03,6840x00, 0x26, 0x06, 0x0B, 0x9C, 0x26, 0x05, 0x05, 0x25, 0xBF, 0x01, 0x00,6850x00, 0x04, 0x6D, 0x25, 0x02, 0x00, 0x26, 0x05, 0x01, 0x00, 0x40, 0x66,6860x36, 0x01, 0x7F, 0x00, 0x01, 0xAA, 0x01, 0x01, 0x03, 0x00, 0x26, 0x06,6870x10, 0x9E, 0x26, 0x05, 0x05, 0x25, 0xBF, 0x01, 0x00, 0x00, 0x02, 0x00,6880x81, 0x03, 0x00, 0x04, 0x6D, 0x25, 0x02, 0x00, 0x26, 0x05, 0x01, 0x00,6890x40, 0x66, 0x36, 0x01, 0x7F, 0x00, 0x01, 0xAA, 0x01, 0x01, 0x03, 0x00,6900x26, 0x06, 0x10, 0xB7, 0x26, 0x05, 0x05, 0x25, 0xBF, 0x01, 0x00, 0x00,6910x02, 0x00, 0x81, 0x03, 0x00, 0x04, 0x6D, 0x25, 0x02, 0x00, 0x26, 0x05,6920x01, 0x00, 0x40, 0x66, 0x36, 0x01, 0x7F, 0x00, 0x00, 0xB7, 0x01, 0x08,6930x0E, 0x3A, 0xB7, 0x33, 0x09, 0x00, 0x00, 0xB7, 0x3A, 0xB7, 0x01, 0x08,6940x0E, 0x33, 0x09, 0x00, 0x00, 0x26, 0x05, 0x02, 0x4E, 0x29, 0x40, 0xB8,6950x00, 0x00, 0x32, 0x26, 0x01, 0x00, 0x13, 0x06, 0x01, 0x00, 0x25, 0x1A,6960x04, 0x74, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x0B, 0x00, 0x00, 0x01,6970x15, 0x00, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x01, 0x29, 0x00, 0x00, 0x01,6980x33, 0x00, 0x00, 0xC0, 0x25, 0x00, 0x00, 0x26, 0x06, 0x07, 0xC1, 0x26,6990x06, 0x01, 0x1A, 0x04, 0x76, 0x00, 0x00, 0x01, 0x00, 0x30, 0x31, 0x0B,7000x41, 0x00, 0x00, 0x01, 0x81, 0x70, 0x00, 0x00, 0x01, 0x82, 0x0D, 0x00,7010x00, 0x01, 0x82, 0x22, 0x00, 0x00, 0x01, 0x82, 0x05, 0x00, 0x00, 0x26,7020x01, 0x83, 0xFB, 0x50, 0x01, 0x83, 0xFB, 0x6F, 0x6F, 0x06, 0x04, 0x25,7030x01, 0x00, 0x00, 0x26, 0x01, 0x83, 0xB0, 0x00, 0x01, 0x83, 0xBF, 0x7F,7040x6F, 0x06, 0x04, 0x25, 0x01, 0x00, 0x00, 0x01, 0x83, 0xFF, 0x7F, 0x15,7050x01, 0x83, 0xFF, 0x7E, 0x0D, 0x00706};707708static const uint16_t t0_caddr[] = {7090,7105,71110,71215,71320,71425,71529,71633,71737,71841,71945,72049,72153,72257,72361,72465,72569,72673,72777,72881,72985,73089,73193,73297,733101,734105,735109,736113,737117,738121,739125,740130,741135,742140,743145,744150,745155,746160,747165,748173,749178,750183,751188,752193,753198,754203,755208,756213,757234,758239,759244,760249,761264,762269,763275,764281,765286,766294,767302,768308,769313,770324,771960,772975,773979,774984,775989,776994,777999,7781004,7791118,7801123,7811135,7821140,7831145,7841150,7851154,7861159,7871164,7881169,7891174,7901184,7911189,7921194,7931206,7941221,7951226,7961240,7971262,7981273,7991376,8001423,8011456,8021547,8031553,8041616,8051623,8061651,8071679,8081784,8091826,8101839,8111851,8121865,8131880,8142100,8152114,8162131,8172140,8182207,8192263,8202267,8212271,8222276,8232324,8242350,8252426,8262470,8272481,8282566,8292604,8302642,8312652,8322662,8332671,8342684,8352688,8362692,8372696,8382700,8392704,8402708,8412712,8422724,8432732,8442737,8452742,8462747,8472752848};849850#define T0_INTERPRETED 60851852#define T0_ENTER(ip, rp, slot) do { \853const unsigned char *t0_newip; \854uint32_t t0_lnum; \855t0_newip = &t0_codeblock[t0_caddr[(slot) - T0_INTERPRETED]]; \856t0_lnum = t0_parse7E_unsigned(&t0_newip); \857(rp) += t0_lnum; \858*((rp) ++) = (uint32_t)((ip) - &t0_codeblock[0]) + (t0_lnum << 16); \859(ip) = t0_newip; \860} while (0)861862#define T0_DEFENTRY(name, slot) \863void \864name(void *ctx) \865{ \866t0_context *t0ctx = ctx; \867t0ctx->ip = &t0_codeblock[0]; \868T0_ENTER(t0ctx->ip, t0ctx->rp, slot); \869}870871T0_DEFENTRY(br_x509_minimal_init_main, 144)872873#define T0_NEXT(t0ipp) (*(*(t0ipp)) ++)874875void876br_x509_minimal_run(void *t0ctx)877{878uint32_t *dp, *rp;879const unsigned char *ip;880881#define T0_LOCAL(x) (*(rp - 2 - (x)))882#define T0_POP() (*-- dp)883#define T0_POPi() (*(int32_t *)(-- dp))884#define T0_PEEK(x) (*(dp - 1 - (x)))885#define T0_PEEKi(x) (*(int32_t *)(dp - 1 - (x)))886#define T0_PUSH(v) do { *dp = (v); dp ++; } while (0)887#define T0_PUSHi(v) do { *(int32_t *)dp = (v); dp ++; } while (0)888#define T0_RPOP() (*-- rp)889#define T0_RPOPi() (*(int32_t *)(-- rp))890#define T0_RPUSH(v) do { *rp = (v); rp ++; } while (0)891#define T0_RPUSHi(v) do { *(int32_t *)rp = (v); rp ++; } while (0)892#define T0_ROLL(x) do { \893size_t t0len = (size_t)(x); \894uint32_t t0tmp = *(dp - 1 - t0len); \895memmove(dp - t0len - 1, dp - t0len, t0len * sizeof *dp); \896*(dp - 1) = t0tmp; \897} while (0)898#define T0_SWAP() do { \899uint32_t t0tmp = *(dp - 2); \900*(dp - 2) = *(dp - 1); \901*(dp - 1) = t0tmp; \902} while (0)903#define T0_ROT() do { \904uint32_t t0tmp = *(dp - 3); \905*(dp - 3) = *(dp - 2); \906*(dp - 2) = *(dp - 1); \907*(dp - 1) = t0tmp; \908} while (0)909#define T0_NROT() do { \910uint32_t t0tmp = *(dp - 1); \911*(dp - 1) = *(dp - 2); \912*(dp - 2) = *(dp - 3); \913*(dp - 3) = t0tmp; \914} while (0)915#define T0_PICK(x) do { \916uint32_t t0depth = (x); \917T0_PUSH(T0_PEEK(t0depth)); \918} while (0)919#define T0_CO() do { \920goto t0_exit; \921} while (0)922#define T0_RET() goto t0_next923924dp = ((t0_context *)t0ctx)->dp;925rp = ((t0_context *)t0ctx)->rp;926ip = ((t0_context *)t0ctx)->ip;927goto t0_next;928for (;;) {929uint32_t t0x;930931t0_next:932t0x = T0_NEXT(&ip);933if (t0x < T0_INTERPRETED) {934switch (t0x) {935int32_t t0off;936937case 0: /* ret */938t0x = T0_RPOP();939rp -= (t0x >> 16);940t0x &= 0xFFFF;941if (t0x == 0) {942ip = NULL;943goto t0_exit;944}945ip = &t0_codeblock[t0x];946break;947case 1: /* literal constant */948T0_PUSHi(t0_parse7E_signed(&ip));949break;950case 2: /* read local */951T0_PUSH(T0_LOCAL(t0_parse7E_unsigned(&ip)));952break;953case 3: /* write local */954T0_LOCAL(t0_parse7E_unsigned(&ip)) = T0_POP();955break;956case 4: /* jump */957t0off = t0_parse7E_signed(&ip);958ip += t0off;959break;960case 5: /* jump if */961t0off = t0_parse7E_signed(&ip);962if (T0_POP()) {963ip += t0off;964}965break;966case 6: /* jump if not */967t0off = t0_parse7E_signed(&ip);968if (!T0_POP()) {969ip += t0off;970}971break;972case 7: {973/* %25 */974975int32_t b = T0_POPi();976int32_t a = T0_POPi();977T0_PUSHi(a % b);978979}980break;981case 8: {982/* * */983984uint32_t b = T0_POP();985uint32_t a = T0_POP();986T0_PUSH(a * b);987988}989break;990case 9: {991/* + */992993uint32_t b = T0_POP();994uint32_t a = T0_POP();995T0_PUSH(a + b);996997}998break;999case 10: {1000/* - */10011002uint32_t b = T0_POP();1003uint32_t a = T0_POP();1004T0_PUSH(a - b);10051006}1007break;1008case 11: {1009/* -rot */1010T0_NROT();1011}1012break;1013case 12: {1014/* / */10151016int32_t b = T0_POPi();1017int32_t a = T0_POPi();1018T0_PUSHi(a / b);10191020}1021break;1022case 13: {1023/* < */10241025int32_t b = T0_POPi();1026int32_t a = T0_POPi();1027T0_PUSH(-(uint32_t)(a < b));10281029}1030break;1031case 14: {1032/* << */10331034int c = (int)T0_POPi();1035uint32_t x = T0_POP();1036T0_PUSH(x << c);10371038}1039break;1040case 15: {1041/* <= */10421043int32_t b = T0_POPi();1044int32_t a = T0_POPi();1045T0_PUSH(-(uint32_t)(a <= b));10461047}1048break;1049case 16: {1050/* <> */10511052uint32_t b = T0_POP();1053uint32_t a = T0_POP();1054T0_PUSH(-(uint32_t)(a != b));10551056}1057break;1058case 17: {1059/* = */10601061uint32_t b = T0_POP();1062uint32_t a = T0_POP();1063T0_PUSH(-(uint32_t)(a == b));10641065}1066break;1067case 18: {1068/* > */10691070int32_t b = T0_POPi();1071int32_t a = T0_POPi();1072T0_PUSH(-(uint32_t)(a > b));10731074}1075break;1076case 19: {1077/* >= */10781079int32_t b = T0_POPi();1080int32_t a = T0_POPi();1081T0_PUSH(-(uint32_t)(a >= b));10821083}1084break;1085case 20: {1086/* >> */10871088int c = (int)T0_POPi();1089int32_t x = T0_POPi();1090T0_PUSHi(x >> c);10911092}1093break;1094case 21: {1095/* and */10961097uint32_t b = T0_POP();1098uint32_t a = T0_POP();1099T0_PUSH(a & b);11001101}1102break;1103case 22: {1104/* blobcopy */11051106size_t len = T0_POP();1107unsigned char *src = (unsigned char *)CTX + T0_POP();1108unsigned char *dst = (unsigned char *)CTX + T0_POP();1109memcpy(dst, src, len);11101111}1112break;1113case 23: {1114/* check-direct-trust */11151116size_t u;11171118for (u = 0; u < CTX->trust_anchors_num; u ++) {1119const br_x509_trust_anchor *ta;1120unsigned char hashed_DN[64];1121int kt;11221123ta = &CTX->trust_anchors[u];1124if (ta->flags & BR_X509_TA_CA) {1125continue;1126}1127hash_dn(CTX, ta->dn.data, ta->dn.len, hashed_DN);1128if (memcmp(hashed_DN, CTX->current_dn_hash, DNHASH_LEN)) {1129continue;1130}1131kt = CTX->pkey.key_type;1132if ((ta->pkey.key_type & 0x0F) != kt) {1133continue;1134}1135switch (kt) {11361137case BR_KEYTYPE_RSA:1138if (!eqbigint(CTX->pkey.key.rsa.n,1139CTX->pkey.key.rsa.nlen,1140ta->pkey.key.rsa.n,1141ta->pkey.key.rsa.nlen)1142|| !eqbigint(CTX->pkey.key.rsa.e,1143CTX->pkey.key.rsa.elen,1144ta->pkey.key.rsa.e,1145ta->pkey.key.rsa.elen))1146{1147continue;1148}1149break;11501151case BR_KEYTYPE_EC:1152if (CTX->pkey.key.ec.curve != ta->pkey.key.ec.curve1153|| CTX->pkey.key.ec.qlen != ta->pkey.key.ec.qlen1154|| memcmp(CTX->pkey.key.ec.q,1155ta->pkey.key.ec.q,1156ta->pkey.key.ec.qlen) != 0)1157{1158continue;1159}1160break;11611162default:1163continue;1164}11651166/*1167* Direct trust match!1168*/1169CTX->err = BR_ERR_X509_OK;1170T0_CO();1171}11721173}1174break;1175case 24: {1176/* check-trust-anchor-CA */11771178size_t u;11791180for (u = 0; u < CTX->trust_anchors_num; u ++) {1181const br_x509_trust_anchor *ta;1182unsigned char hashed_DN[64];11831184ta = &CTX->trust_anchors[u];1185if (!(ta->flags & BR_X509_TA_CA)) {1186continue;1187}1188hash_dn(CTX, ta->dn.data, ta->dn.len, hashed_DN);1189if (memcmp(hashed_DN, CTX->saved_dn_hash, DNHASH_LEN)) {1190continue;1191}1192if (verify_signature(CTX, &ta->pkey) == 0) {1193CTX->err = BR_ERR_X509_OK;1194T0_CO();1195}1196}11971198}1199break;1200case 25: {1201/* check-validity-range */12021203uint32_t nbs = T0_POP();1204uint32_t nbd = T0_POP();1205uint32_t nas = T0_POP();1206uint32_t nad = T0_POP();1207int r;1208if (CTX->itime != 0) {1209r = CTX->itime(CTX->itime_ctx, nbd, nbs, nad, nas);1210if (r < -1 || r > 1) {1211CTX->err = BR_ERR_X509_TIME_UNKNOWN;1212T0_CO();1213}1214} else {1215uint32_t vd = CTX->days;1216uint32_t vs = CTX->seconds;1217if (vd == 0 && vs == 0) {1218#if BR_USE_UNIX_TIME1219time_t x = time(NULL);12201221vd = (uint32_t)(x / 86400) + 719528;1222vs = (uint32_t)(x % 86400);1223#elif BR_USE_WIN32_TIME1224FILETIME ft;1225uint64_t x;12261227GetSystemTimeAsFileTime(&ft);1228x = ((uint64_t)ft.dwHighDateTime << 32)1229+ (uint64_t)ft.dwLowDateTime;1230x = (x / 10000000);1231vd = (uint32_t)(x / 86400) + 584754;1232vs = (uint32_t)(x % 86400);1233#else1234CTX->err = BR_ERR_X509_TIME_UNKNOWN;1235T0_CO();1236#endif1237}1238if (vd < nbd || (vd == nbd && vs < nbs)) {1239r = -1;1240} else if (vd > nad || (vd == nad && vs > nas)) {1241r = 1;1242} else {1243r = 0;1244}1245}1246T0_PUSHi(r);12471248}1249break;1250case 26: {1251/* co */1252T0_CO();1253}1254break;1255case 27: {1256/* compute-dn-hash */12571258CTX->dn_hash_impl->out(&CTX->dn_hash.vtable, CTX->current_dn_hash);1259CTX->do_dn_hash = 0;12601261}1262break;1263case 28: {1264/* compute-tbs-hash */12651266int id = T0_POPi();1267size_t len;1268len = br_multihash_out(&CTX->mhash, id, CTX->tbs_hash);1269T0_PUSH(len);12701271}1272break;1273case 29: {1274/* copy-ee-ec-pkey */12751276size_t qlen = T0_POP();1277uint32_t curve = T0_POP();1278memcpy(CTX->ee_pkey_data, CTX->pkey_data, qlen);1279CTX->pkey.key_type = BR_KEYTYPE_EC;1280CTX->pkey.key.ec.curve = curve;1281CTX->pkey.key.ec.q = CTX->ee_pkey_data;1282CTX->pkey.key.ec.qlen = qlen;12831284}1285break;1286case 30: {1287/* copy-ee-rsa-pkey */12881289size_t elen = T0_POP();1290size_t nlen = T0_POP();1291memcpy(CTX->ee_pkey_data, CTX->pkey_data, nlen + elen);1292CTX->pkey.key_type = BR_KEYTYPE_RSA;1293CTX->pkey.key.rsa.n = CTX->ee_pkey_data;1294CTX->pkey.key.rsa.nlen = nlen;1295CTX->pkey.key.rsa.e = CTX->ee_pkey_data + nlen;1296CTX->pkey.key.rsa.elen = elen;12971298}1299break;1300case 31: {1301/* copy-name-SAN */13021303unsigned tag = T0_POP();1304unsigned ok = T0_POP();1305size_t u, len;13061307len = CTX->pad[0];1308for (u = 0; u < CTX->num_name_elts; u ++) {1309br_name_element *ne;13101311ne = &CTX->name_elts[u];1312if (ne->status == 0 && ne->oid[0] == 0 && ne->oid[1] == tag) {1313if (ok && ne->len > len) {1314memcpy(ne->buf, CTX->pad + 1, len);1315ne->buf[len] = 0;1316ne->status = 1;1317} else {1318ne->status = -1;1319}1320break;1321}1322}13231324}1325break;1326case 32: {1327/* copy-name-element */13281329size_t len;1330int32_t off = T0_POPi();1331int ok = T0_POPi();13321333if (off >= 0) {1334br_name_element *ne = &CTX->name_elts[off];13351336if (ok) {1337len = CTX->pad[0];1338if (len < ne->len) {1339memcpy(ne->buf, CTX->pad + 1, len);1340ne->buf[len] = 0;1341ne->status = 1;1342} else {1343ne->status = -1;1344}1345} else {1346ne->status = -1;1347}1348}13491350}1351break;1352case 33: {1353/* data-get8 */13541355size_t addr = T0_POP();1356T0_PUSH(t0_datablock[addr]);13571358}1359break;1360case 34: {1361/* dn-hash-length */13621363T0_PUSH(DNHASH_LEN);13641365}1366break;1367case 35: {1368/* do-ecdsa-vrfy */13691370size_t qlen = T0_POP();1371int curve = T0_POP();1372br_x509_pkey pk;13731374pk.key_type = BR_KEYTYPE_EC;1375pk.key.ec.curve = curve;1376pk.key.ec.q = CTX->pkey_data;1377pk.key.ec.qlen = qlen;1378T0_PUSH(verify_signature(CTX, &pk));13791380}1381break;1382case 36: {1383/* do-rsa-vrfy */13841385size_t elen = T0_POP();1386size_t nlen = T0_POP();1387br_x509_pkey pk;13881389pk.key_type = BR_KEYTYPE_RSA;1390pk.key.rsa.n = CTX->pkey_data;1391pk.key.rsa.nlen = nlen;1392pk.key.rsa.e = CTX->pkey_data + nlen;1393pk.key.rsa.elen = elen;1394T0_PUSH(verify_signature(CTX, &pk));13951396}1397break;1398case 37: {1399/* drop */1400(void)T0_POP();1401}1402break;1403case 38: {1404/* dup */1405T0_PUSH(T0_PEEK(0));1406}1407break;1408case 39: {1409/* eqOID */14101411const unsigned char *a2 = &t0_datablock[T0_POP()];1412const unsigned char *a1 = &CTX->pad[0];1413size_t len = a1[0];1414int x;1415if (len == a2[0]) {1416x = -(memcmp(a1 + 1, a2 + 1, len) == 0);1417} else {1418x = 0;1419}1420T0_PUSH((uint32_t)x);14211422}1423break;1424case 40: {1425/* eqblob */14261427size_t len = T0_POP();1428const unsigned char *a2 = (const unsigned char *)CTX + T0_POP();1429const unsigned char *a1 = (const unsigned char *)CTX + T0_POP();1430T0_PUSHi(-(memcmp(a1, a2, len) == 0));14311432}1433break;1434case 41: {1435/* fail */14361437CTX->err = T0_POPi();1438T0_CO();14391440}1441break;1442case 42: {1443/* get16 */14441445uint32_t addr = T0_POP();1446T0_PUSH(*(uint16_t *)(void *)((unsigned char *)CTX + addr));14471448}1449break;1450case 43: {1451/* get32 */14521453uint32_t addr = T0_POP();1454T0_PUSH(*(uint32_t *)(void *)((unsigned char *)CTX + addr));14551456}1457break;1458case 44: {1459/* match-server-name */14601461size_t n1, n2;14621463if (CTX->server_name == NULL) {1464T0_PUSH(0);1465T0_RET();1466}1467n1 = strlen(CTX->server_name);1468n2 = CTX->pad[0];1469if (n1 == n2 && eqnocase(&CTX->pad[1], CTX->server_name, n1)) {1470T0_PUSHi(-1);1471T0_RET();1472}1473if (n2 >= 2 && CTX->pad[1] == '*' && CTX->pad[2] == '.') {1474size_t u;14751476u = 0;1477while (u < n1 && CTX->server_name[u] != '.') {1478u ++;1479}1480u ++;1481n1 -= u;1482if ((n2 - 2) == n11483&& eqnocase(&CTX->pad[3], CTX->server_name + u, n1))1484{1485T0_PUSHi(-1);1486T0_RET();1487}1488}1489T0_PUSH(0);14901491}1492break;1493case 45: {1494/* neg */14951496uint32_t a = T0_POP();1497T0_PUSH(-a);14981499}1500break;1501case 46: {1502/* offset-name-element */15031504unsigned san = T0_POP();1505size_t u;15061507for (u = 0; u < CTX->num_name_elts; u ++) {1508if (CTX->name_elts[u].status == 0) {1509const unsigned char *oid;1510size_t len, off;15111512oid = CTX->name_elts[u].oid;1513if (san) {1514if (oid[0] != 0 || oid[1] != 0) {1515continue;1516}1517off = 2;1518} else {1519off = 0;1520}1521len = oid[off];1522if (len != 0 && len == CTX->pad[0]1523&& memcmp(oid + off + 1,1524CTX->pad + 1, len) == 0)1525{1526T0_PUSH(u);1527T0_RET();1528}1529}1530}1531T0_PUSHi(-1);15321533}1534break;1535case 47: {1536/* or */15371538uint32_t b = T0_POP();1539uint32_t a = T0_POP();1540T0_PUSH(a | b);15411542}1543break;1544case 48: {1545/* over */1546T0_PUSH(T0_PEEK(1));1547}1548break;1549case 49: {1550/* read-blob-inner */15511552uint32_t len = T0_POP();1553uint32_t addr = T0_POP();1554size_t clen = CTX->hlen;1555if (clen > len) {1556clen = (size_t)len;1557}1558if (addr != 0) {1559memcpy((unsigned char *)CTX + addr, CTX->hbuf, clen);1560}1561if (CTX->do_mhash) {1562br_multihash_update(&CTX->mhash, CTX->hbuf, clen);1563}1564if (CTX->do_dn_hash) {1565CTX->dn_hash_impl->update(1566&CTX->dn_hash.vtable, CTX->hbuf, clen);1567}1568CTX->hbuf += clen;1569CTX->hlen -= clen;1570T0_PUSH(addr + clen);1571T0_PUSH(len - clen);15721573}1574break;1575case 50: {1576/* read8-low */15771578if (CTX->hlen == 0) {1579T0_PUSHi(-1);1580} else {1581unsigned char x = *CTX->hbuf ++;1582if (CTX->do_mhash) {1583br_multihash_update(&CTX->mhash, &x, 1);1584}1585if (CTX->do_dn_hash) {1586CTX->dn_hash_impl->update(&CTX->dn_hash.vtable, &x, 1);1587}1588CTX->hlen --;1589T0_PUSH(x);1590}15911592}1593break;1594case 51: {1595/* rot */1596T0_ROT();1597}1598break;1599case 52: {1600/* set16 */16011602uint32_t addr = T0_POP();1603*(uint16_t *)(void *)((unsigned char *)CTX + addr) = T0_POP();16041605}1606break;1607case 53: {1608/* set32 */16091610uint32_t addr = T0_POP();1611*(uint32_t *)(void *)((unsigned char *)CTX + addr) = T0_POP();16121613}1614break;1615case 54: {1616/* set8 */16171618uint32_t addr = T0_POP();1619*((unsigned char *)CTX + addr) = (unsigned char)T0_POP();16201621}1622break;1623case 55: {1624/* start-dn-hash */16251626CTX->dn_hash_impl->init(&CTX->dn_hash.vtable);1627CTX->do_dn_hash = 1;16281629}1630break;1631case 56: {1632/* start-tbs-hash */16331634br_multihash_init(&CTX->mhash);1635CTX->do_mhash = 1;16361637}1638break;1639case 57: {1640/* stop-tbs-hash */16411642CTX->do_mhash = 0;16431644}1645break;1646case 58: {1647/* swap */1648T0_SWAP();1649}1650break;1651case 59: {1652/* zero-server-name */16531654T0_PUSHi(-(CTX->server_name == NULL));16551656}1657break;1658}16591660} else {1661T0_ENTER(ip, rp, t0x);1662}1663}1664t0_exit:1665((t0_context *)t0ctx)->dp = dp;1666((t0_context *)t0ctx)->rp = rp;1667((t0_context *)t0ctx)->ip = ip;1668}1669167016711672/*1673* Verify the signature on the certificate with the provided public key.1674* This function checks the public key type with regards to the expected1675* type. Returned value is either 0 on success, or a non-zero error code.1676*/1677static int1678verify_signature(br_x509_minimal_context *ctx, const br_x509_pkey *pk)1679{1680int kt;16811682kt = ctx->cert_signer_key_type;1683if ((pk->key_type & 0x0F) != kt) {1684return BR_ERR_X509_WRONG_KEY_TYPE;1685}1686switch (kt) {1687unsigned char tmp[64];16881689case BR_KEYTYPE_RSA:1690if (ctx->irsa == 0) {1691return BR_ERR_X509_UNSUPPORTED;1692}1693if (!ctx->irsa(ctx->cert_sig, ctx->cert_sig_len,1694&t0_datablock[ctx->cert_sig_hash_oid],1695ctx->cert_sig_hash_len, &pk->key.rsa, tmp))1696{1697return BR_ERR_X509_BAD_SIGNATURE;1698}1699if (memcmp(ctx->tbs_hash, tmp, ctx->cert_sig_hash_len) != 0) {1700return BR_ERR_X509_BAD_SIGNATURE;1701}1702return 0;17031704case BR_KEYTYPE_EC:1705if (ctx->iecdsa == 0) {1706return BR_ERR_X509_UNSUPPORTED;1707}1708if (!ctx->iecdsa(ctx->iec, ctx->tbs_hash,1709ctx->cert_sig_hash_len, &pk->key.ec,1710ctx->cert_sig, ctx->cert_sig_len))1711{1712return BR_ERR_X509_BAD_SIGNATURE;1713}1714return 0;17151716default:1717return BR_ERR_X509_UNSUPPORTED;1718}1719}17201721172217231724