#ifndef _H_SSTRANSIT
#define _H_SSTRANSIT
#include "ssclient.h"
#include <Security/mach++.h>
#include <Security/cssmwalkers.h>
#include <Security/AuthorizationWalkers.h>
#include "ucsp.h"
namespace Security
{
#define UCSP_ARGS mGlobal().serverPort, mGlobal().thread().replyPort, &rcode
#define IPCN(statement) \
{ CSSM_RETURN rcode; check(statement); if (rcode != CSSM_OK) CssmError::throwMe(rcode); }
#define IPC(statement) { activate(); IPCN(statement); }
#define IPCKEY(statement, key, tag) \
{ \
activate(); \
CSSM_RETURN rcode; \
for (bool retried = false;; retried = true) \
{ \
check(statement); \
if (retried || rcode != CSSMERR_CSP_APPLE_ADD_APPLICATION_ACL_SUBJECT) \
break; \
addApplicationAclSubject(key, tag); \
} \
if (rcode != CSSM_OK) \
CssmError::throwMe(rcode); \
}
#define DATA(arg) arg.data(), arg.length()
#define OPTIONALDATA(arg) (arg ? arg->data() : NULL), (arg ? arg->length() : 0)
#define COPY(copy) copy, copy.length(), copy
#define COPY_OUT(copy) ©, ©##Length, ©##Base
#define COPY_OUT_DECL(type,name) type *name, *name##Base; mach_msg_type_number_t name##Length
class DataOutput {
public:
DataOutput(CssmData &arg, CssmAllocator &alloc)
: argument(arg), allocator(alloc) { mData = NULL; mLength = 0; }
~DataOutput();
void **data() { return &mData; }
mach_msg_type_number_t *length() { return &mLength; }
CssmData &argument;
CssmAllocator &allocator;
private:
void *mData;
mach_msg_type_number_t mLength;
};
class DatabaseAccessCredentials : public Copier<AccessCredentials> {
public:
DatabaseAccessCredentials(const AccessCredentials *creds, CssmAllocator &alloc);
private:
void mapKeySample(CSSM_CSP_HANDLE &cspHandle, CssmKey &key);
};
class SendContext {
public:
SendContext(const Context &ctx);
~SendContext() { CssmAllocator::standard().free(attributes); }
const Context &context;
CSSM_CONTEXT_ATTRIBUTE *attributes;
size_t attributeSize;
};
#define CONTEXT(ctx) ctx.context, ctx.attributes, ctx.attributes, ctx.attributeSize
}
#endif //_H_SSTRANSIT