]>
git.saurik.com Git - apple/security.git/blob - AppleCSP/RSA_DSA/RSA_DSA_utils.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.
22 #ifndef _RSA_DSA_UTILS_H_
23 #define _RSA_DSA_UTILS_H_
25 #include <openssl/rsa.h>
26 #include <openssl/dsa.h>
27 #include <AppleCSP/AppleCSPSession.h>
28 #include <Security/context.h>
38 * given an openssl-style error, throw appropriate CssmError.
45 * -- obtain CSSM key (there must only be one)
46 * -- validate keyClass
47 * -- validate keyUsage
48 * -- convert to RSA *, allocating the RSA key if necessary
51 const Context
&context
,
52 AppleCSPSession
&session
,
53 CSSM_KEYCLASS keyClass
, // CSSM_KEYCLASS_{PUBLIC,PRIVATE}_KEY
54 CSSM_KEYUSE usage
, // CSSM_KEYUSE_ENCRYPT, CSSM_KEYUSE_SIGN, etc.
55 bool &mallocdKey
); // RETURNED
58 * Convert a CssmKey to an RSA * key. May result in the creation of a new
59 * RSA (when cssmKey is a raw key); allocdKey is true in that case
60 * in which case the caller generally has to free the allocd key).
63 const CssmKey
&cssmKey
,
64 AppleCSPSession
&session
,
65 bool &allocdKey
); // RETURNED
68 * Convert a raw CssmKey to a newly alloc'd RSA *.
71 const CssmKey
&cssmKey
);
75 * -- obtain CSSM key (there must only be one)
76 * -- validate keyClass
77 * -- validate keyUsage
78 * -- convert to DSA *, allocating the DSA key if necessary
81 const Context
&context
,
82 AppleCSPSession
&session
,
83 CSSM_KEYCLASS keyClass
, // CSSM_KEYCLASS_{PUBLIC,PRIVATE}_KEY
84 CSSM_KEYUSE usage
, // CSSM_KEYUSE_ENCRYPT, CSSM_KEYUSE_SIGN, etc.
85 bool &mallocdKey
); // RETURNED
88 * Convert a CssmKey to an DSA * key. May result in the creation of a new
89 * DSA (when cssmKey is a raw key); allocdKey is true in that case
90 * in which case the caller generally has to free the allocd key).
93 const CssmKey
&cssmKey
,
94 AppleCSPSession
&session
,
95 bool &allocdKey
); // RETURNED
98 * Convert a raw CssmKey to a newly alloc'd DSA *.
100 DSA
*rawCssmKeyToDsa(
101 const CssmKey
&cssmKey
);
107 #endif /*_RSA_DSA_UTILS_H_ */