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
|
|
|
|
*/
|
2003-09-03 18:08:54 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
2003-09-03 17:19:08 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2003-09-03 18:08:54 +00:00
|
|
|
#include "pkcs11-display.h"
|
2003-09-03 17:19:08 +00:00
|
|
|
|
2005-09-07 20:05:13 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <winreg.h>
|
|
|
|
#endif
|
|
|
|
|
2003-09-03 17:19:08 +00:00
|
|
|
#define __PASTE(x,y) x##y
|
|
|
|
|
2003-09-29 09:00:11 +00:00
|
|
|
/* Declare all spy_* Cryptoki function */
|
2003-09-03 17:19:08 +00:00
|
|
|
|
|
|
|
#define CK_NEED_ARG_LIST 1
|
2003-09-28 19:22:30 +00:00
|
|
|
#define CK_PKCS11_FUNCTION_INFO(name) CK_RV name
|
2003-09-03 17:19:08 +00:00
|
|
|
|
2003-09-03 18:08:54 +00:00
|
|
|
#include "rsaref/pkcs11f.h"
|
2003-09-03 17:19:08 +00:00
|
|
|
|
2003-09-04 13:50:30 +00:00
|
|
|
/* Spy Module Function List */
|
2003-09-03 17:19:08 +00:00
|
|
|
CK_FUNCTION_LIST_PTR pkcs11_spy = NULL;
|
2003-09-04 13:50:30 +00:00
|
|
|
/* Real Module Function List */
|
2003-09-03 17:19:08 +00:00
|
|
|
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 */
|
2003-09-03 17:19:08 +00:00
|
|
|
FILE *spy_output = NULL;
|
|
|
|
|
|
|
|
#undef CK_NEED_ARG_LIST
|
|
|
|
#undef CK_PKCS11_FUNCTION_INFO
|
|
|
|
#define CK_PKCS11_FUNCTION_INFO(name) \
|
2003-09-28 19:22:30 +00:00
|
|
|
pkcs11_spy->name = name;
|
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];
|
|
|
|
int temp_len;
|
|
|
|
long rc;
|
|
|
|
HKEY hKey;
|
|
|
|
#endif
|
2003-09-04 13:50:30 +00:00
|
|
|
|
|
|
|
/* Allocates and initializes the pkcs11_spy structure */
|
|
|
|
pkcs11_spy =
|
|
|
|
(CK_FUNCTION_LIST_PTR) malloc(sizeof(CK_FUNCTION_LIST));
|
|
|
|
if (pkcs11_spy) {
|
2003-09-03 18:08:54 +00:00
|
|
|
#include "rsaref/pkcs11f.h"
|
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
|
|
|
|
2005-09-18 11:00:00 +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) {
|
2006-08-13 21:20:05 +00:00
|
|
|
/* try for the machine version first, as we may be runing
|
|
|
|
* without a user during login
|
|
|
|
*/
|
|
|
|
rc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\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 ) {
|
|
|
|
rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\PKCS11-Spy",
|
|
|
|
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
|
|
|
|
* without a user during login
|
|
|
|
*/
|
|
|
|
rc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\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 ) {
|
|
|
|
rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\PKCS11-Spy",
|
|
|
|
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
|
|
|
{
|
2005-01-19 18:15:43 +00:00
|
|
|
fprintf(spy_output, "Returned: %ld %s\n", rv, lookup_enum ( RV_T, rv ));
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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");
|
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
|
|
|
/* After Finalize do not use the module again */
|
|
|
|
C_UnloadModule(modhandle);
|
|
|
|
po = NULL;
|
|
|
|
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) {
|
|
|
|
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++) {
|
|
|
|
fprintf(spy_output, "Object %ld Matches\n", phObject[i]);
|
|
|
|
}
|
|
|
|
}
|
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");
|
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
|
|
|
}
|