]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/certTime/extenCooker.h
Security-57031.10.10.tar.gz
[apple/security.git] / SecurityTests / clxutils / certTime / extenCooker.h
1 /*
2 * extenCooker.h - module to cook up random (but reasonable)
3 * versions of cert extensions
4 */
5
6
7 #ifndef _EXTEN_COOKER_H_
8 #define _EXTEN_COOKER_H_
9
10 #include <Security/cssmtype.h>
11 #include <Security/x509defs.h>
12 #include <Security/cssmapple.h>
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /*
19 * Define one extension test.
20 */
21
22 /*
23 * Cook up this extension with random, reasonable values.
24 * Incoming pointer refers to extension-specific C struct, mallocd
25 * and zeroed by main test routine.
26 */
27 typedef void (*extenCreateFcn)(void *arg);
28
29 /*
30 * Compare two instances of this extension. Return number of
31 * compare errors.
32 */
33 typedef unsigned (*extenCompareFcn)(
34 const void *preEncode,
35 const void *postEncode);
36
37 /*
38 * Free struct components mallocd in extenCreateFcn. Do not free
39 * the outer struct.
40 */
41 typedef void (*extenFreeFcn)(void *arg);
42
43 typedef struct {
44 /* three extension-specific functions */
45 extenCreateFcn createFcn;
46 extenCompareFcn compareFcn;
47 extenFreeFcn freeFcn;
48
49 /* size of C struct passed to all three functions */
50 unsigned extenSize;
51
52 /* the OID for this extension */
53 CSSM_OID extenOid;
54
55 /* description for error logging and blob writing */
56 const char *extenDescr;
57
58 /* command-line letter for this one */
59 char extenLetter;
60
61 } ExtenTest;
62
63 /*
64 * extenCooker.cpp - module to cook up random (but reasonable)
65 * versions of cert extensions
66 */
67
68 #include <stdio.h>
69 #include <stdlib.h>
70 #include "extenCooker.h"
71
72 CSSM_BOOL randBool();
73
74 /* Fill a CSSM_DATA with random data. Its referent is allocd with malloc. */
75 void randData(
76 CSSM_DATA_PTR data,
77 uint8 maxLen);
78
79
80 /*
81 * Various compare tests
82 */
83 int compBool(
84 CSSM_BOOL pre,
85 CSSM_BOOL post,
86 char *desc);
87
88
89 int compCssmData(
90 CSSM_DATA &d1,
91 CSSM_DATA &d2,
92 char *desc);
93
94
95 #pragma mark --- CE_KeyUsage ---
96 void kuCreate(void *arg);
97 unsigned kuCompare(const void *pre, const void *post);
98 /* no free */
99
100 #pragma mark --- CE_BasicConstraints ---
101 void bcCreate(void *arg);
102 unsigned bcCompare(const void *pre, const void *post);
103 /* no free */
104
105 #pragma mark --- CE_SubjectKeyID ---
106 void skidCreate(void *arg);
107 unsigned skidCompare(const void *pre, const void *post);
108 void skidFree(void *arg);
109
110 #pragma mark --- CE_NetscapeCertType ---
111 void nctCreate(void *arg);
112 unsigned nctCompare(const void *pre, const void *post);
113 /* no free */
114
115 #pragma mark --- CE_ExtendedKeyUsage ---
116 void ekuCreate(void *arg);
117 unsigned ekuCompare(const void *pre, const void *post);
118 /* no free */
119
120 #pragma mark --- general purpose X509 name generator ---
121 void rdnCreate(
122 CSSM_X509_RDN_PTR rdn);
123 unsigned rdnCompare(
124 CSSM_X509_RDN_PTR rdn1,
125 CSSM_X509_RDN_PTR rdn2);
126 void rdnFree(
127 CSSM_X509_RDN_PTR rdn);
128
129 void x509NameCreate(
130 CSSM_X509_NAME_PTR x509Name);
131 unsigned x509NameCompare(
132 const CSSM_X509_NAME_PTR n1,
133 const CSSM_X509_NAME_PTR n2);
134 void x509NameFree(
135 CSSM_X509_NAME_PTR n);
136
137 #pragma mark --- general purpose GeneralNames generator ---
138
139 void genNamesCreate(void *arg);
140 unsigned genNamesCompare(const void *pre, const void *post);
141 void genNamesFree(void *arg);
142
143 #pragma mark --- CE_CRLDistPointsSyntax ---
144 void cdpCreate(void *arg);
145 unsigned cdpCompare(const void *pre, const void *post);
146 void cdpFree(void *arg);
147
148 #pragma mark --- CE_AuthorityKeyID ---
149 void authKeyIdCreate(void *arg);
150 unsigned authKeyIdCompare(const void *pre, const void *post);
151 void authKeyIdFree(void *arg);
152
153 #pragma mark --- CE_CertPolicies ---
154 void cpCreate(void *arg);
155 unsigned cpCompare(const void *pre, const void *post);
156 void cpFree(void *arg);
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162 #endif /* _EXTEN_COOKER_H_ */