OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
libDER_config.h
Go to the documentation of this file.
1/* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */
2
3/*
4 * libDER_config.h - platform dependent #defines and typedefs for libDER
5 *
6 * Created Nov. 4 2005 by dmitch
7 */
8
9#ifndef _LIB_DER_CONFIG_H_
10#define _LIB_DER_CONFIG_H_
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16//
17// edk2 porting - start
18//
19#include <Base.h>
20#include <Library/BaseMemoryLib.h>
21#include <Library/DebugLib.h>
22
23#ifndef EFIUSER
24typedef UINT8 uint8_t;
25typedef UINT16 uint16_t;
26typedef UINT32 uint32_t;
27typedef UINT64 uint64_t;
28typedef UINTN size_t;
29
30#ifndef bool
31typedef BOOLEAN bool;
32#endif /* bool */
33
34#ifndef assert
35#define assert ASSERT
36#endif /* assert */
37
38#define memset(ptr, c, len) SetMem(ptr, len, c)
39#define memmove(dst, src, len) CopyMem(dst, src, len)
40#define memcmp(b1, b2, len) CompareMem(b1, b2, len)
41
42#else /* EFIUSER */
43#include <stdio.h>
44#include <stdint.h>
45#include <stdbool.h>
46#include <string.h>
47#include <assert.h>
48#endif /* !EFIUSER */
49
50#define DER_ENCODE_ENABLE 0
51
52#define DER_TAG_SIZE 8
53//
54// edk2 porting - end
55//
56
57/*
58 * Basic data types: unsigned 8-bit integer, unsigned 32-bit integer
59 */
62typedef size_t DERSize;
63
64/*
65 * Use these #defines of you have memset, memmove, and memcmp; else
66 * write your own equivalents.
67 */
68
69#define DERMemset(ptr, c, len) memset(ptr, c, len)
70#define DERMemmove(dst, src, len) memmove(dst, src, len)
71#define DERMemcmp(b1, b2, len) memcmp(b1, b2, len)
72
73
74/***
75 *** Compile time options to trim size of the library.
76 ***/
77
78// CHANGE: conditionally define
79/* enable general DER encode */
80#ifndef DER_ENCODE_ENABLE
81#define DER_ENCODE_ENABLE 1
82#endif
83
84#ifndef DER_MULTIBYTE_TAGS
85/* enable general DER decode */
86#define DER_DECODE_ENABLE 1
87#endif
88
89#ifndef DER_MULTIBYTE_TAGS
90/* enable multibyte tag support. */
91#define DER_MULTIBYTE_TAGS 1
92#endif
93
94#ifndef DER_TAG_SIZE
95/* Iff DER_MULTIBYTE_TAGS is 1 this is the sizeof(DERTag) in bytes. Note that
96 tags are still encoded and decoded from a minimally encoded DER
97 represantation. This value determines how big each DERItemSpecs is, we
98 choose 2 since that makes DERItemSpecs 8 bytes wide. */
99#define DER_TAG_SIZE 2
100#endif
101
102
103/* ---------------------- Do not edit below this line ---------------------- */
104
105/*
106 * Logical representation of a tag (the encoded representation is always in
107 * the minimal number of bytes). The top 3 bits encode class and method
108 * The remaining bits encode the tag value. To obtain smaller DERItemSpecs
109 * sizes, choose the smallest type that fits your needs. Most standard ASN.1
110 * usage only needs single byte tags, but ocasionally custom applications
111 * require a larger tag namespace.
112 */
113#if DER_MULTIBYTE_TAGS
114
115#if DER_TAG_SIZE == 1
116typedef uint8_t DERTag;
117#elif DER_TAG_SIZE == 2
118typedef uint16_t DERTag;
119#elif DER_TAG_SIZE == 4
120typedef uint32_t DERTag;
121#elif DER_TAG_SIZE == 8
123#else
124#error DER_TAG_SIZE invalid
125#endif
126
127#else /* DER_MULTIBYTE_TAGS */
128typedef DERByte DERTag;
129#endif /* !DER_MULTIBYTE_TAGS */
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* _LIB_DER_CONFIG_H_ */
size_t DERSize
uint16_t DERShort
UINTN size_t
uint64_t DERTag
UINT8 uint8_t
BOOLEAN bool
UINT16 uint16_t
uint8_t DERByte
UINT32 uint32_t
UINT64 uint64_t