]>
git.saurik.com Git - apple/security.git/blob - AppleCSPDL/SSContext.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.
20 // SSContext.h - Security Server contexts
25 #include <Security/CSPsession.h>
26 #include <Security/SecurityServerClient.h>
29 // Parent class for all CSPContexts implemented in this CSP. Currently the
30 // only thing we add is a reference to our creator's session.
35 class SSContext
: public CSPFullPluginSession::CSPContext
38 SSContext(SSCSPSession
&session
);
39 virtual void init(const Context
&context
, bool encoding
);
42 SecurityServer::ClientSession
&clientSession();
43 SSCSPSession
&mSession
;
45 // We remeber a pointer to the passed in context and assume it will
46 // remain a valid from init(), update() all the way though the call to
48 const Context
*mContext
;
51 // SSSignContext -- Context for Sign, and GenerateMac operations
52 class SSSignContext
: public SSContext
55 SSSignContext(SSCSPSession
&session
);
56 virtual void update(const CssmData
&data
);
57 virtual size_t outputSize(bool final
, size_t inSize
);
58 virtual void final(CssmData
&out
);
61 // SSVerifyContext -- Context for Verify, and VerifyMac operations
62 class SSVerifyContext
: public SSContext
65 SSVerifyContext(SSCSPSession
&session
);
66 virtual void update(const CssmData
&data
);
67 virtual void final(const CssmData
&in
);
70 // Context for GenerateRandom operations
71 class SSRandomContext
: public SSContext
74 SSRandomContext(SSCSPSession
&session
);
75 virtual void init(const Context
&context
, bool);
76 virtual size_t outputSize(bool final
, size_t inSize
);
77 virtual void final(CssmData
&out
);
83 // Context for Encrypt and Decrypt operations
84 class SSCryptContext
: public SSContext
87 SSCryptContext(SSCSPSession
&session
);
89 virtual void init(const Context
&context
, bool encoding
);
90 virtual size_t inputSize(size_t outSize
);
91 virtual size_t outputSize(bool final
, size_t inSize
);
92 virtual void minimumProgress(size_t &in
, size_t &out
);
93 virtual void update(void *inp
, size_t &inSize
, void *outp
,
95 virtual void final(CssmData
&out
);
100 SecurityServer::KeyHandle mKeyHandle
;
107 // Context for key (pair) generation
108 class SSKeyGenContext
: public SSContext
111 SSKeyGenContext(SSCSPSession
&session
);
113 // Subclass implements generate(const Context &, CssmKey &,
114 // CssmKey &). That method allocates two subclass-specific
115 // SSKeys and calls this method. This will call down to
116 // generate(const Context &, SSKey &, SSKey &)
117 // and optionally to SSKey::generateKeyBlob.
118 void generate(const Context
&context
,
125 // @@@ Subclasses must implement this. It cooks up a key pair.
126 virtual void generate(const Context
&context
,
127 SSKey
&pubBinKey
, // valid on successful return
128 SSKey
&privBinKey
, // ditto
129 uint32
&keySize
); // ditto
132 void generateSymKey(const Context
&context
, CssmKey
&outCssmKey
);
137 #endif // _H_SS_CONTEXT