/*
* 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"
// Function: dlist_add_as_first()
//
// Adds the specified node to the start of the list
//
// Returns: pointer to the start of the list
//
DL_NODE *
{
if (! data)
return (list);
if (! node)
return (NULL);
if (list)
return (node);
}
// Function: dlist_add_as_last()
//
// Adds the specified node to the end of the list
//
// Returns: pointer to the start of the list
//
DL_NODE *
if (! data)
return (list);
if (! node)
return (NULL);
if (! list) {
return (node);
} else {
return (list);
}
}
// Function: dlist_find()
//
DL_NODE *
{
return (node);
}
// Function: dlist_get_first()
//
// Returns the last node in the list or NULL if list is empty
//
DL_NODE *
if (! list)
return (NULL);
return (temp);
}
// Function: dlist_get_last()
//
// Returns the last node in the list or NULL if list is empty
//
DL_NODE *
if (! list)
return (NULL);
return (temp);
}
//
//
while (temp) {
len++;
}
return (len);
}
//
//
DL_NODE *
{
if (! node)
return (NULL);
}
//
//
DL_NODE *
if (! node)
return (NULL);
}
//
//
void
if (! list)
return;
do {
} while (list);
}
// Function: dlist_remove_node()
//
// Attempts to remove the specified node from the list. The caller is
// responsible for freeing the data associated with the node prior to
// calling this routine
//
DL_NODE *
return (NULL);
// special case: removing head of the list
//
if (temp)
return (temp);
}
// we have no guarantee that the node is in the list
// so search through the list to find it
//
if (next)
}
return (list);
}
extern void set_perm(int);
void
{
(void) pthread_mutexattr_init(&mtxattr);
}
int
{
}
int
{
}
int
{
}
//
//
// is_attribute_defined()
//
// determine whether the specified attribute is defined by Cryptoki
//
{
if (type >= CKA_VENDOR_DEFINED)
return (TRUE);
switch (type) {
case CKA_CLASS:
case CKA_TOKEN:
case CKA_PRIVATE:
case CKA_LABEL:
case CKA_APPLICATION:
case CKA_VALUE:
case CKA_CERTIFICATE_TYPE:
case CKA_ISSUER:
case CKA_SERIAL_NUMBER:
case CKA_KEY_TYPE:
case CKA_SUBJECT:
case CKA_ID:
case CKA_SENSITIVE:
case CKA_ENCRYPT:
case CKA_DECRYPT:
case CKA_WRAP:
case CKA_UNWRAP:
case CKA_SIGN:
case CKA_SIGN_RECOVER:
case CKA_VERIFY:
case CKA_VERIFY_RECOVER:
case CKA_DERIVE:
case CKA_START_DATE:
case CKA_END_DATE:
case CKA_MODULUS:
case CKA_MODULUS_BITS:
case CKA_PUBLIC_EXPONENT:
case CKA_PRIVATE_EXPONENT:
case CKA_PRIME_1:
case CKA_PRIME_2:
case CKA_EXPONENT_1:
case CKA_EXPONENT_2:
case CKA_COEFFICIENT:
case CKA_PRIME:
case CKA_SUBPRIME:
case CKA_BASE:
case CKA_VALUE_BITS:
case CKA_VALUE_LEN:
case CKA_EXTRACTABLE:
case CKA_LOCAL:
case CKA_NEVER_EXTRACTABLE:
case CKA_ALWAYS_SENSITIVE:
case CKA_MODIFIABLE:
case CKA_ECDSA_PARAMS:
case CKA_EC_POINT:
case CKA_HW_FEATURE_TYPE:
case CKA_HAS_RESET:
case CKA_RESET_ON_INIT:
case CKA_KEY_GEN_MECHANISM:
case CKA_PRIME_BITS:
case CKA_SUBPRIME_BITS:
case CKA_OBJECT_ID:
case CKA_AC_ISSUER:
case CKA_OWNER:
case CKA_ATTR_TYPES:
case CKA_TRUSTED:
return (TRUE);
}
return (FALSE);
}
void
{
/*
* Much of the token info is pulled from the TPM itself when
* C_Initialize is called.
*/
"PKCS#11 Interface for TPM",
strlen("PKCS#11 Interface for TPM"));
}
/*ARGSUSED*/
void
{
}
static void
{
sizeof (token_info->model));
sizeof (token_info->serialNumber));
//
// I don't see any API support for changing the clock so
// we will use the system clock for the token's clock.
//
SHA1_DIGEST_LENGTH) != 0)
else
// For the release, we made these
// values as CK_UNAVAILABLE_INFORMATION
//
}
//
// the normal USER pin is not set when the token is initialized
//
return (rc);
return (rc);
}
// Function: compute_next_token_obj_name()
//
// Given a token object name (8 bytes in the range [0 - 9A - Z])
// increment by one adjusting as necessary
//
// This gives us a namespace of 36^8 = 2, 821, 109, 907, 456
// objects before wrapping around.
//
int i;
return (CKR_FUNCTION_FAILED);
}
// Convert to integral base 36
//
for (i = 0; i < 8; i++) {
}
val[0]++;
i = 0;
while (val[i] > 35) {
val[i] = 0;
if (i + 1 < 8) {
val[i + 1]++;
i++;
} else {
val[0]++;
i = 0; // start pass 2
}
}
// now, convert back to [0 - 9A - Z]
//
for (i = 0; i < 8; i++) {
if (val[i] < 10)
else
}
return (CKR_OK);
}
//
//
CK_ATTRIBUTE **attrib) {
if (! attr) {
return (CKR_DEVICE_MEMORY);
}
if (data_len > 0) {
}
else
return (CKR_OK);
}
{
return (CKR_FUNCTION_FAILED);
}
for (i = 0; i < pad_len; i++)
return (CKR_OK);
}
{
/* We have 'pad_value' bytes of 'pad_value' appended to the end */
return (CKR_OK);
}
{
for (i = 0; i < attr->ulValueLen; i++) {
if (ptr[i] != 0x0)
break;
}
return (CKR_OK);
}
b = ((b >> 4) ^ b) & 0x0f;
b = ((b >> 2) ^ b) & 0x03;
b = ((b >> 1) ^ b) & 0x01;
if (b == 1)
return (TRUE);
else
return (FALSE);
}
attach_shm() {
if (global_shm != NULL)
return (CKR_OK);
if (global_shm == NULL) {
return (CKR_HOST_MEMORY);
}
return (CKR_OK);
}
{
if (global_shm != NULL) {
global_shm = NULL;
}
return (CKR_OK);
}
{
return (CKR_OK);
}