#ifndef _KERNEL_EMULATE_H
#define _KERNEL_EMULATE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <strings.h>
#include <sys/crypto/ioctl.h>
#include <security/cryptoki.h>
#include "kernelGlobal.h"
#include "kernelSession.h"
#include "kernelSoftCommon.h"
#define SLOT_THRESHOLD(sp) (slot_table[sp->ses_slotid]->sl_threshold)
#define SLOT_HASH_MAX_INDATA_LEN(sp) \
(slot_table[sp->ses_slotid]->sl_hash_max_inlen)
#define SLOT_HMAC_MAX_INDATA_LEN(sp) \
(slot_table[sp->ses_slotid]->sl_hmac_max_inlen)
#define SLOT_HAS_LIMITED_HASH(sp) (slot_table[sp->ses_slotid]->sl_flags & \
CRYPTO_LIMITED_HASH_SUPPORT)
#define SLOT_HAS_LIMITED_HMAC(sp) (slot_table[sp->ses_slotid]->sl_flags & \
CRYPTO_LIMITED_HMAC_SUPPORT)
#define get_sp(opp) (((digest_buf_t *)((opp)->context))->soft_sp)
#define get_spp(opp) (&(((digest_buf_t *)((opp)->context))->soft_sp))
#define REINIT_OPBUF(opp) { \
if ((opp)->flags & CRYPTO_EMULATE) { \
digest_buf_t *bufp = (opp)->context; \
if (bufp != NULL) { \
bzero(bufp->buf, bufp->indata_len); \
bufp->indata_len = 0; \
} \
} \
}
boolean_t is_hmac(CK_MECHANISM_TYPE mechanism);
CK_RV emulate_buf_init(kernel_session_t *session_p, int buflen, int opflag);
CK_RV emulate_init(kernel_session_t *session_p, CK_MECHANISM_PTR pMechanism,
crypto_key_t *keyp, int opflag);
CK_RV emulate_update(kernel_session_t *session_p, CK_BYTE_PTR pPart,
CK_ULONG ulPartLen, int opflag);
#ifdef __cplusplus
}
#endif
#endif