[pkg-opensc-commit] [pkcs11-helper] 19/60: standalone interface removed
Eric Dorland
eric at moszumanska.debian.org
Fri Jan 6 23:39:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to tag pkcs11-helper-1.02
in repository pkcs11-helper.
commit db2ffbcb347bd506cfb16ac0a5288f9b431b1d81
Author: alonbl <alonbl at 485eb718-1723-0410-b8a9-88cf21a28c35>
Date: Wed Nov 29 18:19:55 2006 +0000
standalone interface removed
---
config-w32-vc.h.in | 3 -
configure.ac | 11 -
include/pkcs11-helper-1.0/Makefile.am | 5 -
include/pkcs11-helper-1.0/pkcs11h-core.h | 3 -
include/pkcs11-helper-1.0/pkcs11h-engines.h | 17 -
include/pkcs11-helper-1.0/pkcs11h-standalone.h | 128 ----
lib/Makefile.am | 9 +-
lib/Makefile.w32-vc | 3 -
lib/pkcs11h-core.c | 3 -
lib/pkcs11h-crypto.c | 209 ------
lib/pkcs11h-standalone.c | 856 -------------------------
lib/standalone.exports | 2 -
12 files changed, 1 insertion(+), 1248 deletions(-)
diff --git a/config-w32-vc.h.in b/config-w32-vc.h.in
index fbeb414..bc93e16 100644
--- a/config-w32-vc.h.in
+++ b/config-w32-vc.h.in
@@ -28,9 +28,6 @@
/* Enable slotevent interface */
#define ENABLE_PKCS11H_SLOTEVENT 1
-/* Enable standalone interface */
-#define ENABLE_PKCS11H_STANDALONE 1
-
/* Enable threading */
#define ENABLE_PKCS11H_THREADING 1
diff --git a/configure.ac b/configure.ac
index 29263f2..4a54e97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,12 +147,6 @@ AC_ARG_ENABLE(openssl,
[ENABLE_PKCS11H_OPENSSL="yes"]
)
-AC_ARG_ENABLE(standalone,
- [ --disable-standalone Disable standalone interface],
- [ENABLE_PKCS11H_STANDALONE="${enableval}"],
- [ENABLE_PKCS11H_STANDALONE="yes"]
-)
-
AC_ARG_ENABLE(pedantic,
[ --enable-pedantic Enable pedantic compiler warnings, will not generate a working executable (debugging option)],
[PEDANTIC="${enableval}"],
@@ -359,10 +353,6 @@ if test "${ENABLE_PKCS11H_OPENSSL}" = "yes"; then
AC_DEFINE([ENABLE_PKCS11H_OPENSSL], 1, [Enable openssl interface])
PKCS11H_FEATURES="${PKCS11H_FEATURES} openssl"
fi
-if test "${ENABLE_PKCS11H_STANDALONE}" = "yes"; then
- AC_DEFINE([ENABLE_PKCS11H_STANDALONE], 1, [Enable standalone interface])
- PKCS11H_FEATURES="${PKCS11H_FEATURES} standalone"
-fi
if test \
"${WITH_CRYPTO_ENGINE_OPENSSL}" = "yes" -o \
"${WITH_CRYPTO_ENGINE_GNUTLS}" = "yes" -o \
@@ -384,7 +374,6 @@ AM_CONDITIONAL(ENABLE_PKCS11H_CERTIFICATE, test "${ENABLE_PKCS11H_CERTIFICATE}"
AM_CONDITIONAL(ENABLE_PKCS11H_LOCATE, test "${ENABLE_PKCS11H_LOCATE}" = "yes")
AM_CONDITIONAL(ENABLE_PKCS11H_SLOTEVENT, test "${ENABLE_PKCS11H_SLOTEVENT}" = "yes")
AM_CONDITIONAL(ENABLE_PKCS11H_OPENSSL, test "${ENABLE_PKCS11H_OPENSSL}" = "yes")
-AM_CONDITIONAL(ENABLE_PKCS11H_STANDALONE, test "${ENABLE_PKCS11H_STANDALONE}" = "yes")
AC_CONFIG_FILES([
Makefile
config-w32-vc.h
diff --git a/include/pkcs11-helper-1.0/Makefile.am b/include/pkcs11-helper-1.0/Makefile.am
index 40d839e..6383645 100644
--- a/include/pkcs11-helper-1.0/Makefile.am
+++ b/include/pkcs11-helper-1.0/Makefile.am
@@ -81,11 +81,6 @@ myinc_HEADERS+=pkcs11h-openssl.h
else
noinst_HEADERS+=pkcs11h-openssl.h
endif
-if ENABLE_PKCS11H_STANDALONE
-myinc_HEADERS+=pkcs11h-standalone.h
-else
-noinst_HEADERS+=pkcs11h-standalone.h
-endif
if ENABLE_PKCS11H_TOKEN
myinc_HEADERS+=pkcs11h-token.h
else
diff --git a/include/pkcs11-helper-1.0/pkcs11h-core.h b/include/pkcs11-helper-1.0/pkcs11h-core.h
index b63a5f4..5081fdc 100644
--- a/include/pkcs11-helper-1.0/pkcs11h-core.h
+++ b/include/pkcs11-helper-1.0/pkcs11h-core.h
@@ -86,7 +86,6 @@
* - @ref pkcs11h-data.h "Data" - Handle data objects.
* - @ref pkcs11h-locate.h "Locate" - Simplified object locate interface.
* - @ref pkcs11h-openssl.h "OpenSSL" - OpenSSL engine support.
- * - @ref pkcs11h-standalone.h "Standalone Debugging" - Token structure debugging interface.
* @page License
* @par pkcs11-helper License
* @include COPYING
@@ -140,8 +139,6 @@ extern "C" {
#define PKCS11H_FEATURE_MASK_SLOTEVENT (1<< 8)
/** OpenSSL interface is enabled. */
#define PKCS11H_FEATURE_MASK_OPENSSL (1<< 9)
-/** Standalone interface is enabled. */
-#define PKCS11H_FEATURE_MASK_STANDALONE (1<<10)
/** @} */
/**
diff --git a/include/pkcs11-helper-1.0/pkcs11h-engines.h b/include/pkcs11-helper-1.0/pkcs11h-engines.h
index 180aeb5..8ae9656 100644
--- a/include/pkcs11-helper-1.0/pkcs11h-engines.h
+++ b/include/pkcs11-helper-1.0/pkcs11h-engines.h
@@ -166,23 +166,6 @@ typedef struct pkcs11h_crypto_engine_s {
);
/**
- * @brief Get certificate serial number.
- * @param global_data Engine data.
- * @param blob Certificate blob.
- * @param blob_size Certificate blob size.
- * @param serial serial buffer.
- * @param serial_max serial buffer size.
- * @return None zero - Sucess.
- */
- int (*certificate_get_serial) (
- IN void * const global_data,
- IN const unsigned char * const blob,
- IN const size_t blob_size,
- OUT char * const serial,
- IN const size_t serial_max
- );
-
- /**
* @brief Determine if one certificate is an issuer of another.
* @param global_data Engine data.
* @param issuer_blob Issuer's certificate blob.
diff --git a/include/pkcs11-helper-1.0/pkcs11h-standalone.h b/include/pkcs11-helper-1.0/pkcs11h-standalone.h
deleted file mode 100644
index b2c0a7f..0000000
--- a/include/pkcs11-helper-1.0/pkcs11h-standalone.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2005-2006 Alon Bar-Lev <alon.barlev at gmail.com>
- * All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, or the BSD license.
- *
- * GNU General Public License (GPL) Version 2
- * ===========================================
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program (see the file COPYING.GPL included with this
- * distribution); if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * BSD License
- * ============
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * o Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o Neither the name of the <ORGANIZATION> nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file pkcs11h-standalone.h
- * @brief pkcs11-helper standalone interface.
- * @author Alon Bar-Lev <alon.barlev at gmail.com>
- */
-
-#ifndef __PKCS11H_STANDALONE_H
-#define __PKCS11H_STANDALONE_H
-
-#include <pkcs11-helper-1.0/pkcs11h-core.h>
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/**
- * @brief Output hook.
- * @param global_data Hook global data.
- * @param format printf style format.
- * @param ... printf style args.
- */
-typedef void (*pkcs11h_output_print_t)(
- IN void * const global_data,
- IN const char * const format,
- IN ...
-)
-#if __GNUC__ > 2
- __attribute__ ((format (printf, 2, 3)))
-#endif
-;
-
-
-/**
- * @brief Dumps slots, suitabe for debugging.
- * @param my_output Output function.
- * @param global_data Parameter to output function.
- * @param provider Provider to load.
- * @param prms[] If not null:
- * - 0 slot type parameter name
- * - 1 slot parameter name
- */
-void
-pkcs11h_standalone_dump_slots (
- IN const pkcs11h_output_print_t my_output,
- IN void * const global_data,
- IN const char * const provider,
- IN const char * const prms[]
-);
-
-/**
- * @brief Dumps objects, suitabe for debugging.
- * @param my_output Output function.
- * @param global_data Parameter to output function.
- * @param provider Provider to load.
- * @param slot slot to dump (number).
- * @param pin PIN to use.
- * @param prms[] If not null:
- * - 0 slot type parameter name
- * - 1 slot parameter name
- * - 2 object type parameter name
- * - 3 object parameter name
- */
-void
-pkcs11h_standalone_dump_objects (
- IN const pkcs11h_output_print_t my_output,
- IN void * const global_data,
- IN const char * const provider,
- IN const char * const slot,
- IN const char * const pin,
- IN const char * const prms[]
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __PKCS11H_STANDALONE_H */
diff --git a/lib/Makefile.am b/lib/Makefile.am
index edf88a7..e14e03d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -65,7 +65,6 @@ EXTRA_DIST= \
locate.exports \
openssl.exports \
slotevent.exports \
- standalone.exports \
token.exports
pkgconfig_DATA = libpkcs11-helper-1.pc
@@ -81,7 +80,6 @@ nodist_libpkcs11_helper_la_SOURCES= \
../pkcs11-helper-1.0/pkcs11h-data.h \
../pkcs11-helper-1.0/pkcs11h-locate.h \
../pkcs11-helper-1.0/pkcs11h-openssl.h \
- ../pkcs11-helper-1.0/pkcs11h-standalone.h \
$(PKCS11_INCLUDES) \
pkcs11-helper.exports
libpkcs11_helper_la_SOURCES= \
@@ -99,8 +97,7 @@ libpkcs11_helper_la_SOURCES= \
pkcs11h-locate.c \
pkcs11h-data.c \
pkcs11h-serialization.c \
- pkcs11h-openssl.c \
- pkcs11h-standalone.c
+ pkcs11h-openssl.c
libpkcs11_helper_la_LDFLAGS= \
-version-info @LIBPKCS11_HELPER_LT_CURRENT@:@LIBPKCS11_HELPER_LT_REVISION@:@LIBPKCS11_HELPER_LT_AGE@ \
-export-symbols pkcs11-helper.exports \
@@ -115,7 +112,6 @@ pkcs11-helper.exports: \
locate.exports \
openssl.exports \
slotevent.exports \
- standalone.exports \
token.exports
cat core.exports > pkcs11-helper.exports
if ENABLE_PKCS11H_CERTIFICATE
@@ -133,9 +129,6 @@ endif
if ENABLE_PKCS11H_SLOTEVENT
cat slotevent.exports >> pkcs11-helper.exports
endif
-if ENABLE_PKCS11H_STANDALONE
- cat standalone.exports >> pkcs11-helper.exports
-endif
if ENABLE_PKCS11H_TOKEN
cat token.exports >> pkcs11-helper.exports
endif
diff --git a/lib/Makefile.w32-vc b/lib/Makefile.w32-vc
index 5b8c0dd..e8a36ad 100644
--- a/lib/Makefile.w32-vc
+++ b/lib/Makefile.w32-vc
@@ -111,7 +111,6 @@ HEADERS = \
../include/pkcs11-helper-1.0/pkcs11h-engines.h \
../include/pkcs11-helper-1.0/pkcs11h-locate.h \
../include/pkcs11-helper-1.0/pkcs11h-openssl.h \
- ../include/pkcs11-helper-1.0/pkcs11h-standalone.h \
../include/pkcs11-helper-1.0/pkcs11h-token.h
OBJS = \
@@ -125,7 +124,6 @@ OBJS = \
pkcs11h-serialization.obj \
pkcs11h-session.obj \
pkcs11h-slotevent.obj \
- pkcs11h-standalone.obj \
pkcs11h-sys.obj \
pkcs11h-threading.obj \
pkcs11h-token.obj \
@@ -141,7 +139,6 @@ pkcs11-helper-1.dll.def:
type data.exports >> pkcs11-helper-1.dll.def
type locate.exports >> pkcs11-helper-1.dll.def
type slotevent.exports >> pkcs11-helper-1.dll.def
- type standalone.exports >> pkcs11-helper-1.dll.def
type token.exports >> pkcs11-helper-1.dll.def
!ifdef OPENSSL
type openssl.exports >> pkcs11-helper-1.dll.def
diff --git a/lib/pkcs11h-core.c b/lib/pkcs11h-core.c
index 257f6b6..ee4018f 100644
--- a/lib/pkcs11h-core.c
+++ b/lib/pkcs11h-core.c
@@ -263,9 +263,6 @@ pkcs11h_getFeatures (void) {
#if defined(ENABLE_PKCS11H_OPENSSL)
PKCS11H_FEATURE_MASK_OPENSSL |
#endif
-#if defined(ENABLE_PKCS11H_STANDALONE)
- PKCS11H_FEATURE_MASK_STANDALONE |
-#endif
0
);
return features;
diff --git a/lib/pkcs11h-crypto.c b/lib/pkcs11h-crypto.c
index 1c5768b..8699c83 100644
--- a/lib/pkcs11h-crypto.c
+++ b/lib/pkcs11h-crypto.c
@@ -66,9 +66,6 @@
#if defined(ENABLE_PKCS11H_ENGINE_WIN32)
#include <wincrypt.h>
-#if !defined(X509_MULTI_BYTE_INTEGER)
-#define X509_MULTI_BYTE_INTEGER ((LPCSTR)28)
-#endif
#if !defined(CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT)
#define CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT 0x02
#endif
@@ -148,16 +145,6 @@ __pkcs11h_crypto_openssl_certificate_get_dn (
static
int
-__pkcs11h_crypto_openssl_certificate_get_serial (
- IN void * const global_data,
- IN const unsigned char * const blob,
- IN const size_t blob_size,
- OUT char * const serial,
- IN const size_t serial_max
-);
-
-static
-int
__pkcs11h_crypto_openssl_certificate_is_issuer (
IN void * const global_data,
IN const unsigned char * const signer_blob,
@@ -203,16 +190,6 @@ __pkcs11h_crypto_gnutls_certificate_get_dn (
static
int
-__pkcs11h_crypto_gnutls_certificate_get_serial (
- IN void * const global_data,
- IN const unsigned char * const blob,
- IN const size_t blob_size,
- OUT char * const serial,
- IN const size_t serial_max
-);
-
-static
-int
__pkcs11h_crypto_gnutls_certificate_is_issuer (
IN void * const global_data,
IN const unsigned char * const signer_blob,
@@ -240,15 +217,6 @@ typedef DWORD (WINAPI *CertNameToStrW_t) (
LPWSTR psz,
DWORD csz
);
-typedef BOOL (WINAPI *CryptDecodeObject_t) (
- DWORD dwCertEncodingType,
- LPCSTR lpszStructType,
- const BYTE* pbEncoded,
- DWORD cbEncoded,
- DWORD dwFlags,
- void* pvStructInfo,
- DWORD* pcbStructInfo
-);
typedef BOOL (WINAPI *CryptVerifyCertificateSignatureEx_t) (
void *hCryptProv,
DWORD dwCertEncodingType,
@@ -265,7 +233,6 @@ typedef struct __crypto_win32_data_s {
CertCreateCertificateContext_t p_CertCreateCertificateContext;
CertFreeCertificateContext_t p_CertFreeCertificateContext;
CertNameToStrW_t p_CertNameToStrW;
- CryptDecodeObject_t p_CryptDecodeObject;
CryptVerifyCertificateSignatureEx_t p_CryptVerifyCertificateSignatureEx;
} *__crypto_win32_data_t;
@@ -302,16 +269,6 @@ __pkcs11h_crypto_win32_certificate_get_dn (
static
int
-__pkcs11h_crypto_win32_certificate_get_serial (
- IN void * const global_data,
- IN const unsigned char * const blob,
- IN const size_t blob_size,
- OUT char * const serial,
- IN const size_t serial_max
-);
-
-static
-int
__pkcs11h_crypto_win32_certificate_is_issuer (
IN void * const global_data,
IN const unsigned char * const signer_blob,
@@ -329,7 +286,6 @@ pkcs11h_engine_crypto_t g_pkcs11h_crypto_engine = {
__pkcs11h_crypto_openssl_uninitialize,
__pkcs11h_crypto_openssl_certificate_get_expiration,
__pkcs11h_crypto_openssl_certificate_get_dn,
- __pkcs11h_crypto_openssl_certificate_get_serial,
__pkcs11h_crypto_openssl_certificate_is_issuer
};
#elif defined(ENABLE_PKCS11H_ENGINE_GNUTLS)
@@ -339,7 +295,6 @@ pkcs11h_engine_crypto_t g_pkcs11h_crypto_engine = {
__pkcs11h_crypto_gnutls_uninitialize,
__pkcs11h_crypto_gnutls_certificate_get_expiration,
__pkcs11h_crypto_gnutls_certificate_get_dn,
- __pkcs11h_crypto_gnutls_certificate_get_serial,
__pkcs11h_crypto_gnutls_certificate_is_issuer
};
#elif defined(ENABLE_PKCS11H_ENGINE_WIN32)
@@ -350,7 +305,6 @@ pkcs11h_engine_crypto_t g_pkcs11h_crypto_engine = {
__pkcs11h_crypto_win32_uninitialize,
__pkcs11h_crypto_win32_certificate_get_expiration,
__pkcs11h_crypto_win32_certificate_get_dn,
- __pkcs11h_crypto_win32_certificate_get_serial,
__pkcs11h_crypto_win32_certificate_is_issuer
};
#else
@@ -502,54 +456,6 @@ __pkcs11h_crypto_openssl_certificate_get_dn (
static
int
-__pkcs11h_crypto_openssl_certificate_get_serial (
- IN void * const global_data,
- IN const unsigned char * const blob,
- IN const size_t blob_size,
- OUT char * const serial,
- IN const size_t serial_max
-) {
- X509 *x509 = NULL;
- BIO *bioSerial = NULL;
-
- (void)global_data;
-
- /*PKCS11H_ASSERT (global_data!=NULL); NOT NEEDED*/
- PKCS11H_ASSERT (blob!=NULL);
- PKCS11H_ASSERT (serial!=NULL);
- PKCS11H_ASSERT (serial_max>0);
-
- serial[0] = '\x0';
-
- if ((x509 = X509_new ()) != NULL) {
- pkcs11_openssl_d2i_t d2i1 = (pkcs11_openssl_d2i_t)blob;
- if (d2i_X509 (&x509, &d2i1, blob_size)) {
- if ((bioSerial = BIO_new (BIO_s_mem ())) != NULL) {
- int n;
-
- i2a_ASN1_INTEGER(bioSerial, X509_get_serialNumber (x509));
- n = BIO_read (bioSerial, serial, serial_max-1);
- if (n<0) {
- serial[0] = '\0';
- }
- else {
- serial[n] = '\0';
- }
-
- BIO_free_all (bioSerial);
- bioSerial = NULL;
- }
- }
-
- X509_free (x509);
- x509 = NULL;
- }
-
- return serial[0] != '\x0';
-}
-
-static
-int
__pkcs11h_crypto_openssl_certificate_is_issuer (
IN void * const global_data,
IN const unsigned char * const issuer_blob,
@@ -777,47 +683,6 @@ __pkcs11h_crypto_gnutls_certificate_get_dn (
static
int
-__pkcs11h_crypto_gnutls_certificate_get_serial (
- IN void * const global_data,
- IN const unsigned char * const blob,
- IN const size_t blob_size,
- OUT char * const serial,
- IN const size_t serial_max
-) {
- gnutls_x509_crt_t cert = NULL;
-
- (void)global_data;
-
- /*PKCS11H_ASSERT (global_data!=NULL); NOT NEEDED*/
- PKCS11H_ASSERT (blob!=NULL);
- PKCS11H_ASSERT (serial!=NULL);
- PKCS11H_ASSERT (serial_max>0);
-
- serial[0] = '\x0';
-
- if (gnutls_x509_crt_init (&cert) == GNUTLS_E_SUCCESS) {
- gnutls_datum_t datum = {(unsigned char *)blob, blob_size};
-
- if (gnutls_x509_crt_import (cert, &datum, GNUTLS_X509_FMT_DER) == GNUTLS_E_SUCCESS) {
- unsigned char ser[1024];
- size_t ser_size = sizeof (ser);
- if (gnutls_x509_crt_get_serial (cert, ser, &ser_size) == GNUTLS_E_SUCCESS) {
- _pkcs11h_util_binaryToHex (
- serial,
- serial_max,
- ser,
- ser_size
- );
- }
- }
- gnutls_x509_crt_deinit (cert);
- }
-
- return serial[0] != '\x0';
-}
-
-static
-int
__pkcs11h_crypto_gnutls_certificate_is_issuer (
IN void * const global_data,
IN const unsigned char * const issuer_blob,
@@ -936,10 +801,6 @@ __pkcs11h_crypto_win32_initialize (
data->handle,
"CertNameToStrW"
);
- data->p_CryptDecodeObject = (CryptDecodeObject_t)GetProcAddress (
- data->handle,
- "CryptDecodeObject"
- );
data->p_CryptVerifyCertificateSignatureEx = (CryptVerifyCertificateSignatureEx_t)GetProcAddress (
data->handle,
"CryptVerifyCertificateSignatureEx"
@@ -949,7 +810,6 @@ __pkcs11h_crypto_win32_initialize (
data->p_CertCreateCertificateContext == NULL ||
data->p_CertFreeCertificateContext == NULL ||
data->p_CertNameToStrW == NULL ||
- data->p_CryptDecodeObject == NULL ||
data->p_CryptVerifyCertificateSignatureEx == NULL
) {
__pkcs11h_crypto_win32_uninitialize (data);
@@ -1140,75 +1000,6 @@ __pkcs11h_crypto_win32_certificate_get_dn (
static
int
-__pkcs11h_crypto_win32_certificate_get_serial (
- IN void * const global_data,
- IN const unsigned char * const blob,
- IN const size_t blob_size,
- OUT char * const serial,
- IN const size_t serial_max
-) {
- __crypto_win32_data_t data = (__crypto_win32_data_t)global_data;
- PCCERT_CONTEXT cert = NULL;
- PKCS11H_BOOL ok = TRUE;
- PBYTE bin_serial = NULL;
- size_t i;
-
- PKCS11H_ASSERT (global_data!=NULL);
- PKCS11H_ASSERT (blob!=NULL);
- PKCS11H_ASSERT (serial!=NULL);
- PKCS11H_ASSERT (serial_max>0);
-
- serial[0] = '\x0';
-
- if (
- ok &&
- (cert = data->p_CertCreateCertificateContext (
- PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
- blob,
- blob_size
- )) == NULL
- ) {
- ok = FALSE;
- }
-
- if (
- ok &&
- (bin_serial = (PBYTE)g_pkcs11h_sys_engine.malloc (cert->pCertInfo->SerialNumber.cbData)) == NULL
- ) {
- ok = FALSE;
- }
-
- for (i=0;ok && i<cert->pCertInfo->SerialNumber.cbData;i++) {
- bin_serial[cert->pCertInfo->SerialNumber.cbData-1-i] = cert->pCertInfo->SerialNumber.pbData[i];
- }
-
- if (
- ok &&
- _pkcs11h_util_binaryToHex (
- serial,
- serial_max,
- bin_serial,
- cert->pCertInfo->SerialNumber.cbData
- ) != CKR_OK
- ) {
- ok = FALSE;
- }
-
- if (bin_serial != NULL) {
- g_pkcs11h_sys_engine.free (bin_serial);
- bin_serial = NULL;
- }
-
- if (cert != NULL) {
- data->p_CertFreeCertificateContext (cert);
- cert = NULL;
- }
-
- return ok != FALSE;
-}
-
-static
-int
__pkcs11h_crypto_win32_certificate_is_issuer (
IN void * const global_data,
IN const unsigned char * const issuer_blob,
diff --git a/lib/pkcs11h-standalone.c b/lib/pkcs11h-standalone.c
deleted file mode 100644
index d187947..0000000
--- a/lib/pkcs11h-standalone.c
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * Copyright (c) 2005-2006 Alon Bar-Lev <alon.barlev at gmail.com>
- * All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, or the BSD license.
- *
- * GNU General Public License (GPL) Version 2
- * ===========================================
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program (see the file COPYING.GPL included with this
- * distribution); if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * BSD License
- * ============
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * o Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o Neither the name of the <ORGANIZATION> nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "common.h"
-
-#if defined(ENABLE_PKCS11H_STANDALONE)
-
-#include "_pkcs11h-mem.h"
-#include "_pkcs11h-core.h"
-#include "_pkcs11h-util.h"
-#include "_pkcs11h-crypto.h"
-#include "_pkcs11h-session.h"
-#include "_pkcs11h-token.h"
-#include <pkcs11-helper-1.0/pkcs11h-standalone.h>
-
-void
-pkcs11h_standalone_dump_slots (
- IN const pkcs11h_output_print_t my_output,
- IN void * const global_data,
- IN const char * const provider,
- IN const char * const prms[]
-) {
- CK_RV rv = CKR_OK;
-
- pkcs11h_provider_t pkcs11h_provider;
-
- PKCS11H_ASSERT (my_output!=NULL);
- /*PKCS11H_ASSERT (global_data) NOT NEEDED */
- PKCS11H_ASSERT (provider!=NULL);
-
- if (
- rv == CKR_OK &&
- (rv = pkcs11h_initialize ()) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot initialize interface %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- }
-
- if (
- rv == CKR_OK &&
- (rv = pkcs11h_addProvider (
- provider,
- provider,
- FALSE,
- PKCS11H_PRIVATEMODE_MASK_AUTO,
- PKCS11H_SLOTEVENT_METHOD_AUTO,
- 0,
- FALSE
- )) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot initialize provider %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- }
-
- /*
- * our provider is head
- */
- if (rv == CKR_OK) {
- pkcs11h_provider = g_pkcs11h_data->providers;
- if (pkcs11h_provider == NULL || !pkcs11h_provider->enabled) {
- my_output (global_data, "PKCS#11: Cannot get provider %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- rv = CKR_GENERAL_ERROR;
- }
- }
-
- if (rv == CKR_OK) {
- CK_INFO info;
-
- if ((rv = pkcs11h_provider->f->C_GetInfo (&info)) != CKR_OK) {
- my_output (global_data, "PKCS#11: Cannot get PKCS#11 provider information %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- rv = CKR_OK;
- }
- else {
- char manufacturerID[sizeof (info.manufacturerID)+1];
-
- _pkcs11h_util_fixupFixedString (
- manufacturerID,
- (char *)info.manufacturerID,
- sizeof (info.manufacturerID)
- );
-
- my_output (
- global_data,
- (
- "Provider Information:\n"
- "\tcryptokiVersion:\t%u.%u\n"
- "\tmanufacturerID:\t\t%s\n"
- "\tflags:\t\t\t%08x\n"
- "\n"
- ),
- info.cryptokiVersion.major,
- info.cryptokiVersion.minor,
- manufacturerID,
- (unsigned)info.flags
- );
- }
- }
-
- if (rv == CKR_OK) {
- CK_SLOT_ID_PTR slots = NULL;
- CK_ULONG slotnum;
- CK_SLOT_ID slot_index;
-
- if (
- _pkcs11h_session_getSlotList (
- pkcs11h_provider,
- CK_FALSE,
- &slots,
- &slotnum
- ) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot get slot list %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- }
- else {
- my_output (
- global_data,
- "The following slots are available for use with this provider.\n"
- );
-
- if (prms != NULL) {
- my_output (
- global_data,
- (
- "Each slot shown below may be used as a parameter to a\n"
- "%s and %s options.\n"
- ),
- prms[0],
- prms[1]
- );
- }
-
- my_output (
- global_data,
- (
- "\n"
- "Slots: (id - name)\n"
- )
- );
-
- for (slot_index=0;slot_index < slotnum;slot_index++) {
- CK_SLOT_INFO info;
-
- if (
- (rv = pkcs11h_provider->f->C_GetSlotInfo (
- slots[slot_index],
- &info
- )) == CKR_OK
- ) {
- char current_name[sizeof (info.slotDescription)+1];
-
- _pkcs11h_util_fixupFixedString (
- current_name,
- (char *)info.slotDescription,
- sizeof (info.slotDescription)
- );
-
- my_output (global_data, "\t%lu - %s\n", slots[slot_index], current_name);
- }
- }
- }
-
- if (slots != NULL) {
- _pkcs11h_mem_free ((void *)&slots);
- }
- }
-
- pkcs11h_terminate ();
-}
-
-static
-PKCS11H_BOOL
-_pkcs11h_standalone_dump_objects_pin_prompt (
- IN void * const global_data,
- IN void * const user_data,
- IN const pkcs11h_token_id_t token,
- IN const unsigned retry,
- OUT char * const pin,
- IN const size_t pin_max
-) {
- (void)user_data;
- (void)token;
-
- /*
- * Don't lock card
- */
- if (retry == 0) {
- strncpy (pin, (char *)global_data, pin_max);
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-static
-void
-_pkcs11h_standalone_dump_objects_hex (
- IN const unsigned char * const p,
- IN const size_t p_size,
- OUT char * const sz,
- IN const size_t max,
- IN const char * const prefix
-) {
- size_t j;
-
- sz[0] = '\0';
-
- for (j=0;j<p_size;j+=16) {
- char line[3*16+1];
- size_t k;
-
- line[0] = '\0';
- for (k=0;k<16 && j+k<p_size;k++) {
- sprintf (line+strlen (line), "%02x ", p[j+k]);
- }
-
- strncat (
- sz,
- prefix,
- max-1-strlen (sz)
- );
- strncat (
- sz,
- line,
- max-1-strlen (sz)
- );
- strncat (
- sz,
- "\n",
- max-1-strlen (sz)
- );
- }
-
- sz[max-1] = '\0';
-}
-
-void
-pkcs11h_standalone_dump_objects (
- IN const pkcs11h_output_print_t my_output,
- IN void * const global_data,
- IN const char * const provider,
- IN const char * const slot,
- IN const char * const pin,
- IN const char * const prms[]
-) {
- CK_SLOT_ID s;
- CK_RV rv = CKR_OK;
-
- pkcs11h_provider_t pkcs11h_provider = NULL;
- pkcs11h_token_id_t token_id = NULL;
- pkcs11h_session_t session = NULL;
-
- PKCS11H_ASSERT (my_output!=NULL);
- /*PKCS11H_ASSERT (global_data) NOT NEEDED */
- PKCS11H_ASSERT (provider!=NULL);
- PKCS11H_ASSERT (slot!=NULL);
- PKCS11H_ASSERT (pin!=NULL);
-
- s = atoi (slot);
-
- if (
- rv == CKR_OK &&
- (rv = pkcs11h_initialize ()) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot initialize interface %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- }
-
- if (
- rv == CKR_OK &&
- (rv = pkcs11h_setPINPromptHook (_pkcs11h_standalone_dump_objects_pin_prompt, (void *)pin)) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot set hooks %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- }
-
- if (
- rv == CKR_OK &&
- (rv = pkcs11h_addProvider (
- provider,
- provider,
- FALSE,
- PKCS11H_PRIVATEMODE_MASK_AUTO,
- PKCS11H_SLOTEVENT_METHOD_AUTO,
- 0,
- FALSE
- )) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot initialize provider %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- }
-
- /*
- * our provider is head
- */
- if (rv == CKR_OK) {
- pkcs11h_provider = g_pkcs11h_data->providers;
- if (pkcs11h_provider == NULL || !pkcs11h_provider->enabled) {
- my_output (global_data, "PKCS#11: Cannot get provider %ld-'%s'\n", rv, pkcs11h_getMessage (rv));
- rv = CKR_GENERAL_ERROR;
- }
- }
-
- if (rv == CKR_OK) {
- CK_TOKEN_INFO info;
-
- if (
- (rv = pkcs11h_provider->f->C_GetTokenInfo (
- s,
- &info
- )) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot get token information for slot %ld %ld-'%s'\n", s, rv, pkcs11h_getMessage (rv));
- /* Ignore this error */
- rv = CKR_OK;
- }
- else {
- char label[sizeof (info.label)+1];
- char manufacturerID[sizeof (info.manufacturerID)+1];
- char model[sizeof (info.model)+1];
- char serialNumberNumber[sizeof (info.serialNumber)+1];
-
- _pkcs11h_util_fixupFixedString (
- label,
- (char *)info.label,
- sizeof (info.label)
- );
- _pkcs11h_util_fixupFixedString (
- manufacturerID,
- (char *)info.manufacturerID,
- sizeof (info.manufacturerID)
- );
- _pkcs11h_util_fixupFixedString (
- model,
- (char *)info.model,
- sizeof (info.model)
- );
- _pkcs11h_util_fixupFixedString (
- serialNumberNumber,
- (char *)info.serialNumber,
- sizeof (info.serialNumber)
- );
-
- my_output (
- global_data,
- (
- "Token Information:\n"
- "\tlabel:\t\t%s\n"
- "\tmanufacturerID:\t%s\n"
- "\tmodel:\t\t%s\n"
- "\tserialNumber:\t%s\n"
- "\tflags:\t\t%08x\n"
- "\n"
- ),
- label,
- manufacturerID,
- model,
- serialNumberNumber,
- (unsigned)info.flags
- );
-
- if (prms!=NULL) {
- my_output (
- global_data,
- (
- "You can access this token using\n"
- "%s \"label\" %s \"%s\" options.\n"
- "\n"
- ),
- prms[0],
- prms[1],
- label
- );
- }
-
- if (
- rv == CKR_OK &&
- (rv = _pkcs11h_token_getTokenId (
- &info,
- &token_id
- )) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot get token id for slot %ld %ld-'%s'\n", s, rv, pkcs11h_getMessage (rv));
- rv = CKR_OK;
- }
- }
- }
-
- if (token_id != NULL) {
- if (
- (rv = _pkcs11h_session_getSessionByTokenId (
- token_id,
- &session
- )) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot session for token '%s' %ld-'%s'\n", token_id->display, rv, pkcs11h_getMessage (rv));
- rv = CKR_OK;
- }
- }
-
- if (session != NULL) {
- CK_OBJECT_HANDLE *objects = NULL;
- CK_ULONG objects_found = 0;
- CK_ULONG i;
-
- if (
- (rv = _pkcs11h_session_login (
- session,
- FALSE,
- TRUE,
- NULL,
- PKCS11H_PROMPT_MASK_ALLOW_PIN_PROMPT
- )) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot open session to token '%s' %ld-'%s'\n", session->token_id->display, rv, pkcs11h_getMessage (rv));
- }
-
- my_output (
- global_data,
- "The following objects are available for use with this token.\n"
- );
-
- if (prms != NULL) {
- my_output (
- global_data,
- (
- "Each object shown below may be used as a parameter to\n"
- "%s and %s options.\n"
- ),
- prms[2],
- prms[3]
- );
- }
-
- my_output (
- global_data,
- "\n"
- );
-
- if (
- rv == CKR_OK &&
- (rv = _pkcs11h_session_findObjects (
- session,
- NULL,
- 0,
- &objects,
- &objects_found
- )) != CKR_OK
- ) {
- my_output (global_data, "PKCS#11: Cannot query objects for token '%s' %ld-'%s'\n", session->token_id->display, rv, pkcs11h_getMessage (rv));
- }
-
- for (i=0;rv == CKR_OK && i < objects_found;i++) {
- CK_OBJECT_CLASS attrs_class = 0;
- CK_ATTRIBUTE attrs[] = {
- {CKA_CLASS, &attrs_class, sizeof (attrs_class)}
- };
-
- if (
- _pkcs11h_session_getObjectAttributes (
- session,
- objects[i],
- attrs,
- sizeof (attrs) / sizeof (CK_ATTRIBUTE)
- ) == CKR_OK
- ) {
- if (attrs_class == CKO_CERTIFICATE) {
- CK_ATTRIBUTE attrs_cert[] = {
- {CKA_ID, NULL, 0},
- {CKA_LABEL, NULL, 0},
- {CKA_VALUE, NULL, 0}
- };
- unsigned char *attrs_id = NULL;
- int attrs_id_size = 0;
- unsigned char *attrs_value = NULL;
- int attrs_value_size = 0;
- char *attrs_label = NULL;
- char hex_id[1024];
- char subject[1024];
- char serialNumber[1024];
- time_t notAfter = 0;
-
- subject[0] = '\0';
- serialNumber[0] = '\0';
-
-
- if (
- _pkcs11h_session_getObjectAttributes (
- session,
- objects[i],
- attrs_cert,
- sizeof (attrs_cert) / sizeof (CK_ATTRIBUTE)
- ) == CKR_OK &&
- _pkcs11h_mem_malloc (
- (void *)&attrs_label,
- attrs_cert[1].ulValueLen+1
- ) == CKR_OK
- ) {
- attrs_id = (unsigned char *)attrs_cert[0].pValue;
- attrs_id_size = attrs_cert[0].ulValueLen;
- attrs_value = (unsigned char *)attrs_cert[2].pValue;
- attrs_value_size = attrs_cert[2].ulValueLen;
-
- memset (attrs_label, 0, attrs_cert[1].ulValueLen+1);
- memmove (attrs_label, attrs_cert[1].pValue, attrs_cert[1].ulValueLen);
- _pkcs11h_standalone_dump_objects_hex (
- attrs_id,
- attrs_id_size,
- hex_id,
- sizeof (hex_id),
- "\t\t"
- );
- }
-
- if (attrs_value != NULL) {
- if (
- !g_pkcs11h_crypto_engine.certificate_get_dn (
- g_pkcs11h_crypto_engine.global_data,
- attrs_value,
- attrs_value_size,
- subject,
- sizeof (subject)
- )
- ) {
- subject[0] = '\x0';
- }
-
- if (
- !g_pkcs11h_crypto_engine.certificate_get_expiration (
- g_pkcs11h_crypto_engine.global_data,
- attrs_value,
- attrs_value_size,
- ¬After
- )
- ) {
- notAfter = (time_t)0;
- }
-
- if (
- !g_pkcs11h_crypto_engine.certificate_get_serial (
- g_pkcs11h_crypto_engine.global_data,
- attrs_value,
- attrs_value_size,
- serialNumber,
- sizeof (serialNumber)
- )
- ) {
- serialNumber[0] = '\x0';
- }
- }
-
- my_output (
- global_data,
- (
- "Object\n"
- "\tType:\t\t\tCertificate\n"
- "\tCKA_ID:\n"
- "%s"
- "\tCKA_LABEL:\t\t%s\n"
- "\tsubject:\t\t%s\n"
- "\tserialNumber:\t\t%s\n"
- "\tnotAfter:\t\t%s\n"
- ),
- hex_id,
- attrs_label,
- subject,
- serialNumber,
- asctime (localtime (¬After))
- );
-
- if (attrs_label != NULL) {
- _pkcs11h_mem_free ((void *)&attrs_label);
- attrs_label = NULL;
- }
-
- _pkcs11h_session_freeObjectAttributes (
- attrs_cert,
- sizeof (attrs_cert) / sizeof (CK_ATTRIBUTE)
- );
- }
- else if (attrs_class == CKO_PRIVATE_KEY) {
- CK_BBOOL sign_recover = CK_FALSE;
- CK_BBOOL sign = CK_FALSE;
- CK_ATTRIBUTE attrs_key[] = {
- {CKA_SIGN, &sign, sizeof (sign)},
- {CKA_SIGN_RECOVER, &sign_recover, sizeof (sign_recover)}
- };
- CK_ATTRIBUTE attrs_key_common[] = {
- {CKA_ID, NULL, 0},
- {CKA_LABEL, NULL, 0}
- };
- unsigned char *attrs_id = NULL;
- int attrs_id_size = 0;
- char *attrs_label = NULL;
- char hex_id[1024];
-
- pkcs11h_provider->f->C_GetAttributeValue (
- session->session_handle,
- objects[i],
- attrs_key,
- sizeof (attrs_key) / sizeof (CK_ATTRIBUTE)
- );
-
- if (
- _pkcs11h_session_getObjectAttributes (
- session,
- objects[i],
- attrs_key_common,
- sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE)
- ) == CKR_OK &&
- _pkcs11h_mem_malloc (
- (void *)&attrs_label,
- attrs_key_common[1].ulValueLen+1
- ) == CKR_OK
- ) {
- attrs_id = (unsigned char *)attrs_key_common[0].pValue;
- attrs_id_size = attrs_key_common[0].ulValueLen;
-
- memset (attrs_label, 0, attrs_key_common[1].ulValueLen+1);
- memmove (attrs_label, attrs_key_common[1].pValue, attrs_key_common[1].ulValueLen);
-
- _pkcs11h_standalone_dump_objects_hex (
- attrs_id,
- attrs_id_size,
- hex_id,
- sizeof (hex_id),
- "\t\t"
- );
-
- }
-
- my_output (
- global_data,
- (
- "Object\n"
- "\tType:\t\t\tPrivate Key\n"
- "\tCKA_ID:\n"
- "%s"
- "\tCKA_LABEL:\t\t%s\n"
- "\tCKA_SIGN:\t\t%s\n"
- "\tCKA_SIGN_RECOVER:\t%s\n"
- ),
- hex_id,
- attrs_label,
- sign ? "TRUE" : "FALSE",
- sign_recover ? "TRUE" : "FALSE"
- );
-
- if (attrs_label != NULL) {
- _pkcs11h_mem_free ((void *)&attrs_label);
- attrs_label = NULL;
- }
-
- _pkcs11h_session_freeObjectAttributes (
- attrs_key_common,
- sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE)
- );
- }
- else if (attrs_class == CKO_PUBLIC_KEY) {
- CK_ATTRIBUTE attrs_key_common[] = {
- {CKA_ID, NULL, 0},
- {CKA_LABEL, NULL, 0}
- };
- unsigned char *attrs_id = NULL;
- int attrs_id_size = 0;
- char *attrs_label = NULL;
- char hex_id[1024];
-
- if (
- _pkcs11h_session_getObjectAttributes (
- session,
- objects[i],
- attrs_key_common,
- sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE)
- ) == CKR_OK &&
- _pkcs11h_mem_malloc (
- (void *)&attrs_label,
- attrs_key_common[1].ulValueLen+1
- ) == CKR_OK
- ) {
- attrs_id = (unsigned char *)attrs_key_common[0].pValue;
- attrs_id_size = attrs_key_common[0].ulValueLen;
-
- memset (attrs_label, 0, attrs_key_common[1].ulValueLen+1);
- memmove (attrs_label, attrs_key_common[1].pValue, attrs_key_common[1].ulValueLen);
-
- _pkcs11h_standalone_dump_objects_hex (
- attrs_id,
- attrs_id_size,
- hex_id,
- sizeof (hex_id),
- "\t\t"
- );
-
- }
-
- my_output (
- global_data,
- (
- "Object\n"
- "\tType:\t\t\tPublic Key\n"
- "\tCKA_ID:\n"
- "%s"
- "\tCKA_LABEL:\t\t%s\n"
- ),
- hex_id,
- attrs_label
- );
-
- _pkcs11h_mem_free ((void *)&attrs_label);
-
- _pkcs11h_session_freeObjectAttributes (
- attrs_key_common,
- sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE)
- );
- }
- else if (attrs_class == CKO_DATA) {
- CK_ATTRIBUTE attrs_key_common[] = {
- {CKA_APPLICATION, NULL, 0},
- {CKA_LABEL, NULL, 0}
- };
- char *attrs_application = NULL;
- char *attrs_label = NULL;
-
- if (
- _pkcs11h_session_getObjectAttributes (
- session,
- objects[i],
- attrs_key_common,
- sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE)
- ) == CKR_OK &&
- _pkcs11h_mem_malloc (
- (void *)&attrs_application,
- attrs_key_common[0].ulValueLen+1
- ) == CKR_OK &&
- _pkcs11h_mem_malloc (
- (void *)&attrs_label,
- attrs_key_common[1].ulValueLen+1
- ) == CKR_OK
- ) {
- memset (attrs_application, 0, attrs_key_common[0].ulValueLen+1);
- memmove (attrs_application, attrs_key_common[0].pValue, attrs_key_common[0].ulValueLen);
- memset (attrs_label, 0, attrs_key_common[1].ulValueLen+1);
- memmove (attrs_label, attrs_key_common[1].pValue, attrs_key_common[1].ulValueLen);
- }
-
- my_output (
- global_data,
- (
- "Object\n"
- "\tType:\t\t\tData\n"
- "\tCKA_APPLICATION\t\t%s\n"
- "\tCKA_LABEL:\t\t%s\n"
- ),
- attrs_application,
- attrs_label
- );
-
- _pkcs11h_mem_free ((void *)&attrs_application);
- _pkcs11h_mem_free ((void *)&attrs_label);
-
- _pkcs11h_session_freeObjectAttributes (
- attrs_key_common,
- sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE)
- );
- }
- else {
- my_output (
- global_data,
- (
- "Object\n"
- "\tType:\t\t\tUnsupported\n"
- )
- );
- }
- }
-
- _pkcs11h_session_freeObjectAttributes (
- attrs,
- sizeof (attrs) / sizeof (CK_ATTRIBUTE)
- );
-
- /*
- * Ignore any error and
- * perform next iteration
- */
- rv = CKR_OK;
- }
-
- if (objects != NULL) {
- _pkcs11h_mem_free ((void *)&objects);
- }
-
- /*
- * Ignore this error
- */
- rv = CKR_OK;
- }
-
- if (session != NULL) {
- _pkcs11h_session_release (session);
- session = NULL;
- }
-
- if (token_id != NULL) {
- pkcs11h_token_freeTokenId (token_id);
- token_id = NULL;
- }
-
- pkcs11h_terminate ();
-}
-
-#endif /* ENABLE_PKCS11H_STANDALONE */
diff --git a/lib/standalone.exports b/lib/standalone.exports
deleted file mode 100644
index 289f476..0000000
--- a/lib/standalone.exports
+++ /dev/null
@@ -1,2 +0,0 @@
-pkcs11h_standalone_dump_objects
-pkcs11h_standalone_dump_slots
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/pkcs11-helper.git
More information about the pkg-opensc-commit
mailing list