]>
Commit | Line | Data |
---|---|---|
b1ab9ed8 A |
1 | /* |
2 | * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved. | |
3 | * | |
4 | * The contents of this file constitute Original Code as defined in and are | |
5 | * subject to the Apple Public Source License Version 1.2 (the 'License'). | |
6 | * You may not use this file except in compliance with the License. Please | |
7 | * obtain a copy of the License at http://www.apple.com/publicsource and | |
8 | * read it before using this file. | |
9 | * | |
10 | * This Original Code and all software distributed under the License are | |
11 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
12 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
13 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
14 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
15 | * Please see the License for the specific language governing rights and | |
16 | * limitations under the License. | |
17 | */ | |
18 | /* | |
19 | * pbkdDigest.h - SHA1/MD5 digest object for HMAC and PBE routines | |
20 | */ | |
21 | ||
22 | #ifndef _PBKD_DIGEST_H_ | |
23 | #define _PBKD_DIGEST_H_ | |
24 | ||
25 | #include <Security/cssmtype.h> | |
26 | #include <CommonCrypto/CommonDigest.h> | |
27 | ||
28 | #ifdef __cplusplus | |
29 | extern "C" { | |
30 | #endif | |
31 | ||
32 | #define kSHA1DigestSize CC_SHA1_DIGEST_LENGTH | |
33 | #define kSHA1BlockSize CC_SHA1_BLOCK_BYTES | |
34 | ||
35 | #define kMD5DigestSize CC_MD5_DIGEST_LENGTH | |
36 | #define kMD5BlockSize CC_MD5_BLOCK_BYTES | |
37 | ||
38 | #define kMD2DigestSize CC_MD2_DIGEST_LENGTH | |
39 | #define kMD2BlockSize CC_MD2_BLOCK_BYTES | |
40 | ||
41 | #define kMaxDigestSize kSHA1DigestSize | |
42 | ||
43 | typedef int (*DigestInitFcn)(void *ctx); | |
44 | typedef int (*DigestUpdateFcn)(void *ctx, const void *data, unsigned long len); | |
45 | typedef int (*DigestFinalFcn)(void *md, void *c); | |
46 | ||
47 | /* callouts to eay/libmd implementations */ | |
48 | typedef struct { | |
49 | DigestInitFcn init; | |
50 | DigestUpdateFcn update; | |
51 | DigestFinalFcn final; | |
52 | } DigestOps; | |
53 | ||
54 | typedef struct { | |
55 | union { | |
56 | CC_SHA1_CTX sha1Context; | |
57 | CC_MD5_CTX md5Context; | |
58 | CC_MD2_CTX md2Context; | |
59 | } dig; | |
60 | DigestOps *ops; | |
61 | CSSM_ALGORITHMS hashAlg; | |
62 | } DigestCtx; | |
63 | ||
64 | /* Ops on a DigestCtx - all return zero on error, like the underlying digests do */ | |
65 | int DigestCtxInit( | |
66 | DigestCtx *ctx, | |
67 | CSSM_ALGORITHMS hashAlg); | |
68 | void DigestCtxFree( | |
69 | DigestCtx *ctx); | |
70 | int DigestCtxUpdate( | |
71 | DigestCtx *ctx, | |
72 | const void *textPtr, | |
73 | uint32 textLen); | |
74 | int DigestCtxFinal( | |
75 | DigestCtx *ctx, | |
76 | void *digest); | |
77 | ||
78 | #ifdef __cplusplus | |
79 | } | |
80 | #endif | |
81 | ||
82 | #endif /* _PBKD_DIGEST_H_ */ | |
83 |