X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/Security/libsecurity_cdsa_client/lib/tpclient.h diff --git a/Security/libsecurity_cdsa_client/lib/tpclient.h b/Security/libsecurity_cdsa_client/lib/tpclient.h new file mode 100644 index 00000000..ca28f2a4 --- /dev/null +++ b/Security/libsecurity_cdsa_client/lib/tpclient.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2000-2002,2011-2012,2014 Apple Inc. All Rights Reserved. + * + * The contents of this file constitute Original Code as defined in and are + * subject to the Apple Public Source License Version 1.2 (the 'License'). + * You may not use this file except in compliance with the License. Please obtain + * a copy of the License at http://www.apple.com/publicsource and read it before + * using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS + * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT + * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the + * specific language governing rights and limitations under the License. + */ + + +// +// tpclient - client interface to CSSM TPs and their operations +// +#ifndef _H_CDSA_CLIENT_TPCLIENT +#define _H_CDSA_CLIENT_TPCLIENT 1 + +#include +#include +#include +#include +#include +#include + + +namespace Security { +namespace CssmClient { + + +// +// A TP attachment +// +class TPImpl : public AttachmentImpl +{ +public: + TPImpl(const Guid &guid); + TPImpl(const Module &module); + virtual ~TPImpl(); + +public: + // the CL and CSP used with many TP operations is usually + // pretty stable. The system may even figure them out + // automatically in the future. + void use(CL &cl); + void use(CSP &csp); + CL &usedCL(); + CSP &usedCSP(); + +public: + void certGroupVerify(const CertGroup &certGroup, const TPVerifyContext &context, + TPVerifyResult *result); + +private: + void setupCL(); // setup mUseCL + void setupCSP(); // setup mUseCSP + +private: + CL *mUseCL; // use this CL for TP operation + CSP *mUseCSP; // use this CSP for TP operation + bool mOwnCL, mOwnCSP; // whether we've made our own +}; + + +class TP : public Attachment +{ +public: + typedef TPImpl Impl; + + explicit TP(Impl *impl) : Attachment(impl) {} + TP(const Guid &guid) : Attachment(new Impl(guid)) {} + TP(const Module &module) : Attachment(new Impl(module)) {} + + Impl *operator ->() const { return &impl(); } + Impl &operator *() const { return impl(); } +}; + + +// +// A self-building TPVerifyContext. +// This is a TPVerifyContext, but it's NOT A PODWRAPPER (it's larger). +// +// NOTE: This is not a client-side object. +// +class TPBuildVerifyContext : public TPVerifyContext { +public: + TPBuildVerifyContext(CSSM_TP_ACTION action = CSSM_TP_ACTION_DEFAULT, + Allocator &alloc = Allocator::standard()); + + Allocator &allocator; + +private: + TPCallerAuth mCallerAuth; + // PolicyInfo mPolicyInfo; // -- unused + CssmDlDbList mDlDbList; +}; + + +} // end namespace CssmClient +} // end namespace Security + +#endif // _H_CDSA_CLIENT_CLCLIENT