]>
git.saurik.com Git - apple/security.git/blob - libsecurity_apple_csp/lib/pbkdDigest.cpp
2 * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
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.
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.
19 * pbkdDigest.cpp - SHA1/MD5 digest object for HMAC and PBE routines
22 #include "pbkdDigest.h"
23 #include <Security/cssmerr.h>
26 /* the casts are necessary to cover the polymorphous context types */
28 (DigestInitFcn
)CC_MD2_Init
,
29 (DigestUpdateFcn
)CC_MD2_Update
,
30 (DigestFinalFcn
)CC_MD2_Final
33 (DigestInitFcn
)CC_MD5_Init
,
34 (DigestUpdateFcn
)CC_MD5_Update
,
35 (DigestFinalFcn
)CC_MD5_Final
38 (DigestInitFcn
)CC_SHA1_Init
,
39 (DigestUpdateFcn
)CC_SHA1_Update
,
40 (DigestFinalFcn
)CC_SHA1_Final
43 /* Ops on a DigestCtx - all return zero on error, like the underlying digests do */
46 CSSM_ALGORITHMS hashAlg
)
61 ctx
->hashAlg
= hashAlg
;
62 return ctx
->ops
->init(&ctx
->dig
);
68 memset(ctx
, 0, sizeof(DigestCtx
));
76 return ctx
->ops
->update(&ctx
->dig
, textPtr
, textLen
);
83 return ctx
->ops
->final(digest
, &ctx
->dig
);