]>
git.saurik.com Git - apple/security.git/blob - Security/libsecurity_apple_csp/lib/AppleCSPKeys.h
2 * Copyright (c) 2003,2011,2014 Apple 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
7 * obtain a copy of the License at http://www.apple.com/publicsource and
8 * read it before using this file.
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
12 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
13 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
15 * Please see the License for the specific language governing rights and
16 * limitations under the License.
19 * AppleCSPKeys.h - Key support
22 #ifndef _APPLE_CSP_KEYS_H_
23 #define _APPLE_CSP_KEYS_H_
25 #include "AppleCSPSession.h"
28 * Class to provide key-specific info. Each module dealing with keys
29 * implements one of these. It's sort of like a CSP-specific CSPContext
30 * without the Context object. AppleCSPSession finds one of these by
31 * querying module-specific subclasses, looking for one in which
32 * the constructor succeeds (which occurs when the specified key
33 * meets a subclass's specification).
35 class CSPKeyInfoProvider
39 const CssmKey
&cssmKey
,
40 AppleCSPSession
&session
) :
45 * This is the public way to construct - returns NULL if key is
46 * not handled. Static declaration per subclass.
48 * static CSPKeyInfoProvider *provider(
49 * const CssmKey &cssmKey,
50 * AppleCSPSession &session);
52 virtual ~CSPKeyInfoProvider() { }
55 * Cook up a Binary key.
57 * Incoming paramKey optionally contains a key from which
58 * additional algorithm parameters may be obtained to create
59 * a fully specified key in case the key provided to our
60 * constructor was a partial key.
62 * The attrFlags argument is a means for the info provider to
63 * inform the caller that the incoming key has additional
64 * attributes, currently CSSM_KEYATTR_PARTIAL. The provider
65 * ORs in bits as appropriate.
67 virtual void CssmKeyToBinary(
68 CssmKey
*paramKey
, // optional
69 CSSM_KEYATTR_FLAGS
&attrFlags
, // IN/OUT
70 BinaryKey
**binKey
) = 0; // RETURNED
72 /* obtain key size in bits */
73 virtual void QueryKeySizeInBits(
74 CSSM_KEY_SIZE
&keySize
) = 0; // RETURNED
77 * Get blob appropriate for calculating key digest, if possible
78 * to do without generating a BinaryKey. Returns true if
79 * successful, falseif BinaryKey generation is required.
81 virtual bool getHashableBlob(
83 CssmData
&hashBlob
) = 0; // blob to hash goes here
87 AppleCSPSession
&mSession
;
91 * CSPKeyInfoProvider for symmetric keys (handled directly by
94 class SymmetricKeyInfoProvider
: public CSPKeyInfoProvider
97 SymmetricKeyInfoProvider(
98 const CssmKey
&cssmKey
,
99 AppleCSPSession
&session
);
101 static CSPKeyInfoProvider
*provider(
102 const CssmKey
&cssmKey
,
103 AppleCSPSession
&session
);
105 ~SymmetricKeyInfoProvider() { }
106 void CssmKeyToBinary(
107 CssmKey
*paramKey
, // ignored
108 CSSM_KEYATTR_FLAGS
&attrFlags
, // IN/OUT
109 BinaryKey
**binKey
); // RETURNED
110 void QueryKeySizeInBits(
111 CSSM_KEY_SIZE
&keySize
); // RETURNED
112 bool getHashableBlob(
113 Allocator
&allocator
,
117 #endif /* _APPLE_CSP_KEYS_H_ */