]>
git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-lib/inc/cdsaUtils.h
2 * Copyright (c) 2000-2001 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 obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
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 EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 * cdsaUtils.h - utility functions for CDSA-related code
23 #ifndef _SNACC_CDSA_UTILS_H_
24 #define _SNACC_CDSA_UTILS_H_
26 #include <Security/asn-incl.h>
27 #include <Security/utilities.h>
28 #include <Security/cssmdata.h>
34 /* all decoding errors throw CSSMERR_CL_UNKNOWN_FORMAT */
36 /* malloc/copy AsnBits.bits -->CssmOwnedData */
37 void SC_asnBitsToCssmData(
39 CssmOwnedData
&oData
);
41 /* given DER-encoded bit string, decoded it and malloc/copy results
42 * back to a CssmOwnedData */
43 void SC_decodeAsnBitsToCssmData(
44 const CssmData encodedBits
,
45 CssmOwnedData
&oData
);
47 /* DER-decode any AsnType object */
49 const CssmData
&derEncoded
,
52 /* DER-encode any AsnType object. */
55 CssmOwnedData
&derEncoded
,
56 size_t maxEncodedSize
);
59 * Given a contentLength, obtain the length of the DER length encoding.
61 size_t SC_lengthOfLength(
65 * Encode a DER length field. Pass in the lengthOfLength if you've obtained
66 * it in a previous call to CL_lengthOfLength.
71 size_t lengthOfLength
= 0);
77 #endif /* _SNACC_CDSA_UTILS_H_ */