]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/libDER/libDER/DER_Digest.h
68503a35bfccf996a0facc23472622d61d0fb2a9
2 * Copyright (c) 2005-2008,2010-2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 * DER_Digest.h - DER encode a DigestInfo
30 #ifndef _DER_DIGEST_H_
31 #define _DER_DIGEST_H_
37 #include <libDER/libDER.h>
40 * Create an encoded DigestInfo based on the specified SHA1 digest.
41 * The incoming digest must be 20 bytes long.
43 * Result is placed in caller's buffer, which must be at least of
44 * length DER_SHA1_DIGEST_INFO_LEN bytes.
46 * The *resultLen parameter is the available size in the result
47 * buffer on input, and the actual length of the encoded DigestInfo
50 #define DER_SHA1_DIGEST_LEN 20
51 #define DER_SHA1_DIGEST_INFO_LEN 35
53 DERReturn
DEREncodeSHA1DigestInfo(
54 const DERByte
*sha1Digest
,
55 DERSize sha1DigestLen
,
56 DERByte
*result
, /* encoded result RETURNED here */
57 DERSize
*resultLen
); /* IN/OUT */
59 #define DER_SHA256_DIGEST_LEN 32
60 #define DER_SHA256_DIGEST_INFO_LEN 51
62 DERReturn
DEREncodeSHA256DigestInfo(
63 const DERByte
*sha256Digest
,
64 DERSize sha256DigestLen
,
65 DERByte
*result
, /* encoded result RETURNED here */
66 DERSize
*resultLen
); /* IN/OUT */
69 * Likewise, create an encoded DIgestInfo for specified MD5 or MD2 digest.
71 #define DER_MD_DIGEST_LEN 16
72 #define DER_MD_DIGEST_INFO_LEN 34
79 DERReturn
DEREncodeMDDigestInfo(
80 WhichDigest whichDigest
,
81 const DERByte
*mdDigest
,
83 DERByte
*result
, /* encoded result RETURNED here */
84 DERSize
*resultLen
); /* IN/OUT */
86 /* max sizes you'll need in the general cases */
87 #define DER_MAX_DIGEST_LEN DER_SHA256_DIGEST_LEN
88 #define DER_MAX_ENCODED_INFO_LEN DER_SHA256_DIGEST_INFO_LEN
94 #endif /* _DER_DIGEST_H_ */