/*
* The Initial Developer of the Original Code is International
* Business Machines Corporation. Portions created by IBM
* Corporation are Copyright (C) 2005 International Business
* Machines Corporation. All Rights Reserved.
*
* it under the terms of the Common Public License as published by
* IBM Corporation; either version 1 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Common Public License for more details.
*
* You should have received a copy of the Common Public License
* along with this program; if not, a copy can be viewed at
*/
/* (C) COPYRIGHT International Business Machines Corp. 2001, 2002, 2005 */
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "tpmtok_int.h"
CK_MECHANISM * mech,
{
return (CKR_FUNCTION_FAILED);
}
return (CKR_OPERATION_ACTIVE);
}
return (CKR_KEY_HANDLE_INVALID);
}
return (CKR_KEY_TYPE_INCONSISTENT);
} else {
return (CKR_KEY_FUNCTION_NOT_PERMITTED);
}
}
case CKM_RSA_PKCS:
{
CKA_KEY_TYPE, &attr);
return (CKR_KEY_TYPE_INCONSISTENT);
} else {
return (CKR_KEY_TYPE_INCONSISTENT);
}
}
// must be a PRIVATE key
//
return (CKR_KEY_TYPE_INCONSISTENT);
}
else
if (class != CKO_PRIVATE_KEY) {
return (CKR_KEY_TYPE_INCONSISTENT);
}
// PKCS #11 doesn't allow multi - part RSA operations
//
ctx->context_len = 0;
}
break;
case CKM_MD5_RSA_PKCS:
case CKM_SHA1_RSA_PKCS:
{
CKA_KEY_TYPE, &attr);
return (CKR_KEY_TYPE_INCONSISTENT);
} else {
return (CKR_KEY_TYPE_INCONSISTENT);
}
}
// must be a PRIVATE key operation
//
return (CKR_FUNCTION_FAILED);
}
else
if (class != CKO_PRIVATE_KEY) {
return (CKR_FUNCTION_FAILED);
}
sizeof (RSA_DIGEST_CONTEXT));
return (CKR_HOST_MEMORY);
}
sizeof (RSA_DIGEST_CONTEXT));
}
break;
case CKM_MD5_HMAC:
case CKM_SHA_1_HMAC:
{
if (mech->ulParameterLen != 0) {
return (CKR_MECHANISM_PARAM_INVALID);
}
CKA_KEY_TYPE, &attr);
return (CKR_KEY_TYPE_INCONSISTENT);
} else {
if (keytype != CKK_GENERIC_SECRET) {
return (CKR_KEY_TYPE_INCONSISTENT);
}
}
// PKCS #11 doesn't allow multi - part HMAC operations
//
ctx->context_len = 0;
}
break;
case CKM_MD5_HMAC_GENERAL:
case CKM_SHA_1_HMAC_GENERAL:
{
if (mech->ulParameterLen !=
sizeof (CK_MAC_GENERAL_PARAMS)) {
return (CKR_MECHANISM_PARAM_INVALID);
}
(*param > 16)) {
return (CKR_MECHANISM_PARAM_INVALID);
}
(*param > 20)) {
return (CKR_MECHANISM_PARAM_INVALID);
}
CKA_KEY_TYPE, &attr);
return (CKR_KEY_TYPE_INCONSISTENT);
} else {
if (keytype != CKK_GENERIC_SECRET) {
return (CKR_KEY_TYPE_INCONSISTENT);
}
}
// PKCS #11 doesn't allow multi - part HMAC operations
//
ctx->context_len = 0;
}
break;
default:
return (CKR_MECHANISM_INVALID);
}
return (CKR_ARGUMENTS_BAD);
if (mech->ulParameterLen > 0) {
if (! ptr) {
return (CKR_HOST_MEMORY);
}
}
return (CKR_OK);
}
{
if (! ctx) {
return (CKR_FUNCTION_FAILED);
}
ctx->context_len = 0;
}
}
return (CKR_OK);
}
{
return (CKR_FUNCTION_FAILED);
}
return (CKR_OPERATION_NOT_INITIALIZED);
}
return (CKR_OPERATION_NOT_INITIALIZED);
}
// if the caller just wants the signature length, there is no reason to
// specify the input data. I just need the input data length
//
return (CKR_FUNCTION_FAILED);
}
return (CKR_OPERATION_ACTIVE);
}
case CKM_RSA_PKCS:
out_data, out_data_len));
case CKM_MD5_RSA_PKCS:
case CKM_SHA1_RSA_PKCS:
out_data, out_data_len));
case CKM_MD5_HMAC:
case CKM_MD5_HMAC_GENERAL:
out_data, out_data_len));
case CKM_SHA_1_HMAC:
case CKM_SHA_1_HMAC_GENERAL:
out_data, out_data_len));
default:
return (CKR_MECHANISM_INVALID);
}
}
{
return (CKR_FUNCTION_FAILED);
}
return (CKR_OPERATION_NOT_INITIALIZED);
}
return (CKR_OPERATION_NOT_INITIALIZED);
}
case CKM_MD5_RSA_PKCS:
case CKM_SHA1_RSA_PKCS:
in_data, in_data_len));
default:
return (CKR_MECHANISM_INVALID);
}
}
{
return (CKR_FUNCTION_FAILED);
}
return (CKR_OPERATION_NOT_INITIALIZED);
}
return (CKR_OPERATION_NOT_INITIALIZED);
}
case CKM_MD5_RSA_PKCS:
case CKM_SHA1_RSA_PKCS:
default:
return (CKR_MECHANISM_INVALID);
}
}
{
return (CKR_FUNCTION_FAILED);
}
return (CKR_OPERATION_NOT_INITIALIZED);
}
return (CKR_OPERATION_NOT_INITIALIZED);
}
// if the caller just wants the signature length, there is no reason to
// specify the input data. I just need the input data length
//
return (CKR_FUNCTION_FAILED);
}
return (CKR_OPERATION_ACTIVE);
}
case CKM_RSA_PKCS:
out_data, out_data_len));
default:
return (CKR_MECHANISM_INVALID);
}
}