pax_global_header00006660000000000000000000000064134052451500014511gustar00rootroot0000000000000052 comment=3fa3203624ab1799a13804cec0bc5955b96e3065 pkcs11-dump-pkcs11-dump-0.3.5/000077500000000000000000000000001340524515000156265ustar00rootroot00000000000000pkcs11-dump-pkcs11-dump-0.3.5/.gitattributes000066400000000000000000000000201340524515000205110ustar00rootroot00000000000000ChangeLog ident pkcs11-dump-pkcs11-dump-0.3.5/.gitignore000066400000000000000000000006031340524515000176150ustar00rootroot00000000000000.deps .libs *.bz2 *.gz *.o *.obj *.exe *.dll *.lib *.a *.def *.exp *.idb *.manifest *.out *.in *.lo *.la ltsugar.m4 libtool.m4 ltversion.m4 lt~obsolete.m4 ltoptions.m4 test-* *.[0-9].html configure config.log depcomp config.h Makefile config.status config.guess config.sub stamp-h1 autom4te.cache missing aclocal.m4 install-sh ltmain.sh libtool copyright versioninfo.rc pkcs11-dump pkcs11-dump-pkcs11-dump-0.3.5/AUTHORS000066400000000000000000000000451340524515000166750ustar00rootroot00000000000000Alon Bar-Lev pkcs11-dump-pkcs11-dump-0.3.5/COPYING000066400000000000000000000035371340524515000166710ustar00rootroot00000000000000 pkcs11-dump License Copyright (c) 2005-2006 Alon Bar-Lev All rights reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Special exception for linking with OpenSSL: In addition, as a special exception, the author gives permission to link the code of this program with the OpenSSL library (or with modified versions of OpenSSL that use the same license as OpenSSL), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than OpenSSL. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. m4 Macros License autoconf/automake Copyright (C) 2002, 2003 Free Software Foundation, Inc. pkg.m4 Copyright © 2004 Scott James Remnant . OpenSSL License This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.OpenSSL.org/) This product includes cryptographic software written by Eric Young (eay@cryptsoft.com). This product includes software written by Tim Hudson (tjh@cryptsoft.com). pkcs11-dump-pkcs11-dump-0.3.5/COPYING.GPL000066400000000000000000000431331340524515000173060ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pkcs11-dump-pkcs11-dump-0.3.5/ChangeLog000066400000000000000000000011031340524515000173730ustar00rootroot00000000000000pkcs11-dump Copyright (c) 2005-2008 Alon Bar-Lev 2010-01-10 -- Version 0.3.4 * Support large slot numbers, thanks to Martin Paljak. * Perform GetSlotList() before accessing slot, workaround some PKCS#11 implementations, thanks to Martin Paljak. 2008-08-05 -- Version 0.3.3 * gcc-4.3 update, thanks to Max Vozeler. 2008-06-01 -- Version 0.3.2 * License cleanups. 2008-05-31 -- Version 0.3.1 * Some minor build fixups. * Added man page, thanks to Max Vozeler. * Fix OpenSSL license issue. 2006-12-02 -- Version 0.3 * Autoconf package. pkcs11-dump-pkcs11-dump-0.3.5/INSTALL000066400000000000000000000011661340524515000166630ustar00rootroot00000000000000pkcs11-dump -- PKCS#11 token dump. Copyright (c) 2006 Alon Bar-Lev POSIX Dependencies: dl OpenSSL>=0.9.7 http://www.openssl.org Build: $ ./configure $ make $ make install Cross-MinGW32 Dependencies: OpenSSL>=0.9.7 http://www.openssl.org Build: w32root=/tmp/gpg-win32 OpenSSL ./Configure --prefix=// mingw-cross make install INSTALL_PREFIX="${w32root}" pkcs11-dump ./configure --prefix=/ --host=mingw32 \ PKG_CONFIG=true \ OPENSSL_CFLAGS="-I${w32root}/include" \ OPENSSL_LIBS="-L${w32root}/lib -lcrypto" make install DESTDIR="${w32root}" pkcs11-dump-pkcs11-dump-0.3.5/Makefile.am000066400000000000000000000033351340524515000176660ustar00rootroot00000000000000# # Copyright (c) 2005-2008 Alon Bar-Lev # All rights reserved. # # 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., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # AUTOMAKE_OPTIONS=foreign dist-bzip2 1.10 ACLOCAL_AMFLAGS=-I m4 MAINTAINERCLEANFILES = \ config.log config.status \ $(srcdir)/Makefile.in \ $(srcdir)/config.h.in $(srcdir)/config.h.in~ $(srcdir)/configure \ $(srcdir)/install-sh $(srcdir)/ltmain.sh $(srcdir)/missing \ $(srcdir)/depcomp $(srcdir)/aclocal.m4 \ $(srcdir)/config.guess $(srcdir)/config.sub CLEANFILES=pkcs11-dump.1.html bin_PROGRAMS=pkcs11-dump dist_doc_DATA=README COPYING COPYING.GPL pkcs11_dump_SOURCES= \ pkcs11.h \ pkcs11-dump.cpp if WIN32 nodist_pkcs11_dump_SOURCES=versioninfo.rc endif if WIN32 nodist_html_DATA=pkcs11-dump.1.html dist_noinst_DATA=pkcs11-dump.1 pkcs11-dump.1.html: pkcs11-dump.1 $(MAN2HTML) < "$^" > "$@" else dist_man_MANS=pkcs11-dump.1 endif RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE) .rc.lo: $(LTRCCOMPILE) -i $< -o $@ .rc.o: $(RCCOMPILE) -i $< -o $@ pkcs11-dump-pkcs11-dump-0.3.5/README000066400000000000000000000004041340524515000165040ustar00rootroot00000000000000pkcs11-dump -- PKCS#11 token dump. Copyright (c) 2006 Alon Bar-Lev ABOUT A small utility to dump PKCS#11 token contents. Intended for debugging. AUTHORS Alon Bar-Lev SUPPORT http://www.opensc-project.org pkcs11-dump-pkcs11-dump-0.3.5/THANKS000066400000000000000000000002321340524515000165360ustar00rootroot00000000000000 Max Vozeler - For writing the man page. - For maintaining Debian packaging. Apologies to anyone I have missed. Alon Bar-Lev pkcs11-dump-pkcs11-dump-0.3.5/configure.ac000066400000000000000000000100311340524515000201070ustar00rootroot00000000000000# # Copyright (c) 2005-2008 Alon Bar-Lev # All rights reserved. # # 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., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # AC_PREREQ([2.60]) define([PACKAGE_VERSION_MAJOR], [0]) define([PACKAGE_VERSION_MINOR], [3]) define([PACKAGE_VERSION_FIX], [5]) AC_INIT([pkcs11-dump], [PACKAGE_VERSION_MAJOR.PACKAGE_VERSION_MINOR.PACKAGE_VERSION_FIX]) AM_INIT_AUTOMAKE AM_CONFIG_HEADER([config.h]) AC_CONFIG_SRCDIR([pkcs11-dump.cpp]) AC_CONFIG_MACRO_DIR([m4]) PKCS11_DUMP_VERSION_MAJOR="PACKAGE_VERSION_MAJOR" PKCS11_DUMP_VERSION_MINOR="PACKAGE_VERSION_MINOR" PKCS11_DUMP_VERSION_FIX="PACKAGE_VERSION_FIX" AC_CANONICAL_HOST AC_ARG_WITH( [cygwin-native], [AC_HELP_STRING([--with-cygwin-native], [compile native win32])], , [with_cygwin_native="no"] ) dnl Check for some target-specific stuff test -z "${WIN32}" && WIN32="no" test -z "${CYGWIN}" && CYGWIN="no" case "${host}" in *-mingw32*|*-winnt*) WIN32="yes" CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN" ;; *-cygwin*) AC_MSG_CHECKING([cygwin mode to use]) CYGWIN="yes" if test "${with_cygwin_native}" = "yes"; then AC_MSG_RESULT([Using native win32]) CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN" CFLAGS="${CFLAGS} -mno-cygwin" WIN32="yes" else AC_MSG_RESULT([Using cygwin]) CPPFLAGS="${CPPFLAGS} -DCRYPTOKI_FORCE_WIN32" AC_DEFINE([USE_CYGWIN], [1], [Define if you are on Cygwin]) fi ;; esac AC_ARG_ENABLE( [pedantic], [AC_HELP_STRING([--enable-pedantic], [enable pedantic compile mode @<:@disabled@:>@])], , [enable_pedantic="no"] ) # Checks for programs. AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL PKG_PROG_PKG_CONFIG dnl Add libtool support. ifdef( [LT_INIT], [ LT_INIT([win32-dll]) LT_LANG([Windows Resource]) ], [ AC_LIBTOOL_WIN32_DLL AC_LIBTOOL_RC AC_PROG_LIBTOOL ] ) if test "${WIN32}" = "yes"; then AC_ARG_VAR([MAN2HTML], [man2html utility]) AC_CHECK_PROGS([MAN2HTML], [man2html]) test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32]) fi AC_FUNC_MKTIME AC_FUNC_VPRINTF AC_CHECK_FUNCS([ \ gettimeofday memmove memset socket strchr strdup strerror strrchr \ snprintf \ ]) # Checks for header files. AC_HEADER_STDC AC_C_CONST AC_C_VOLATILE AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_HEADER_TIME AC_STRUCT_TM AC_CHECK_HEADERS([[ \ stdio.h \ stdlib.h \ stdargs.h \ malloc.h \ ctype.h \ string.h \ errno.h \ ]]) AC_CHECK_HEADERS([ \ signal.h \ dlfcn.h \ unistd.h \ ]) if test "${WIN32}" != "yes"; then AC_CHECK_LIB([dl], [dlopen]) PKG_CHECK_MODULES( [OPENSSL], [libcrypto >= 0.9.7], [have_openssl="yes"], [PKG_CHECK_MODULES( [OPENSSL], [openssl >= 0.9.7], [have_openssl="yes"], [AC_CHECK_LIB( [crypto], [RSA_version], [ have_openssl="yes" OPENSSL_LIBS="-lcrypto" ], [have_openssl="no"] )] )] ) CXXFLAGS="${CXXFLAGS} ${OPENSSL_CFLAGS}" LIBS="${LIBS} ${OPENSSL_LIBS}" fi if test "${enable_pedantic}" = "yes"; then CXXFLAGS="${CXXFLAGS} -ansi -pedantic -D__STRICT_ANSI__ -D_ISOC99_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE" CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wsign-compare -Wno-unused-parameter -Wno-unused-function" fi if test "${WIN32}" = "yes"; then LIBS="${LIBS} -lcrypt32" fi AC_SUBST([PKCS11_DUMP_VERSION_MAJOR]) AC_SUBST([PKCS11_DUMP_VERSION_MINOR]) AC_SUBST([PKCS11_DUMP_VERSION_FIX]) AM_CONDITIONAL(WIN32, test "${WIN32}" = "yes") AM_CONDITIONAL(CYGWIN, test "${CYGWIN}" = "yes") AC_OUTPUT([ Makefile versioninfo.rc ]) pkcs11-dump-pkcs11-dump-0.3.5/m4/000077500000000000000000000000001340524515000161465ustar00rootroot00000000000000pkcs11-dump-pkcs11-dump-0.3.5/m4/.keep000066400000000000000000000000001340524515000170610ustar00rootroot00000000000000pkcs11-dump-pkcs11-dump-0.3.5/pkcs11-dump.1000066400000000000000000000023131340524515000177540ustar00rootroot00000000000000.TH PKCS11-DUMP 1 "2008-05-30" .SH NAME pkcs11-dump \- dump PKCS#11 token content . .SH SYNOPSIS . .B pkcs11-dump info .I /path/to/pkcs11.so .br .B pkcs11-dump slotlist .I /path/to/pkcs11.so .br .B pkcs11-dump dump .I /path/to/pkcs11.so slotnum userpin|- .br . .SH DESCRIPTION .B pkcs11-dump is a program to query PKCS#11 provider modules for objects available on a specific crypto device. .B pkcs11-dump then dumps those objects to stdout in a human-readable format. .PP .B pkcs11-dump knows about PKCS#11 object types and attributes specified in PKCS#11 versions up to and including v2.20. .PP These object types are supported .IP \(bu 4 CKO_DATA .IP \(bu 4 CKO_CERTIFICATE .IP \(bu 4 CKO_PUBLIC_KEY .IP \(bu 4 CKO_PRIVATE_KEY .IP \(bu 4 CKO_SECRET_KEY .IP \(bu 4 CKO_HW_FEATURE .IP \(bu 4 CKO_DOMAIN_PARAMETERS .IP \(bu 4 CKO_MECHANISM .IP \(bu 4 CKO_VENDOR_DEFINED . .SH SEE ALSO .BR pkcs11-data (1) .br .SH AUTHOR pkcs11-dump was written by Alon Bar-Lev . .PP The pkcs11-dump project homepage is at .nf .nh .B http://alon.barlev.googlepages.com/pkcs11-utilities .hy .fi .PP This manual page was written by Max Vozeler , for the Debian project (but may be used by others). pkcs11-dump-pkcs11-dump-0.3.5/pkcs11-dump.cpp000066400000000000000000001256511340524515000204110ustar00rootroot00000000000000/* * Copyright (c) 2005-2008 Alon Bar-Lev * All rights reserved. * * 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., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef PACKAGE_NAME #define PACKAGE_NAME "pkcs11-dump" #define PACKAGE_VERSION "unknown" #endif #if defined(_WIN32) #include #include #include #else #include #include #include #endif #include #include #include #include #include "pkcs11.h" #if defined(_WIN32) #define PKCS11_MODULE_HANDLE HMODULE #else #define PKCS11_MODULE_HANDLE void * #endif #if !defined(IN) #define IN #endif #if !defined(OUT) #define OUT #endif #if !defined(_WIN32) #if OPENSSL_VERSION_NUMBER < 0x00908000L typedef unsigned char *pkcs11_openssl_d2i_t; #else typedef const unsigned char *pkcs11_openssl_d2i_t; #endif #endif typedef enum { attrtypeUnknown, attrtypeString, attrtypeByteArray, attrtypeSubject, attrtypeSubject1, attrtypeBigInteger, attrtypeCK_BBOOL, attrtypeCK_DATE, attrtypeCK_ULONG, attrtypeCK_CERTIFICATE_TYPE, attrtypeCK_KEY_TYPE, attrtypeCK_MECHANISM_TYPE, attrtypeCK_OBJECT_CLASS, attrtypeCK_HW_FEATURE_TYPE, attrtypeCK_CHAR, attrtypeCK_ATTRIBUTE_PTR, attrtypeCK_MECHANISM_TYPE_PTR } AttributeType; typedef struct { int nId; const char *szName; AttributeType attrtypeType; int nSize; } AttributeDescription; class CEGeneral { public: CEGeneral ( IN const std::string &str ) : m_str(str) {}; public: std::string m_str; }; class CEPKCS11 { public: CEPKCS11 ( IN const std::string &str, IN const CK_RV rv ) : m_str(str), m_rv(rv) {}; public: std::string m_str; CK_RV m_rv; }; const AttributeDescription attrdescAttributes[] = { {CKA_CLASS, "CKA_CLASS", attrtypeCK_OBJECT_CLASS, 0}, {CKA_TOKEN, "CKA_TOKEN", attrtypeCK_BBOOL, 0}, {CKA_PRIVATE, "CKA_PRIVATE", attrtypeCK_BBOOL, 0}, {CKA_LABEL, "CKA_LABEL", attrtypeString, 0}, {CKA_APPLICATION, "CKA_APPLICATION", attrtypeString, 0}, {CKA_VALUE, "CKA_VALUE", attrtypeByteArray, 16}, {CKA_OBJECT_ID, "CKA_OBJECT_ID", attrtypeByteArray, 0}, {CKA_CERTIFICATE_TYPE, "CKA_CERTIFICATE_TYPE", attrtypeCK_CERTIFICATE_TYPE, 0}, {CKA_ISSUER, "CKA_ISSUER", attrtypeSubject, 0}, {CKA_SERIAL_NUMBER, "CKA_SERIAL_NUMBER", attrtypeByteArray, 0}, {CKA_AC_ISSUER, "CKA_AC_ISSUER", attrtypeSubject1, 0}, {CKA_OWNER, "CKA_OWNER", attrtypeSubject1, 0}, {CKA_ATTR_TYPES, "CKA_ATTR_TYPES", attrtypeByteArray, 0}, {CKA_TRUSTED, "CKA_TRUSTED", attrtypeCK_BBOOL, 0}, {CKA_CERTIFICATE_CATEGORY, "CKA_CERTIFICATE_CATEGORY", attrtypeCK_ULONG, 0}, {CKA_JAVA_MIDP_SECURITY_DOMAIN, "CKA_JAVA_MIDP_SECURITY_DOMAIN", attrtypeCK_ULONG, 0}, {CKA_URL, "CKA_URL", attrtypeString, 0}, {CKA_HASH_OF_SUBJECT_PUBLIC_KEY, "CKA_HASH_OF_SUBJECT_PUBLIC_KEY", attrtypeByteArray, 0}, {CKA_HASH_OF_ISSUER_PUBLIC_KEY, "CKA_HASH_OF_ISSUER_PUBLIC_KEY", attrtypeByteArray, 0}, {CKA_CHECK_VALUE, "CKA_CHECK_VALUE", attrtypeByteArray, 0}, {CKA_KEY_TYPE, "CKA_KEY_TYPE", attrtypeCK_KEY_TYPE, 0}, {CKA_SUBJECT, "CKA_SUBJECT", attrtypeSubject, 0}, {CKA_ID, "CKA_ID", attrtypeByteArray, 0}, {CKA_SENSITIVE, "CKA_SENSITIVE", attrtypeCK_BBOOL, 0}, {CKA_ENCRYPT, "CKA_ENCRYPT", attrtypeCK_BBOOL, 0}, {CKA_DECRYPT, "CKA_DECRYPT", attrtypeCK_BBOOL, 0}, {CKA_WRAP, "CKA_WRAP", attrtypeCK_BBOOL, 0}, {CKA_UNWRAP, "CKA_UNWRAP", attrtypeCK_BBOOL, 0}, {CKA_SIGN, "CKA_SIGN", attrtypeCK_BBOOL, 0}, {CKA_SIGN_RECOVER, "CKA_SIGN_RECOVER", attrtypeCK_BBOOL, 0}, {CKA_VERIFY, "CKA_VERIFY", attrtypeCK_BBOOL, 0}, {CKA_VERIFY_RECOVER, "CKA_VERIFY_RECOVER", attrtypeCK_BBOOL, 0}, {CKA_DERIVE, "CKA_DERIVE", attrtypeCK_BBOOL, 0}, {CKA_START_DATE, "CKA_START_DATE", attrtypeCK_DATE, 0}, {CKA_END_DATE, "CKA_END_DATE", attrtypeCK_DATE, 0}, {CKA_MODULUS, "CKA_MODULUS", attrtypeBigInteger, 0}, {CKA_MODULUS_BITS, "CKA_MODULUS_BITS", attrtypeCK_ULONG, 0}, {CKA_PUBLIC_EXPONENT, "CKA_PUBLIC_EXPONENT", attrtypeBigInteger, 0}, {CKA_PRIVATE_EXPONENT, "CKA_PRIVATE_EXPONENT", attrtypeBigInteger, 0}, {CKA_PRIME_1, "CKA_PRIME_1", attrtypeBigInteger, 0}, {CKA_PRIME_2, "CKA_PRIME_2", attrtypeBigInteger, 0}, {CKA_EXPONENT_1, "CKA_EXPONENT_1", attrtypeBigInteger, 0}, {CKA_EXPONENT_2, "CKA_EXPONENT_2", attrtypeBigInteger, 0}, {CKA_COEFFICIENT, "CKA_COEFFICIENT", attrtypeBigInteger, 0}, {CKA_PRIME, "CKA_PRIME", attrtypeBigInteger, 0}, {CKA_SUBPRIME, "CKA_SUBPRIME", attrtypeBigInteger, 0}, {CKA_BASE, "CKA_BASE", attrtypeBigInteger, 0}, {CKA_PRIME_BITS, "CKA_PRIME_BITS", attrtypeCK_ULONG, 0}, //OS {CKA_SUBPRIME_BITS, "CKA_SUBPRIME_BITS", attrtypeCK_ULONG, 0}, {CKA_SUB_PRIME_BITS, "CKA_SUB_PRIME_BITS", attrtypeCK_ULONG, 0}, {CKA_VALUE_BITS, "CKA_VALUE_BITS", attrtypeCK_ULONG, 0}, {CKA_VALUE_LEN, "CKA_VALUE_LEN", attrtypeCK_ULONG, 0}, {CKA_EXTRACTABLE, "CKA_EXTRACTABLE", attrtypeCK_BBOOL, 0}, {CKA_LOCAL, "CKA_LOCAL", attrtypeCK_BBOOL, 0}, {CKA_NEVER_EXTRACTABLE, "CKA_NEVER_EXTRACTABLE", attrtypeCK_BBOOL, 0}, {CKA_ALWAYS_SENSITIVE, "CKA_ALWAYS_SENSITIVE", attrtypeCK_BBOOL, 0}, {CKA_KEY_GEN_MECHANISM, "CKA_KEY_GEN_MECHANISM", attrtypeCK_MECHANISM_TYPE, 0}, {CKA_MODIFIABLE, "CKA_MODIFIABLE", attrtypeCK_BBOOL, 0}, {CKA_ECDSA_PARAMS, "CKA_ECDSA_PARAMS", attrtypeByteArray, 0}, {CKA_EC_PARAMS, "CKA_EC_PARAMS", attrtypeByteArray, 0}, {CKA_EC_POINT, "CKA_EC_POINT", attrtypeByteArray, 0}, {CKA_SECONDARY_AUTH, "CKA_SECONDARY_AUTH", attrtypeUnknown, 0}, {CKA_AUTH_PIN_FLAGS, "CKA_AUTH_PIN_FLAGS", attrtypeUnknown, 0}, {CKA_ALWAYS_AUTHENTICATE, "CKA_ALWAYS_AUTHENTICATE", attrtypeCK_BBOOL, 0}, {CKA_WRAP_WITH_TRUSTED, "CKA_WRAP_WITH_TRUSTED", attrtypeCK_BBOOL, 0}, {CKA_WRAP_TEMPLATE, "CKA_WRAP_TEMPLATE", attrtypeCK_ATTRIBUTE_PTR, 0}, {CKA_UNWRAP_TEMPLATE, "CKA_UNWRAP_TEMPLATE", attrtypeCK_ATTRIBUTE_PTR, 0}, {CKA_HW_FEATURE_TYPE, "CKA_HW_FEATURE_TYPE", attrtypeCK_HW_FEATURE_TYPE, 0}, {CKA_RESET_ON_INIT, "CKA_RESET_ON_INIT", attrtypeCK_BBOOL, 0}, {CKA_HAS_RESET, "CKA_HAS_RESET", attrtypeCK_BBOOL, 0}, {CKA_PIXEL_X, "CKA_PIXEL_X", attrtypeCK_ULONG, 0}, {CKA_PIXEL_Y, "CKA_PIXEL_Y", attrtypeCK_ULONG, 0}, {CKA_RESOLUTION, "CKA_RESOLUTION", attrtypeCK_ULONG, 0}, {CKA_CHAR_ROWS, "CKA_CHAR_ROWS", attrtypeCK_ULONG, 0}, {CKA_CHAR_COLUMNS, "CKA_CHAR_COLUMNS", attrtypeCK_ULONG, 0}, {CKA_COLOR, "CKA_COLOR", attrtypeCK_BBOOL, 0}, {CKA_BITS_PER_PIXEL, "CKA_BITS_PER_PIXEL", attrtypeCK_ULONG, 0}, {CKA_CHAR_SETS, "CKA_CHAR_SETS", attrtypeString, 0}, {CKA_ENCODING_METHODS, "CKA_ENCODING_METHODS", attrtypeString, 0}, {CKA_MIME_TYPES, "CKA_MIME_TYPES", attrtypeString, 0}, {CKA_MECHANISM_TYPE, "CKA_MECHANISM_TYPE", attrtypeCK_MECHANISM_TYPE, 0}, {CKA_REQUIRED_CMS_ATTRIBUTES, "CKA_REQUIRED_CMS_ATTRIBUTES", attrtypeByteArray, 0}, {CKA_DEFAULT_CMS_ATTRIBUTES, "CKA_DEFAULT_CMS_ATTRIBUTES", attrtypeByteArray, 0}, {CKA_SUPPORTED_CMS_ATTRIBUTES, "CKA_SUPPORTED_CMS_ATTRIBUTES", attrtypeByteArray, 0}, {CKA_ALLOWED_MECHANISMS, "CKA_ALLOWED_MECHANISMS", attrtypeCK_MECHANISM_TYPE_PTR, 0}, {-1, NULL, attrtypeUnknown, 0} }; static std::string Resolve_CK_OBJECT_CLASS ( IN const CK_OBJECT_CLASS c ) { switch (c) { case CKO_DATA: return "CKO_DATA"; case CKO_CERTIFICATE: return "CKO_CERTIFICATE"; case CKO_PUBLIC_KEY: return "CKO_PUBLIC_KEY"; case CKO_PRIVATE_KEY: return "CKO_PRIVATE_KEY"; case CKO_SECRET_KEY: return "CKO_SECRET_KEY"; case CKO_HW_FEATURE: return "CKO_HW_FEATURE"; case CKO_DOMAIN_PARAMETERS: return "CKO_DOMAIN_PARAMETERS"; case CKO_MECHANISM: return "CKO_MECHANISM"; case CKO_VENDOR_DEFINED: return "CKO_VENDOR_DEFINED"; default: { char szError[1024]; sprintf (szError, "Unknown CK_OBJECT_CLASS %08lx", c); return szError; } } } static std::string Resolve_CK_KEY_TYPE ( IN const CK_KEY_TYPE t ) { switch (t) { case CKK_RSA: return "CKK_RSA"; case CKK_DSA: return "CKK_DSA"; case CKK_DH: return "CKK_DH"; case CKK_ECDSA: return "CKK_ECDSA"; // case CKK_EC: return "CKK_EC"; case CKK_X9_42_DH: return "CKK_X9_42_DH"; case CKK_KEA: return "CKK_KEA"; case CKK_GENERIC_SECRET: return "CKK_GENERIC_SECRET"; case CKK_RC2: return "CKK_RC2"; case CKK_RC4: return "CKK_RC4"; case CKK_DES: return "CKK_DES"; case CKK_DES2: return "CKK_DES2"; case CKK_DES3: return "CKK_DES3"; case CKK_CAST: return "CKK_CAST"; case CKK_CAST3: return "CKK_CAST3"; //OS case CKK_CAST5: return "CKK_CAST5"; // case CKK_CAST128: return "CKK_CAST128"; case CKK_RC5: return "CKK_RC5"; case CKK_IDEA: return "CKK_IDEA"; case CKK_SKIPJACK: return "CKK_SKIPJACK"; case CKK_BATON: return "CKK_BATON"; case CKK_JUNIPER: return "CKK_JUNIPER"; case CKK_CDMF: return "CKK_CDMF"; case CKK_AES: return "CKK_AES"; case CKK_BLOWFISH: return "CKK_BLOWFISH"; case CKK_TWOFISH: return "CKK_TWOFISH"; case CKK_VENDOR_DEFINED: return "CKK_VENDOR_DEFINED"; default: { char szError[1024]; sprintf (szError, "Unknown CK_KEY_TYPE %08lx", t); return szError; } } } static std::string Resolve_CK_MECHANISM_TYPE ( IN CK_MECHANISM_TYPE t ) { switch (t) { case CKM_RSA_PKCS_KEY_PAIR_GEN: return "CKM_RSA_PKCS_KEY_PAIR_GEN"; case CKM_RSA_PKCS: return "CKM_RSA_PKCS"; case CKM_RSA_9796: return "CKM_RSA_9796"; case CKM_RSA_X_509: return "CKM_RSA_X_509"; case CKM_MD2_RSA_PKCS: return "CKM_MD2_RSA_PKCS"; case CKM_MD5_RSA_PKCS: return "CKM_MD5_RSA_PKCS"; case CKM_SHA1_RSA_PKCS: return "CKM_SHA1_RSA_PKCS"; case CKM_RIPEMD128_RSA_PKCS: return "CKM_RIPEMD128_RSA_PKCS"; case CKM_RIPEMD160_RSA_PKCS: return "CKM_RIPEMD160_RSA_PKCS"; case CKM_RSA_PKCS_OAEP: return "CKM_RSA_PKCS_OAEP"; case CKM_RSA_X9_31_KEY_PAIR_GEN: return "CKM_RSA_X9_31_KEY_PAIR_GEN"; case CKM_RSA_X9_31: return "CKM_RSA_X9_31"; case CKM_SHA1_RSA_X9_31: return "CKM_SHA1_RSA_X9_31"; case CKM_RSA_PKCS_PSS: return "CKM_RSA_PKCS_PSS"; case CKM_SHA1_RSA_PKCS_PSS: return "CKM_SHA1_RSA_PKCS_PSS"; case CKM_DSA_KEY_PAIR_GEN: return "CKM_DSA_KEY_PAIR_GEN"; case CKM_DSA: return "CKM_DSA"; case CKM_DSA_SHA1: return "CKM_DSA_SHA1"; case CKM_DH_PKCS_KEY_PAIR_GEN: return "CKM_DH_PKCS_KEY_PAIR_GEN"; case CKM_DH_PKCS_DERIVE: return "CKM_DH_PKCS_DERIVE"; case CKM_X9_42_DH_KEY_PAIR_GEN: return "CKM_X9_42_DH_KEY_PAIR_GEN"; case CKM_X9_42_DH_DERIVE: return "CKM_X9_42_DH_DERIVE"; case CKM_X9_42_DH_HYBRID_DERIVE: return "CKM_X9_42_DH_HYBRID_DERIVE"; case CKM_X9_42_MQV_DERIVE: return "CKM_X9_42_MQV_DERIVE"; /*OS case CKM_SHA256_RSA_PKCS: return "CKM_SHA256_RSA_PKCS"; case CKM_SHA384_RSA_PKCS: return "CKM_SHA384_RSA_PKCS"; case CKM_SHA512_RSA_PKCS: return "CKM_SHA512_RSA_PKCS"; case CKM_SHA256_RSA_PKCS_PSS: return "CKM_SHA256_RSA_PKCS_PSS"; case CKM_SHA384_RSA_PKCS_PSS: return "CKM_SHA384_RSA_PKCS_PSS"; case CKM_SHA512_RSA_PKCS_PSS: return "CKM_SHA512_RSA_PKCS_PSS"; */ case CKM_RC2_KEY_GEN: return "CKM_RC2_KEY_GEN"; case CKM_RC2_ECB: return "CKM_RC2_ECB"; case CKM_RC2_CBC: return "CKM_RC2_CBC"; case CKM_RC2_MAC: return "CKM_RC2_MAC"; case CKM_RC2_MAC_GENERAL: return "CKM_RC2_MAC_GENERAL"; case CKM_RC2_CBC_PAD: return "CKM_RC2_CBC_PAD"; case CKM_RC4_KEY_GEN: return "CKM_RC4_KEY_GEN"; case CKM_RC4: return "CKM_RC4"; case CKM_DES_KEY_GEN: return "CKM_DES_KEY_GEN"; case CKM_DES_ECB: return "CKM_DES_ECB"; case CKM_DES_CBC: return "CKM_DES_CBC"; case CKM_DES_MAC: return "CKM_DES_MAC"; case CKM_DES_MAC_GENERAL: return "CKM_DES_MAC_GENERAL"; case CKM_DES_CBC_PAD: return "CKM_DES_CBC_PAD"; case CKM_DES2_KEY_GEN: return "CKM_DES2_KEY_GEN"; case CKM_DES3_KEY_GEN: return "CKM_DES3_KEY_GEN"; case CKM_DES3_ECB: return "CKM_DES3_ECB"; case CKM_DES3_CBC: return "CKM_DES3_CBC"; case CKM_DES3_MAC: return "CKM_DES3_MAC"; case CKM_DES3_MAC_GENERAL: return "CKM_DES3_MAC_GENERAL"; case CKM_DES3_CBC_PAD: return "CKM_DES3_CBC_PAD"; case CKM_CDMF_KEY_GEN: return "CKM_CDMF_KEY_GEN"; case CKM_CDMF_ECB: return "CKM_CDMF_ECB"; case CKM_CDMF_CBC: return "CKM_CDMF_CBC"; case CKM_CDMF_MAC: return "CKM_CDMF_MAC"; case CKM_CDMF_MAC_GENERAL: return "CKM_CDMF_MAC_GENERAL"; case CKM_CDMF_CBC_PAD: return "CKM_CDMF_CBC_PAD"; /*OS case CKM_DES_OFB64: return "CKM_DES_OFB64"; case CKM_DES_OFB8: return "CKM_DES_OFB8"; case CKM_DES_CFB64: return "CKM_DES_CFB64"; case CKM_DES_CFB8: return "CKM_DES_CFB8"; */ case CKM_MD2: return "CKM_MD2"; case CKM_MD2_HMAC: return "CKM_MD2_HMAC"; case CKM_MD2_HMAC_GENERAL: return "CKM_MD2_HMAC_GENERAL"; case CKM_MD5: return "CKM_MD5"; case CKM_MD5_HMAC: return "CKM_MD5_HMAC"; case CKM_MD5_HMAC_GENERAL: return "CKM_MD5_HMAC_GENERAL"; case CKM_SHA_1: return "CKM_SHA_1"; case CKM_SHA_1_HMAC: return "CKM_SHA_1_HMAC"; case CKM_SHA_1_HMAC_GENERAL: return "CKM_SHA_1_HMAC_GENERAL"; case CKM_RIPEMD128: return "CKM_RIPEMD128"; case CKM_RIPEMD128_HMAC: return "CKM_RIPEMD128_HMAC"; case CKM_RIPEMD128_HMAC_GENERAL: return "CKM_RIPEMD128_HMAC_GENERAL"; case CKM_RIPEMD160: return "CKM_RIPEMD160"; case CKM_RIPEMD160_HMAC: return "CKM_RIPEMD160_HMAC"; case CKM_RIPEMD160_HMAC_GENERAL: return "CKM_RIPEMD160_HMAC_GENERAL"; /*OS case CKM_SHA256: return "CKM_SHA256"; case CKM_SHA256_HMAC: return "CKM_SHA256_HMAC"; case CKM_SHA256_HMAC_GENERAL: return "CKM_SHA256_HMAC_GENERAL"; case CKM_SHA384: return "CKM_SHA384"; case CKM_SHA384_HMAC: return "CKM_SHA384_HMAC"; case CKM_SHA384_HMAC_GENERAL: return "CKM_SHA384_HMAC_GENERAL"; case CKM_SHA512: return "CKM_SHA512"; case CKM_SHA512_HMAC: return "CKM_SHA512_HMAC"; case CKM_SHA512_HMAC_GENERAL: return "CKM_SHA512_HMAC_GENERAL"; */ case CKM_CAST_KEY_GEN: return "CKM_CAST_KEY_GEN"; case CKM_CAST_ECB: return "CKM_CAST_ECB"; case CKM_CAST_CBC: return "CKM_CAST_CBC"; case CKM_CAST_MAC: return "CKM_CAST_MAC"; case CKM_CAST_MAC_GENERAL: return "CKM_CAST_MAC_GENERAL"; case CKM_CAST_CBC_PAD: return "CKM_CAST_CBC_PAD"; case CKM_CAST3_KEY_GEN: return "CKM_CAST3_KEY_GEN"; case CKM_CAST3_ECB: return "CKM_CAST3_ECB"; case CKM_CAST3_CBC: return "CKM_CAST3_CBC"; case CKM_CAST3_MAC: return "CKM_CAST3_MAC"; case CKM_CAST3_MAC_GENERAL: return "CKM_CAST3_MAC_GENERAL"; case CKM_CAST3_CBC_PAD: return "CKM_CAST3_CBC_PAD"; case CKM_CAST5_KEY_GEN: return "CKM_CAST5_KEY_GEN"; // case CKM_CAST128_KEY_GEN: return "CKM_CAST128_KEY_GEN"; case CKM_CAST5_ECB: return "CKM_CAST5_ECB"; // case CKM_CAST128_ECB: return "CKM_CAST128_ECB"; case CKM_CAST5_CBC: return "CKM_CAST5_CBC"; // case CKM_CAST128_CBC: return "CKM_CAST128_CBC"; case CKM_CAST5_MAC: return "CKM_CAST5_MAC"; // case CKM_CAST128_MAC: return "CKM_CAST128_MAC"; case CKM_CAST5_MAC_GENERAL: return "CKM_CAST5_MAC_GENERAL"; // case CKM_CAST128_MAC_GENERAL: return "CKM_CAST128_MAC_GENERAL"; case CKM_CAST5_CBC_PAD: return "CKM_CAST5_CBC_PAD"; // case CKM_CAST128_CBC_PAD: return "CKM_CAST128_CBC_PAD"; case CKM_RC5_KEY_GEN: return "CKM_RC5_KEY_GEN"; case CKM_RC5_ECB: return "CKM_RC5_ECB"; case CKM_RC5_CBC: return "CKM_RC5_CBC"; case CKM_RC5_MAC: return "CKM_RC5_MAC"; case CKM_RC5_MAC_GENERAL: return "CKM_RC5_MAC_GENERAL"; case CKM_RC5_CBC_PAD: return "CKM_RC5_CBC_PAD"; case CKM_IDEA_KEY_GEN: return "CKM_IDEA_KEY_GEN"; case CKM_IDEA_ECB: return "CKM_IDEA_ECB"; case CKM_IDEA_CBC: return "CKM_IDEA_CBC"; case CKM_IDEA_MAC: return "CKM_IDEA_MAC"; case CKM_IDEA_MAC_GENERAL: return "CKM_IDEA_MAC_GENERAL"; case CKM_IDEA_CBC_PAD: return "CKM_IDEA_CBC_PAD"; case CKM_GENERIC_SECRET_KEY_GEN: return "CKM_GENERIC_SECRET_KEY_GEN"; case CKM_CONCATENATE_BASE_AND_KEY: return "CKM_CONCATENATE_BASE_AND_KEY"; case CKM_CONCATENATE_BASE_AND_DATA: return "CKM_CONCATENATE_BASE_AND_DATA"; case CKM_CONCATENATE_DATA_AND_BASE: return "CKM_CONCATENATE_DATA_AND_BASE"; case CKM_XOR_BASE_AND_DATA: return "CKM_XOR_BASE_AND_DATA"; case CKM_EXTRACT_KEY_FROM_KEY: return "CKM_EXTRACT_KEY_FROM_KEY"; case CKM_SSL3_PRE_MASTER_KEY_GEN: return "CKM_SSL3_PRE_MASTER_KEY_GEN"; case CKM_SSL3_MASTER_KEY_DERIVE: return "CKM_SSL3_MASTER_KEY_DERIVE"; case CKM_SSL3_KEY_AND_MAC_DERIVE: return "CKM_SSL3_KEY_AND_MAC_DERIVE"; case CKM_SSL3_MASTER_KEY_DERIVE_DH: return "CKM_SSL3_MASTER_KEY_DERIVE_DH"; case CKM_TLS_PRE_MASTER_KEY_GEN: return "CKM_TLS_PRE_MASTER_KEY_GEN"; case CKM_TLS_MASTER_KEY_DERIVE: return "CKM_TLS_MASTER_KEY_DERIVE"; case CKM_TLS_KEY_AND_MAC_DERIVE: return "CKM_TLS_KEY_AND_MAC_DERIVE"; case CKM_TLS_MASTER_KEY_DERIVE_DH: return "CKM_TLS_MASTER_KEY_DERIVE_DH"; //OS case CKM_TLS_PRF: return "CKM_TLS_PRF"; case CKM_SSL3_MD5_MAC: return "CKM_SSL3_MD5_MAC"; case CKM_SSL3_SHA1_MAC: return "CKM_SSL3_SHA1_MAC"; case CKM_MD5_KEY_DERIVATION: return "CKM_MD5_KEY_DERIVATION"; case CKM_MD2_KEY_DERIVATION: return "CKM_MD2_KEY_DERIVATION"; case CKM_SHA1_KEY_DERIVATION: return "CKM_SHA1_KEY_DERIVATION"; /*OS case CKM_SHA256_KEY_DERIVATION: return "CKM_SHA256_KEY_DERIVATION"; case CKM_SHA384_KEY_DERIVATION: return "CKM_SHA384_KEY_DERIVATION"; case CKM_SHA512_KEY_DERIVATION: return "CKM_SHA512_KEY_DERIVATION"; */ case CKM_PBE_MD2_DES_CBC: return "CKM_PBE_MD2_DES_CBC"; case CKM_PBE_MD5_DES_CBC: return "CKM_PBE_MD5_DES_CBC"; case CKM_PBE_MD5_CAST_CBC: return "CKM_PBE_MD5_CAST_CBC"; case CKM_PBE_MD5_CAST3_CBC: return "CKM_PBE_MD5_CAST3_CBC"; case CKM_PBE_MD5_CAST5_CBC: return "CKM_PBE_MD5_CAST5_CBC"; // case CKM_PBE_MD5_CAST128_CBC: return "CKM_PBE_MD5_CAST128_CBC"; case CKM_PBE_SHA1_CAST5_CBC: return "CKM_PBE_SHA1_CAST5_CBC"; // case CKM_PBE_SHA1_CAST128_CBC: return "CKM_PBE_SHA1_CAST128_CBC"; case CKM_PBE_SHA1_RC4_128: return "CKM_PBE_SHA1_RC4_128"; case CKM_PBE_SHA1_RC4_40: return "CKM_PBE_SHA1_RC4_40"; case CKM_PBE_SHA1_DES3_EDE_CBC: return "CKM_PBE_SHA1_DES3_EDE_CBC"; case CKM_PBE_SHA1_DES2_EDE_CBC: return "CKM_PBE_SHA1_DES2_EDE_CBC"; case CKM_PBE_SHA1_RC2_128_CBC: return "CKM_PBE_SHA1_RC2_128_CBC"; case CKM_PBE_SHA1_RC2_40_CBC: return "CKM_PBE_SHA1_RC2_40_CBC"; case CKM_PKCS5_PBKD2: return "CKM_PKCS5_PBKD2"; case CKM_PBA_SHA1_WITH_SHA1_HMAC: return "CKM_PBA_SHA1_WITH_SHA1_HMAC"; /*OS case CKM_WTLS_PRE_MASTER_KEY_GEN: return "CKM_WTLS_PRE_MASTER_KEY_GEN"; case CKM_WTLS_MASTER_KEY_DERIVE: return "CKM_WTLS_MASTER_KEY_DERIVE"; // case CKM_WTLS_MASTER_KEY_DERVIE_DH_ECC: return "CKM_WTLS_MASTER_KEY_DERVIE_DH_ECC"; case CKM_WTLS_PRF: return "CKM_WTLS_PRF"; case CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE: return "CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE"; case CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE: return "CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE"; */ case CKM_KEY_WRAP_LYNKS: return "CKM_KEY_WRAP_LYNKS"; case CKM_KEY_WRAP_SET_OAEP: return "CKM_KEY_WRAP_SET_OAEP"; //OS case CKM_CMS_SIG: return "CKM_CMS_SIG"; case CKM_SKIPJACK_KEY_GEN: return "CKM_SKIPJACK_KEY_GEN"; case CKM_SKIPJACK_ECB64: return "CKM_SKIPJACK_ECB64"; case CKM_SKIPJACK_CBC64: return "CKM_SKIPJACK_CBC64"; case CKM_SKIPJACK_OFB64: return "CKM_SKIPJACK_OFB64"; case CKM_SKIPJACK_CFB64: return "CKM_SKIPJACK_CFB64"; case CKM_SKIPJACK_CFB32: return "CKM_SKIPJACK_CFB32"; case CKM_SKIPJACK_CFB16: return "CKM_SKIPJACK_CFB16"; case CKM_SKIPJACK_CFB8: return "CKM_SKIPJACK_CFB8"; case CKM_SKIPJACK_WRAP: return "CKM_SKIPJACK_WRAP"; case CKM_SKIPJACK_PRIVATE_WRAP: return "CKM_SKIPJACK_PRIVATE_WRAP"; case CKM_SKIPJACK_RELAYX: return "CKM_SKIPJACK_RELAYX"; case CKM_KEA_KEY_PAIR_GEN: return "CKM_KEA_KEY_PAIR_GEN"; case CKM_KEA_KEY_DERIVE: return "CKM_KEA_KEY_DERIVE"; case CKM_FORTEZZA_TIMESTAMP: return "CKM_FORTEZZA_TIMESTAMP"; case CKM_BATON_KEY_GEN: return "CKM_BATON_KEY_GEN"; case CKM_BATON_ECB128: return "CKM_BATON_ECB128"; case CKM_BATON_ECB96: return "CKM_BATON_ECB96"; case CKM_BATON_CBC128: return "CKM_BATON_CBC128"; case CKM_BATON_COUNTER: return "CKM_BATON_COUNTER"; case CKM_BATON_SHUFFLE: return "CKM_BATON_SHUFFLE"; case CKM_BATON_WRAP: return "CKM_BATON_WRAP"; case CKM_ECDSA_KEY_PAIR_GEN: return "CKM_ECDSA_KEY_PAIR_GEN"; // case CKM_EC_KEY_PAIR_GEN: return "CKM_EC_KEY_PAIR_GEN"; case CKM_ECDSA: return "CKM_ECDSA"; case CKM_ECDSA_SHA1: return "CKM_ECDSA_SHA1"; case CKM_ECDH1_DERIVE: return "CKM_ECDH1_DERIVE"; case CKM_ECDH1_COFACTOR_DERIVE: return "CKM_ECDH1_COFACTOR_DERIVE"; case CKM_ECMQV_DERIVE: return "CKM_ECMQV_DERIVE"; case CKM_JUNIPER_KEY_GEN: return "CKM_JUNIPER_KEY_GEN"; case CKM_JUNIPER_ECB128: return "CKM_JUNIPER_ECB128"; case CKM_JUNIPER_CBC128: return "CKM_JUNIPER_CBC128"; case CKM_JUNIPER_COUNTER: return "CKM_JUNIPER_COUNTER"; case CKM_JUNIPER_SHUFFLE: return "CKM_JUNIPER_SHUFFLE"; case CKM_JUNIPER_WRAP: return "CKM_JUNIPER_WRAP"; case CKM_FASTHASH: return "CKM_FASTHASH"; case CKM_AES_KEY_GEN: return "CKM_AES_KEY_GEN"; case CKM_AES_ECB: return "CKM_AES_ECB"; case CKM_AES_CBC: return "CKM_AES_CBC"; case CKM_AES_MAC: return "CKM_AES_MAC"; case CKM_AES_MAC_GENERAL: return "CKM_AES_MAC_GENERAL"; case CKM_AES_CBC_PAD: return "CKM_AES_CBC_PAD"; /*OS case CKM_BLOWFISH_KEY_GEN: return "CKM_BLOWFISH_KEY_GEN"; case CKM_BLOWFISH_CBC: return "CKM_BLOWFISH_CBC"; case CKM_TWOFISH_KEY_GEN: return "CKM_TWOFISH_KEY_GEN"; case CKM_TWOFISH_CBC: return "CKM_TWOFISH_CBC"; case CKM_DES_ECB_ENCRYPT_DATA: return "CKM_DES_ECB_ENCRYPT_DATA"; case CKM_DES_CBC_ENCRYPT_DATA: return "CKM_DES_CBC_ENCRYPT_DATA"; case CKM_DES3_ECB_ENCRYPT_DATA: return "CKM_DES3_ECB_ENCRYPT_DATA"; case CKM_DES3_CBC_ENCRYPT_DATA: return "CKM_DES3_CBC_ENCRYPT_DATA"; case CKM_AES_ECB_ENCRYPT_DATA: return "CKM_AES_ECB_ENCRYPT_DATA"; case CKM_AES_CBC_ENCRYPT_DATA: return "CKM_AES_CBC_ENCRYPT_DATA"; case CKM_DSA_PARAMETER_GEN: return "CKM_DSA_PARAMETER_GEN"; */ case CKM_DH_PKCS_PARAMETER_GEN: return "CKM_DH_PKCS_PARAMETER_GEN"; case CKM_X9_42_DH_PARAMETER_GEN: return "CKM_X9_42_DH_PARAMETER_GEN"; case CKM_VENDOR_DEFINED: return "CKM_VENDOR_DEFINED"; default: { char szError[1024]; sprintf (szError, "Unknown CK_MECHANISM_TYPE %08lx", t); return szError; } } } static std::string Resolve_CK_RV ( IN const CK_RV rv ) { switch (rv) { case CKR_OK: return "CKR_OK"; case CKR_CANCEL: return "CKR_CANCEL"; case CKR_HOST_MEMORY: return "CKR_HOST_MEMORY"; case CKR_SLOT_ID_INVALID: return "CKR_SLOT_ID_INVALID"; case CKR_GENERAL_ERROR: return "CKR_GENERAL_ERROR"; case CKR_FUNCTION_FAILED: return "CKR_FUNCTION_FAILED"; case CKR_ARGUMENTS_BAD: return "CKR_ARGUMENTS_BAD"; case CKR_NO_EVENT: return "CKR_NO_EVENT"; case CKR_NEED_TO_CREATE_THREADS: return "CKR_NEED_TO_CREATE_THREADS"; case CKR_CANT_LOCK: return "CKR_CANT_LOCK"; case CKR_ATTRIBUTE_READ_ONLY: return "CKR_ATTRIBUTE_READ_ONLY"; case CKR_ATTRIBUTE_SENSITIVE: return "CKR_ATTRIBUTE_SENSITIVE"; case CKR_ATTRIBUTE_TYPE_INVALID: return "CKR_ATTRIBUTE_TYPE_INVALID"; case CKR_ATTRIBUTE_VALUE_INVALID: return "CKR_ATTRIBUTE_VALUE_INVALID"; case CKR_DATA_INVALID: return "CKR_DATA_INVALID"; case CKR_DATA_LEN_RANGE: return "CKR_DATA_LEN_RANGE"; case CKR_DEVICE_ERROR: return "CKR_DEVICE_ERROR"; case CKR_DEVICE_MEMORY: return "CKR_DEVICE_MEMORY"; case CKR_DEVICE_REMOVED: return "CKR_DEVICE_REMOVED"; case CKR_ENCRYPTED_DATA_INVALID: return "CKR_ENCRYPTED_DATA_INVALID"; case CKR_ENCRYPTED_DATA_LEN_RANGE: return "CKR_ENCRYPTED_DATA_LEN_RANGE"; case CKR_FUNCTION_CANCELED: return "CKR_FUNCTION_CANCELED"; case CKR_FUNCTION_NOT_PARALLEL: return "CKR_FUNCTION_NOT_PARALLEL"; case CKR_FUNCTION_NOT_SUPPORTED: return "CKR_FUNCTION_NOT_SUPPORTED"; case CKR_KEY_HANDLE_INVALID: return "CKR_KEY_HANDLE_INVALID"; case CKR_KEY_SIZE_RANGE: return "CKR_KEY_SIZE_RANGE"; case CKR_KEY_TYPE_INCONSISTENT: return "CKR_KEY_TYPE_INCONSISTENT"; case CKR_KEY_NOT_NEEDED: return "CKR_KEY_NOT_NEEDED"; case CKR_KEY_CHANGED: return "CKR_KEY_CHANGED"; case CKR_KEY_NEEDED: return "CKR_KEY_NEEDED"; case CKR_KEY_INDIGESTIBLE: return "CKR_KEY_INDIGESTIBLE"; case CKR_KEY_FUNCTION_NOT_PERMITTED: return "CKR_KEY_FUNCTION_NOT_PERMITTED"; case CKR_KEY_NOT_WRAPPABLE: return "CKR_KEY_NOT_WRAPPABLE"; case CKR_KEY_UNEXTRACTABLE: return "CKR_KEY_UNEXTRACTABLE"; case CKR_MECHANISM_INVALID: return "CKR_MECHANISM_INVALID"; case CKR_MECHANISM_PARAM_INVALID: return "CKR_MECHANISM_PARAM_INVALID"; case CKR_OBJECT_HANDLE_INVALID: return "CKR_OBJECT_HANDLE_INVALID"; case CKR_OPERATION_ACTIVE: return "CKR_OPERATION_ACTIVE"; case CKR_OPERATION_NOT_INITIALIZED: return "CKR_OPERATION_NOT_INITIALIZED"; case CKR_PIN_INCORRECT: return "CKR_PIN_INCORRECT"; case CKR_PIN_INVALID: return "CKR_PIN_INVALID"; case CKR_PIN_LEN_RANGE: return "CKR_PIN_LEN_RANGE"; case CKR_PIN_EXPIRED: return "CKR_PIN_EXPIRED"; case CKR_PIN_LOCKED: return "CKR_PIN_LOCKED"; case CKR_SESSION_CLOSED: return "CKR_SESSION_CLOSED"; case CKR_SESSION_COUNT: return "CKR_SESSION_COUNT"; case CKR_SESSION_HANDLE_INVALID: return "CKR_SESSION_HANDLE_INVALID"; case CKR_SESSION_PARALLEL_NOT_SUPPORTED: return "CKR_SESSION_PARALLEL_NOT_SUPPORTED"; case CKR_SESSION_READ_ONLY: return "CKR_SESSION_READ_ONLY"; case CKR_SESSION_EXISTS: return "CKR_SESSION_EXISTS"; case CKR_SESSION_READ_ONLY_EXISTS: return "CKR_SESSION_READ_ONLY_EXISTS"; case CKR_SESSION_READ_WRITE_SO_EXISTS: return "CKR_SESSION_READ_WRITE_SO_EXISTS"; case CKR_SIGNATURE_INVALID: return "CKR_SIGNATURE_INVALID"; case CKR_SIGNATURE_LEN_RANGE: return "CKR_SIGNATURE_LEN_RANGE"; case CKR_TEMPLATE_INCOMPLETE: return "CKR_TEMPLATE_INCOMPLETE"; case CKR_TEMPLATE_INCONSISTENT: return "CKR_TEMPLATE_INCONSISTENT"; case CKR_TOKEN_NOT_PRESENT: return "CKR_TOKEN_NOT_PRESENT"; case CKR_TOKEN_NOT_RECOGNIZED: return "CKR_TOKEN_NOT_RECOGNIZED"; case CKR_TOKEN_WRITE_PROTECTED: return "CKR_TOKEN_WRITE_PROTECTED"; case CKR_UNWRAPPING_KEY_HANDLE_INVALID: return "CKR_UNWRAPPING_KEY_HANDLE_INVALID"; case CKR_UNWRAPPING_KEY_SIZE_RANGE: return "CKR_UNWRAPPING_KEY_SIZE_RANGE"; case CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT: return "CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT"; case CKR_USER_ALREADY_LOGGED_IN: return "CKR_USER_ALREADY_LOGGED_IN"; case CKR_USER_NOT_LOGGED_IN: return "CKR_USER_NOT_LOGGED_IN"; case CKR_USER_PIN_NOT_INITIALIZED: return "CKR_USER_PIN_NOT_INITIALIZED"; case CKR_USER_TYPE_INVALID: return "CKR_USER_TYPE_INVALID"; case CKR_USER_ANOTHER_ALREADY_LOGGED_IN: return "CKR_USER_ANOTHER_ALREADY_LOGGED_IN"; case CKR_USER_TOO_MANY_TYPES: return "CKR_USER_TOO_MANY_TYPES"; case CKR_WRAPPED_KEY_INVALID: return "CKR_WRAPPED_KEY_INVALID"; case CKR_WRAPPED_KEY_LEN_RANGE: return "CKR_WRAPPED_KEY_LEN_RANGE"; case CKR_WRAPPING_KEY_HANDLE_INVALID: return "CKR_WRAPPING_KEY_HANDLE_INVALID"; case CKR_WRAPPING_KEY_SIZE_RANGE: return "CKR_WRAPPING_KEY_SIZE_RANGE"; case CKR_WRAPPING_KEY_TYPE_INCONSISTENT: return "CKR_WRAPPING_KEY_TYPE_INCONSISTENT"; case CKR_RANDOM_SEED_NOT_SUPPORTED: return "CKR_RANDOM_SEED_NOT_SUPPORTED"; case CKR_RANDOM_NO_RNG: return "CKR_RANDOM_NO_RNG"; case CKR_DOMAIN_PARAMS_INVALID: return "CKR_DOMAIN_PARAMS_INVALID"; case CKR_BUFFER_TOO_SMALL: return "CKR_BUFFER_TOO_SMALL"; case CKR_SAVED_STATE_INVALID: return "CKR_SAVED_STATE_INVALID"; case CKR_INFORMATION_SENSITIVE: return "CKR_INFORMATION_SENSITIVE"; case CKR_STATE_UNSAVEABLE: return "CKR_STATE_UNSAVEABLE"; case CKR_CRYPTOKI_NOT_INITIALIZED: return "CKR_CRYPTOKI_NOT_INITIALIZED"; case CKR_CRYPTOKI_ALREADY_INITIALIZED: return "CKR_CRYPTOKI_ALREADY_INITIALIZED"; case CKR_MUTEX_BAD: return "CKR_MUTEX_BAD"; case CKR_MUTEX_NOT_LOCKED: return "CKR_MUTEX_NOT_LOCKED"; case CKR_FUNCTION_REJECTED: return "CKR_FUNCTION_REJECTED"; case CKR_VENDOR_DEFINED: return "CKR_VENDOR_DEFINED"; default: { char szError[1024]; sprintf (szError, "PKCS#11 Error %08lx", rv); return szError; } } } static std::string Resolve_CK_FLAGS ( IN const CK_FLAGS f ) { std::string r; if ((f&CKF_RNG)!=0) { r += "CKF_RNG,"; } if ((f&CKF_WRITE_PROTECTED)!=0) { r += "CKF_WRITE_PROTECTED,"; } if ((f&CKF_LOGIN_REQUIRED)!=0) { r += "CKF_LOGIN_REQUIRED,"; } if ((f&CKF_USER_PIN_INITIALIZED)!=0) { r += "CKF_USER_PIN_INITIALIZED,"; } if ((f&CKF_RESTORE_KEY_NOT_NEEDED)!=0) { r += "CKF_RESTORE_KEY_NOT_NEEDED,"; } if ((f&CKF_CLOCK_ON_TOKEN)!=0) { r += "CKF_CLOCK_ON_TOKEN,"; } if ((f&CKF_PROTECTED_AUTHENTICATION_PATH)!=0) { r += "CKF_PROTECTED_AUTHENTICATION_PATH,"; } if ((f&CKF_DUAL_CRYPTO_OPERATIONS)!=0) { r += "CKF_DUAL_CRYPTO_OPERATIONS,"; } if ((f&CKF_TOKEN_INITIALIZED)!=0) { r += "CKF_TOKEN_INITIALIZED,"; } if ((f&CKF_SECONDARY_AUTHENTICATION)!=0) { r += "CKF_SECONDARY_AUTHENTICATION,"; } if ((f&CKF_USER_PIN_COUNT_LOW)!=0) { r += "CKF_USER_PIN_COUNT_LOW,"; } if ((f&CKF_USER_PIN_FINAL_TRY)!=0) { r += "CKF_USER_PIN_FINAL_TRY,"; } if ((f&CKF_USER_PIN_LOCKED)!=0) { r += "CKF_USER_PIN_LOCKED,"; } if ((f&CKF_USER_PIN_TO_BE_CHANGED)!=0) { r += "CKF_USER_PIN_TO_BE_CHANGED,"; } if ((f&CKF_SO_PIN_COUNT_LOW)!=0) { r += "CKF_SO_PIN_COUNT_LOW,"; } if ((f&CKF_SO_PIN_FINAL_TRY)!=0) { r += "CKF_SO_PIN_FINAL_TRY,"; } if ((f&CKF_SO_PIN_LOCKED)!=0) { r += "CKF_SO_PIN_LOCKED,"; } if ((f&CKF_SO_PIN_TO_BE_CHANGED)!=0) { r += "CKF_SO_PIN_TO_BE_CHANGED,"; } if (r!="") { r.erase (r.length ()-1); } return r; } static std::string Resolve_CK_CERTIFICATE_TYPE ( IN const CK_CERTIFICATE_TYPE t ) { switch (t) { case CKC_X_509: return "CKC_X_509"; case CKC_X_509_ATTR_CERT: return "CKC_X_509_ATTR_CERT"; case CKC_WTLS: return "CKC_WTLS"; case CKC_VENDOR_DEFINED: return "CKC_VENDOR_DEFINED"; default: { char szError[1024]; sprintf (szError, "Unknown CK_CERTIFICATE_TYPE %08lx", t); return szError; } } } static std::string Resolve_CK_HW_FEATURE_TYPE ( IN const CK_HW_FEATURE_TYPE t ) { switch (t) { case CKH_MONOTONIC_COUNTER: return "CKH_MONOTONIC_COUNTER"; case CKH_CLOCK: return "CKH_CLOCK"; case CKH_USER_INTERFACE: return "CKH_USER_INTERFACE"; case CKH_VENDOR_DEFINED: return "CKH_VENDOR_DEFINED"; default: { char szError[1024]; sprintf (szError, "Unknown CK_HW_FEATURE_TYPE %08lx", t); return szError; } } } static std::string ParseSubject ( IN const void * const p, IN const unsigned s ) { char szSubject[1024]; bool fOK = false; #if defined(_WIN32) CRYPT_DER_BLOB blobSubject = {s, (PBYTE)p}; if ( CertNameToStrA ( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, &blobSubject, CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, szSubject, sizeof (szSubject) ) != 0 ) { fOK = true; } #else X509_NAME *name; name = X509_NAME_new (); if (name != NULL) { pkcs11_openssl_d2i_t pp = (pkcs11_openssl_d2i_t)p; if ( d2i_X509_NAME ( &name, &pp, s ) ) { X509_NAME_oneline ( name, szSubject, sizeof (szSubject) ); fOK = true; } X509_NAME_free (name); } #endif if (fOK) { return szSubject; } else { return "ERROR"; } } static std::string FixedStringToString ( IN const void * const p, IN const unsigned s ) { std::string r; for (unsigned long k=0;kC_Initialize (NULL)) != CKR_OK) { throw CEPKCS11 ("Cannot initialize", rv); } } static void Unload ( IN OUT PKCS11_MODULE_HANDLE &hPKCS11, IN OUT CK_FUNCTION_LIST_PTR &pkcs11 ) { if (pkcs11 != NULL) { pkcs11->C_Finalize (NULL); pkcs11 = NULL; } if (hPKCS11 != NULL) { #if defined(_WIN32) FreeLibrary (hPKCS11); #else dlclose (hPKCS11); #endif hPKCS11 = NULL; } } static void Info ( IN const CK_FUNCTION_LIST_PTR &pkcs11 ) { CK_RV rv; CK_INFO info; if ( (rv = pkcs11->C_GetInfo ( &info )) != CKR_OK ) { throw CEPKCS11 ("C_GetInfo", rv); } printf ( ( "Provider Information:\n" "%30s: %u.%u\n" "%30s: %s\n" "%30s: %08lx\n" ), "cryptokiVersion", info.cryptokiVersion.major, info.cryptokiVersion.minor, "manufacturerID", FixedStringToString (info.manufacturerID, sizeof (info.manufacturerID)).c_str (), "flags", info.flags ); if (info.cryptokiVersion.major >= 2) { printf ( ( "%30s: %u.%u\n" "%30s: %s\n" ), "libraryVersion", info.libraryVersion.major, info.libraryVersion.minor, "libraryDescription", FixedStringToString (info.libraryDescription, sizeof (info.libraryDescription)).c_str () ); } } static void SlotList ( IN const CK_FUNCTION_LIST_PTR &pkcs11 ) { CK_RV rv; CK_SLOT_ID slots[1024]; CK_ULONG slotsnum; if ( (rv = pkcs11->C_GetSlotList ( FALSE, NULL, &slotsnum )) != CKR_OK ) { throw CEPKCS11 ("C_GetSlotList", rv); } if (slotsnum >= sizeof(slots)/sizeof(slots[0])) { throw CEPKCS11 ("C_GetSlotList", CKR_BUFFER_TOO_SMALL); } if ( (rv = pkcs11->C_GetSlotList ( FALSE, slots, &slotsnum )) != CKR_OK ) { throw CEPKCS11 ("C_GetSlotList", rv); } if (slotsnum == 0) { printf ("No slot found\n"); } for (CK_SLOT_ID slot=0;slotC_GetSlotInfo ( slots[slot], &info )) == CKR_OK ) { printf ("%lu\t%s\n", slots[slot], FixedStringToString (info.slotDescription, sizeof (info.slotDescription)).c_str ()); } else { printf ("C_GetSlotInfo failed %08lx\n", rv); } } } static void Dump ( IN const CK_FUNCTION_LIST_PTR &pkcs11, IN const CK_SLOT_ID slotSlot, IN const std::string &strPIN ) { CK_RV rv; CK_SESSION_HANDLE hSession; CK_OBJECT_HANDLE objects[1024]; CK_ULONG objectsmax = sizeof (objects) / sizeof (CK_OBJECT_HANDLE); CK_ULONG objectssize; CK_ULONG i; CK_SLOT_ID slots[1024]; CK_ULONG slotsnum; if ( (rv = pkcs11->C_GetSlotList ( FALSE, NULL, &slotsnum )) != CKR_OK ) { throw CEPKCS11 ("C_GetSlotList", rv); } if (slotsnum >= sizeof(slots)/sizeof(slots[0])) { throw CEPKCS11 ("C_GetSlotList", CKR_BUFFER_TOO_SMALL); } if ( (rv = pkcs11->C_GetSlotList ( FALSE, slots, &slotsnum )) != CKR_OK ) { throw CEPKCS11 ("C_GetSlotList", rv); } if ( (rv=pkcs11->C_OpenSession ( slotSlot, CKF_SERIAL_SESSION, NULL_PTR, NULL_PTR, &hSession )) != CKR_OK ) { throw CEPKCS11 ("C_OpenSession", rv); } CK_TOKEN_INFO info; if ( (rv = pkcs11->C_GetTokenInfo ( slotSlot, &info )) != CKR_OK ) { throw CEPKCS11 ("C_GetTokenInfo", rv); } printf ( ( "Token Information:\n" "%30s: %s\n" "%30s: %s\n" "%30s: %s\n" "%30s: %s\n" "%30s: %s\n" "%30s: %ld\n" "%30s: %ld\n" "%30s: %ld\n" "%30s: %ld\n" "%30s: %ld\n" "%30s: %ld\n" "%30s: %ld\n" "%30s: %ld\n" "%30s: %03d.%03d\n" "%30s: %03d.%03d\n" "%30s: %s\n" ), "label", FixedStringToString (info.label, sizeof (info.label)).c_str (), "manufacturerID", FixedStringToString (info.manufacturerID, sizeof (info.manufacturerID)).c_str (), "model", FixedStringToString (info.model, sizeof (info.model)).c_str (), "serialNumber", FixedStringToString (info.serialNumber, sizeof (info.serialNumber)).c_str (), "flags", Resolve_CK_FLAGS (info.flags).c_str (), "ulMaxSessionCount", info.ulMaxSessionCount, "ulMaxSessionCount", info.ulMaxSessionCount, "ulMaxPinLen", info.ulMaxPinLen, "ulMinPinLen", info.ulMinPinLen, "ulTotalPublicMemory", info.ulTotalPublicMemory, "ulFreePublicMemory", info.ulFreePublicMemory, "ulTotalPrivateMemory", info.ulTotalPrivateMemory, "ulFreePrivateMemory", info.ulFreePrivateMemory, "hardwareVersion", info.hardwareVersion.major, info.hardwareVersion.minor, "firmwareVersion", info.firmwareVersion.major, info.firmwareVersion.minor, "utcTime", FixedStringToString (info.utcTime, sizeof (info.utcTime)).c_str () ); if ( (rv=pkcs11->C_Login ( hSession, CKU_USER, (CK_CHAR_PTR)strPIN.c_str (), (CK_ULONG)strPIN.length () )) != CKR_OK && rv != CKR_USER_ALREADY_LOGGED_IN ) { throw CEPKCS11 ("C_Login", rv); } if ( (rv=pkcs11->C_FindObjectsInit ( hSession, NULL_PTR, 0 )) != CKR_OK ) { throw CEPKCS11 ("C_FindObjectsInit", rv); } if ( (rv=pkcs11->C_FindObjects ( hSession, objects, objectsmax, &objectssize )) != CKR_OK ) { throw CEPKCS11 ("C_FindObjects", rv); } for (i=0;iC_GetObjectSize ( hSession, objects[i], &lObjectSize )) != CKR_OK ) { printf ("%30s: Unknown\n", "Object size"); } else { printf ("%30s: %ld\n", "Object size", lObjectSize); } for (int j=0;attrdescAttributes[j].nId!=-1;j++) { char Buffer[10*1024]; CK_ATTRIBUTE t[] = { {(CK_ATTRIBUTE_TYPE)attrdescAttributes[j].nId, Buffer, sizeof (Buffer)} }; if ( (rv=pkcs11->C_GetAttributeValue ( hSession, objects[i], t, sizeof (t) / sizeof (CK_ATTRIBUTE) )) == CKR_OK ) { printf ("%30s: ", attrdescAttributes[j].szName); switch (attrdescAttributes[j].attrtypeType) { case attrtypeUnknown: printf ("Unknown value type"); break; case attrtypeString: case attrtypeCK_CHAR: case attrtypeCK_DATE: printf ("%s", FixedStringToString (t[0].pValue, t[0].ulValueLen).c_str ()); break; case attrtypeBigInteger: case attrtypeByteArray: printf ("%s", DumpToString (t[0].pValue, t[0].ulValueLen).c_str ()); break; break; case attrtypeSubject: case attrtypeSubject1: printf ("%s\n", ParseSubject (t[0].pValue, t[0].ulValueLen).c_str ()); break; case attrtypeCK_BBOOL: { CK_BBOOL b = *(CK_BBOOL *)t[0].pValue; if (b != CK_FALSE) { printf ("TRUE"); } else { printf ("FALSE"); } } break; case attrtypeCK_ULONG: { CK_ULONG l = *(CK_ULONG *)t[0].pValue; printf ("%ld", l); } break; case attrtypeCK_CERTIFICATE_TYPE: printf ("%s", Resolve_CK_CERTIFICATE_TYPE (*(CK_CERTIFICATE_TYPE *)t[0].pValue).c_str ()); break; case attrtypeCK_KEY_TYPE: printf ("%s", Resolve_CK_KEY_TYPE (*(CK_KEY_TYPE *)t[0].pValue).c_str ()); break; case attrtypeCK_MECHANISM_TYPE: printf ("%s", Resolve_CK_MECHANISM_TYPE (*(CK_MECHANISM_TYPE *)t[0].pValue).c_str ()); break; case attrtypeCK_OBJECT_CLASS: printf ("%s", Resolve_CK_OBJECT_CLASS (*(CK_OBJECT_CLASS *)t[0].pValue).c_str ()); break; case attrtypeCK_HW_FEATURE_TYPE: printf ("%s", Resolve_CK_HW_FEATURE_TYPE (*(CK_HW_FEATURE_TYPE *)t[0].pValue).c_str ()); break; case attrtypeCK_ATTRIBUTE_PTR: printf ("Exists but value not parsed"); break; case attrtypeCK_MECHANISM_TYPE_PTR: printf ("Exists but value not parsed"); break; default: printf ("Unknown type"); break; } printf ("\n"); } } } pkcs11->C_FindObjectsFinal (hSession); pkcs11->C_Logout (hSession); pkcs11->C_CloseSession (hSession); } std::string GetPIN ( IN const std::string &strPIN ) { std::string strR; if (strPIN != "-") { strR = strPIN; } else { #if defined(_WIN32) char c; fprintf (stderr, "Please enter PIN: "); while ((c = getch ()) != '\r') { fputc ('*', stderr); strR += c; } fprintf (stderr, "\n"); #else strR = getpass ("Please enter PIN: "); #endif } return strR; } int main ( const int argc, const char * const argv[] ) { fprintf ( stderr, ( "%s %s - PKI Cryptoki token dump\n" "Written by Alon Bar-Lev\n" "\n" "Copyright (C) 2005-2006 Alon Bar-Lev.\n" "This is free software; see the source for copying conditions.\n" "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" "\n" ), PACKAGE_NAME, PACKAGE_VERSION ); bool fUsageOK = false; bool fOK = false; if (argc > 1) { std::string strCommand = argv[1]; if (strCommand == "info") { if (argc == 3) { std::string strModule = argv[2]; fUsageOK = true; PKCS11_MODULE_HANDLE hPKCS11 = NULL; CK_FUNCTION_LIST_PTR pkcs11 = NULL; try { Load (strModule, hPKCS11, pkcs11); Info (pkcs11); fOK = true; } catch (const CEPKCS11 &e) { fprintf (stderr, "Fatal: %s-%s\n", e.m_str.c_str (), Resolve_CK_RV (e.m_rv).c_str ()); } catch (const CEGeneral &e) { fprintf (stderr, "Fatal: %s\n", e.m_str.c_str ()); } catch (...) { fprintf (stderr, "Unknown error\n"); } Unload (hPKCS11, pkcs11); } } else if (strCommand == "slotlist") { if (argc == 3) { std::string strModule = argv[2]; fUsageOK = true; PKCS11_MODULE_HANDLE hPKCS11 = NULL; CK_FUNCTION_LIST_PTR pkcs11 = NULL; try { Load (strModule, hPKCS11, pkcs11); //while (1) { SlotList (pkcs11); //sleep (1); //} fOK = true; } catch (const CEPKCS11 &e) { fprintf (stderr, "Fatal: %s-%s\n", e.m_str.c_str (), Resolve_CK_RV (e.m_rv).c_str ()); } catch (const CEGeneral &e) { fprintf (stderr, "Fatal: %s\n", e.m_str.c_str ()); } catch (...) { fprintf (stderr, "Unknown error\n"); } Unload (hPKCS11, pkcs11); } } else if (strCommand == "dump") { if (argc == 5) { std::string strModule = argv[2]; CK_SLOT_ID slotSlot = strtoul(argv[3], NULL, 0); std::string strPIN = GetPIN (argv[4]); fUsageOK = true; PKCS11_MODULE_HANDLE hPKCS11 = NULL; CK_FUNCTION_LIST_PTR pkcs11 = NULL; try { Load (strModule, hPKCS11, pkcs11); Dump (pkcs11, slotSlot, strPIN); fOK = true; } catch (const CEPKCS11 &e) { fprintf (stderr, "Fatal: %s-%s\n", e.m_str.c_str (), Resolve_CK_RV (e.m_rv).c_str ()); } catch (const CEGeneral &e) { fprintf (stderr, "Fatal: %s\n", e.m_str.c_str ()); } catch (...) { fprintf (stderr, "Unknown error\n"); } Unload (hPKCS11, pkcs11); } } } if (!fUsageOK) { std::string strModule = argv[0]; size_t n = strModule.find_last_of ('\\'); if (n != std::string::npos) { strModule = strModule.substr (n+1); } fprintf ( stderr, ( "Usage:\n" "%s info module\n" "%s slotlist module\n" "%s dump module slot user_pin|-\n" ), strModule.c_str (), strModule.c_str (), strModule.c_str () ); fOK = false; } if (fOK) { exit (0); } else { exit (1); } return 1; } pkcs11-dump-pkcs11-dump-0.3.5/pkcs11.h000066400000000000000000001216501340524515000171060ustar00rootroot00000000000000/* pkcs11.h Copyright 2006 g10 Code GmbH Copyright 2006 Andreas Jellinghaus This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ /* Please submit changes back to the Scute project at http://www.scute.org/ (or send them to marcus@g10code.com), so that they can be picked up by other projects from there as well. */ /* This file is a modified implementation of the PKCS #11 standard by RSA Security Inc. It is mostly a drop-in replacement, with the following change: This header file does not require any macro definitions by the user (like CK_DEFINE_FUNCTION etc). In fact, it defines those macros for you (if useful, some are missing, let me know if you need more). There is an additional API available that does comply better to the GNU coding standard. It can be switched on by defining CRYPTOKI_GNU before including this header file. For this, the following changes are made to the specification: All structure types are changed to a "struct ck_foo" where CK_FOO is the type name in PKCS #11. All non-structure types are changed to ck_foo_t where CK_FOO is the lowercase version of the type name in PKCS #11. The basic types (CK_ULONG et al.) are removed without substitute. All members of structures are modified in the following way: Type indication prefixes are removed, and underscore characters are inserted before words. Then the result is lowercased. Note that function names are still in the original case, as they need for ABI compatibility. CK_FALSE, CK_TRUE and NULL_PTR are removed without substitute. Use . If CRYPTOKI_COMPAT is defined before including this header file, then none of the API changes above take place, and the API is the one defined by the PKCS #11 standard. */ #ifndef PKCS11_H #define PKCS11_H 1 #if defined(__cplusplus) extern "C" { #endif /* The version of cryptoki we implement. The revision is changed with each modification of this file. If you do not use the "official" version of this file, please consider deleting the revision macro (you may use a macro with a different name to keep track of your versions). */ #define CRYPTOKI_VERSION_MAJOR 2 #define CRYPTOKI_VERSION_MINOR 20 #define CRYPTOKI_VERSION_REVISION 6 /* Compatibility interface is default, unless CRYPTOKI_GNU is given. */ #ifndef CRYPTOKI_GNU #ifndef CRYPTOKI_COMPAT #define CRYPTOKI_COMPAT 1 #endif #endif /* System dependencies. */ #if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32) /* There is a matching pop below. */ #pragma pack(push, cryptoki, 1) #ifdef CRYPTOKI_EXPORTS #define CK_SPEC __declspec(dllexport) #else #define CK_SPEC __declspec(dllimport) #endif #else #define CK_SPEC #endif #ifdef CRYPTOKI_COMPAT /* If we are in compatibility mode, switch all exposed names to the PKCS #11 variant. There are corresponding #undefs below. */ #define ck_flags_t CK_FLAGS #define ck_version _CK_VERSION #define ck_info _CK_INFO #define cryptoki_version cryptokiVersion #define manufacturer_id manufacturerID #define library_description libraryDescription #define library_version libraryVersion #define ck_notification_t CK_NOTIFICATION #define ck_slot_id_t CK_SLOT_ID #define ck_slot_info _CK_SLOT_INFO #define slot_description slotDescription #define hardware_version hardwareVersion #define firmware_version firmwareVersion #define ck_token_info _CK_TOKEN_INFO #define serial_number serialNumber #define max_session_count ulMaxSessionCount #define session_count ulSessionCount #define max_rw_session_count ulMaxRwSessionCount #define rw_session_count ulRwSessionCount #define max_pin_len ulMaxPinLen #define min_pin_len ulMinPinLen #define total_public_memory ulTotalPublicMemory #define free_public_memory ulFreePublicMemory #define total_private_memory ulTotalPrivateMemory #define free_private_memory ulFreePrivateMemory #define utc_time utcTime #define ck_session_handle_t CK_SESSION_HANDLE #define ck_user_type_t CK_USER_TYPE #define ck_state_t CK_STATE #define ck_session_info _CK_SESSION_INFO #define slot_id slotID #define device_error ulDeviceError #define ck_object_handle_t CK_OBJECT_HANDLE #define ck_object_class_t CK_OBJECT_CLASS #define ck_hw_feature_type_t CK_HW_FEATURE_TYPE #define ck_key_type_t CK_KEY_TYPE #define ck_certificate_type_t CK_CERTIFICATE_TYPE #define ck_attribute_type_t CK_ATTRIBUTE_TYPE #define ck_attribute _CK_ATTRIBUTE #define value pValue #define value_len ulValueLen #define ck_date _CK_DATE #define ck_mechanism_type_t CK_MECHANISM_TYPE #define ck_mechanism _CK_MECHANISM #define parameter pParameter #define parameter_len ulParameterLen #define ck_mechanism_info _CK_MECHANISM_INFO #define min_key_size ulMinKeySize #define max_key_size ulMaxKeySize #define ck_rv_t CK_RV #define ck_notify_t CK_NOTIFY #define ck_function_list _CK_FUNCTION_LIST #define ck_createmutex_t CK_CREATEMUTEX #define ck_destroymutex_t CK_DESTROYMUTEX #define ck_lockmutex_t CK_LOCKMUTEX #define ck_unlockmutex_t CK_UNLOCKMUTEX #define ck_c_initialize_args _CK_C_INITIALIZE_ARGS #define create_mutex CreateMutex #define destroy_mutex DestroyMutex #define lock_mutex LockMutex #define unlock_mutex UnlockMutex #define reserved pReserved #endif /* CRYPTOKI_COMPAT */ typedef unsigned long ck_flags_t; struct ck_version { unsigned char major; unsigned char minor; }; struct ck_info { struct ck_version cryptoki_version; unsigned char manufacturer_id[32]; ck_flags_t flags; unsigned char library_description[32]; struct ck_version library_version; }; typedef unsigned long ck_notification_t; #define CKN_SURRENDER (0) typedef unsigned long ck_slot_id_t; struct ck_slot_info { unsigned char slot_description[64]; unsigned char manufacturer_id[32]; ck_flags_t flags; struct ck_version hardware_version; struct ck_version firmware_version; }; #define CKF_TOKEN_PRESENT (1 << 0) #define CKF_REMOVABLE_DEVICE (1 << 1) #define CKF_HW_SLOT (1 << 2) #define CKF_ARRAY_ATTRIBUTE (1 << 30) struct ck_token_info { unsigned char label[32]; unsigned char manufacturer_id[32]; unsigned char model[16]; unsigned char serial_number[16]; ck_flags_t flags; unsigned long max_session_count; unsigned long session_count; unsigned long max_rw_session_count; unsigned long rw_session_count; unsigned long max_pin_len; unsigned long min_pin_len; unsigned long total_public_memory; unsigned long free_public_memory; unsigned long total_private_memory; unsigned long free_private_memory; struct ck_version hardware_version; struct ck_version firmware_version; unsigned char utc_time[16]; }; #define CKF_RNG (1 << 0) #define CKF_WRITE_PROTECTED (1 << 1) #define CKF_LOGIN_REQUIRED (1 << 2) #define CKF_USER_PIN_INITIALIZED (1 << 3) #define CKF_RESTORE_KEY_NOT_NEEDED (1 << 5) #define CKF_CLOCK_ON_TOKEN (1 << 6) #define CKF_PROTECTED_AUTHENTICATION_PATH (1 << 8) #define CKF_DUAL_CRYPTO_OPERATIONS (1 << 9) #define CKF_TOKEN_INITIALIZED (1 << 10) #define CKF_SECONDARY_AUTHENTICATION (1 << 11) #define CKF_USER_PIN_COUNT_LOW (1 << 16) #define CKF_USER_PIN_FINAL_TRY (1 << 17) #define CKF_USER_PIN_LOCKED (1 << 18) #define CKF_USER_PIN_TO_BE_CHANGED (1 << 19) #define CKF_SO_PIN_COUNT_LOW (1 << 20) #define CKF_SO_PIN_FINAL_TRY (1 << 21) #define CKF_SO_PIN_LOCKED (1 << 22) #define CKF_SO_PIN_TO_BE_CHANGED (1 << 23) #define CK_UNAVAILABLE_INFORMATION ((unsigned long) -1) #define CK_EFFECTIVELY_INFINITE (0) typedef unsigned long ck_session_handle_t; #define CK_INVALID_HANDLE (0) typedef unsigned long ck_user_type_t; #define CKU_SO (0) #define CKU_USER (1) #define CKU_CONTEXT_SPECIFIC (2) typedef unsigned long ck_state_t; #define CKS_RO_PUBLIC_SESSION (0) #define CKS_RO_USER_FUNCTIONS (1) #define CKS_RW_PUBLIC_SESSION (2) #define CKS_RW_USER_FUNCTIONS (3) #define CKS_RW_SO_FUNCTIONS (4) struct ck_session_info { ck_slot_id_t slot_id; ck_state_t state; ck_flags_t flags; unsigned long device_error; }; #define CKF_RW_SESSION (1 << 1) #define CKF_SERIAL_SESSION (1 << 2) typedef unsigned long ck_object_handle_t; typedef unsigned long ck_object_class_t; #define CKO_DATA (0) #define CKO_CERTIFICATE (1) #define CKO_PUBLIC_KEY (2) #define CKO_PRIVATE_KEY (3) #define CKO_SECRET_KEY (4) #define CKO_HW_FEATURE (5) #define CKO_DOMAIN_PARAMETERS (6) #define CKO_MECHANISM (7) #define CKO_VENDOR_DEFINED ((unsigned long) (1 << 31)) typedef unsigned long ck_hw_feature_type_t; #define CKH_MONOTONIC_COUNTER (1) #define CKH_CLOCK (2) #define CKH_USER_INTERFACE (3) #define CKH_VENDOR_DEFINED ((unsigned long) (1 << 31)) typedef unsigned long ck_key_type_t; #define CKK_RSA (0) #define CKK_DSA (1) #define CKK_DH (2) #define CKK_ECDSA (3) #define CKK_EC (3) #define CKK_X9_42_DH (4) #define CKK_KEA (5) #define CKK_GENERIC_SECRET (0x10) #define CKK_RC2 (0x11) #define CKK_RC4 (0x12) #define CKK_DES (0x13) #define CKK_DES2 (0x14) #define CKK_DES3 (0x15) #define CKK_CAST (0x16) #define CKK_CAST3 (0x17) #define CKK_CAST128 (0x18) #define CKK_RC5 (0x19) #define CKK_IDEA (0x1a) #define CKK_SKIPJACK (0x1b) #define CKK_BATON (0x1c) #define CKK_JUNIPER (0x1d) #define CKK_CDMF (0x1e) #define CKK_AES (0x1f) #define CKK_BLOWFISH (0x20) #define CKK_TWOFISH (0x21) #define CKK_VENDOR_DEFINED ((unsigned long) (1 << 31)) typedef unsigned long ck_certificate_type_t; #define CKC_X_509 (0) #define CKC_X_509_ATTR_CERT (1) #define CKC_WTLS (2) #define CKC_VENDOR_DEFINED ((unsigned long) (1 << 31)) typedef unsigned long ck_attribute_type_t; #define CKA_CLASS (0) #define CKA_TOKEN (1) #define CKA_PRIVATE (2) #define CKA_LABEL (3) #define CKA_APPLICATION (0x10) #define CKA_VALUE (0x11) #define CKA_OBJECT_ID (0x12) #define CKA_CERTIFICATE_TYPE (0x80) #define CKA_ISSUER (0x81) #define CKA_SERIAL_NUMBER (0x82) #define CKA_AC_ISSUER (0x83) #define CKA_OWNER (0x84) #define CKA_ATTR_TYPES (0x85) #define CKA_TRUSTED (0x86) #define CKA_CERTIFICATE_CATEGORY (0x87) #define CKA_JAVA_MIDP_SECURITY_DOMAIN (0x88) #define CKA_URL (0x89) #define CKA_HASH_OF_SUBJECT_PUBLIC_KEY (0x8a) #define CKA_HASH_OF_ISSUER_PUBLIC_KEY (0x8b) #define CKA_CHECK_VALUE (0x90) #define CKA_KEY_TYPE (0x100) #define CKA_SUBJECT (0x101) #define CKA_ID (0x102) #define CKA_SENSITIVE (0x103) #define CKA_ENCRYPT (0x104) #define CKA_DECRYPT (0x105) #define CKA_WRAP (0x106) #define CKA_UNWRAP (0x107) #define CKA_SIGN (0x108) #define CKA_SIGN_RECOVER (0x109) #define CKA_VERIFY (0x10a) #define CKA_VERIFY_RECOVER (0x10b) #define CKA_DERIVE (0x10c) #define CKA_START_DATE (0x110) #define CKA_END_DATE (0x111) #define CKA_MODULUS (0x120) #define CKA_MODULUS_BITS (0x121) #define CKA_PUBLIC_EXPONENT (0x122) #define CKA_PRIVATE_EXPONENT (0x123) #define CKA_PRIME_1 (0x124) #define CKA_PRIME_2 (0x125) #define CKA_EXPONENT_1 (0x126) #define CKA_EXPONENT_2 (0x127) #define CKA_COEFFICIENT (0x128) #define CKA_PRIME (0x130) #define CKA_SUBPRIME (0x131) #define CKA_BASE (0x132) #define CKA_PRIME_BITS (0x133) #define CKA_SUB_PRIME_BITS (0x134) #define CKA_VALUE_BITS (0x160) #define CKA_VALUE_LEN (0x161) #define CKA_EXTRACTABLE (0x162) #define CKA_LOCAL (0x163) #define CKA_NEVER_EXTRACTABLE (0x164) #define CKA_ALWAYS_SENSITIVE (0x165) #define CKA_KEY_GEN_MECHANISM (0x166) #define CKA_MODIFIABLE (0x170) #define CKA_ECDSA_PARAMS (0x180) #define CKA_EC_PARAMS (0x180) #define CKA_EC_POINT (0x181) #define CKA_SECONDARY_AUTH (0x200) #define CKA_AUTH_PIN_FLAGS (0x201) #define CKA_ALWAYS_AUTHENTICATE (0x202) #define CKA_WRAP_WITH_TRUSTED (0x210) #define CKA_HW_FEATURE_TYPE (0x300) #define CKA_RESET_ON_INIT (0x301) #define CKA_HAS_RESET (0x302) #define CKA_PIXEL_X (0x400) #define CKA_PIXEL_Y (0x401) #define CKA_RESOLUTION (0x402) #define CKA_CHAR_ROWS (0x403) #define CKA_CHAR_COLUMNS (0x404) #define CKA_COLOR (0x405) #define CKA_BITS_PER_PIXEL (0x406) #define CKA_CHAR_SETS (0x480) #define CKA_ENCODING_METHODS (0x481) #define CKA_MIME_TYPES (0x482) #define CKA_MECHANISM_TYPE (0x500) #define CKA_REQUIRED_CMS_ATTRIBUTES (0x501) #define CKA_DEFAULT_CMS_ATTRIBUTES (0x502) #define CKA_SUPPORTED_CMS_ATTRIBUTES (0x503) #define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x211) #define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x212) #define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE | 0x600) #define CKA_VENDOR_DEFINED ((unsigned long) (1 << 31)) struct ck_attribute { ck_attribute_type_t type; void *value; unsigned long value_len; }; struct ck_date { unsigned char year[4]; unsigned char month[2]; unsigned char day[2]; }; typedef unsigned long ck_mechanism_type_t; #define CKM_RSA_PKCS_KEY_PAIR_GEN (0) #define CKM_RSA_PKCS (1) #define CKM_RSA_9796 (2) #define CKM_RSA_X_509 (3) #define CKM_MD2_RSA_PKCS (4) #define CKM_MD5_RSA_PKCS (5) #define CKM_SHA1_RSA_PKCS (6) #define CKM_RIPEMD128_RSA_PKCS (7) #define CKM_RIPEMD160_RSA_PKCS (8) #define CKM_RSA_PKCS_OAEP (9) #define CKM_RSA_X9_31_KEY_PAIR_GEN (0xa) #define CKM_RSA_X9_31 (0xb) #define CKM_SHA1_RSA_X9_31 (0xc) #define CKM_RSA_PKCS_PSS (0xd) #define CKM_SHA1_RSA_PKCS_PSS (0xe) #define CKM_DSA_KEY_PAIR_GEN (0x10) #define CKM_DSA (0x11) #define CKM_DSA_SHA1 (0x12) #define CKM_DH_PKCS_KEY_PAIR_GEN (0x20) #define CKM_DH_PKCS_DERIVE (0x21) #define CKM_X9_42_DH_KEY_PAIR_GEN (0x30) #define CKM_X9_42_DH_DERIVE (0x31) #define CKM_X9_42_DH_HYBRID_DERIVE (0x32) #define CKM_X9_42_MQV_DERIVE (0x33) #define CKM_RC2_KEY_GEN (0x100) #define CKM_RC2_ECB (0x101) #define CKM_RC2_CBC (0x102) #define CKM_RC2_MAC (0x103) #define CKM_RC2_MAC_GENERAL (0x104) #define CKM_RC2_CBC_PAD (0x105) #define CKM_RC4_KEY_GEN (0x110) #define CKM_RC4 (0x111) #define CKM_DES_KEY_GEN (0x120) #define CKM_DES_ECB (0x121) #define CKM_DES_CBC (0x122) #define CKM_DES_MAC (0x123) #define CKM_DES_MAC_GENERAL (0x124) #define CKM_DES_CBC_PAD (0x125) #define CKM_DES2_KEY_GEN (0x130) #define CKM_DES3_KEY_GEN (0x131) #define CKM_DES3_ECB (0x132) #define CKM_DES3_CBC (0x133) #define CKM_DES3_MAC (0x134) #define CKM_DES3_MAC_GENERAL (0x135) #define CKM_DES3_CBC_PAD (0x136) #define CKM_CDMF_KEY_GEN (0x140) #define CKM_CDMF_ECB (0x141) #define CKM_CDMF_CBC (0x142) #define CKM_CDMF_MAC (0x143) #define CKM_CDMF_MAC_GENERAL (0x144) #define CKM_CDMF_CBC_PAD (0x145) #define CKM_MD2 (0x200) #define CKM_MD2_HMAC (0x201) #define CKM_MD2_HMAC_GENERAL (0x202) #define CKM_MD5 (0x210) #define CKM_MD5_HMAC (0x211) #define CKM_MD5_HMAC_GENERAL (0x212) #define CKM_SHA_1 (0x220) #define CKM_SHA_1_HMAC (0x221) #define CKM_SHA_1_HMAC_GENERAL (0x222) #define CKM_RIPEMD128 (0x230) #define CKM_RIPEMD128_HMAC (0x231) #define CKM_RIPEMD128_HMAC_GENERAL (0x232) #define CKM_RIPEMD160 (0x240) #define CKM_RIPEMD160_HMAC (0x241) #define CKM_RIPEMD160_HMAC_GENERAL (0x242) #define CKM_CAST_KEY_GEN (0x300) #define CKM_CAST_ECB (0x301) #define CKM_CAST_CBC (0x302) #define CKM_CAST_MAC (0x303) #define CKM_CAST_MAC_GENERAL (0x304) #define CKM_CAST_CBC_PAD (0x305) #define CKM_CAST3_KEY_GEN (0x310) #define CKM_CAST3_ECB (0x311) #define CKM_CAST3_CBC (0x312) #define CKM_CAST3_MAC (0x313) #define CKM_CAST3_MAC_GENERAL (0x314) #define CKM_CAST3_CBC_PAD (0x315) #define CKM_CAST5_KEY_GEN (0x320) #define CKM_CAST128_KEY_GEN (0x320) #define CKM_CAST5_ECB (0x321) #define CKM_CAST128_ECB (0x321) #define CKM_CAST5_CBC (0x322) #define CKM_CAST128_CBC (0x322) #define CKM_CAST5_MAC (0x323) #define CKM_CAST128_MAC (0x323) #define CKM_CAST5_MAC_GENERAL (0x324) #define CKM_CAST128_MAC_GENERAL (0x324) #define CKM_CAST5_CBC_PAD (0x325) #define CKM_CAST128_CBC_PAD (0x325) #define CKM_RC5_KEY_GEN (0x330) #define CKM_RC5_ECB (0x331) #define CKM_RC5_CBC (0x332) #define CKM_RC5_MAC (0x333) #define CKM_RC5_MAC_GENERAL (0x334) #define CKM_RC5_CBC_PAD (0x335) #define CKM_IDEA_KEY_GEN (0x340) #define CKM_IDEA_ECB (0x341) #define CKM_IDEA_CBC (0x342) #define CKM_IDEA_MAC (0x343) #define CKM_IDEA_MAC_GENERAL (0x344) #define CKM_IDEA_CBC_PAD (0x345) #define CKM_GENERIC_SECRET_KEY_GEN (0x350) #define CKM_CONCATENATE_BASE_AND_KEY (0x360) #define CKM_CONCATENATE_BASE_AND_DATA (0x362) #define CKM_CONCATENATE_DATA_AND_BASE (0x363) #define CKM_XOR_BASE_AND_DATA (0x364) #define CKM_EXTRACT_KEY_FROM_KEY (0x365) #define CKM_SSL3_PRE_MASTER_KEY_GEN (0x370) #define CKM_SSL3_MASTER_KEY_DERIVE (0x371) #define CKM_SSL3_KEY_AND_MAC_DERIVE (0x372) #define CKM_SSL3_MASTER_KEY_DERIVE_DH (0x373) #define CKM_TLS_PRE_MASTER_KEY_GEN (0x374) #define CKM_TLS_MASTER_KEY_DERIVE (0x375) #define CKM_TLS_KEY_AND_MAC_DERIVE (0x376) #define CKM_TLS_MASTER_KEY_DERIVE_DH (0x377) #define CKM_SSL3_MD5_MAC (0x380) #define CKM_SSL3_SHA1_MAC (0x381) #define CKM_MD5_KEY_DERIVATION (0x390) #define CKM_MD2_KEY_DERIVATION (0x391) #define CKM_SHA1_KEY_DERIVATION (0x392) #define CKM_PBE_MD2_DES_CBC (0x3a0) #define CKM_PBE_MD5_DES_CBC (0x3a1) #define CKM_PBE_MD5_CAST_CBC (0x3a2) #define CKM_PBE_MD5_CAST3_CBC (0x3a3) #define CKM_PBE_MD5_CAST5_CBC (0x3a4) #define CKM_PBE_MD5_CAST128_CBC (0x3a4) #define CKM_PBE_SHA1_CAST5_CBC (0x3a5) #define CKM_PBE_SHA1_CAST128_CBC (0x3a5) #define CKM_PBE_SHA1_RC4_128 (0x3a6) #define CKM_PBE_SHA1_RC4_40 (0x3a7) #define CKM_PBE_SHA1_DES3_EDE_CBC (0x3a8) #define CKM_PBE_SHA1_DES2_EDE_CBC (0x3a9) #define CKM_PBE_SHA1_RC2_128_CBC (0x3aa) #define CKM_PBE_SHA1_RC2_40_CBC (0x3ab) #define CKM_PKCS5_PBKD2 (0x3b0) #define CKM_PBA_SHA1_WITH_SHA1_HMAC (0x3c0) #define CKM_KEY_WRAP_LYNKS (0x400) #define CKM_KEY_WRAP_SET_OAEP (0x401) #define CKM_SKIPJACK_KEY_GEN (0x1000) #define CKM_SKIPJACK_ECB64 (0x1001) #define CKM_SKIPJACK_CBC64 (0x1002) #define CKM_SKIPJACK_OFB64 (0x1003) #define CKM_SKIPJACK_CFB64 (0x1004) #define CKM_SKIPJACK_CFB32 (0x1005) #define CKM_SKIPJACK_CFB16 (0x1006) #define CKM_SKIPJACK_CFB8 (0x1007) #define CKM_SKIPJACK_WRAP (0x1008) #define CKM_SKIPJACK_PRIVATE_WRAP (0x1009) #define CKM_SKIPJACK_RELAYX (0x100a) #define CKM_KEA_KEY_PAIR_GEN (0x1010) #define CKM_KEA_KEY_DERIVE (0x1011) #define CKM_FORTEZZA_TIMESTAMP (0x1020) #define CKM_BATON_KEY_GEN (0x1030) #define CKM_BATON_ECB128 (0x1031) #define CKM_BATON_ECB96 (0x1032) #define CKM_BATON_CBC128 (0x1033) #define CKM_BATON_COUNTER (0x1034) #define CKM_BATON_SHUFFLE (0x1035) #define CKM_BATON_WRAP (0x1036) #define CKM_ECDSA_KEY_PAIR_GEN (0x1040) #define CKM_EC_KEY_PAIR_GEN (0x1040) #define CKM_ECDSA (0x1041) #define CKM_ECDSA_SHA1 (0x1042) #define CKM_ECDH1_DERIVE (0x1050) #define CKM_ECDH1_COFACTOR_DERIVE (0x1051) #define CKM_ECMQV_DERIVE (0x1052) #define CKM_JUNIPER_KEY_GEN (0x1060) #define CKM_JUNIPER_ECB128 (0x1061) #define CKM_JUNIPER_CBC128 (0x1062) #define CKM_JUNIPER_COUNTER (0x1063) #define CKM_JUNIPER_SHUFFLE (0x1064) #define CKM_JUNIPER_WRAP (0x1065) #define CKM_FASTHASH (0x1070) #define CKM_AES_KEY_GEN (0x1080) #define CKM_AES_ECB (0x1081) #define CKM_AES_CBC (0x1082) #define CKM_AES_MAC (0x1083) #define CKM_AES_MAC_GENERAL (0x1084) #define CKM_AES_CBC_PAD (0x1085) #define CKM_DSA_PARAMETER_GEN (0x2000) #define CKM_DH_PKCS_PARAMETER_GEN (0x2001) #define CKM_X9_42_DH_PARAMETER_GEN (0x2002) #define CKM_VENDOR_DEFINED ((unsigned long) (1 << 31)) struct ck_mechanism { ck_mechanism_type_t mechanism; void *parameter; unsigned long parameter_len; }; struct ck_mechanism_info { unsigned long min_key_size; unsigned long max_key_size; ck_flags_t flags; }; #define CKF_HW (1 << 0) #define CKF_ENCRYPT (1 << 8) #define CKF_DECRYPT (1 << 9) #define CKF_DIGEST (1 << 10) #define CKF_SIGN (1 << 11) #define CKF_SIGN_RECOVER (1 << 12) #define CKF_VERIFY (1 << 13) #define CKF_VERIFY_RECOVER (1 << 14) #define CKF_GENERATE (1 << 15) #define CKF_GENERATE_KEY_PAIR (1 << 16) #define CKF_WRAP (1 << 17) #define CKF_UNWRAP (1 << 18) #define CKF_DERIVE (1 << 19) #define CKF_EXTENSION ((unsigned long) (1 << 31)) /* Flags for C_WaitForSlotEvent. */ #define CKF_DONT_BLOCK (1) typedef unsigned long ck_rv_t; typedef ck_rv_t (*ck_notify_t) (ck_session_handle_t session, ck_notification_t event, void *application); /* Forward reference. */ struct ck_function_list; #define _CK_DECLARE_FUNCTION(name, args) \ typedef ck_rv_t (*CK_ ## name) args; \ ck_rv_t CK_SPEC name args _CK_DECLARE_FUNCTION (C_Initialize, (void *init_args)); _CK_DECLARE_FUNCTION (C_Finalize, (void *reserved)); _CK_DECLARE_FUNCTION (C_GetInfo, (struct ck_info *info)); _CK_DECLARE_FUNCTION (C_GetFunctionList, (struct ck_function_list **function_list)); _CK_DECLARE_FUNCTION (C_GetSlotList, (unsigned char token_present, ck_slot_id_t *slot_list, unsigned long *count)); _CK_DECLARE_FUNCTION (C_GetSlotInfo, (ck_slot_id_t slot_id, struct ck_slot_info *info)); _CK_DECLARE_FUNCTION (C_GetTokenInfo, (ck_slot_id_t slot_id, struct ck_token_info *info)); _CK_DECLARE_FUNCTION (C_WaitForSlotEvent, (ck_flags_t flags, ck_slot_id_t *slot, void *reserved)); _CK_DECLARE_FUNCTION (C_GetMechanismList, (ck_slot_id_t slot_id, ck_mechanism_type_t *mechanism_list, unsigned long *count)); _CK_DECLARE_FUNCTION (C_GetMechanismInfo, (ck_slot_id_t slot_id, ck_mechanism_type_t type, struct ck_mechanism_info *info)); _CK_DECLARE_FUNCTION (C_InitToken, (ck_slot_id_t slot_id, unsigned char *pin, unsigned long pin_len, unsigned char *label)); _CK_DECLARE_FUNCTION (C_InitPIN, (ck_session_handle_t session, unsigned char *pin, unsigned long pin_len)); _CK_DECLARE_FUNCTION (C_SetPIN, (ck_session_handle_t session, unsigned char *old_pin, unsigned long old_len, unsigned char *new_pin, unsigned long new_len)); _CK_DECLARE_FUNCTION (C_OpenSession, (ck_slot_id_t slot_id, ck_flags_t flags, void *application, ck_notify_t notify, ck_session_handle_t *session)); _CK_DECLARE_FUNCTION (C_CloseSession, (ck_session_handle_t session)); _CK_DECLARE_FUNCTION (C_CloseAllSessions, (ck_slot_id_t slot_id)); _CK_DECLARE_FUNCTION (C_GetSessionInfo, (ck_session_handle_t session, struct ck_session_info *info)); _CK_DECLARE_FUNCTION (C_GetOperationState, (ck_session_handle_t session, unsigned char *operation_state, unsigned long *operation_state_len)); _CK_DECLARE_FUNCTION (C_SetOperationState, (ck_session_handle_t session, unsigned char *operation_state, unsigned long operation_state_len, ck_object_handle_t encryption_key, ck_object_handle_t authentiation_key)); _CK_DECLARE_FUNCTION (C_Login, (ck_session_handle_t session, ck_user_type_t user_type, unsigned char *pin, unsigned long pin_len)); _CK_DECLARE_FUNCTION (C_Logout, (ck_session_handle_t session)); _CK_DECLARE_FUNCTION (C_CreateObject, (ck_session_handle_t session, struct ck_attribute *templ, unsigned long count, ck_object_handle_t *object)); _CK_DECLARE_FUNCTION (C_CopyObject, (ck_session_handle_t session, ck_object_handle_t object, struct ck_attribute *templ, unsigned long count, ck_object_handle_t *new_object)); _CK_DECLARE_FUNCTION (C_DestroyObject, (ck_session_handle_t session, ck_object_handle_t object)); _CK_DECLARE_FUNCTION (C_GetObjectSize, (ck_session_handle_t session, ck_object_handle_t object, unsigned long *size)); _CK_DECLARE_FUNCTION (C_GetAttributeValue, (ck_session_handle_t session, ck_object_handle_t object, struct ck_attribute *templ, unsigned long count)); _CK_DECLARE_FUNCTION (C_SetAttributeValue, (ck_session_handle_t session, ck_object_handle_t object, struct ck_attribute *templ, unsigned long count)); _CK_DECLARE_FUNCTION (C_FindObjectsInit, (ck_session_handle_t session, struct ck_attribute *templ, unsigned long count)); _CK_DECLARE_FUNCTION (C_FindObjects, (ck_session_handle_t session, ck_object_handle_t *object, unsigned long max_object_count, unsigned long *object_count)); _CK_DECLARE_FUNCTION (C_FindObjectsFinal, (ck_session_handle_t session)); _CK_DECLARE_FUNCTION (C_EncryptInit, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t key)); _CK_DECLARE_FUNCTION (C_Encrypt, (ck_session_handle_t session, unsigned char *data, unsigned long data_len, unsigned char *encrypted_data, unsigned long *encrypted_data_len)); _CK_DECLARE_FUNCTION (C_EncryptUpdate, (ck_session_handle_t session, unsigned char *part, unsigned long part_len, unsigned char *encrypted_part, unsigned long *encrypted_part_len)); _CK_DECLARE_FUNCTION (C_EncryptFinal, (ck_session_handle_t session, unsigned char *last_encrypted_part, unsigned long *last_encrypted_part_len)); _CK_DECLARE_FUNCTION (C_DecryptInit, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t key)); _CK_DECLARE_FUNCTION (C_Decrypt, (ck_session_handle_t session, unsigned char *encrypted_data, unsigned long encrypted_data_len, unsigned char *data, unsigned long *data_len)); _CK_DECLARE_FUNCTION (C_DecryptUpdate, (ck_session_handle_t session, unsigned char *encrypted_part, unsigned long encrypted_part_len, unsigned char *part, unsigned long *part_len)); _CK_DECLARE_FUNCTION (C_DecryptFinal, (ck_session_handle_t session, unsigned char *last_part, unsigned long *last_part_len)); _CK_DECLARE_FUNCTION (C_DigestInit, (ck_session_handle_t session, struct ck_mechanism *mechanism)); _CK_DECLARE_FUNCTION (C_Digest, (ck_session_handle_t session, unsigned char *data, unsigned long data_len, unsigned char *digest, unsigned long *digest_len)); _CK_DECLARE_FUNCTION (C_DigestUpdate, (ck_session_handle_t session, unsigned char *part, unsigned long part_len)); _CK_DECLARE_FUNCTION (C_DigestKey, (ck_session_handle_t session, ck_object_handle_t key)); _CK_DECLARE_FUNCTION (C_DigestFinal, (ck_session_handle_t session, unsigned char *digest, unsigned long *digest_len)); _CK_DECLARE_FUNCTION (C_SignInit, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t key)); _CK_DECLARE_FUNCTION (C_Sign, (ck_session_handle_t session, unsigned char *data, unsigned long data_len, unsigned char *signature, unsigned long *signature_len)); _CK_DECLARE_FUNCTION (C_SignUpdate, (ck_session_handle_t session, unsigned char *part, unsigned long part_len)); _CK_DECLARE_FUNCTION (C_SignFinal, (ck_session_handle_t session, unsigned char *signature, unsigned long *signature_len)); _CK_DECLARE_FUNCTION (C_SignRecoverInit, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t key)); _CK_DECLARE_FUNCTION (C_SignRecover, (ck_session_handle_t session, unsigned char *data, unsigned long data_len, unsigned char *signature, unsigned long *signature_len)); _CK_DECLARE_FUNCTION (C_VerifyInit, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t key)); _CK_DECLARE_FUNCTION (C_Verify, (ck_session_handle_t session, unsigned char *data, unsigned long data_len, unsigned char *signature, unsigned long signature_len)); _CK_DECLARE_FUNCTION (C_VerifyUpdate, (ck_session_handle_t session, unsigned char *part, unsigned long part_len)); _CK_DECLARE_FUNCTION (C_VerifyFinal, (ck_session_handle_t session, unsigned char *signature, unsigned long signature_len)); _CK_DECLARE_FUNCTION (C_VerifyRecoverInit, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t key)); _CK_DECLARE_FUNCTION (C_VerifyRecover, (ck_session_handle_t session, unsigned char *signature, unsigned long signature_len, unsigned char *data, unsigned long *data_len)); _CK_DECLARE_FUNCTION (C_DigestEncryptUpdate, (ck_session_handle_t session, unsigned char *part, unsigned long part_len, unsigned char *encrypted_part, unsigned long *encrypted_part_len)); _CK_DECLARE_FUNCTION (C_DecryptDigestUpdate, (ck_session_handle_t session, unsigned char *encrypted_part, unsigned long encrypted_part_len, unsigned char *part, unsigned long *part_len)); _CK_DECLARE_FUNCTION (C_SignEncryptUpdate, (ck_session_handle_t session, unsigned char *part, unsigned long part_len, unsigned char *encrypted_part, unsigned long *encrypted_part_len)); _CK_DECLARE_FUNCTION (C_DecryptVerifyUpdate, (ck_session_handle_t session, unsigned char *encrypted_part, unsigned long encrypted_part_len, unsigned char *part, unsigned long *part_len)); _CK_DECLARE_FUNCTION (C_GenerateKey, (ck_session_handle_t session, struct ck_mechanism *mechanism, struct ck_attribute *templ, unsigned long count, ck_object_handle_t *key)); _CK_DECLARE_FUNCTION (C_GenerateKeyPair, (ck_session_handle_t session, struct ck_mechanism *mechanism, struct ck_attribute *public_key_template, unsigned long public_key_attribute_count, struct ck_attribute *private_key_template, unsigned long private_key_attribute_count, ck_object_handle_t *public_key, ck_object_handle_t *private_key)); _CK_DECLARE_FUNCTION (C_WrapKey, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t wrapping_key, ck_object_handle_t key, unsigned char *wrapped_key, unsigned long *wrapped_key_len)); _CK_DECLARE_FUNCTION (C_UnwrapKey, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t unwrapping_key, unsigned char *wrapped_key, unsigned long wrapped_key_len, struct ck_attribute *templ, unsigned long attribute_count, ck_object_handle_t *key)); _CK_DECLARE_FUNCTION (C_DeriveKey, (ck_session_handle_t session, struct ck_mechanism *mechanism, ck_object_handle_t base_key, struct ck_attribute *templ, unsigned long attribute_count, ck_object_handle_t *key)); _CK_DECLARE_FUNCTION (C_SeedRandom, (ck_session_handle_t session, unsigned char *seed, unsigned long seed_len)); _CK_DECLARE_FUNCTION (C_GenerateRandom, (ck_session_handle_t session, unsigned char *random_data, unsigned long random_len)); _CK_DECLARE_FUNCTION (C_GetFunctionStatus, (ck_session_handle_t session)); _CK_DECLARE_FUNCTION (C_CancelFunction, (ck_session_handle_t session)); struct ck_function_list { struct ck_version version; CK_C_Initialize C_Initialize; CK_C_Finalize C_Finalize; CK_C_GetInfo C_GetInfo; CK_C_GetFunctionList C_GetFunctionList; CK_C_GetSlotList C_GetSlotList; CK_C_GetSlotInfo C_GetSlotInfo; CK_C_GetTokenInfo C_GetTokenInfo; CK_C_GetMechanismList C_GetMechanismList; CK_C_GetMechanismInfo C_GetMechanismInfo; CK_C_InitToken C_InitToken; CK_C_InitPIN C_InitPIN; CK_C_SetPIN C_SetPIN; CK_C_OpenSession C_OpenSession; CK_C_CloseSession C_CloseSession; CK_C_CloseAllSessions C_CloseAllSessions; CK_C_GetSessionInfo C_GetSessionInfo; CK_C_GetOperationState C_GetOperationState; CK_C_SetOperationState C_SetOperationState; CK_C_Login C_Login; CK_C_Logout C_Logout; CK_C_CreateObject C_CreateObject; CK_C_CopyObject C_CopyObject; CK_C_DestroyObject C_DestroyObject; CK_C_GetObjectSize C_GetObjectSize; CK_C_GetAttributeValue C_GetAttributeValue; CK_C_SetAttributeValue C_SetAttributeValue; CK_C_FindObjectsInit C_FindObjectsInit; CK_C_FindObjects C_FindObjects; CK_C_FindObjectsFinal C_FindObjectsFinal; CK_C_EncryptInit C_EncryptInit; CK_C_Encrypt C_Encrypt; CK_C_EncryptUpdate C_EncryptUpdate; CK_C_EncryptFinal C_EncryptFinal; CK_C_DecryptInit C_DecryptInit; CK_C_Decrypt C_Decrypt; CK_C_DecryptUpdate C_DecryptUpdate; CK_C_DecryptFinal C_DecryptFinal; CK_C_DigestInit C_DigestInit; CK_C_Digest C_Digest; CK_C_DigestUpdate C_DigestUpdate; CK_C_DigestKey C_DigestKey; CK_C_DigestFinal C_DigestFinal; CK_C_SignInit C_SignInit; CK_C_Sign C_Sign; CK_C_SignUpdate C_SignUpdate; CK_C_SignFinal C_SignFinal; CK_C_SignRecoverInit C_SignRecoverInit; CK_C_SignRecover C_SignRecover; CK_C_VerifyInit C_VerifyInit; CK_C_Verify C_Verify; CK_C_VerifyUpdate C_VerifyUpdate; CK_C_VerifyFinal C_VerifyFinal; CK_C_VerifyRecoverInit C_VerifyRecoverInit; CK_C_VerifyRecover C_VerifyRecover; CK_C_DigestEncryptUpdate C_DigestEncryptUpdate; CK_C_DecryptDigestUpdate C_DecryptDigestUpdate; CK_C_SignEncryptUpdate C_SignEncryptUpdate; CK_C_DecryptVerifyUpdate C_DecryptVerifyUpdate; CK_C_GenerateKey C_GenerateKey; CK_C_GenerateKeyPair C_GenerateKeyPair; CK_C_WrapKey C_WrapKey; CK_C_UnwrapKey C_UnwrapKey; CK_C_DeriveKey C_DeriveKey; CK_C_SeedRandom C_SeedRandom; CK_C_GenerateRandom C_GenerateRandom; CK_C_GetFunctionStatus C_GetFunctionStatus; CK_C_CancelFunction C_CancelFunction; CK_C_WaitForSlotEvent C_WaitForSlotEvent; }; typedef ck_rv_t (*ck_createmutex_t) (void **mutex); typedef ck_rv_t (*ck_destroymutex_t) (void *mutex); typedef ck_rv_t (*ck_lockmutex_t) (void *mutex); typedef ck_rv_t (*ck_unlockmutex_t) (void *mutex); struct ck_c_initialize_args { ck_createmutex_t create_mutex; ck_destroymutex_t destroy_mutex; ck_lockmutex_t lock_mutex; ck_unlockmutex_t unlock_mutex; ck_flags_t flags; void *reserved; }; #define CKF_LIBRARY_CANT_CREATE_OS_THREADS (1 << 0) #define CKF_OS_LOCKING_OK (1 << 1) #define CKR_OK (0) #define CKR_CANCEL (1) #define CKR_HOST_MEMORY (2) #define CKR_SLOT_ID_INVALID (3) #define CKR_GENERAL_ERROR (5) #define CKR_FUNCTION_FAILED (6) #define CKR_ARGUMENTS_BAD (7) #define CKR_NO_EVENT (8) #define CKR_NEED_TO_CREATE_THREADS (9) #define CKR_CANT_LOCK (0xa) #define CKR_ATTRIBUTE_READ_ONLY (0x10) #define CKR_ATTRIBUTE_SENSITIVE (0x11) #define CKR_ATTRIBUTE_TYPE_INVALID (0x12) #define CKR_ATTRIBUTE_VALUE_INVALID (0x13) #define CKR_DATA_INVALID (0x20) #define CKR_DATA_LEN_RANGE (0x21) #define CKR_DEVICE_ERROR (0x30) #define CKR_DEVICE_MEMORY (0x31) #define CKR_DEVICE_REMOVED (0x32) #define CKR_ENCRYPTED_DATA_INVALID (0x40) #define CKR_ENCRYPTED_DATA_LEN_RANGE (0x41) #define CKR_FUNCTION_CANCELED (0x50) #define CKR_FUNCTION_NOT_PARALLEL (0x51) #define CKR_FUNCTION_NOT_SUPPORTED (0x54) #define CKR_KEY_HANDLE_INVALID (0x60) #define CKR_KEY_SIZE_RANGE (0x62) #define CKR_KEY_TYPE_INCONSISTENT (0x63) #define CKR_KEY_NOT_NEEDED (0x64) #define CKR_KEY_CHANGED (0x65) #define CKR_KEY_NEEDED (0x66) #define CKR_KEY_INDIGESTIBLE (0x67) #define CKR_KEY_FUNCTION_NOT_PERMITTED (0x68) #define CKR_KEY_NOT_WRAPPABLE (0x69) #define CKR_KEY_UNEXTRACTABLE (0x6a) #define CKR_MECHANISM_INVALID (0x70) #define CKR_MECHANISM_PARAM_INVALID (0x71) #define CKR_OBJECT_HANDLE_INVALID (0x82) #define CKR_OPERATION_ACTIVE (0x90) #define CKR_OPERATION_NOT_INITIALIZED (0x91) #define CKR_PIN_INCORRECT (0xa0) #define CKR_PIN_INVALID (0xa1) #define CKR_PIN_LEN_RANGE (0xa2) #define CKR_PIN_EXPIRED (0xa3) #define CKR_PIN_LOCKED (0xa4) #define CKR_SESSION_CLOSED (0xb0) #define CKR_SESSION_COUNT (0xb1) #define CKR_SESSION_HANDLE_INVALID (0xb3) #define CKR_SESSION_PARALLEL_NOT_SUPPORTED (0xb4) #define CKR_SESSION_READ_ONLY (0xb5) #define CKR_SESSION_EXISTS (0xb6) #define CKR_SESSION_READ_ONLY_EXISTS (0xb7) #define CKR_SESSION_READ_WRITE_SO_EXISTS (0xb8) #define CKR_SIGNATURE_INVALID (0xc0) #define CKR_SIGNATURE_LEN_RANGE (0xc1) #define CKR_TEMPLATE_INCOMPLETE (0xd0) #define CKR_TEMPLATE_INCONSISTENT (0xd1) #define CKR_TOKEN_NOT_PRESENT (0xe0) #define CKR_TOKEN_NOT_RECOGNIZED (0xe1) #define CKR_TOKEN_WRITE_PROTECTED (0xe2) #define CKR_UNWRAPPING_KEY_HANDLE_INVALID (0xf0) #define CKR_UNWRAPPING_KEY_SIZE_RANGE (0xf1) #define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT (0xf2) #define CKR_USER_ALREADY_LOGGED_IN (0x100) #define CKR_USER_NOT_LOGGED_IN (0x101) #define CKR_USER_PIN_NOT_INITIALIZED (0x102) #define CKR_USER_TYPE_INVALID (0x103) #define CKR_USER_ANOTHER_ALREADY_LOGGED_IN (0x104) #define CKR_USER_TOO_MANY_TYPES (0x105) #define CKR_WRAPPED_KEY_INVALID (0x110) #define CKR_WRAPPED_KEY_LEN_RANGE (0x112) #define CKR_WRAPPING_KEY_HANDLE_INVALID (0x113) #define CKR_WRAPPING_KEY_SIZE_RANGE (0x114) #define CKR_WRAPPING_KEY_TYPE_INCONSISTENT (0x115) #define CKR_RANDOM_SEED_NOT_SUPPORTED (0x120) #define CKR_RANDOM_NO_RNG (0x121) #define CKR_DOMAIN_PARAMS_INVALID (0x130) #define CKR_BUFFER_TOO_SMALL (0x150) #define CKR_SAVED_STATE_INVALID (0x160) #define CKR_INFORMATION_SENSITIVE (0x170) #define CKR_STATE_UNSAVEABLE (0x180) #define CKR_CRYPTOKI_NOT_INITIALIZED (0x190) #define CKR_CRYPTOKI_ALREADY_INITIALIZED (0x191) #define CKR_MUTEX_BAD (0x1a0) #define CKR_MUTEX_NOT_LOCKED (0x1a1) #define CKR_FUNCTION_REJECTED (0x200) #define CKR_VENDOR_DEFINED ((unsigned long) (1 << 31)) /* Compatibility layer. */ #ifdef CRYPTOKI_COMPAT #undef CK_DEFINE_FUNCTION #define CK_DEFINE_FUNCTION(retval, name) retval CK_SPEC name /* For NULL. */ #include typedef unsigned char CK_BYTE; typedef unsigned char CK_CHAR; typedef unsigned char CK_UTF8CHAR; typedef unsigned char CK_BBOOL; typedef unsigned long int CK_ULONG; typedef long int CK_LONG; typedef CK_BYTE *CK_BYTE_PTR; typedef CK_CHAR *CK_CHAR_PTR; typedef CK_UTF8CHAR *CK_UTF8CHAR_PTR; typedef CK_ULONG *CK_ULONG_PTR; typedef void *CK_VOID_PTR; typedef void **CK_VOID_PTR_PTR; #define CK_FALSE 0 #define CK_TRUE 1 #ifndef CK_DISABLE_TRUE_FALSE #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #endif typedef struct ck_version CK_VERSION; typedef struct ck_version *CK_VERSION_PTR; typedef struct ck_info CK_INFO; typedef struct ck_info *CK_INFO_PTR; typedef ck_slot_id_t *CK_SLOT_ID_PTR; typedef struct ck_slot_info CK_SLOT_INFO; typedef struct ck_slot_info *CK_SLOT_INFO_PTR; typedef struct ck_token_info CK_TOKEN_INFO; typedef struct ck_token_info *CK_TOKEN_INFO_PTR; typedef ck_session_handle_t *CK_SESSION_HANDLE_PTR; typedef struct ck_session_info CK_SESSION_INFO; typedef struct ck_session_info *CK_SESSION_INFO_PTR; typedef ck_object_handle_t *CK_OBJECT_HANDLE_PTR; typedef ck_object_class_t *CK_OBJECT_CLASS_PTR; typedef struct ck_attribute CK_ATTRIBUTE; typedef struct ck_attribute *CK_ATTRIBUTE_PTR; typedef struct ck_date CK_DATE; typedef struct ck_date *CK_DATE_PTR; typedef ck_mechanism_type_t *CK_MECHANISM_TYPE_PTR; typedef struct ck_mechanism CK_MECHANISM; typedef struct ck_mechanism *CK_MECHANISM_PTR; typedef struct ck_mechanism_info CK_MECHANISM_INFO; typedef struct ck_mechanism_info *CK_MECHANISM_INFO_PTR; typedef struct ck_function_list CK_FUNCTION_LIST; typedef struct ck_function_list *CK_FUNCTION_LIST_PTR; typedef struct ck_function_list **CK_FUNCTION_LIST_PTR_PTR; typedef struct ck_c_initialize_args CK_C_INITIALIZE_ARGS; typedef struct ck_c_initialize_args *CK_C_INITIALIZE_ARGS_PTR; #define NULL_PTR NULL /* Delete the helper macros defined at the top of the file. */ #undef ck_flags_t #undef ck_version #undef ck_info #undef cryptoki_version #undef manufacturer_id #undef library_description #undef library_version #undef ck_notification_t #undef ck_slot_id_t #undef ck_slot_info #undef slot_description #undef hardware_version #undef firmware_version #undef ck_token_info #undef serial_number #undef max_session_count #undef session_count #undef max_rw_session_count #undef rw_session_count #undef max_pin_len #undef min_pin_len #undef total_public_memory #undef free_public_memory #undef total_private_memory #undef free_private_memory #undef utc_time #undef ck_session_handle_t #undef ck_user_type_t #undef ck_state_t #undef ck_session_info #undef slot_id #undef device_error #undef ck_object_handle_t #undef ck_object_class_t #undef ck_hw_feature_type_t #undef ck_key_type_t #undef ck_certificate_type_t #undef ck_attribute_type_t #undef ck_attribute #undef value #undef value_len #undef ck_date #undef ck_mechanism_type_t #undef ck_mechanism #undef parameter #undef parameter_len #undef ck_mechanism_info #undef min_key_size #undef max_key_size #undef ck_rv_t #undef ck_notify_t #undef ck_function_list #undef ck_createmutex_t #undef ck_destroymutex_t #undef ck_lockmutex_t #undef ck_unlockmutex_t #undef ck_c_initialize_args #undef create_mutex #undef destroy_mutex #undef lock_mutex #undef unlock_mutex #undef reserved #endif /* CRYPTOKI_COMPAT */ /* System dependencies. */ #if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32) #pragma pack(pop, cryptoki) #endif #if defined(__cplusplus) } #endif #endif /* PKCS11_H */ pkcs11-dump-pkcs11-dump-0.3.5/versioninfo.rc.in000066400000000000000000000024661340524515000211320ustar00rootroot00000000000000/* This file is processed by configure to create versioninfo.rc */ /* Every component changes @@FILE_DESCRIPTION@@ to local string */ #include VS_VERSION_INFO VERSIONINFO FILEVERSION @PKCS11_DUMP_VERSION_MAJOR@,@PKCS11_DUMP_VERSION_MINOR@,@PKCS11_DUMP_VERSION_FIX@,0 PRODUCTVERSION @PKCS11_DUMP_VERSION_MAJOR@,@PKCS11_DUMP_VERSION_MINOR@,@PKCS11_DUMP_VERSION_FIX@,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x21L #else FILEFLAGS 0x20L #endif FILEOS 0x40004L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "Comments", "Provided under the terms of the GNU General Public License (GPLv2.1+).\0" VALUE "CompanyName", "Alon Bar-Lev\0" VALUE "FileDescription", "Dump PKCS#11 contents\0" VALUE "FileVersion", "@PKCS11_DUMP_VERSION_MAJOR@.@PKCS11_DUMP_VERSION_MINOR@.@PKCS11_DUMP_VERSION_FIX@.0\0" VALUE "InternalName", "@PACKAGE_NAME@\0" VALUE "LegalCopyright", "Copyright © 2005-2008 Alon Bar-Lev \0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "@PACKAGE_NAME@.exe\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "@PACKAGE_NAME@\0" VALUE "ProductVersion", "@PKCS11_DUMP_VERSION_MAJOR@,@PKCS11_DUMP_VERSION_MINOR@,@PKCS11_DUMP_VERSION_FIX@,0\0" VALUE "SpecialBuild", "\0" END END END