]> git.saurik.com Git - apple/security.git/blob - libsecurity_ocspd/common/ocspdUtils.h
Security-55179.13.tar.gz
[apple/security.git] / libsecurity_ocspd / common / ocspdUtils.h
1 /*
2 * Copyright (c) 2002,2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 /*
24 * ocspUtils.h - common utilities for OCSPD
25 */
26 #ifndef _OCSPD_UTILS_H_
27 #define _OCSPD_UTILS_H_
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #include <CommonCrypto/CommonDigest.h>
34 #include <Security/cssmtype.h>
35 #include <CoreFoundation/CoreFoundation.h>
36
37 /*
38 * Compare two CSSM_DATAs, return CSSM_TRUE if identical.
39 */
40 CSSM_BOOL ocspdCompareCssmData(
41 const CSSM_DATA *data1,
42 const CSSM_DATA *data2);
43
44 /*
45 * Parse a GeneralizedTime string into a CFAbsoluteTime. Returns NULL_TIME on
46 * parse error. Fractional parts of a second are discarded.
47 */
48 #define NULL_TIME 0.0
49
50 CFAbsoluteTime genTimeToCFAbsTime(
51 const CSSM_DATA *strData);
52
53 /*
54 * Convert CFAbsoluteTime to generalized time string, GMT format (4 digit year,
55 * trailing 'Z'). Caller allocated the output which is GENERAL_TIME_STRLEN bytes plus
56 * a NULL.
57 */
58 #define GENERAL_TIME_STRLEN 15 /* NOT including trailing NULL */
59
60 void cfAbsTimeToGgenTime(
61 CFAbsoluteTime absTime,
62 char *genTime);
63
64 #define OCSPD_MAX_DIGEST_LEN CC_SHA256_DIGEST_LENGTH
65
66 void ocspdSha1(
67 const void *data,
68 CC_LONG len,
69 unsigned char *md); // allocd by caller, CC_SHA1_DIGEST_LENGTH bytes
70 void ocspdMD5(
71 const void *data,
72 CC_LONG len,
73 unsigned char *md); // allocd by caller, CC_MD5_DIGEST_LENGTH bytes
74 void ocspdMD4(
75 const void *data,
76 CC_LONG len,
77 unsigned char *md); // allocd by caller, CC_MD4_DIGEST_LENGTH bytes
78 void ocspdSHA256(
79 const void *data,
80 CC_LONG len,
81 unsigned char *md); // allocd by caller, CC_SHA256_DIGEST_LENGTH bytes
82
83 /*
84 * How many items in a NULL-terminated array of pointers?
85 */
86 unsigned ocspdArraySize(
87 const void **array);
88
89 #define CFRELEASE(cf) \
90 if(cf != NULL) { \
91 CFRelease(cf); \
92 }
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif /* _OCSPD_UTILS_H_ */