2 * Copyright (c) 2000-2001,2011-2012,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 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 * SignatureContext.h - AppleCSPContext subclass for generic sign/verify
22 * This class performs all of the sign/verify operations in the CSP. The general
23 * scheme is that an instance of this class has references to one DigestObject
24 * and one RawSigner. Sign and Verify "updates" go to the DigestObject. The "final"
25 * operation consists of obtaining the final digest from the DigestObject and
26 * performing a sign or verify on that data via the RawSigner.
28 * This class knows nothing about any of the algorithms involved; all sign and
29 * verify operations follow this same scheme. Various modules' AlgorithmFactories
30 * construct one of these objects by providing the appropriate DigestObject and
33 * The seemingly special case of "raw RSA sign", in which the app calculates the
34 * digest separately from the sign operation, is handled via the NullDigest object.
37 #ifndef _SIGNATURE_CONTEXT_H_
38 #define _SIGNATURE_CONTEXT_H_
40 #include <RawSigner.h>
41 #include <security_cdsa_utilities/digestobject.h>
42 #include <AppleCSPContext.h>
44 class SignatureContext
: public AppleCSPContext
{
47 AppleCSPSession
&session
,
50 AppleCSPContext(session
),
57 /* called out from CSPFullPluginSession....
58 * both sign & verify: */
59 void init(const Context
&context
, bool isSigning
);
60 void update(const CssmData
&data
);
63 void final(CssmData
&out
);
66 void final(const CssmData
&in
);
68 size_t outputSize(bool final
, size_t inSize
);
70 /* for raw sign/verify - optionally called after init */
71 virtual void setDigestAlgorithm(CSSM_ALGORITHMS digestAlg
);
75 DigestObject
&mDigest
;
77 bool mInitFlag
; // true after init
81 #endif /* _SIGNATURE_CONTEXT_H_ */