]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_client/macclient.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 // macclient - client interface to CSSM sign/verify mac contexts
22 #ifndef _H_CDSA_CLIENT_MACCLIENT
23 #define _H_CDSA_CLIENT_MACCLIENT 1
25 #include <Security/cspclient.h>
26 #include <Security/keyclient.h>
35 // A signing/verifying mac context
37 class MacContext
: public Context
40 MacContext(const CSP
&csp
, CSSM_ALGORITHMS alg
)
41 : Context(csp
, alg
) { }
43 // preliminary interface
44 Key
key() const { assert(mKey
); return mKey
; }
45 void key(const Key
&k
) { mKey
= k
; set(CSSM_ATTRIBUTE_KEY
, mKey
); }
53 class GenerateMac
: public MacContext
56 GenerateMac(const CSP
&csp
, CSSM_ALGORITHMS alg
) : MacContext(csp
, alg
) { }
59 void sign(const CssmData
&data
, CssmData
&mac
) { sign(&data
, 1, mac
); }
60 void sign(const CssmData
*data
, uint32 count
, CssmData
&mac
);
63 void init(); // Optional
64 void sign(const CssmData
&data
) { sign(&data
, 1); }
65 void sign(const CssmData
*data
, uint32 count
);
66 void operator () (CssmData
&mac
);
67 CssmData
operator () () { CssmData mac
; (*this)(mac
); return mac
; }
70 class VerifyMac
: public MacContext
73 VerifyMac(const CSP
&csp
, CSSM_ALGORITHMS alg
) : MacContext(csp
, alg
) { }
76 void verify(const CssmData
&data
, const CssmData
&mac
) { verify(&data
, 1, mac
); }
77 void verify(const CssmData
*data
, uint32 count
, const CssmData
&mac
);
80 void init(); // Optional
81 void verify(const CssmData
&data
) { verify(&data
, 1); }
82 void verify(const CssmData
*data
, uint32 count
);
83 void operator () (const CssmData
&mac
);
86 } // end namespace CssmClient
88 } // end namespace Security
90 #endif // _H_CDSA_CLIENT_MACCLIENT