User guide

MOTOROLA MPC184/MPC185 Security Co-Processor Software User’s Guide 69
PRELIMINARY—SUBJECT TO CHANGE WITHOUT NOTICE
Sample Code
5.2 IPSec Sample
/* define User Requests structures */
IPSEC_CBC_REQ ipsecReq;
.
.
.
.
/* Ipsec dynamic descriptor triple DES with SHA-1 authentication */
ipsecReq.opId = DPD_IPSEC_CBC_TDES_ENCRYPT_SHA_PAD;
ipsecReq.channel = 0;
ipsecReq.notify = (void *) notifyFunc;
ipsecReq.notify_on_error = (void *) notifyFunc;
ipsecReq.status = 0;
ipsecReq.hashKeyBytes = 16; /* key length for HMAC SHA-1 */
ipsecReq.hashKeyData = authKey; /* pointer to HMAC Key */
ipsecReq.cryptCtxInBytes = 8; /* length of input iv */
ipsecReq.cryptCtxInData = in_iv; /* pointer to input iv */
ipsecReq.cryptKeyBytes = 24; /* DES key length */
ipsecReq.cryptKeyData = EncKey; /* pointer to DES key */
ipsecReq.hashInDataBytes = 8; /* length of data to be hashed only */
ipsecReq.hashInData = PlainText; /* pointer to data to be
hashed only */
ipsecReq.inDataBytes = packet_length-8; /* length of data to be
hashed and encrypted */
ipsecReq.inData = &PlainText[8]; /* pointer to data to be
hashed and encrypted */
ipsecReq.cryptDataOut = Result; /* pointer to encrypted results */
ipsecReq.hashDataOutBytes = 20; /* length of output digest */
ipsecReq.hashDataOut = digest; /* pointer to output digest */
ipsecReq.nextReq = 0; /* no chained requests */
/* call the driver */
status = Ioctl(device, IOCTL_PROC_REQ, &ipsecReq);
/* First Level Error Checking */
if (status != 0) {
.
.
.
}
.
.
.
void notifyFunc (void)
{
/* Second Level Error Checking */
if (ipsecReq.status != 0) {
.
.
.
}
.
.
)