Debian Codegraph @

simulator/ms-tpm-20-ref/TPMCmd/tpm/include/X509.h

raw
1 /* Microsoft Reference Implementation for TPM 2.0
2 *
3 * The copyright in this software is being made available under the BSD License,
4 * included below. This software may be subject to other third party and
5 * contributor rights, including patent rights, and no such rights are granted
6 * under this license.
7 *
8 * Copyright (c) Microsoft Corporation
9 *
10 * All rights reserved.
11 *
12 * BSD License
13 *
14 * Redistribution and use in source and binary forms, with or without modification,
15 * are permitted provided that the following conditions are met:
16 *
17 * Redistributions of source code must retain the above copyright notice, this list
18 * of conditions and the following disclaimer.
19 *
20 * Redistributions in binary form must reproduce the above copyright notice, this
21 * list of conditions and the following disclaimer in the documentation and/or
22 * other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 //** Introduction
36 // This file contains the macro and structure definitions for the X509 commands and
37 // functions.
38
39 #ifndef _X509_H_
40 #define _X509_H_
41
42 //** Includes
43
44 #include "Tpm.h"
45 #include "TpmASN1.h"
46
47 //** Defined Constants
48
49 //*** X509 Application-specific types
50 #define X509_SELECTION 0xA0
51 #define X509_ISSUER_UNIQUE_ID 0xA1
52 #define X509_SUBJECT_UNIQUE_ID 0xA2
53 #define X509_EXTENSIONS 0xA3
54
55 // These defines give the order in which values appear in the TBScertificate
56 // of an x.509 certificate. These values are used to index into an array of
57 //
58 #define ENCODED_SIZE_REF 0
59 #define VERSION_REF (ENCODED_SIZE_REF + 1)
60 #define SERIAL_NUMBER_REF (VERSION_REF + 1)
61 #define SIGNATURE_REF (SERIAL_NUMBER_REF + 1)
62 #define ISSUER_REF (SIGNATURE_REF + 1)
63 #define VALIDITY_REF (ISSUER_REF + 1)
64 #define SUBJECT_KEY_REF (VALIDITY_REF + 1)
65 #define SUBJECT_PUBLIC_KEY_REF (SUBJECT_KEY_REF + 1)
66 #define EXTENSIONS_REF (SUBJECT_PUBLIC_KEY_REF + 1)
67 #define REF_COUNT (EXTENSIONS_REF + 1)
68
69 #undef MAKE_OID
70 #ifdef _X509_SPT_
71 # define MAKE_OID(NAME) \
72 const BYTE OID##NAME[] = {OID##NAME##_VALUE}
73 #else
74 # define MAKE_OID(NAME) \
75 extern const BYTE OID##NAME[]
76 #endif
77
78
79 //** Structures
80
81
82 // Used to access the fields of a TBSsignature some of which are in the in_CertifyX509
83 // structure and some of which are in the out_CertifyX509 structure.
84 typedef struct stringRef
85 {
86 BYTE *buf;
87 INT16 len;
88 } stringRef;
89
90
91 typedef union x509KeyUsageUnion {
92 TPMA_X509_KEY_USAGE x509;
93 UINT32 integer;
94 } x509KeyUsageUnion;
95
96
97 //** Global X509 Constants
98 // These values are instanced by X509_spt.c and referenced by other X509-related
99 // files.
100
101
102 // This is the DER-encoded value for the Key Usage OID (2.5.29.15). This is the
103 // full OID, not just the numeric value
104 #define OID_KEY_USAGE_EXTENSTION_VALUE 0x06, 0x03, 0x55, 0x1D, 0x0F
105 MAKE_OID(_KEY_USAGE_EXTENSTION);
106
107 // This is the DER-encoded value for the TCG-defined TPMA_OBJECT OID
108 // (2.23.133.10.1.1.1)
109 #define OID_TCG_TPMA_OBJECT_VALUE 0x06, 0x07, 0x67, 0x81, 0x05, 0x0a, 0x01, \
110 0x01, 0x01
111 MAKE_OID(_TCG_TPMA_OBJECT);
112
113 #ifdef _X509_SPT_
114 const x509KeyUsageUnion keyUsageSign = { TPMA_X509_KEY_USAGE_INITIALIZER(
115 /* digitalsignature */ 1, /* nonrepudiation */ 0,
116 /* keyencipherment */ 0, /* dataencipherment */ 0,
117 /* keyagreement */ 0, /* keycertsign */ 1,
118 /* crlsign */ 1, /* encipheronly */ 0,
119 /* decipheronly */ 0, /* bits_at_9 */ 0) };
120
121 const x509KeyUsageUnion keyUsageDecrypt = { TPMA_X509_KEY_USAGE_INITIALIZER(
122 /* digitalsignature */ 0, /* nonrepudiation */ 0,
123 /* keyencipherment */ 1, /* dataencipherment */ 1,
124 /* keyagreement */ 1, /* keycertsign */ 0,
125 /* crlsign */ 0, /* encipheronly */ 1,
126 /* decipheronly */ 1, /* bits_at_9 */ 0) };
127 #else
128 extern x509KeyUsageUnion keyUsageSign;
129 extern x509KeyUsageUnion keyUsageDecrypt;
130 #endif
131
132 #undef MAKE_OID
133
134 #endif // _X509_H_