]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/clAppUtils/CertBuilderApp.h
Security-57031.10.10.tar.gz
[apple/security.git] / SecurityTests / clxutils / clAppUtils / CertBuilderApp.h
1 /*
2 * CertBuilderApp.cpp - support for constructing certs, CDSA version
3 */
4
5 #ifndef _CERT_BUILDER_APP_H_
6 #define _CERT_BUILDER_APP_H_
7
8 #include <Security/cssm.h>
9 #include <Security/x509defs.h>
10 #include <time.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /*
17 * Name/OID pair used in CB_BuildX509Name
18 */
19 typedef struct {
20 const char *string;
21 const CSSM_OID *oid;
22 } CB_NameOid;
23
24 /*
25 * Build up a CSSM_X509_NAME from an arbitrary list of name/OID pairs.
26 * We do one a/v pair per RDN.
27 */
28 CSSM_X509_NAME *CB_BuildX509Name(
29 const CB_NameOid *nameArray,
30 unsigned numNames);
31
32 /* free the CSSM_X509_NAME obtained from CB_BuildX509Name */
33 void CB_FreeX509Name(
34 CSSM_X509_NAME *top);
35
36 /* Obtain a CSSM_X509_TIME representing "now" plus specified seconds, or
37 * from a preformatted gen time string */
38 CSSM_X509_TIME *CB_BuildX509Time(
39 unsigned secondsFromNow, /* ignored if timeStr non-NULL */
40 const char *timeStr=NULL); /* optional, from genTimeAtNowPlus */
41
42 /* Free CSSM_X509_TIME obtained in CB_BuildX509Time */
43 void CB_FreeX509Time(
44 CSSM_X509_TIME *xtime);
45
46 CSSM_DATA_PTR CB_MakeCertTemplate(
47 /* required */
48 CSSM_CL_HANDLE clHand,
49 uint32 serialNumber,
50 const CSSM_X509_NAME *issuerName,
51 const CSSM_X509_NAME *subjectName,
52 const CSSM_X509_TIME *notBefore,
53 const CSSM_X509_TIME *notAfter,
54 const CSSM_KEY_PTR subjectPubKey,
55 CSSM_ALGORITHMS sigAlg, // e.g., CSSM_ALGID_SHA1WithRSA
56 /* optional */
57 const CSSM_DATA *subjectUniqueId,
58 const CSSM_DATA *issuerUniqueId,
59 CSSM_X509_EXTENSION *extensions,
60 unsigned numExtensions);
61
62 #ifdef __cplusplus
63 }
64 #endif
65 #endif /* _CERT_BUILDER_APP_H_ */