/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <errno.h>
#include <stdio.h>
#include <strings.h>
#include <security/cryptoki.h>
#include "kernelGlobal.h"
#include "kernelSession.h"
#include "kernelEmulate.h"
/*
* Helper routine to know if this is a HMAC. We can't just check
* the CKF_SIGN mech flag as it is set for non-HMAC mechs too.
*/
{
switch (mechanism) {
case CKM_SSL3_MD5_MAC:
case CKM_SSL3_SHA1_MAC:
case CKM_MD5_HMAC_GENERAL:
case CKM_MD5_HMAC:
case CKM_SHA_1_HMAC_GENERAL:
case CKM_SHA_1_HMAC:
case CKM_SHA256_HMAC_GENERAL:
case CKM_SHA256_HMAC:
case CKM_SHA384_HMAC_GENERAL:
case CKM_SHA384_HMAC:
case CKM_SHA512_HMAC_GENERAL:
case CKM_SHA512_HMAC:
return (B_TRUE);
default:
return (B_FALSE);
}
}
/*
* Helper routine to allocate an emulation structure for the session.
* buflen indicates the size of the scratch buffer to be allocated.
*/
{
bufp->indata_len = 0;
/*
* We can reuse the context structure, digest_buf_t.
* See if we can reuse the scratch buffer in the context too.
*/
}
} else {
return (CKR_HOST_MEMORY);
}
}
return (CKR_HOST_MEMORY);
}
}
return (CKR_OK);
}
/*
* Setup the support necessary to do this operation in a
* single part. We allocate a buffer to accumulate the
* input data from later calls. We also get ready for
* the case where we have to do it in software by initializing
* a standby context. The opflag tells if this is a sign or verify.
*/
{
return (rv);
return (rv);
}
} else { \
}
/*
* Accumulate the input data in the buffer, allocating a bigger
* buffer if needed. If we reach the maximum input data size
* that can be accumulated, start using the software from then on.
* The opflag tells if this is a digest, sign or verify.
*/
{
int maxlen;
if (!SLOT_HAS_LIMITED_HASH(session_p))
return (CKR_ARGUMENTS_BAD);
if (!SLOT_HAS_LIMITED_HMAC(session_p))
return (CKR_ARGUMENTS_BAD);
} else
return (CKR_ARGUMENTS_BAD);
return (rv);
}
return (CKR_FUNCTION_FAILED);
}
/* Did we exceed the maximum allowed? */
/* Try harder rather than failing */
} else
}
if (use_soft) {
return (rv);
}
}
return (rv);
}
/* accumulate the update data */
return (CKR_OK);
}