2003-09-03 17:19:08 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003 Mathias Brossard <mathias.brossard@idealx.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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 GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
|
|
|
|
* USA
|
|
|
|
*/
|
2010-03-04 08:14:36 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-03 17:19:08 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2005-09-07 20:05:13 +00:00
|
|
|
#ifdef _WIN32
|
2008-03-06 16:06:59 +00:00
|
|
|
#include <windows.h>
|
2005-09-07 20:05:13 +00:00
|
|
|
#include <winreg.h>
|
2008-03-06 16:06:59 +00:00
|
|
|
#include <limits.h>
|
2005-09-07 20:05:13 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-04 08:14:36 +00:00
|
|
|
#define CRYPTOKI_EXPORTS
|
|
|
|
#include "pkcs11-display.h"
|
|
|
|
|
2003-09-03 17:19:08 +00:00
|
|
|
#define __PASTE(x,y) x##y
|
|
|
|
|
2006-11-30 08:11:58 +00:00
|
|
|
extern void *C_LoadModule(const char *name, CK_FUNCTION_LIST_PTR_PTR);
|
|
|
|
extern CK_RV C_UnloadModule(void *module);
|
2003-09-03 17:19:08 +00:00
|
|
|
|
2006-11-30 08:11:58 +00:00
|
|
|
/* Declare all spy_* Cryptoki function */
|
2003-09-03 17:19:08 +00:00
|
|
|
|
2003-09-04 13:50:30 +00:00
|
|
|
/* Spy Module Function List */
|
2007-06-21 12:01:39 +00:00
|
|
|
static CK_FUNCTION_LIST_PTR pkcs11_spy = NULL;
|
2003-09-04 13:50:30 +00:00
|
|
|
/* Real Module Function List */
|
2007-06-21 12:01:39 +00:00
|
|
|
static CK_FUNCTION_LIST_PTR po = NULL;
|
2003-09-04 13:50:30 +00:00
|
|
|
/* Dynamic Module Handle */
|
2003-09-06 16:18:15 +00:00
|
|
|
static void *modhandle = NULL;
|
2003-09-04 13:50:30 +00:00
|
|
|
/* Spy module output */
|
2007-06-21 12:01:39 +00:00
|
|
|
static FILE *spy_output = NULL;
|
2003-09-03 17:19:08 +00:00
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
/* Inits the spy. If successfull, po != NULL */
|
2005-02-06 10:28:43 +00:00
|
|
|
static CK_RV init_spy(void)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
2005-09-18 11:00:00 +00:00
|
|
|
const char *output, *module;
|
|
|
|
int rv = CKR_OK;
|
|
|
|
#ifdef _WIN32
|
|
|
|
char temp_path[PATH_MAX];
|
2008-03-06 16:06:59 +00:00
|
|
|
DWORD temp_len;
|
2005-09-18 11:00:00 +00:00
|
|
|
long rc;
|
|
|
|
HKEY hKey;
|
|
|
|
#endif
|
2003-09-04 13:50:30 +00:00
|
|
|
|
|
|
|
/* Allocates and initializes the pkcs11_spy structure */
|
Do not cast the return value of malloc(3) and calloc(3)
From http://en.wikipedia.org/wiki/Malloc#Casting_and_type_safety
" Casting and type safety
malloc returns a void pointer (void *), which indicates that it is a
pointer to a region of unknown data type. One may "cast" (see type
conversion) this pointer to a specific type, as in
int *ptr = (int*)malloc(10 * sizeof (int));
When using C, this is considered bad practice; it is redundant under the
C standard. Moreover, putting in a cast may mask failure to include the
header stdlib.h, in which the prototype for malloc is found. In the
absence of a prototype for malloc, the C compiler will assume that
malloc returns an int, and will issue a warning in a context such as the
above, provided the error is not masked by a cast. On certain
architectures and data models (such as LP64 on 64 bit systems, where
long and pointers are 64 bit and int is 32 bit), this error can actually
result in undefined behavior, as the implicitly declared malloc returns
a 32 bit value whereas the actually defined function returns a 64 bit
value. Depending on calling conventions and memory layout, this may
result in stack smashing.
The returned pointer need not be explicitly cast to a more specific
pointer type, since ANSI C defines an implicit conversion between the
void pointer type and other pointers to objects. An explicit cast of
malloc's return value is sometimes performed because malloc originally
returned a char *, but this cast is unnecessary in standard C
code.[4][5] Omitting the cast, however, creates an incompatibility with
C++, which does require it.
The lack of a specific pointer type returned from malloc is type-unsafe
behaviour: malloc allocates based on byte count but not on type. This
distinguishes it from the C++ new operator that returns a pointer whose
type relies on the operand. (see C Type Safety). "
See also
http://www.opensc-project.org/pipermail/opensc-devel/2010-August/014586.html
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4636 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 15:08:51 +00:00
|
|
|
pkcs11_spy = malloc(sizeof(CK_FUNCTION_LIST));
|
2003-09-04 13:50:30 +00:00
|
|
|
if (pkcs11_spy) {
|
2006-11-30 08:11:58 +00:00
|
|
|
/* with our own pkcs11.h we need to maintain this ourself */
|
|
|
|
pkcs11_spy->version.major = 2;
|
|
|
|
pkcs11_spy->version.major = 11;
|
|
|
|
pkcs11_spy->C_Initialize = C_Initialize;
|
|
|
|
pkcs11_spy->C_Finalize = C_Finalize;
|
|
|
|
pkcs11_spy->C_GetInfo = C_GetInfo;
|
|
|
|
pkcs11_spy->C_GetFunctionList = C_GetFunctionList;
|
|
|
|
pkcs11_spy->C_GetSlotList = C_GetSlotList;
|
|
|
|
pkcs11_spy->C_GetSlotInfo = C_GetSlotInfo;
|
|
|
|
pkcs11_spy->C_GetTokenInfo = C_GetTokenInfo;
|
|
|
|
pkcs11_spy->C_GetMechanismList = C_GetMechanismList;
|
|
|
|
pkcs11_spy->C_GetMechanismInfo = C_GetMechanismInfo;
|
|
|
|
pkcs11_spy->C_InitToken = C_InitToken;
|
|
|
|
pkcs11_spy->C_InitPIN = C_InitPIN;
|
|
|
|
pkcs11_spy->C_SetPIN = C_SetPIN;
|
|
|
|
pkcs11_spy->C_OpenSession = C_OpenSession;
|
|
|
|
pkcs11_spy->C_CloseSession = C_CloseSession;
|
|
|
|
pkcs11_spy->C_CloseAllSessions = C_CloseAllSessions;
|
|
|
|
pkcs11_spy->C_GetSessionInfo = C_GetSessionInfo;
|
|
|
|
pkcs11_spy->C_GetOperationState = C_GetOperationState;
|
|
|
|
pkcs11_spy->C_SetOperationState = C_SetOperationState;
|
|
|
|
pkcs11_spy->C_Login = C_Login;
|
|
|
|
pkcs11_spy->C_Logout = C_Logout;
|
|
|
|
pkcs11_spy->C_CreateObject = C_CreateObject;
|
|
|
|
pkcs11_spy->C_CopyObject = C_CopyObject;
|
|
|
|
pkcs11_spy->C_DestroyObject = C_DestroyObject;
|
|
|
|
pkcs11_spy->C_GetObjectSize = C_GetObjectSize;
|
|
|
|
pkcs11_spy->C_GetAttributeValue = C_GetAttributeValue;
|
|
|
|
pkcs11_spy->C_SetAttributeValue = C_SetAttributeValue;
|
|
|
|
pkcs11_spy->C_FindObjectsInit = C_FindObjectsInit;
|
|
|
|
pkcs11_spy->C_FindObjects = C_FindObjects;
|
|
|
|
pkcs11_spy->C_FindObjectsFinal = C_FindObjectsFinal;
|
|
|
|
pkcs11_spy->C_EncryptInit = C_EncryptInit;
|
|
|
|
pkcs11_spy->C_Encrypt = C_Encrypt;
|
|
|
|
pkcs11_spy->C_EncryptUpdate = C_EncryptUpdate;
|
|
|
|
pkcs11_spy->C_EncryptFinal = C_EncryptFinal;
|
|
|
|
pkcs11_spy->C_DecryptInit = C_DecryptInit;
|
|
|
|
pkcs11_spy->C_Decrypt = C_Decrypt;
|
|
|
|
pkcs11_spy->C_DecryptUpdate = C_DecryptUpdate;
|
|
|
|
pkcs11_spy->C_DecryptFinal = C_DecryptFinal;
|
|
|
|
pkcs11_spy->C_DigestInit = C_DigestInit;
|
|
|
|
pkcs11_spy->C_Digest = C_Digest;
|
|
|
|
pkcs11_spy->C_DigestUpdate = C_DigestUpdate;
|
|
|
|
pkcs11_spy->C_DigestKey = C_DigestKey;
|
|
|
|
pkcs11_spy->C_DigestFinal = C_DigestFinal;
|
|
|
|
pkcs11_spy->C_SignInit = C_SignInit;
|
|
|
|
pkcs11_spy->C_Sign = C_Sign;
|
|
|
|
pkcs11_spy->C_SignUpdate = C_SignUpdate;
|
|
|
|
pkcs11_spy->C_SignFinal = C_SignFinal;
|
|
|
|
pkcs11_spy->C_SignRecoverInit = C_SignRecoverInit;
|
|
|
|
pkcs11_spy->C_SignRecover = C_SignRecover;
|
|
|
|
pkcs11_spy->C_VerifyInit = C_VerifyInit;
|
|
|
|
pkcs11_spy->C_Verify = C_Verify;
|
|
|
|
pkcs11_spy->C_VerifyUpdate = C_VerifyUpdate;
|
|
|
|
pkcs11_spy->C_VerifyFinal = C_VerifyFinal;
|
|
|
|
pkcs11_spy->C_VerifyRecoverInit = C_VerifyRecoverInit;
|
|
|
|
pkcs11_spy->C_VerifyRecover = C_VerifyRecover;
|
|
|
|
pkcs11_spy->C_DigestEncryptUpdate = C_DigestEncryptUpdate;
|
|
|
|
pkcs11_spy->C_DecryptDigestUpdate = C_DecryptDigestUpdate;
|
|
|
|
pkcs11_spy->C_SignEncryptUpdate = C_SignEncryptUpdate;
|
|
|
|
pkcs11_spy->C_DecryptVerifyUpdate = C_DecryptVerifyUpdate;
|
|
|
|
pkcs11_spy->C_GenerateKey = C_GenerateKey;
|
|
|
|
pkcs11_spy->C_GenerateKeyPair = C_GenerateKeyPair;
|
|
|
|
pkcs11_spy->C_WrapKey = C_WrapKey;
|
|
|
|
pkcs11_spy->C_UnwrapKey = C_UnwrapKey;
|
|
|
|
pkcs11_spy->C_DeriveKey = C_DeriveKey;
|
|
|
|
pkcs11_spy->C_SeedRandom = C_SeedRandom;
|
|
|
|
pkcs11_spy->C_GenerateRandom = C_GenerateRandom;
|
|
|
|
pkcs11_spy->C_GetFunctionStatus = C_GetFunctionStatus;
|
|
|
|
pkcs11_spy->C_CancelFunction = C_CancelFunction;
|
|
|
|
pkcs11_spy->C_WaitForSlotEvent = C_WaitForSlotEvent;
|
2003-09-04 13:50:30 +00:00
|
|
|
} else {
|
2003-09-28 19:22:30 +00:00
|
|
|
return CKR_HOST_MEMORY;
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
2003-09-28 19:22:30 +00:00
|
|
|
|
2012-04-02 22:00:56 +00:00
|
|
|
/*
|
2003-09-29 09:00:11 +00:00
|
|
|
* Don't use getenv() as the last parameter for scconf_get_str(),
|
|
|
|
* as we want to be able to override configuration file via
|
|
|
|
* environment variables
|
|
|
|
*/
|
2005-09-18 11:00:00 +00:00
|
|
|
output = getenv("PKCS11SPY_OUTPUT");
|
|
|
|
if (output) {
|
|
|
|
spy_output = fopen(output, "a");
|
2003-09-28 19:22:30 +00:00
|
|
|
}
|
2005-09-18 11:00:00 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
if (!spy_output) {
|
2012-04-02 22:00:56 +00:00
|
|
|
/* try for the machine version first, as we may be runing
|
|
|
|
* without a user during login
|
2006-08-13 21:20:05 +00:00
|
|
|
*/
|
2010-12-12 10:30:07 +00:00
|
|
|
rc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\OpenSC Project\\PKCS11-Spy",
|
2005-09-18 11:00:00 +00:00
|
|
|
0, KEY_QUERY_VALUE, &hKey );
|
2006-08-13 21:20:05 +00:00
|
|
|
if (rc != ERROR_SUCCESS ) {
|
2010-12-12 10:30:07 +00:00
|
|
|
rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\OpenSC Project\\PKCS11-Spy",
|
2006-08-13 21:20:05 +00:00
|
|
|
0, KEY_QUERY_VALUE, &hKey );
|
|
|
|
}
|
2005-09-18 11:00:00 +00:00
|
|
|
if( rc == ERROR_SUCCESS ) {
|
|
|
|
temp_len = PATH_MAX;
|
|
|
|
rc = RegQueryValueEx( hKey, "Output", NULL, NULL,
|
|
|
|
(LPBYTE) temp_path, &temp_len);
|
|
|
|
if( (rc == ERROR_SUCCESS) && (temp_len < PATH_MAX) )
|
|
|
|
output = temp_path;
|
|
|
|
RegCloseKey( hKey );
|
|
|
|
}
|
|
|
|
spy_output = fopen(output, "a");
|
|
|
|
}
|
|
|
|
#endif
|
2003-09-28 19:22:30 +00:00
|
|
|
if (!spy_output) {
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_output = stderr;
|
|
|
|
}
|
2003-09-28 19:22:30 +00:00
|
|
|
fprintf(spy_output, "\n\n*************** OpenSC PKCS#11 spy *****************\n");
|
2003-09-03 17:19:08 +00:00
|
|
|
|
2005-09-18 11:00:00 +00:00
|
|
|
module = getenv("PKCS11SPY");
|
|
|
|
#ifdef _WIN32
|
|
|
|
if (!module) {
|
2006-08-13 21:20:05 +00:00
|
|
|
/* try for the machine version first, as we may be runing
|
2012-04-02 22:00:56 +00:00
|
|
|
* without a user during login
|
2006-08-13 21:20:05 +00:00
|
|
|
*/
|
2010-12-12 10:30:07 +00:00
|
|
|
rc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\OpenSC Project\\PKCS11-Spy",
|
2005-09-18 11:00:00 +00:00
|
|
|
0, KEY_QUERY_VALUE, &hKey );
|
2006-08-13 21:20:05 +00:00
|
|
|
if (rc != ERROR_SUCCESS ) {
|
2010-12-12 10:30:07 +00:00
|
|
|
rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\OpenSC Project\\PKCS11-Spy",
|
2006-08-13 21:20:05 +00:00
|
|
|
0, KEY_QUERY_VALUE, &hKey );
|
|
|
|
}
|
2005-09-18 11:00:00 +00:00
|
|
|
if( rc == ERROR_SUCCESS ) {
|
|
|
|
temp_len = PATH_MAX;
|
|
|
|
rc = RegQueryValueEx( hKey, "Module", NULL, NULL,
|
|
|
|
(LPBYTE) temp_path, &temp_len);
|
|
|
|
if( (rc == ERROR_SUCCESS) && (temp_len < PATH_MAX) )
|
|
|
|
module = temp_path;
|
|
|
|
RegCloseKey( hKey );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (module == NULL) {
|
|
|
|
fprintf(spy_output, "Error: no module specified. Please set PKCS11SPY environment.\n");
|
2005-09-07 20:05:13 +00:00
|
|
|
free(pkcs11_spy);
|
|
|
|
return CKR_DEVICE_ERROR;
|
|
|
|
}
|
2005-09-18 11:00:00 +00:00
|
|
|
modhandle = C_LoadModule(module, &po);
|
2003-09-04 13:50:30 +00:00
|
|
|
if (modhandle && po) {
|
2005-09-18 11:00:00 +00:00
|
|
|
fprintf(spy_output, "Loaded: \"%s\"\n", module);
|
2003-09-29 09:00:11 +00:00
|
|
|
} else {
|
2003-09-28 19:22:30 +00:00
|
|
|
po = NULL;
|
|
|
|
free(pkcs11_spy);
|
|
|
|
rv = CKR_GENERAL_ERROR;
|
|
|
|
}
|
|
|
|
return rv;
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void enter(const char *function)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
static int count = 0;
|
|
|
|
fprintf(spy_output, "\n\n%d: %s\n", count++, function);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static CK_RV retne(CK_RV rv)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
2006-11-30 08:11:58 +00:00
|
|
|
fprintf(spy_output, "Returned: %ld %s\n", (unsigned long) rv, lookup_enum ( RV_T, rv ));
|
2005-01-19 18:15:43 +00:00
|
|
|
fflush(spy_output);
|
|
|
|
return rv;
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_dump_string_in(const char *name, CK_VOID_PTR data, CK_ULONG size)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[in] %s ", name);
|
|
|
|
print_generic(spy_output, 0, data, size, NULL);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_dump_string_out(const char *name, CK_VOID_PTR data, CK_ULONG size)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[out] %s ", name);
|
|
|
|
print_generic(spy_output, 0, data, size, NULL);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_dump_ulong_in(const char *name, CK_ULONG value)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[in] %s = 0x%lx\n", name, value);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_dump_ulong_out(const char *name, CK_ULONG value)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[out] %s = 0x%lx\n", name, value);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_dump_desc_out(const char *name)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[out] %s: \n", name);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_dump_array_out(const char *name, CK_ULONG size)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[out] %s[%ld]: \n", name, size);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_attribute_req_in(const char *name, CK_ATTRIBUTE_PTR pTemplate,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_ULONG ulCount)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[in] %s[%ld]: \n", name, ulCount);
|
|
|
|
print_attribute_list_req(spy_output, pTemplate, ulCount);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_attribute_list_in(const char *name, CK_ATTRIBUTE_PTR pTemplate,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_ULONG ulCount)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[in] %s[%ld]: \n", name, ulCount);
|
|
|
|
print_attribute_list(spy_output, pTemplate, ulCount);
|
|
|
|
}
|
|
|
|
|
2005-02-06 10:28:43 +00:00
|
|
|
static void spy_attribute_list_out(const char *name, CK_ATTRIBUTE_PTR pTemplate,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_ULONG ulCount)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
fprintf(spy_output, "[out] %s[%ld]: \n", name, ulCount);
|
|
|
|
print_attribute_list(spy_output, pTemplate, ulCount);
|
|
|
|
}
|
|
|
|
|
2008-05-20 09:41:44 +00:00
|
|
|
static void print_ptr_in(const char *name, CK_VOID_PTR ptr)
|
|
|
|
{
|
2008-05-20 09:47:27 +00:00
|
|
|
fprintf(spy_output, "[in] %s = %p\n", name, ptr);
|
2008-05-20 09:41:44 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetFunctionList
|
|
|
|
(CK_FUNCTION_LIST_PTR_PTR ppFunctionList)
|
|
|
|
{
|
|
|
|
if (po == NULL) {
|
|
|
|
CK_RV rv = init_spy();
|
|
|
|
if (rv != CKR_OK)
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
enter("C_GetFunctionList");
|
|
|
|
*ppFunctionList = pkcs11_spy;
|
|
|
|
return retne(CKR_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
CK_RV C_Initialize(CK_VOID_PTR pInitArgs)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-28 19:22:30 +00:00
|
|
|
|
|
|
|
if (po == NULL) {
|
|
|
|
rv = init_spy();
|
|
|
|
if (rv != CKR_OK)
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Initialize");
|
2008-05-20 09:41:44 +00:00
|
|
|
print_ptr_in("pInitArgs", pInitArgs);
|
2003-09-03 17:19:08 +00:00
|
|
|
rv = po->C_Initialize(pInitArgs);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_Finalize(CK_VOID_PTR pReserved)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Finalize");
|
2003-09-03 17:19:08 +00:00
|
|
|
rv = po->C_Finalize(pReserved);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetInfo(CK_INFO_PTR pInfo)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetInfo");
|
2003-09-03 17:19:08 +00:00
|
|
|
rv = po->C_GetInfo(pInfo);
|
|
|
|
if(rv == CKR_OK) {
|
2008-11-24 21:53:56 +00:00
|
|
|
spy_dump_desc_out("pInfo");
|
2003-09-03 17:19:08 +00:00
|
|
|
print_ck_info(spy_output, pInfo);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetSlotList(CK_BBOOL tokenPresent,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_SLOT_ID_PTR pSlotList,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulCount)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetSlotList");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("tokenPresent", tokenPresent);
|
|
|
|
rv = po->C_GetSlotList(tokenPresent, pSlotList, pulCount);
|
|
|
|
if(rv == CKR_OK) {
|
|
|
|
spy_dump_desc_out("pSlotList");
|
|
|
|
print_slot_list(spy_output, pSlotList, *pulCount);
|
|
|
|
spy_dump_ulong_out("*pulCount", *pulCount);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetSlotInfo(CK_SLOT_ID slotID,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_SLOT_INFO_PTR pInfo)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetSlotInfo");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("slotID", slotID);
|
|
|
|
rv = po->C_GetSlotInfo(slotID, pInfo);
|
|
|
|
if(rv == CKR_OK) {
|
|
|
|
spy_dump_desc_out("pInfo");
|
|
|
|
print_slot_info(spy_output, pInfo);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetTokenInfo(CK_SLOT_ID slotID,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_TOKEN_INFO_PTR pInfo)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetTokenInfo");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("slotID", slotID);
|
|
|
|
rv = po->C_GetTokenInfo(slotID, pInfo);
|
|
|
|
if(rv == CKR_OK) {
|
|
|
|
spy_dump_desc_out("pInfo");
|
|
|
|
print_token_info(spy_output, pInfo);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetMechanismList(CK_SLOT_ID slotID,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_MECHANISM_TYPE_PTR pMechanismList,
|
|
|
|
CK_ULONG_PTR pulCount)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetMechanismList");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("slotID", slotID);
|
|
|
|
rv = po->C_GetMechanismList(slotID, pMechanismList, pulCount);
|
|
|
|
if(rv == CKR_OK) {
|
|
|
|
spy_dump_array_out("pMechanismList", *pulCount);
|
|
|
|
print_mech_list(spy_output, pMechanismList, *pulCount);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetMechanismInfo(CK_SLOT_ID slotID,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_MECHANISM_TYPE type,
|
|
|
|
CK_MECHANISM_INFO_PTR pInfo)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
|
|
|
const char *name = lookup_enum(MEC_T, type);
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetMechanismInfo");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("slotID", slotID);
|
|
|
|
if (name) {
|
|
|
|
fprintf(spy_output, "%30s \n", name);
|
|
|
|
} else {
|
|
|
|
fprintf(spy_output, " Unknown Mechanism (%08lx) \n", type);
|
|
|
|
}
|
|
|
|
rv = po->C_GetMechanismInfo(slotID, type, pInfo);
|
|
|
|
if(rv == CKR_OK) {
|
|
|
|
spy_dump_desc_out("pInfo");
|
|
|
|
print_mech_info(spy_output, type, pInfo);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_InitToken (CK_SLOT_ID slotID,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_UTF8CHAR_PTR pPin,
|
|
|
|
CK_ULONG ulPinLen,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_UTF8CHAR_PTR pLabel)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_InitToken");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("slotID", slotID);
|
|
|
|
spy_dump_string_in("pPin[ulPinLen]", pPin, ulPinLen);
|
|
|
|
spy_dump_string_in("pLabel[32]", pLabel, 32);
|
|
|
|
rv = po->C_InitToken (slotID, pPin, ulPinLen, pLabel);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_InitPIN(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_UTF8CHAR_PTR pPin,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulPinLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_InitPIN");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pPin[ulPinLen]", pPin, ulPinLen);
|
|
|
|
rv = po->C_InitPIN(hSession, pPin, ulPinLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SetPIN(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_UTF8CHAR_PTR pOldPin,
|
|
|
|
CK_ULONG ulOldLen,
|
|
|
|
CK_UTF8CHAR_PTR pNewPin,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulNewLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SetPIN");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pOldPin[ulOldLen]", pOldPin, ulOldLen);
|
|
|
|
spy_dump_string_in("pNewPin[ulNewLen]", pNewPin, ulNewLen);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_SetPIN(hSession, pOldPin, ulOldLen,
|
2003-09-03 17:19:08 +00:00
|
|
|
pNewPin, ulNewLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_OpenSession(CK_SLOT_ID slotID,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_FLAGS flags,
|
|
|
|
CK_VOID_PTR pApplication,
|
|
|
|
CK_NOTIFY Notify,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_SESSION_HANDLE_PTR phSession)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_OpenSession");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("slotID", slotID);
|
|
|
|
spy_dump_ulong_in("flags", flags);
|
|
|
|
fprintf(spy_output, "pApplication=%p\n", pApplication);
|
|
|
|
fprintf(spy_output, "Notify=%p\n", (void *)Notify);
|
|
|
|
rv = po->C_OpenSession(slotID, flags, pApplication,
|
|
|
|
Notify, phSession);
|
|
|
|
spy_dump_ulong_out("*phSession", *phSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_CloseSession(CK_SESSION_HANDLE hSession)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_CloseSession");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_CloseSession(hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_CloseAllSessions(CK_SLOT_ID slotID)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_CloseAllSessions");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("slotID", slotID);
|
|
|
|
rv = po->C_CloseAllSessions(slotID);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetSessionInfo(CK_SESSION_HANDLE hSession,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_SESSION_INFO_PTR pInfo)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetSessionInfo");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_GetSessionInfo(hSession, pInfo);
|
|
|
|
if(rv == CKR_OK) {
|
|
|
|
spy_dump_desc_out("pInfo");
|
|
|
|
print_session_info(spy_output, pInfo);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetOperationState(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pOperationState,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulOperationStateLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetOperationState");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_GetOperationState(hSession, pOperationState,
|
|
|
|
pulOperationStateLen);
|
|
|
|
if (rv == CKR_OK) {
|
2003-09-04 13:50:30 +00:00
|
|
|
spy_dump_string_out("pOperationState[*pulOperationStateLen]",
|
|
|
|
pOperationState, *pulOperationStateLen);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SetOperationState(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pOperationState,
|
|
|
|
CK_ULONG ulOperationStateLen,
|
|
|
|
CK_OBJECT_HANDLE hEncryptionKey,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hAuthenticationKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("SetOperationState");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
spy_dump_string_in("pOperationState[ulOperationStateLen]",
|
|
|
|
pOperationState, ulOperationStateLen);
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hEncryptionKey", hEncryptionKey);
|
|
|
|
spy_dump_ulong_in("hAuthenticationKey", hAuthenticationKey);
|
|
|
|
rv = po->C_SetOperationState(hSession, pOperationState,
|
|
|
|
ulOperationStateLen,
|
|
|
|
hEncryptionKey,
|
|
|
|
hAuthenticationKey);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_Login(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_USER_TYPE userType,
|
|
|
|
CK_UTF8CHAR_PTR pPin,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulPinLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Login");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "[in] userType = %s\n",
|
|
|
|
lookup_enum(USR_T, userType));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_string_in("pPin[ulPinLen]", pPin, ulPinLen);
|
|
|
|
rv = po->C_Login(hSession, userType, pPin, ulPinLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_Logout(CK_SESSION_HANDLE hSession)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Logout");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_Logout(hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_CreateObject(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_ATTRIBUTE_PTR pTemplate,
|
|
|
|
CK_ULONG ulCount,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE_PTR phObject)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_CreateObject");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_attribute_list_in("pTemplate", pTemplate, ulCount);
|
|
|
|
rv = po->C_CreateObject(hSession, pTemplate, ulCount, phObject);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_ulong_out("*phObject", *phObject);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_CopyObject(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_OBJECT_HANDLE hObject,
|
|
|
|
CK_ATTRIBUTE_PTR pTemplate,
|
|
|
|
CK_ULONG ulCount,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE_PTR phNewObject)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_CopyObject");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_ulong_in("hObject", hObject);
|
|
|
|
spy_attribute_list_in("pTemplate", pTemplate, ulCount);
|
|
|
|
rv = po->C_CopyObject(hSession, hObject, pTemplate, ulCount, phNewObject);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_ulong_out("*phNewObject", *phNewObject);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DestroyObject(CK_SESSION_HANDLE hSession,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hObject)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DestroyObject");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_ulong_in("hObject", hObject);
|
|
|
|
rv = po->C_DestroyObject(hSession, hObject);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetObjectSize(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_OBJECT_HANDLE hObject,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulSize)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetObjectSize");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_ulong_in("hObject", hObject);
|
|
|
|
rv = po->C_GetObjectSize(hSession, hObject, pulSize);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_ulong_out("*pulSize", *pulSize);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetAttributeValue(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_OBJECT_HANDLE hObject,
|
|
|
|
CK_ATTRIBUTE_PTR pTemplate,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulCount)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetAttributeValue");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-12-04 15:07:26 +00:00
|
|
|
spy_dump_ulong_in("hObject", hObject);
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_attribute_req_in("pTemplate", pTemplate, ulCount);
|
2005-07-08 21:04:23 +00:00
|
|
|
/* PKCS#11 says:
|
|
|
|
* ``Note that the error codes CKR_ATTRIBUTE_SENSITIVE,
|
|
|
|
* CKR_ATTRIBUTE_TYPE_INVALID, and CKR_BUFFER_TOO_SMALL do not denote
|
|
|
|
* true errors for C_GetAttributeValue.''
|
|
|
|
* That's why we ignore these error codes, because we want to display
|
|
|
|
* all other attributes anyway (they may have been returned correctly) */
|
2003-09-03 17:19:08 +00:00
|
|
|
rv = po->C_GetAttributeValue(hSession, hObject, pTemplate, ulCount);
|
2005-07-08 21:04:23 +00:00
|
|
|
if (rv == CKR_OK || rv == CKR_ATTRIBUTE_SENSITIVE ||
|
|
|
|
rv == CKR_ATTRIBUTE_TYPE_INVALID || rv == CKR_BUFFER_TOO_SMALL) {
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_attribute_list_out("pTemplate", pTemplate, ulCount);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SetAttributeValue(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_OBJECT_HANDLE hObject,
|
|
|
|
CK_ATTRIBUTE_PTR pTemplate,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulCount)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SetAttributeValue");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_ulong_in("hObject", hObject);
|
|
|
|
spy_attribute_list_in("pTemplate", pTemplate, ulCount);
|
|
|
|
rv = po->C_SetAttributeValue(hSession, hObject, pTemplate, ulCount);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_FindObjectsInit(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_ATTRIBUTE_PTR pTemplate,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulCount)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_FindObjectsInit");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_attribute_list_in("pTemplate", pTemplate, ulCount);
|
|
|
|
rv = po->C_FindObjectsInit(hSession, pTemplate, ulCount);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_FindObjects(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_OBJECT_HANDLE_PTR phObject,
|
|
|
|
CK_ULONG ulMaxObjectCount,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulObjectCount)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_FindObjects");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_ulong_in("ulMaxObjectCount", ulMaxObjectCount);
|
|
|
|
rv = po->C_FindObjects(hSession, phObject, ulMaxObjectCount,
|
|
|
|
pulObjectCount);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
CK_ULONG i;
|
|
|
|
spy_dump_ulong_out("ulObjectCount", *pulObjectCount);
|
|
|
|
for (i = 0; i < *pulObjectCount; i++) {
|
2010-10-05 14:42:01 +00:00
|
|
|
fprintf(spy_output, "Object 0x%lx matches\n", phObject[i]);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_FindObjectsFinal");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_FindObjectsFinal(hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_EncryptInit(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_EncryptInit");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hKey", hKey);
|
|
|
|
rv = po->C_EncryptInit(hSession, pMechanism, hKey);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_Encrypt(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pData,
|
|
|
|
CK_ULONG ulDataLen,
|
|
|
|
CK_BYTE_PTR pEncryptedData,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulEncryptedDataLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Encrypt");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pData[ulDataLen]", pData, ulDataLen);
|
|
|
|
rv = po->C_Encrypt(hSession, pData, ulDataLen,
|
|
|
|
pEncryptedData, pulEncryptedDataLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pEncryptedData[*pulEncryptedDataLen]",
|
|
|
|
pEncryptedData, *pulEncryptedDataLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_EncryptUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pPart,
|
|
|
|
CK_ULONG ulPartLen,
|
|
|
|
CK_BYTE_PTR pEncryptedPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulEncryptedPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_EncryptUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pPart[ulPartLen]", pPart, ulPartLen);
|
|
|
|
rv = po->C_EncryptUpdate(hSession, pPart, ulPartLen, pEncryptedPart,
|
|
|
|
pulEncryptedPartLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pEncryptedPart[*pulEncryptedPartLen]",
|
|
|
|
pEncryptedPart, *pulEncryptedPartLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_EncryptFinal(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pLastEncryptedPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulLastEncryptedPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_EncryptFinal");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_EncryptFinal(hSession, pLastEncryptedPart,
|
|
|
|
pulLastEncryptedPartLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pLastEncryptedPart[*pulLastEncryptedPartLen]",
|
|
|
|
pLastEncryptedPart, *pulLastEncryptedPartLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DecryptInit(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DecryptInit");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hKey", hKey);
|
|
|
|
rv = po->C_DecryptInit(hSession, pMechanism, hKey);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_Decrypt(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pEncryptedData,
|
|
|
|
CK_ULONG ulEncryptedDataLen,
|
|
|
|
CK_BYTE_PTR pData,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulDataLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Decrypt");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pEncryptedData[ulEncryptedDataLen]",
|
|
|
|
pEncryptedData, ulEncryptedDataLen);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_Decrypt(hSession, pEncryptedData, ulEncryptedDataLen,
|
2003-09-03 17:19:08 +00:00
|
|
|
pData, pulDataLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pData[*pulDataLen]", pData, *pulDataLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DecryptUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pEncryptedPart,
|
|
|
|
CK_ULONG ulEncryptedPartLen,
|
|
|
|
CK_BYTE_PTR pPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DecryptUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pEncryptedPart[ulEncryptedPartLen]",
|
|
|
|
pEncryptedPart, ulEncryptedPartLen);
|
|
|
|
rv = po->C_DecryptUpdate(hSession, pEncryptedPart, ulEncryptedPartLen,
|
|
|
|
pPart, pulPartLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pPart[*pulPartLen]", pPart, *pulPartLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DecryptFinal(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pLastPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulLastPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DecryptFinal");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_DecryptFinal(hSession, pLastPart, pulLastPartLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pLastPart[*pulLastPartLen]",
|
|
|
|
pLastPart, *pulLastPartLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DigestInit(CK_SESSION_HANDLE hSession,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DigestInit");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
rv = po->C_DigestInit(hSession, pMechanism);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_Digest(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pData,
|
|
|
|
CK_ULONG ulDataLen,
|
|
|
|
CK_BYTE_PTR pDigest,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulDigestLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Digest");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pData[ulDataLen]", pData, ulDataLen);
|
|
|
|
rv = po->C_Digest(hSession, pData, ulDataLen, pDigest, pulDigestLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pDigest[*pulDigestLen]",
|
|
|
|
pDigest, *pulDigestLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DigestUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DigestUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pPart[ulPartLen]", pPart, ulPartLen);
|
|
|
|
rv = po->C_DigestUpdate(hSession, pPart, ulPartLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DigestKey(CK_SESSION_HANDLE hSession,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DigestKey");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_ulong_in("hKey", hKey);
|
|
|
|
rv = po->C_DigestKey(hSession, hKey);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DigestFinal(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pDigest,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulDigestLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DigestFinal");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_DigestFinal(hSession, pDigest, pulDigestLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pDigest[*pulDigestLen]",
|
|
|
|
pDigest, *pulDigestLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SignInit(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SignInit");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hKey", hKey);
|
|
|
|
rv = po->C_SignInit(hSession, pMechanism, hKey);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_Sign(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pData,
|
|
|
|
CK_ULONG ulDataLen,
|
|
|
|
CK_BYTE_PTR pSignature,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulSignatureLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Sign");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pData[ulDataLen]", pData, ulDataLen);
|
|
|
|
rv = po->C_Sign(hSession, pData, ulDataLen, pSignature, pulSignatureLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pSignature[*pulSignatureLen]",
|
|
|
|
pSignature, *pulSignatureLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SignUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SignUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pPart[ulPartLen]", pPart, ulPartLen);
|
|
|
|
rv = po->C_SignUpdate(hSession, pPart, ulPartLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SignFinal(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pSignature,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulSignatureLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SignFinal");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_SignFinal(hSession, pSignature, pulSignatureLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pSignature[*pulSignatureLen]",
|
|
|
|
pSignature, *pulSignatureLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SignRecoverInit(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SignRecoverInit");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hKey", hKey);
|
|
|
|
rv = po->C_SignRecoverInit(hSession, pMechanism, hKey);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SignRecover(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pData,
|
|
|
|
CK_ULONG ulDataLen,
|
|
|
|
CK_BYTE_PTR pSignature,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulSignatureLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SignRecover");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pData[ulDataLen]", pData, ulDataLen);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_SignRecover(hSession, pData, ulDataLen,
|
2003-09-03 17:19:08 +00:00
|
|
|
pSignature, pulSignatureLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pSignature[*pulSignatureLen]",
|
|
|
|
pSignature, *pulSignatureLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_VerifyInit");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hKey", hKey);
|
|
|
|
rv = po->C_VerifyInit(hSession, pMechanism, hKey);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_Verify(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pData,
|
|
|
|
CK_ULONG ulDataLen,
|
|
|
|
CK_BYTE_PTR pSignature,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulSignatureLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_Verify");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pData[ulDataLen]", pData, ulDataLen);
|
|
|
|
spy_dump_string_in("pSignature[ulSignatureLen]",
|
|
|
|
pSignature, ulSignatureLen);
|
|
|
|
rv = po->C_Verify(hSession, pData, ulDataLen, pSignature, ulSignatureLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_VerifyUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_VerifyUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pPart[ulPartLen]", pPart, ulPartLen);
|
|
|
|
rv = po->C_VerifyUpdate(hSession, pPart, ulPartLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_VerifyFinal(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pSignature,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulSignatureLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_VerifyFinal");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pSignature[ulSignatureLen]",
|
|
|
|
pSignature, ulSignatureLen);
|
|
|
|
rv = po->C_VerifyFinal(hSession, pSignature, ulSignatureLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_VerifyRecoverInit(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE hKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_VerifyRecoverInit");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hKey", hKey);
|
|
|
|
rv = po->C_VerifyRecoverInit(hSession, pMechanism, hKey);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_VerifyRecover(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pSignature,
|
|
|
|
CK_ULONG ulSignatureLen,
|
|
|
|
CK_BYTE_PTR pData,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulDataLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_VerifyRecover");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pSignature[ulSignatureLen]",
|
|
|
|
pSignature, ulSignatureLen);
|
|
|
|
rv = po->C_VerifyRecover(hSession, pSignature, ulSignatureLen,
|
|
|
|
pData, pulDataLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pData[*pulDataLen]", pData, *pulDataLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DigestEncryptUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pPart,
|
|
|
|
CK_ULONG ulPartLen,
|
|
|
|
CK_BYTE_PTR pEncryptedPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulEncryptedPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DigestEncryptUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pPart[ulPartLen]", pPart, ulPartLen);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_DigestEncryptUpdate(hSession, pPart, ulPartLen,
|
2003-09-03 17:19:08 +00:00
|
|
|
pEncryptedPart, pulEncryptedPartLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pEncryptedPart[*pulEncryptedPartLen]",
|
|
|
|
pEncryptedPart, *pulEncryptedPartLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DecryptDigestUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pEncryptedPart,
|
|
|
|
CK_ULONG ulEncryptedPartLen,
|
|
|
|
CK_BYTE_PTR pPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DecryptDigestUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pEncryptedPart[ulEncryptedPartLen]",
|
|
|
|
pEncryptedPart, ulEncryptedPartLen);
|
|
|
|
rv = po->C_DecryptDigestUpdate(hSession, pEncryptedPart,
|
|
|
|
ulEncryptedPartLen,
|
|
|
|
pPart, pulPartLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pPart[*pulPartLen]", pPart, *pulPartLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SignEncryptUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pPart,
|
|
|
|
CK_ULONG ulPartLen,
|
|
|
|
CK_BYTE_PTR pEncryptedPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulEncryptedPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SignEncryptUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pPart[ulPartLen]", pPart, ulPartLen);
|
|
|
|
rv = po->C_SignEncryptUpdate(hSession, pPart, ulPartLen,
|
|
|
|
pEncryptedPart, pulEncryptedPartLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pEncryptedPart[*pulEncryptedPartLen]",
|
|
|
|
pEncryptedPart, *pulEncryptedPartLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DecryptVerifyUpdate(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pEncryptedPart,
|
|
|
|
CK_ULONG ulEncryptedPartLen,
|
|
|
|
CK_BYTE_PTR pPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulPartLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DecryptVerifyUpdate");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pEncryptedPart[ulEncryptedPartLen]",
|
|
|
|
pEncryptedPart, ulEncryptedPartLen);
|
|
|
|
rv = po->C_DecryptVerifyUpdate(hSession, pEncryptedPart,
|
2003-09-03 18:08:54 +00:00
|
|
|
ulEncryptedPartLen, pPart,
|
2003-09-03 17:19:08 +00:00
|
|
|
pulPartLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pPart[*pulPartLen]", pPart, *pulPartLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GenerateKey(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
|
|
|
CK_ATTRIBUTE_PTR pTemplate,
|
|
|
|
CK_ULONG ulCount,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE_PTR phKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GenerateKey");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_attribute_list_in("pTemplate", pTemplate, ulCount);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_GenerateKey(hSession, pMechanism, pTemplate,
|
2003-09-03 17:19:08 +00:00
|
|
|
ulCount, phKey);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_ulong_out("hKey", *phKey);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GenerateKeyPair(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
|
|
|
CK_ATTRIBUTE_PTR pPublicKeyTemplate,
|
|
|
|
CK_ULONG ulPublicKeyAttributeCount,
|
|
|
|
CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
|
|
|
|
CK_ULONG ulPrivateKeyAttributeCount,
|
|
|
|
CK_OBJECT_HANDLE_PTR phPublicKey,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE_PTR phPrivateKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GenerateKeyPair");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
|
|
|
spy_attribute_list_in("pPublicKeyTemplate",
|
|
|
|
pPublicKeyTemplate, ulPublicKeyAttributeCount);
|
|
|
|
spy_attribute_list_in("pPrivateKeyTemplate",
|
|
|
|
pPrivateKeyTemplate, ulPrivateKeyAttributeCount);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_GenerateKeyPair(hSession, pMechanism, pPublicKeyTemplate,
|
|
|
|
ulPublicKeyAttributeCount, pPrivateKeyTemplate,
|
|
|
|
ulPrivateKeyAttributeCount, phPublicKey,
|
2003-09-03 17:19:08 +00:00
|
|
|
phPrivateKey);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_ulong_out("hPublicKey", *phPublicKey);
|
|
|
|
spy_dump_ulong_out("hPrivateKey", *phPrivateKey);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_WrapKey(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
|
|
|
CK_OBJECT_HANDLE hWrappingKey,
|
|
|
|
CK_OBJECT_HANDLE hKey,
|
|
|
|
CK_BYTE_PTR pWrappedKey,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG_PTR pulWrappedKeyLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_WrapKey");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hWrappingKey", hWrappingKey);
|
|
|
|
spy_dump_ulong_in("hKey", hKey);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_WrapKey(hSession, pMechanism, hWrappingKey,
|
2003-09-03 17:19:08 +00:00
|
|
|
hKey, pWrappedKey, pulWrappedKeyLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("pWrappedKey[*pulWrappedKeyLen]",
|
|
|
|
pWrappedKey, *pulWrappedKeyLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_UnwrapKey(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
|
|
|
CK_OBJECT_HANDLE hUnwrappingKey,
|
|
|
|
CK_BYTE_PTR pWrappedKey,
|
|
|
|
CK_ULONG ulWrappedKeyLen,
|
|
|
|
CK_ATTRIBUTE_PTR pTemplate,
|
|
|
|
CK_ULONG ulAttributeCount,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE_PTR phKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_UnwrapKey");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hUnwrappingKey", hUnwrappingKey);
|
|
|
|
spy_dump_string_in("pWrappedKey[ulWrappedKeyLen]",
|
|
|
|
pWrappedKey, ulWrappedKeyLen);
|
|
|
|
spy_attribute_list_in("pTemplate", pTemplate, ulAttributeCount);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_UnwrapKey(hSession, pMechanism, hUnwrappingKey,
|
|
|
|
pWrappedKey, ulWrappedKeyLen, pTemplate,
|
2003-09-03 17:19:08 +00:00
|
|
|
ulAttributeCount, phKey);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_ulong_out("hKey", *phKey);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_DeriveKey(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_MECHANISM_PTR pMechanism,
|
|
|
|
CK_OBJECT_HANDLE hBaseKey,
|
|
|
|
CK_ATTRIBUTE_PTR pTemplate,
|
|
|
|
CK_ULONG ulAttributeCount,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_OBJECT_HANDLE_PTR phKey)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_DeriveKey");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
fprintf(spy_output, "pMechanism->type=%s\n",
|
|
|
|
lookup_enum(MEC_T, pMechanism->mechanism));
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hBaseKey", hBaseKey);
|
|
|
|
spy_attribute_list_in("pTemplate", pTemplate, ulAttributeCount);
|
2003-09-03 18:08:54 +00:00
|
|
|
rv = po->C_DeriveKey(hSession, pMechanism, hBaseKey,
|
2003-09-03 17:19:08 +00:00
|
|
|
pTemplate, ulAttributeCount, phKey);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_ulong_out("hKey", *phKey);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_SeedRandom(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR pSeed,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulSeedLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_SeedRandom");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
spy_dump_string_in("pSeed[ulSeedLen]", pSeed, ulSeedLen);
|
|
|
|
rv = po->C_SeedRandom(hSession, pSeed, ulSeedLen);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GenerateRandom(CK_SESSION_HANDLE hSession,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_BYTE_PTR RandomData,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_ULONG ulRandomLen)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GenerateRandom");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_GenerateRandom(hSession, RandomData, ulRandomLen);
|
|
|
|
if (rv == CKR_OK) {
|
|
|
|
spy_dump_string_out("RandomData[ulRandomLen]",
|
|
|
|
RandomData, ulRandomLen);
|
|
|
|
}
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_GetFunctionStatus(CK_SESSION_HANDLE hSession)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_GetFunctionStatus");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_GetFunctionStatus(hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_CancelFunction(CK_SESSION_HANDLE hSession)
|
2003-09-03 17:19:08 +00:00
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_CancelFunction");
|
2003-09-03 17:19:08 +00:00
|
|
|
spy_dump_ulong_in("hSession", hSession);
|
|
|
|
rv = po->C_CancelFunction(hSession);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 19:22:30 +00:00
|
|
|
CK_RV C_WaitForSlotEvent(CK_FLAGS flags,
|
2003-09-03 18:08:54 +00:00
|
|
|
CK_SLOT_ID_PTR pSlot,
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_VOID_PTR pRserved)
|
|
|
|
{
|
|
|
|
CK_RV rv;
|
2003-09-04 13:50:30 +00:00
|
|
|
enter("C_WaitForSlotEvent");
|
2008-11-24 22:06:27 +00:00
|
|
|
spy_dump_ulong_in("flags", flags);
|
2003-09-03 17:19:08 +00:00
|
|
|
rv = po->C_WaitForSlotEvent(flags, pSlot, pRserved);
|
2003-09-04 13:50:30 +00:00
|
|
|
return retne(rv);
|
2003-09-03 17:19:08 +00:00
|
|
|
}
|