#ifdef BSAFE_CSP_ENABLE
#ifndef _H_BSOBJECTS
#define _H_BSOBJECTS
#include <security_cdsa_utilities/cssmutilities.h>
#include <security_utilities/alloc.h>
#include <aglobal.h>
#include <bsafe.h>
class BSafeItem : public PodWrapper<BSafeItem, ITEM> {
public:
BSafeItem() { ((ITEM *)this)->data = NULL; len = 0; }
BSafeItem(void *addr, size_t sz)
{ ((ITEM *)this)->data = (unsigned char *)addr; len = sz; }
BSafeItem(const CSSM_DATA &cData)
{ ((ITEM *)this)->data = cData.Data; len = cData.Length; }
BSafeItem(const ITEM &cData)
{ *(ITEM *)this = cData; }
void operator = (const CssmData &cData)
{ ((ITEM *)this)->data = (unsigned char *)cData.data(); len = cData.length(); }
void *data() const { return ((ITEM *)this)->data; }
size_t length() const { return len; }
template <class T>
T copy(Allocator &alloc)
{ return T(memcpy(alloc.malloc(length()), data(), length()), length()); }
template <class T>
T *copyp(Allocator &alloc)
{ return new(alloc) T(copy<T>(alloc)); }
void *operator new (size_t size, Allocator &alloc)
{ return alloc.malloc(size); }
};
#endif //_H_BSOBJECTS
#endif