Cleanup rutoken interface. During the mingw build efforts I had to invest much time in this module. I believe there are many more issue with this module compliant to other OpenSC components. This is yet another cleanup, put rutoken signature to all exportable functions, and install proper header file for this.
The main issue is why we need the pkcs15-prkey-rutoken.c??? Why it is the only card that added this? Doesn't it have a proper PKCS#15 emulation? And if it doesn't have, shouldn't it have one, and drop this file? Alon. svn diff -r 3436:3437 https://www.opensc-project.org/svn/opensc/branches/alonbl/rutoken-fixups --- Index: src/tools/rutoken-tool.c =================================================================== --- src/tools/rutoken-tool.c (revision 3436) +++ src/tools/rutoken-tool.c (revision 3437) @@ -33,6 +33,7 @@ #include <fcntl.h> #include <opensc/opensc.h> #include <opensc/cardctl.h> +#include <opensc/rutoken.h> #include "util.h" #define IV_SIZE 8 Index: src/include/opensc/Makefile.am =================================================================== --- src/include/opensc/Makefile.am (revision 3436) +++ src/include/opensc/Makefile.am (revision 3437) @@ -13,6 +13,7 @@ @$(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/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-opensc.h pkcs11-opensc.h @$(LN_S) $(top_srcdir)/src/pkcs15init/keycache.h keycache.h Index: src/pkcs15init/pkcs15-rutoken.c =================================================================== --- src/pkcs15init/pkcs15-rutoken.c (revision 3436) +++ src/pkcs15init/pkcs15-rutoken.c (revision 3437) @@ -31,6 +31,7 @@ #include <opensc/cardctl.h> #include <opensc/log.h> #include <opensc/pkcs15.h> +#include <opensc/rutoken.h> #include "pkcs15-init.h" #include "profile.h" @@ -74,8 +75,6 @@ { 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. */ Index: src/libopensc/card-rutoken.c =================================================================== --- src/libopensc/card-rutoken.c (revision 3436) +++ src/libopensc/card-rutoken.c (revision 3437) @@ -45,6 +45,7 @@ #include <opensc/asn1.h> #include <openssl/x509.h> #include <openssl/err.h> +#include "rutoken.h" #endif #define FDESCR_DF 0x38 /*00111000b*/ @@ -52,10 +53,6 @@ #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 #define MF_PATH "\x3F\x00" #else @@ -1122,7 +1119,7 @@ { r = sc_read_binary(card, 0, data, file->size, 0); 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); free(data); } Index: src/libopensc/libopensc.exports =================================================================== --- src/libopensc/libopensc.exports (revision 3436) +++ src/libopensc/libopensc.exports (revision 3437) @@ -184,6 +184,7 @@ sc_reset sc_reset_retry_counter sc_restore_security_env +sc_rutoken_get_prkey_from_bin sc_rutoken_get_bin_from_prkey sc_select_file sc_set_card_driver Index: src/libopensc/pkcs15-prkey-rutoken.c =================================================================== --- src/libopensc/pkcs15-prkey-rutoken.c (revision 3436) +++ src/libopensc/pkcs15-prkey-rutoken.c (revision 3437) @@ -28,6 +28,7 @@ #include <assert.h> #include <opensc/opensc.h> #include <opensc/pkcs15.h> +#include <opensc/rutoken.h> #if defined(HAVE_INTTYPES_H) #include <inttypes.h> #elif defined(HAVE_STDINT_H) @@ -327,7 +328,7 @@ 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; PRIVATEKEYBLOB pr_blob; Index: src/libopensc/Makefile.am =================================================================== --- src/libopensc/Makefile.am (revision 3436) +++ src/libopensc/Makefile.am (revision 3437) @@ -9,7 +9,8 @@ openscinclude_HEADERS = \ opensc.h pkcs15.h emv.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 \ internal-winscard.h p15card-helper.h pkgconfig_DATA = libopensc.pc libpkcs15init.pc libscconf.pc Index: src/libopensc/rutoken.h =================================================================== --- src/libopensc/rutoken.h (revision 0) +++ src/libopensc/rutoken.h (revision 3437) @@ -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 _______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel