ruToken cleanups
Move constants out of standard files. Create ruToken specific interface. Update symbols. Thread at: http://www.opensc-project.org/pipermail/opensc-devel/2008-March/010917.html Cleanup of: http://www.opensc-project.org/pipermail/opensc-devel/2007-December/010617.html git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3439 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
d0e0dd2820
commit
80a16f686d
|
@ -13,7 +13,9 @@ all-local:
|
||||||
@$(LN_S) $(top_srcdir)/src/libopensc/pkcs15.h pkcs15.h
|
@$(LN_S) $(top_srcdir)/src/libopensc/pkcs15.h pkcs15.h
|
||||||
@$(LN_S) $(top_srcdir)/src/libopensc/types.h types.h
|
@$(LN_S) $(top_srcdir)/src/libopensc/types.h types.h
|
||||||
@$(LN_S) $(top_srcdir)/src/libopensc/ui.h ui.h
|
@$(LN_S) $(top_srcdir)/src/libopensc/ui.h ui.h
|
||||||
|
@$(LN_S) $(top_srcdir)/src/libopensc/rutoken.h rutoken.h
|
||||||
@$(LN_S) $(top_srcdir)/src/pkcs11/pkcs11.h pkcs11.h
|
@$(LN_S) $(top_srcdir)/src/pkcs11/pkcs11.h pkcs11.h
|
||||||
|
@$(LN_S) $(top_srcdir)/src/pkcs11/pkcs11-opensc.h pkcs11-opensc.h
|
||||||
@$(LN_S) $(top_srcdir)/src/pkcs15init/keycache.h keycache.h
|
@$(LN_S) $(top_srcdir)/src/pkcs15init/keycache.h keycache.h
|
||||||
@$(LN_S) $(top_srcdir)/src/pkcs15init/pkcs15-init.h pkcs15-init.h
|
@$(LN_S) $(top_srcdir)/src/pkcs15init/pkcs15-init.h pkcs15-init.h
|
||||||
@$(LN_S) $(top_srcdir)/src/scconf/scconf.h scconf.h
|
@$(LN_S) $(top_srcdir)/src/scconf/scconf.h scconf.h
|
||||||
|
|
|
@ -9,7 +9,8 @@ lib_LTLIBRARIES = libopensc.la
|
||||||
openscinclude_HEADERS = \
|
openscinclude_HEADERS = \
|
||||||
opensc.h pkcs15.h emv.h \
|
opensc.h pkcs15.h emv.h \
|
||||||
cardctl.h asn1.h log.h ui.h \
|
cardctl.h asn1.h log.h ui.h \
|
||||||
errors.h types.h compression.h
|
errors.h types.h compression.h \
|
||||||
|
rutoken.h
|
||||||
noinst_HEADERS = cards.h ctbcs.h internal.h esteid.h muscle.h muscle-filesystem.h \
|
noinst_HEADERS = cards.h ctbcs.h internal.h esteid.h muscle.h muscle-filesystem.h \
|
||||||
internal-winscard.h p15card-helper.h
|
internal-winscard.h p15card-helper.h
|
||||||
pkgconfig_DATA = libopensc.pc libpkcs15init.pc libscconf.pc
|
pkgconfig_DATA = libopensc.pc libpkcs15init.pc libscconf.pc
|
||||||
|
|
|
@ -45,6 +45,7 @@ typedef unsigned __int16 uint16_t;
|
||||||
#include <opensc/asn1.h>
|
#include <opensc/asn1.h>
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
#include "rutoken.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FDESCR_DF 0x38 /*00111000b*/
|
#define FDESCR_DF 0x38 /*00111000b*/
|
||||||
|
@ -52,10 +53,6 @@ typedef unsigned __int16 uint16_t;
|
||||||
|
|
||||||
#define ID_RESERVED_CURDF 0x3FFF /*Reserved ID for current DF*/
|
#define ID_RESERVED_CURDF 0x3FFF /*Reserved ID for current DF*/
|
||||||
|
|
||||||
#ifdef ENABLE_OPENSSL
|
|
||||||
int get_prkey_from_bin(const u8 *data, size_t len, struct sc_pkcs15_prkey **key);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BIG_ENDIAN_RUTOKEN
|
#ifdef BIG_ENDIAN_RUTOKEN
|
||||||
#define MF_PATH "\x3F\x00"
|
#define MF_PATH "\x3F\x00"
|
||||||
#else
|
#else
|
||||||
|
@ -1122,7 +1119,7 @@ static int rutoken_read_prkey(sc_card_t *card, struct sc_pkcs15_prkey **out)
|
||||||
{
|
{
|
||||||
r = sc_read_binary(card, 0, data, file->size, 0);
|
r = sc_read_binary(card, 0, data, file->size, 0);
|
||||||
if(r > 0 && (size_t)r == file->size)
|
if(r > 0 && (size_t)r == file->size)
|
||||||
r = get_prkey_from_bin(data, file->size, out);
|
r = sc_rutoken_get_prkey_from_bin(data, file->size, out);
|
||||||
memset(data, 0, file->size);
|
memset(data, 0, file->size);
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,7 @@ sc_release_context
|
||||||
sc_reset
|
sc_reset
|
||||||
sc_reset_retry_counter
|
sc_reset_retry_counter
|
||||||
sc_restore_security_env
|
sc_restore_security_env
|
||||||
|
sc_rutoken_get_prkey_from_bin
|
||||||
sc_rutoken_get_bin_from_prkey
|
sc_rutoken_get_bin_from_prkey
|
||||||
sc_select_file
|
sc_select_file
|
||||||
sc_set_card_driver
|
sc_set_card_driver
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <opensc/opensc.h>
|
#include <opensc/opensc.h>
|
||||||
#include <opensc/pkcs15.h>
|
#include <opensc/pkcs15.h>
|
||||||
|
#include <opensc/rutoken.h>
|
||||||
#if defined(HAVE_INTTYPES_H)
|
#if defined(HAVE_INTTYPES_H)
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#elif defined(HAVE_STDINT_H)
|
#elif defined(HAVE_STDINT_H)
|
||||||
|
@ -327,7 +328,7 @@ static int clean_prkey_private_blob(const PRIVATEKEYBLOB* pr_blob)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_prkey_from_bin(const u8 *data, size_t len, struct sc_pkcs15_prkey **key)
|
int sc_rutoken_get_prkey_from_bin(const u8 *data, size_t len, struct sc_pkcs15_prkey **key)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
PRIVATEKEYBLOB pr_blob;
|
PRIVATEKEYBLOB pr_blob;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef RUTOKEN_H
|
||||||
|
#define RUTOKEN_H
|
||||||
|
|
||||||
|
int sc_rutoken_get_prkey_from_bin(const u8 *data, size_t len, struct sc_pkcs15_prkey **key);
|
||||||
|
int sc_rutoken_get_bin_from_prkey(const struct sc_pkcs15_prkey_rsa *rsa, u8 *key, size_t *keysize);
|
||||||
|
|
||||||
|
#endif
|
|
@ -5,7 +5,7 @@ CLEANFILES = versioninfo.rc
|
||||||
EXTRA_DIST = Makefile.mak
|
EXTRA_DIST = Makefile.mak
|
||||||
|
|
||||||
dist_noinst_SCRIPTS = opensc_pkcs11_install.js
|
dist_noinst_SCRIPTS = opensc_pkcs11_install.js
|
||||||
openscinclude_HEADERS = pkcs11.h
|
openscinclude_HEADERS = pkcs11.h pkcs11-opensc.h
|
||||||
lib_LTLIBRARIES = opensc-pkcs11.la pkcs11-spy.la onepin-opensc-pkcs11.la
|
lib_LTLIBRARIES = opensc-pkcs11.la pkcs11-spy.la onepin-opensc-pkcs11.la
|
||||||
noinst_LTLIBRARIES = libpkcs11.la
|
noinst_LTLIBRARIES = libpkcs11.la
|
||||||
|
|
||||||
|
|
|
@ -2079,7 +2079,7 @@ static CK_RV pkcs15_prkey_sign(struct sc_pkcs11_session *ses, void *obj,
|
||||||
case CKM_RSA_X_509:
|
case CKM_RSA_X_509:
|
||||||
flags = SC_ALGORITHM_RSA_RAW;
|
flags = SC_ALGORITHM_RSA_RAW;
|
||||||
break;
|
break;
|
||||||
case CKM_GOST:
|
case CKM_OPENSC_GOST:
|
||||||
flags = SC_ALGORITHM_GOST;
|
flags = SC_ALGORITHM_GOST;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2160,7 +2160,7 @@ pkcs15_prkey_decrypt(struct sc_pkcs11_session *ses, void *obj,
|
||||||
case CKM_RSA_X_509:
|
case CKM_RSA_X_509:
|
||||||
flags |= SC_ALGORITHM_RSA_RAW;
|
flags |= SC_ALGORITHM_RSA_RAW;
|
||||||
break;
|
break;
|
||||||
case CKM_GOST:
|
case CKM_OPENSC_GOST:
|
||||||
flags |= SC_ALGORITHM_GOST;
|
flags |= SC_ALGORITHM_GOST;
|
||||||
default:
|
default:
|
||||||
return CKR_MECHANISM_INVALID;
|
return CKR_MECHANISM_INVALID;
|
||||||
|
@ -2834,7 +2834,7 @@ static int register_mechanisms(struct sc_pkcs11_card *p11card)
|
||||||
#endif
|
#endif
|
||||||
mech_info.ulMinKeySize = 32;
|
mech_info.ulMinKeySize = 32;
|
||||||
mech_info.ulMaxKeySize = 32;
|
mech_info.ulMaxKeySize = 32;
|
||||||
mt = sc_pkcs11_new_fw_mechanism(CKM_GOST,
|
mt = sc_pkcs11_new_fw_mechanism(CKM_OPENSC_GOST,
|
||||||
&mech_info, CKK_RSA, NULL);
|
&mech_info, CKK_RSA, NULL);
|
||||||
rc = sc_pkcs11_register_mechanism(p11card, mt);
|
rc = sc_pkcs11_register_mechanism(p11card, mt);
|
||||||
sc_debug(card->ctx, "register GOST!!! %d", rc);
|
sc_debug(card->ctx, "register GOST!!! %d", rc);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef PKCS11_OPENSC_H
|
||||||
|
#define PKCS11_OPENSC_H
|
||||||
|
|
||||||
|
/* OpenSC specific extensions */
|
||||||
|
|
||||||
|
#define CKK_OPENSC_GOST (CKK_VENDOR_DEFINED+1)
|
||||||
|
#define CKA_OPENSC_GOST (CKA_VENDOR_DEFINED+1)
|
||||||
|
#define CKM_OPENSC_GOST (CKM_VENDOR_DEFINED+1)
|
||||||
|
|
||||||
|
#endif
|
|
@ -358,11 +358,6 @@ typedef unsigned long ck_key_type_t;
|
||||||
#define CKK_TWOFISH (0x21)
|
#define CKK_TWOFISH (0x21)
|
||||||
#define CKK_VENDOR_DEFINED ((unsigned long) (1 << 31))
|
#define CKK_VENDOR_DEFINED ((unsigned long) (1 << 31))
|
||||||
|
|
||||||
//rutoken:
|
|
||||||
#define CKK_GOST (CKK_VENDOR_DEFINED+1)
|
|
||||||
#define CKA_GOST CKA_VENDOR_DEFINED+1
|
|
||||||
#define CKM_GOST CKM_VENDOR_DEFINED+1
|
|
||||||
|
|
||||||
typedef unsigned long ck_certificate_type_t;
|
typedef unsigned long ck_certificate_type_t;
|
||||||
|
|
||||||
#define CKC_X_509 (0)
|
#define CKC_X_509 (0)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#define CRYPTOKI_EXPORTS
|
#define CRYPTOKI_EXPORTS
|
||||||
#include <pkcs11.h>
|
#include <pkcs11.h>
|
||||||
|
#include <pkcs11-opensc.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <opensc/cardctl.h>
|
#include <opensc/cardctl.h>
|
||||||
#include <opensc/log.h>
|
#include <opensc/log.h>
|
||||||
#include <opensc/pkcs15.h>
|
#include <opensc/pkcs15.h>
|
||||||
|
#include <opensc/rutoken.h>
|
||||||
#include "pkcs15-init.h"
|
#include "pkcs15-init.h"
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
|
|
||||||
|
@ -74,8 +75,6 @@ static const struct
|
||||||
{ AODF_name, AODFid, SC_PKCS15_AODF }
|
{ AODF_name, AODFid, SC_PKCS15_AODF }
|
||||||
};
|
};
|
||||||
|
|
||||||
int sc_rutoken_get_bin_from_prkey(const struct sc_pkcs15_prkey_rsa *rsa, u8 *key, size_t *keysize);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create/override new EF.
|
* Create/override new EF.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <opensc/pkcs11.h>
|
#include <opensc/pkcs11.h>
|
||||||
|
#include <opensc/pkcs11-opensc.h>
|
||||||
#include <compat_getpass.h>
|
#include <compat_getpass.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -3572,7 +3573,7 @@ static struct mech_info p11_mechanisms[] = {
|
||||||
{ CKM_DSA_PARAMETER_GEN, "DSA-PARAMETER-GEN", NULL },
|
{ CKM_DSA_PARAMETER_GEN, "DSA-PARAMETER-GEN", NULL },
|
||||||
{ CKM_DH_PKCS_PARAMETER_GEN,"DH-PKCS-PARAMETER-GEN", NULL },
|
{ CKM_DH_PKCS_PARAMETER_GEN,"DH-PKCS-PARAMETER-GEN", NULL },
|
||||||
{ CKM_X9_42_DH_PARAMETER_GEN,"X9-42-DH-PARAMETER-GEN", NULL },
|
{ CKM_X9_42_DH_PARAMETER_GEN,"X9-42-DH-PARAMETER-GEN", NULL },
|
||||||
{ CKM_GOST,"GOST", NULL },
|
{ CKM_OPENSC_GOST, "GOST", NULL },
|
||||||
{ NO_MECHANISM, NULL, NULL }
|
{ NO_MECHANISM, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <opensc/opensc.h>
|
#include <opensc/opensc.h>
|
||||||
#include <opensc/cardctl.h>
|
#include <opensc/cardctl.h>
|
||||||
|
#include <opensc/rutoken.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define IV_SIZE 8
|
#define IV_SIZE 8
|
||||||
|
|
Loading…
Reference in New Issue