Security-57337.40.85.tar.gz
[apple/security.git] / SecurityTests / cspxutils / hashTimeLibCrypt / pbkdDigest.h
CommitLineData
b1ab9ed8 1/*
d8f41ccd 2 * Copyright (c) 2003-2005 Apple Computer, Inc. All Rights Reserved.
b1ab9ed8
A
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/*
d8f41ccd 19 * pbkdDigest.h - SHA1/MD5 digest object
b1ab9ed8
A
20 */
21
22#ifndef _PBKD_DIGEST_H_
23#define _PBKD_DIGEST_H_
24
25#include <Security/cssmtype.h>
d8f41ccd
A
26#include <openssl/md5.h>
27#include <openssl/sha.h>
b1ab9ed8
A
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
d8f41ccd
A
33#define kSHA1DigestSize SHA_DIGEST_LENGTH
34#define kSHA1BlockSize SHA_CBLOCK
b1ab9ed8 35
d8f41ccd
A
36#define kMD5DigestSize MD5_DIGEST_LENGTH
37#define kMD5BlockSize MD5_CBLOCK
b1ab9ed8
A
38
39typedef int (*DigestInitFcn)(void *ctx);
40typedef int (*DigestUpdateFcn)(void *ctx, const void *data, unsigned long len);
41typedef int (*DigestFinalFcn)(void *md, void *c);
42
d8f41ccd 43/* callouts to libcrypt */
b1ab9ed8
A
44typedef struct {
45 DigestInitFcn init;
46 DigestUpdateFcn update;
47 DigestFinalFcn final;
48} DigestOps;
49
50typedef struct {
51 union {
d8f41ccd
A
52 SHA_CTX sha1Context;
53 MD5_CTX md5Context;
b1ab9ed8
A
54 } dig;
55 DigestOps *ops;
d8f41ccd 56 CSSM_BOOL isSha1;
b1ab9ed8
A
57} DigestCtx;
58
d8f41ccd 59/* Ops on a DigestCtx */
b1ab9ed8 60int DigestCtxInit(
d8f41ccd
A
61 DigestCtx *ctx,
62 CSSM_BOOL isSha1);
b1ab9ed8
A
63void DigestCtxFree(
64 DigestCtx *ctx);
65int DigestCtxUpdate(
66 DigestCtx *ctx,
67 const void *textPtr,
68 uint32 textLen);
69int DigestCtxFinal(
70 DigestCtx *ctx,
71 void *digest);
72
73#ifdef __cplusplus
74}
75#endif
76
77#endif /* _PBKD_DIGEST_H_ */
78