]> git.saurik.com Git - apple/security.git/blob - libsecurity_apple_csp/lib/FEEKeys.h
Security-55163.44.tar.gz
[apple/security.git] / libsecurity_apple_csp / lib / FEEKeys.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 * FEEKeys.h - FEE-related asymmetric key pair classes.
21 *
22 * Created 2/21/2001 by dmitch.
23 */
24
25 #ifdef CRYPTKIT_CSP_ENABLE
26
27 #ifndef _FEE_KEYS_H_
28 #define _FEE_KEYS_H_
29
30 #include "AppleCSPContext.h"
31 #include "AppleCSPSession.h"
32 #include "AppleCSPKeys.h"
33 #include "cryptkitcsp.h"
34 #include <security_cryptkit/feeTypes.h>
35
36 namespace CryptKit {
37
38 /*
39 * FEE/ECDSA version of a BinaryKey.
40 */
41 class FEEBinaryKey : public BinaryKey {
42 public:
43 FEEBinaryKey(feePubKey feeKey = NULL);
44 ~FEEBinaryKey();
45 void generateKeyBlob(
46 Allocator &allocator,
47 CssmData &blob,
48 CSSM_KEYBLOB_FORMAT &format,
49 AppleCSPSession &session,
50 const CssmKey *paramKey, /* optional, unused here */
51 CSSM_KEYATTR_FLAGS &attrFlags); /* IN/OUT */
52
53 feePubKey feeKey() { return mFeeKey; }
54 private:
55 feePubKey mFeeKey;
56 };
57
58 class FEEKeyPairGenContext :
59 public AppleCSPContext, private AppleKeyPairGenContext {
60 public:
61 FEEKeyPairGenContext(
62 AppleCSPSession &session,
63 const Context &) :
64 AppleCSPContext(session) {}
65
66 ~FEEKeyPairGenContext() { }
67
68 /* no init functionality, but we need to implement it */
69 void init(
70 const Context &,
71 bool) { }
72
73 // this one is specified in, and called from, CSPFullPluginSession
74 void generate(
75 const Context &context,
76 CssmKey &pubKey,
77 CssmKey &privKey);
78
79 // this one is specified in, and called from, AppleKeyPairGenContext
80 void generate(
81 const Context &context,
82 BinaryKey &pubBinKey,
83 BinaryKey &privBinKey,
84 uint32 &keySize);
85
86 }; /* KeyPairGenContext */
87
88 /*
89 * CSPKeyInfoProvider for FEE and ECDSA keys
90 */
91 class FEEKeyInfoProvider : public CSPKeyInfoProvider
92 {
93 private:
94 FEEKeyInfoProvider(
95 const CssmKey &cssmKey,
96 AppleCSPSession &session);
97 public:
98 static CSPKeyInfoProvider *provider(
99 const CssmKey &cssmKey,
100 AppleCSPSession &session);
101
102 ~FEEKeyInfoProvider() { }
103 void CssmKeyToBinary(
104 CssmKey *paramKey, // optional, ignored here
105 CSSM_KEYATTR_FLAGS &attrFlags, // IN/OUT
106 BinaryKey **binKey); // RETURNED
107 void QueryKeySizeInBits(
108 CSSM_KEY_SIZE &keySize); // RETURNED
109 bool getHashableBlob(
110 Allocator &allocator,
111 CssmData &hashBlob);
112 };
113
114 } /* namespace CryptKit */
115
116 #endif /* _FEE_KEYS_H_ */
117 #endif /* CRYPTKIT_CSP_ENABLE */