]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/libDER/libDER/DER_Digest.h
734d752ca3c64625827b0c08b1d7e6df425f18aa
2 * Copyright (c) 2005-2016 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_
33 #include <libDER/libDER.h>
38 * Create an encoded DigestInfo based on the specified SHA1 digest.
39 * The incoming digest must be 20 bytes long.
41 * Result is placed in caller's buffer, which must be at least of
42 * length DER_SHA1_DIGEST_INFO_LEN bytes.
44 * The *resultLen parameter is the available size in the result
45 * buffer on input, and the actual length of the encoded DigestInfo
48 #define DER_SHA1_DIGEST_LEN 20
49 #define DER_SHA1_DIGEST_INFO_LEN 35
51 DERReturn
DEREncodeSHA1DigestInfo(
52 const DERByte
*sha1Digest
,
53 DERSize sha1DigestLen
,
54 DERByte
*result
, /* encoded result RETURNED here */
55 DERSize
*resultLen
); /* IN/OUT */
57 #define DER_SHA256_DIGEST_LEN 32
58 #define DER_SHA256_DIGEST_INFO_LEN 51
60 DERReturn
DEREncodeSHA256DigestInfo(
61 const DERByte
*sha256Digest
,
62 DERSize sha256DigestLen
,
63 DERByte
*result
, /* encoded result RETURNED here */
64 DERSize
*resultLen
); /* IN/OUT */
67 * Likewise, create an encoded DIgestInfo for specified MD5 or MD2 digest.
69 #define DER_MD_DIGEST_LEN 16
70 #define DER_MD_DIGEST_INFO_LEN 34
77 DERReturn
DEREncodeMDDigestInfo(
78 WhichDigest whichDigest
,
79 const DERByte
*mdDigest
,
81 DERByte
*result
, /* encoded result RETURNED here */
82 DERSize
*resultLen
); /* IN/OUT */
84 /* max sizes you'll need in the general cases */
85 #define DER_MAX_DIGEST_LEN DER_SHA256_DIGEST_LEN
86 #define DER_MAX_ENCODED_INFO_LEN DER_SHA256_DIGEST_INFO_LEN
90 #endif /* _DER_DIGEST_H_ */