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