algorithm.c revision 30a5e8fa1253cb33980ee4514743cf683f584b4e
/*
* Copyright (c) 1995-2000 Intel Corporation. All rights reserved.
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <kmfapiP.h>
#include <algorithm.h>
#include <security/cryptoki.h>
typedef struct _pkcs_key_type_map
{
}
static const PKCS_KEY_TYPE_MAP _PKCS2KMFKeyTypeMap[] = {
{ KMF_ALGID_RSA, CKK_RSA },
{ KMF_ALGID_DSA, CKK_DSA }
};
static const PKCS_ALGORITHM_MAP _PKCS2KMFMap[] = {
/*
* PKCS #11 Mechanism,
* Alg. ID
* Alg. Class
* Alg. Mode
* Milti-Part
* Fix Key Length
* Key Length
* Fix Block Size
* Block Size
* Needs IV
* IV Length
* Alg. Flags
* Type
* Description
*/
KMF_ALGMODE_NONE, 0, 0, 0,\
0, 0, 0, 0, CKF_GENERATE_KEY_PAIR,\
CKK_RSA, "RSA PKCS #1 Key Pair Generation")
0, 0, 0, 0, 0, 0, 0, CKF_ENCRYPT,
CKK_RSA, "RSA RAW Encryption")
0, 0, 0, 0, 0, 0, 0, CKF_SIGN_RECOVER,
CKK_RSA, "RSA RAW Private Key Encryption")
0, 0, 0, 0, 0, 0, 0, CKF_SIGN,
CKK_RSA, "RSA RAW Signature")
"RSA PKCS #1 Signature")
KMF_ALGMODE_PKCS1_EMSA_V15, 1, 0, 0, 0, 0,
KMF_ALGMODE_PKCS1_EMSA_V15, 1, 0, 0, 0, 0,
KMF_ALGMODE_PKCS1_EMSA_V15, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, CKF_SIGN,
CKK_DSA, "DSA Signature")
KMF_ALGMODE_NONE, 1, 0, 0, 0, 0, 0,
};
/* Undefine the macro definitions */
/* Number of items in the algorithm map table */
#define _PKCS2KMFMapCount (\
sizeof (_PKCS2KMFMap) / sizeof (_PKCS2KMFMap[0]))
/* Indicator that the algorithm was not found */
#define PKCS_ALGORITHM_NOT_FOUND ((uint32_t)(~0))
/*
* Name: pkcs_get_alg_map
*
* Description:
* Searches the _PKCS2KMFMap table for a matching set of alg.
* description parameters.
*
* Parameters:
* algType (input) - KMF_ALGCLASS_* identifier to match.
* algID (input) - KMF_ALGID_* identifier to match.
* mode (input) - KMF_ALGMODE_* identifier to match. Use
* KMF_ALGMODE_NONE if a mode does not apply.
*
* Returns:
* Pointer to the lookup table entry that matches requested parameters.
* Ptr->keylength will equal PKCS11CONVERT_NOT_FOUND if no match is found.
*/
{
uint32_t i = 0;
for (i = 0; i < _PKCS2KMFMapCount; i++) {
return ((PKCS_ALGORITHM_MAP *)&(_PKCS2KMFMap[i]));
}
}
return (NULL);
}
{
sizeof (_PKCS2KMFKeyTypeMap) / sizeof (PKCS_KEY_TYPE_MAP);
return (1);
}
}
return (0);
}