]> git.saurik.com Git - apple/security.git/blob - AppleCSP/DiffieHellman/DH_utils.h
Security-54.1.tar.gz
[apple/security.git] / AppleCSP / DiffieHellman / DH_utils.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19 /*
20 * DH_utils.h
21 */
22 #ifndef _DH_UTILS_H_
23 #define _DH_UTILS_H_
24
25 #include <openssl/dh.h>
26 #include <AppleCSP/AppleCSPSession.h>
27 #include <Security/context.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 void throwDh(
34 const char *op);
35
36 /*
37 * Given a Context:
38 * -- obtain CSSM key (there must only be one)
39 * -- validate keyClass - MUST be private! (DH public keys are never found
40 * in contexts.)
41 * -- validate keyUsage
42 * -- convert to DH *, allocating the DH key if necessary
43 */
44 DH *contextToDhKey(
45 const Context &context,
46 AppleCSPSession &session,
47 CSSM_KEYUSE usage, // CSSM_KEYUSE_ENCRYPT, CSSM_KEYUSE_SIGN, etc.
48 bool &mallocdKey); // RETURNED
49
50 /*
51 * Convert a CssmKey to an DH * key. May result in the creation of a new
52 * DH (when cssmKey is a raw key); allocdKey is true in that case
53 * in which case the caller generally has to free the allocd key).
54 */
55 DH *cssmKeyToDh(
56 const CssmKey &cssmKey,
57 AppleCSPSession &session,
58 bool &allocdKey); // RETURNED
59
60 /*
61 * Convert a raw CssmKey to a newly alloc'd DH *.
62 */
63 DH *rawCssmKeyToDh(
64 const CssmKey &cssmKey);
65
66
67 #ifdef __cplusplus
68 }
69 #endif
70
71 #endif /*_DH_UTILS_H_ */