/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <security/cryptoki.h>
#include "softObject.h"
#include "softOps.h"
#include "softSession.h"
#include "softMAC.h"
#include "softRSA.h"
#include "softDSA.h"
#include "softEC.h"
#include "softCrypt.h"
/*
* soft_verify_init()
*
* Arguments:
* session_p: pointer to soft_session_t struct
* pMechanism: pointer to CK_MECHANISM struct provided by application
* key_p: pointer to key soft_object_t struct
*
* Description:
* called by C_VerifyInit(). This function calls the corresponding
* verify init routine based on the mechanism.
*
*/
{
switch (pMechanism->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:
case CKM_RSA_X_509:
case CKM_RSA_PKCS:
case CKM_MD5_RSA_PKCS:
case CKM_SHA1_RSA_PKCS:
case CKM_SHA256_RSA_PKCS:
case CKM_SHA384_RSA_PKCS:
case CKM_SHA512_RSA_PKCS:
case CKM_DSA:
case CKM_DSA_SHA1:
case CKM_ECDSA:
case CKM_ECDSA_SHA1:
case CKM_DES_MAC_GENERAL:
case CKM_DES_MAC:
default:
return (CKR_MECHANISM_INVALID);
}
}
/*
* soft_verify()
*
* Arguments:
* session_p: pointer to soft_session_t struct
* pData: pointer to the input data
* ulDataLen: length of the input data
* pSignature: pointer to the signature
* ulSignatureLen: length of the signature
*
* Description:
* called by C_Verify(). This function calls the corresponding
* verify routine based on the mechanism.
*
*/
{
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:
{
if (len != ulSignatureLen) {
}
}
}
return (rv);
}
case CKM_DES_MAC_GENERAL:
case CKM_DES_MAC:
{
/* Pass local buffer to avoid overflow. */
if (len != ulSignatureLen) {
}
}
}
return (rv);
}
case CKM_RSA_X_509:
case CKM_RSA_PKCS:
case CKM_MD5_RSA_PKCS:
case CKM_SHA1_RSA_PKCS:
case CKM_SHA256_RSA_PKCS:
case CKM_SHA384_RSA_PKCS:
case CKM_SHA512_RSA_PKCS:
case CKM_DSA:
case CKM_DSA_SHA1:
case CKM_ECDSA:
case CKM_ECDSA_SHA1:
default:
return (CKR_MECHANISM_INVALID);
}
}
/*
* soft_verify_update()
*
* Arguments:
* session_p: pointer to soft_session_t struct
* pPart: pointer to the input data
* ulPartLen: length of the input data
*
* Description:
* called by C_VerifyUpdate(). This function calls the corresponding
* verify update routine based on the mechanism.
*
*/
{
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:
case CKM_DES_MAC_GENERAL:
case CKM_DES_MAC:
ulPartLen));
case CKM_MD5_RSA_PKCS:
case CKM_SHA1_RSA_PKCS:
case CKM_SHA256_RSA_PKCS:
case CKM_SHA384_RSA_PKCS:
case CKM_SHA512_RSA_PKCS:
/*
* of the multiple-part digesting operation. In the final
* operation, the digest is encoded and then perform RSA
* verification.
*/
case CKM_DSA_SHA1:
case CKM_ECDSA_SHA1:
default:
/* PKCS11: The mechanism only supports single-part operation. */
return (CKR_MECHANISM_INVALID);
}
}
/*
* soft_verify_final()
*
* Arguments:
* session_p: pointer to soft_session_t struct
* pSignature: pointer to the signature
* ulSignatureLen: length of the signature
*
* Description:
* called by C_VerifyFinal(). This function calls the corresponding
* verify final routine based on the mechanism.
*
*/
{
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:
{
if (len != ulSignatureLen) {
}
}
}
return (rv);
}
case CKM_DES_MAC_GENERAL:
case CKM_DES_MAC:
{
/* Pass local buffer to avoid overflow. */
if (len != ulSignatureLen) {
}
}
}
return (rv);
}
case CKM_MD5_RSA_PKCS:
case CKM_SHA1_RSA_PKCS:
case CKM_SHA256_RSA_PKCS:
case CKM_SHA384_RSA_PKCS:
case CKM_SHA512_RSA_PKCS:
case CKM_DSA_SHA1:
case CKM_ECDSA_SHA1:
default:
/* PKCS11: The mechanism only supports single-part operation. */
return (CKR_MECHANISM_INVALID);
}
}
{
switch (pMechanism->mechanism) {
case CKM_RSA_X_509:
case CKM_RSA_PKCS:
default:
return (CKR_MECHANISM_INVALID);
}
}
{
switch (mechanism) {
case CKM_RSA_X_509:
case CKM_RSA_PKCS:
default:
return (CKR_MECHANISM_INVALID);
}
}