From fedora-directory-commits at redhat.com Thu Jun 1 19:43:57 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Thu, 1 Jun 2006 12:43:57 -0700 Subject: [Fedora-directory-commits] dsgw - Imported sources Message-ID: <200606011943.k51JhvnJ030391@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/dsgw In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30376 Log Message: Initial import of code from ldapserver, modified to use autoconf for build Status: Vendor Tag: DSGW_INITIAL_IMPORT Release Tags: DSGW_INITIAL_IMPORT_0_01 N dsgw/install-sh N dsgw/Makefile.in N dsgw/dosearch.c N dsgw/search.c N dsgw/aclocal.m4 N dsgw/dsgw-httpd.conf.in N dsgw/lang.c N dsgw/setup.in N dsgw/entrydisplay.c N dsgw/dsgwutil.c N dsgw/sort.c N dsgw/domodify.c N dsgw/dsgwi18n.h N dsgw/README N dsgw/dbtdsgw.h N dsgw/build_RHATdsgwx_pkg N dsgw/dnedit.c N dsgw/config.h.in N dsgw/dsgw.spec.template N dsgw/AUTHORS N dsgw/ldaputil.c N dsgw/build_RHATdsgw_pkg N dsgw/getopt.c N dsgw/unauth.c N dsgw/configure.ac N dsgw/build_dsgw_rpm N dsgw/config-h.in N dsgw/ckput.c N dsgw/secglue.c N dsgw/depcomp N dsgw/propmaker.c N dsgw/ldif.h N dsgw/collate.c N dsgw/ChangeLog N dsgw/LICENSE N dsgw/config.c N dsgw/htmlout.c N dsgw/missing N dsgw/dsgw.h N dsgw/newentry.c N dsgw/fileurl.h N dsgw/cookie.c N dsgw/dsgwgetlang.c N dsgw/auth.c N dsgw/tutor.c N dsgw/doauth.c N dsgw/vcard.c N dsgw/genrb_wrapper.sh N dsgw/NEWS N dsgw/Versiongw.c N dsgw/ckget.c N dsgw/htmlparse.c N dsgw/Makefile.am N dsgw/ckdel.c N dsgw/ckdump.c N dsgw/edit.c N dsgw/utf8compare.c N dsgw/line64.c N dsgw/error.c N dsgw/configure N dsgw/csearch.c N dsgw/emitauth.c N dsgw/emitf.c N dsgw/ckpurge.c N dsgw/fileurl.c N dsgw/cgiutil.c N dsgw/config/display-ntgroup.html N dsgw/config/display-orgperson.html N dsgw/config/display-ntperson.html N dsgw/config/list-fa-People.html N dsgw/config/list-Organizations.html N dsgw/config/list-Domaincomponent.html N dsgw/config/csearchMatch.html N dsgw/config/list-Org-Units.html N dsgw/config/dsgwfilter_adm.conf N dsgw/config/dsgwsearchprefs.conf N dsgw/config/authSearch.html N dsgw/config/dsgwfilter.conf N dsgw/config/display-org.html N dsgw/config/display-groupun.html N dsgw/config/csearch.html N dsgw/config/list-NT-Groups.html N dsgw/config/edit-passwd.html N dsgw/config/display-group.html N dsgw/config/display-dnedit.html N dsgw/config/newentryType.html N dsgw/config/list-Groups.html N dsgw/config/list-urlsearch.html N dsgw/config/search.html N dsgw/config/display-country.html N dsgw/config/list-People.html N dsgw/config/dsgw_adm.conf N dsgw/config/newentry.html N dsgw/config/display-person.html N dsgw/config/list-NT-People.html N dsgw/config/csearchAttr.html N dsgw/config/ns-license-schema.conf N dsgw/config/csearchBase.html N dsgw/config/dsgw.tmpl N dsgw/config/csearchType.html N dsgw/config/display-orgunit.html N dsgw/config/display-dneditpeople.html N dsgw/config/list-Anything.html N dsgw/config/newentryName.html N dsgw/config/csearchString.html N dsgw/config/list-Auth.html N dsgw/config/list-fa-Groups.html N dsgw/config/display-dc.html N dsgw/config/authPassword.html N dsgw/config/searchString.html N dsgw/config/dsgw-l10n.conf N dsgw/config/zh/dsgwcharset.conf N dsgw/config/zh/dsgw-l10n.conf N dsgw/config/en/dsgwcollate.conf N dsgw/config/en/dsgw-l10n.conf N dsgw/config/fr/display-ntgroup.html N dsgw/config/fr/display-orgperson.html N dsgw/config/fr/display-ntperson.html N dsgw/config/fr/list-fa-People.html N dsgw/config/fr/list-Organizations.html N dsgw/config/fr/list-Org-Units.html N dsgw/config/fr/dsgwfilter_adm.conf N dsgw/config/fr/dsgwsearchprefs.conf N dsgw/config/fr/authSearch.html N dsgw/config/fr/dsgwfilter.conf N dsgw/config/fr/display-org.html N dsgw/config/fr/display-groupun.html N dsgw/config/fr/csearch.html N dsgw/config/fr/list-NT-Groups.html N dsgw/config/fr/edit-passwd.html N dsgw/config/fr/display-group.html N dsgw/config/fr/display-dnedit.html N dsgw/config/fr/newentryType.html N dsgw/config/fr/list-Groups.html N dsgw/config/fr/list-urlsearch.html N dsgw/config/fr/display-mailgroup.html N dsgw/config/fr/search.html N dsgw/config/fr/display-umperson.html N dsgw/config/fr/display-country.html N dsgw/config/fr/list-People.html N dsgw/config/fr/dsgw_adm.conf N dsgw/config/fr/newentry.html N dsgw/config/fr/display-person.html N dsgw/config/fr/list-NT-People.html N dsgw/config/fr/csearchAttr.html N dsgw/config/fr/csearchBase.html N dsgw/config/fr/dsgw.conf N dsgw/config/fr/dsgw.tmpl N dsgw/config/fr/csearchType.html N dsgw/config/fr/display-orgunit.html N dsgw/config/fr/display-dneditpeople.html N dsgw/config/fr/list-Anything.html N dsgw/config/fr/newentryName.html N dsgw/config/fr/csearchString.html N dsgw/config/fr/list-Auth.html N dsgw/config/fr/list-fa-Groups.html N dsgw/config/fr/authPassword.html N dsgw/config/fr/searchString.html N dsgw/config/fr/dsgw-l10n.conf N dsgw/config/en-us/dsgwcollate.conf N dsgw/config/en-us/dsgw-l10n.conf N dsgw/config/es/display-ntgroup.html N dsgw/config/es/display-orgperson.html N dsgw/config/es/display-ntperson.html N dsgw/config/es/list-fa-People.html N dsgw/config/es/list-Organizations.html N dsgw/config/es/list-Org-Units.html N dsgw/config/es/dsgwfilter_adm.conf N dsgw/config/es/dsgwsearchprefs.conf N dsgw/config/es/authSearch.html N dsgw/config/es/dsgwfilter.conf N dsgw/config/es/display-org.html N dsgw/config/es/display-groupun.html N dsgw/config/es/csearch.html N dsgw/config/es/list-NT-Groups.html N dsgw/config/es/edit-passwd.html N dsgw/config/es/display-group.html N dsgw/config/es/display-dnedit.html N dsgw/config/es/newentryType.html N dsgw/config/es/list-Groups.html N dsgw/config/es/list-urlsearch.html N dsgw/config/es/search.html N dsgw/config/es/display-country.html N dsgw/config/es/list-People.html N dsgw/config/es/dsgw_adm.conf N dsgw/config/es/newentry.html N dsgw/config/es/display-person.html N dsgw/config/es/list-NT-People.html N dsgw/config/es/csearchAttr.html N dsgw/config/es/ns-license-schema.conf N dsgw/config/es/csearchBase.html N dsgw/config/es/dsgw.tmpl N dsgw/config/es/csearchType.html N dsgw/config/es/display-orgunit.html N dsgw/config/es/display-dneditpeople.html N dsgw/config/es/list-Anything.html N dsgw/config/es/newentryName.html N dsgw/config/es/csearchString.html N dsgw/config/es/list-Auth.html N dsgw/config/es/list-fa-Groups.html N dsgw/config/es/authPassword.html N dsgw/config/es/searchString.html N dsgw/config/es/dsgw-l10n.conf N dsgw/config/ko/dsgwcharset.conf N dsgw/config/ko/dsgw-l10n.conf N dsgw/config/ja/display-ntgroup.html N dsgw/config/ja/display-orgperson.html N dsgw/config/ja/display-ntperson.html N dsgw/config/ja/list-fa-People.html N dsgw/config/ja/list-Organizations.html N dsgw/config/ja/dsgwcollate.conf N dsgw/config/ja/list-Org-Units.html N dsgw/config/ja/dsgwfilter_adm.conf N dsgw/config/ja/dsgwsearchprefs.conf N dsgw/config/ja/dsgwcharset.conf N dsgw/config/ja/authSearch.html N dsgw/config/ja/dsgwfilter.conf N dsgw/config/ja/display-org.html N dsgw/config/ja/display-groupun.html N dsgw/config/ja/csearch.html N dsgw/config/ja/list-NT-Groups.html N dsgw/config/ja/edit-passwd.html N dsgw/config/ja/display-group.html N dsgw/config/ja/display-dnedit.html N dsgw/config/ja/newentryType.html N dsgw/config/ja/list-Groups.html N dsgw/config/ja/list-urlsearch.html N dsgw/config/ja/display-mailgroup.html N dsgw/config/ja/search.html N dsgw/config/ja/display-umperson.html N dsgw/config/ja/display-country.html N dsgw/config/ja/list-People.html N dsgw/config/ja/dsgw_adm.conf N dsgw/config/ja/newentry.html N dsgw/config/ja/display-person.html N dsgw/config/ja/list-NT-People.html N dsgw/config/ja/csearchAttr.html N dsgw/config/ja/csearchBase.html N dsgw/config/ja/dsgw.conf N dsgw/config/ja/dsgw.tmpl N dsgw/config/ja/csearchType.html N dsgw/config/ja/display-orgunit.html N dsgw/config/ja/display-dneditpeople.html N dsgw/config/ja/list-Anything.html N dsgw/config/ja/newentryName.html N dsgw/config/ja/csearchString.html N dsgw/config/ja/list-Auth.html N dsgw/config/ja/list-fa-Groups.html N dsgw/config/ja/authPassword.html N dsgw/config/ja/searchString.html N dsgw/config/ja/dsgw-l10n.conf N dsgw/config/de/display-ntgroup.html N dsgw/config/de/display-orgperson.html N dsgw/config/de/display-ntperson.html N dsgw/config/de/list-fa-People.html N dsgw/config/de/list-Organizations.html N dsgw/config/de/list-Org-Units.html N dsgw/config/de/dsgwfilter_adm.conf N dsgw/config/de/dsgwsearchprefs.conf N dsgw/config/de/authSearch.html N dsgw/config/de/dsgwfilter.conf N dsgw/config/de/display-org.html N dsgw/config/de/display-groupun.html N dsgw/config/de/list-NT-Groups.html N dsgw/config/de/edit-passwd.html N dsgw/config/de/display-group.html N dsgw/config/de/display-dnedit.html N dsgw/config/de/newentryType.html N dsgw/config/de/list-Groups.html N dsgw/config/de/list-urlsearch.html N dsgw/config/de/display-mailgroup.html N dsgw/config/de/search.html N dsgw/config/de/display-umperson.html N dsgw/config/de/display-country.html N dsgw/config/de/list-People.html N dsgw/config/de/dsgw_adm.conf N dsgw/config/de/newentry.html N dsgw/config/de/display-person.html N dsgw/config/de/list-NT-People.html N dsgw/config/de/csearchAttr.html N dsgw/config/de/csearchBase.html N dsgw/config/de/dsgw.conf N dsgw/config/de/dsgw.tmpl N dsgw/config/de/csearchType.html N dsgw/config/de/display-orgunit.html N dsgw/config/de/display-dneditpeople.html N dsgw/config/de/list-Anything.html N dsgw/config/de/newentryName.html N dsgw/config/de/csearchString.html N dsgw/config/de/list-Auth.html N dsgw/config/de/list-fa-Groups.html N dsgw/config/de/authPassword.html N dsgw/config/de/searchString.html N dsgw/config/de/dsgw-l10n.conf N dsgw/m4/nss.m4 N dsgw/m4/icu.m4 N dsgw/m4/httpd.m4 N dsgw/m4/mozldap.m4 N dsgw/m4/nspr.m4 N dsgw/m4/adminutil.m4 N dsgw/pbconfig/display-orgperson.html N dsgw/pbconfig/dsgwsearchprefs.conf N dsgw/pbconfig/display-room.html N dsgw/pbconfig/authSearch.html N dsgw/pbconfig/dsgwfilter.conf N dsgw/pbconfig/edit-passwd.html N dsgw/pbconfig/list-People.html N dsgw/pbconfig/pb.tmpl N dsgw/pbconfig/display-orgunit.html N dsgw/pbconfig/list-Auth.html N dsgw/pbconfig/authPassword.html N dsgw/pbhtml/get_cert.gif N dsgw/pbhtml/phone.js N dsgw/pbhtml/16-person.gif N dsgw/pbhtml/clear.gif N dsgw/pbhtml/view_vcard_sm.gif N dsgw/pbhtml/conference.gif N dsgw/pbhtml/report.html N dsgw/pbhtml/aim-online.gif N dsgw/pbhtml/vendor.gif N dsgw/pbhtml/index.html N dsgw/pbhtml/confirm.html N dsgw/pbhtml/pbrd.jpg N dsgw/pbhtml/rolodex.gif N dsgw/pbhtml/32-conference.gif N dsgw/pbhtml/32-message.gif N dsgw/pbhtml/carded.html N dsgw/pbhtml/office.gif N dsgw/pbhtml/32-office.gif N dsgw/pbhtml/modify.html N dsgw/pbhtml/32-person.gif N dsgw/pbhtml/view_vcard.gif N dsgw/pbhtml/tiny_vcard.gif N dsgw/pbhtml/intro.html N dsgw/pbhtml/32-alert.gif N dsgw/pbhtml/16-conference.gif N dsgw/pbhtml/department.gif N dsgw/pbhtml/person.gif N dsgw/pbhtml/style.css N dsgw/pbhtml/orgicon.gif N dsgw/pbhtml/emptyFrame.html N dsgw/pbhtml/nonemp.html N dsgw/pbhtml/alert.html N dsgw/pbhtml/nullStringError.html N dsgw/pbhtml/get_cert_sm.gif N dsgw/pbhtml/pixel.gif N dsgw/pbhtml/phone.html N dsgw/pbhtml/tiny_cert.gif N dsgw/html/confirm.gif N dsgw/html/content1.gif N dsgw/html/left_off.gif N dsgw/html/country.gif N dsgw/html/exit1.gif N dsgw/html/back1.gif N dsgw/html/eduser.html N dsgw/html/right_off.gif N dsgw/html/authroot.html N dsgw/html/left_bottom.gif N dsgw/html/maintitle.html N dsgw/html/searchtitle.html N dsgw/html/clear.gif N dsgw/html/organization.gif N dsgw/html/aim-online.gif N dsgw/html/index.html N dsgw/html/group.gif N dsgw/html/confirm.html N dsgw/html/csearchtitle.html N dsgw/html/rolodex.gif N dsgw/html/newentrytitle.html N dsgw/html/orgunit.gif N dsgw/html/forward1.gif N dsgw/html/right_bottom.gif N dsgw/html/right_on.gif N dsgw/html/index1.gif N dsgw/html/greeting.html N dsgw/html/dc.gif N dsgw/html/person.gif N dsgw/html/authtitle.html N dsgw/html/style.css N dsgw/html/orgicon.gif N dsgw/html/emptyFrame.html N dsgw/html/transparent.gif N dsgw/html/alert.html N dsgw/html/auth.html N dsgw/html/alert.gif N dsgw/html/message.gif N dsgw/html/left_on.gif N dsgw/html/fr/content1.gif N dsgw/html/fr/back.gif N dsgw/html/fr/exit1.gif N dsgw/html/fr/back1.gif N dsgw/html/fr/adsearch_off.gif N dsgw/html/fr/eduser.html N dsgw/html/fr/adsearch_on.gif N dsgw/html/fr/authroot.html N dsgw/html/fr/maintitle.html N dsgw/html/fr/searchtitle.html N dsgw/html/fr/stsearch_off.gif N dsgw/html/fr/title.gif N dsgw/html/fr/index.html N dsgw/html/fr/csearchtitle.html N dsgw/html/fr/newentrytitle.html N dsgw/html/fr/forward1.gif N dsgw/html/fr/authen_on.gif N dsgw/html/fr/newentry_on.gif N dsgw/html/fr/index1.gif N dsgw/html/fr/greeting.html N dsgw/html/fr/content.gif N dsgw/html/fr/authtitle.html N dsgw/html/fr/stsearch_on.gif N dsgw/html/fr/auth.html N dsgw/html/fr/newentry_off.gif N dsgw/html/fr/authen_off.gif N dsgw/html/es/content1.gif N dsgw/html/es/country.gif N dsgw/html/es/exit1.gif N dsgw/html/es/back1.gif N dsgw/html/es/adsearch_off.gif N dsgw/html/es/eduser.html N dsgw/html/es/adsearch_on.gif N dsgw/html/es/authroot.html N dsgw/html/es/maintitle.html N dsgw/html/es/searchtitle.html N dsgw/html/es/stsearch_off.gif N dsgw/html/es/organization.gif N dsgw/html/es/title.gif N dsgw/html/es/index.html N dsgw/html/es/group.gif N dsgw/html/es/csearchtitle.html N dsgw/html/es/blank.gif N dsgw/html/es/newentrytitle.html N dsgw/html/es/orgunit.gif N dsgw/html/es/forward1.gif N dsgw/html/es/authen_on.gif N dsgw/html/es/newentry_on.gif N dsgw/html/es/index1.gif N dsgw/html/es/greeting.html N dsgw/html/es/person.gif N dsgw/html/es/authtitle.html N dsgw/html/es/stsearch_on.gif N dsgw/html/es/auth.html N dsgw/html/es/newentry_off.gif N dsgw/html/es/authen_off.gif N dsgw/html/ja/content1.gif N dsgw/html/ja/back.gif N dsgw/html/ja/exit1.gif N dsgw/html/ja/back1.gif N dsgw/html/ja/adsearch_off.gif N dsgw/html/ja/eduser.html N dsgw/html/ja/adsearch_on.gif N dsgw/html/ja/authroot.html N dsgw/html/ja/maintitle.html N dsgw/html/ja/searchtitle.html N dsgw/html/ja/stsearch_off.gif N dsgw/html/ja/title.gif N dsgw/html/ja/index.html N dsgw/html/ja/csearchtitle.html N dsgw/html/ja/newentrytitle.html N dsgw/html/ja/forward1.gif N dsgw/html/ja/authen_on.gif N dsgw/html/ja/newentry_on.gif N dsgw/html/ja/index1.gif N dsgw/html/ja/greeting.html N dsgw/html/ja/content.gif N dsgw/html/ja/authtitle.html N dsgw/html/ja/stsearch_on.gif N dsgw/html/ja/auth.html N dsgw/html/ja/newentry_off.gif N dsgw/html/ja/authen_off.gif N dsgw/html/de/content1.gif N dsgw/html/de/back.gif N dsgw/html/de/exit1.gif N dsgw/html/de/back1.gif N dsgw/html/de/adsearch_off.gif N dsgw/html/de/eduser.html N dsgw/html/de/adsearch_on.gif N dsgw/html/de/authroot.html N dsgw/html/de/maintitle.html N dsgw/html/de/searchtitle.html N dsgw/html/de/stsearch_off.gif N dsgw/html/de/title.gif N dsgw/html/de/index.html N dsgw/html/de/csearchtitle.html N dsgw/html/de/newentrytitle.html N dsgw/html/de/forward1.gif N dsgw/html/de/authen_on.gif N dsgw/html/de/newentry_on.gif N dsgw/html/de/index1.gif N dsgw/html/de/greeting.html N dsgw/html/de/content.gif N dsgw/html/de/authtitle.html N dsgw/html/de/stsearch_on.gif N dsgw/html/de/auth.html N dsgw/html/de/newentry_off.gif N dsgw/html/de/authen_off.gif No conflicts created by this import From fedora-directory-commits at redhat.com Fri Jun 2 15:39:09 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 08:39:09 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console build.properties, 1.12, NONE build.xml, 1.2, NONE javarules.mk, 1.6, NONE rules.mk, 1.5, NONE Message-ID: <200606021539.k52Fd9Bv002627@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/adminserver/admserv/console In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2575/adminserver/admserv/console Removed Files: build.properties build.xml javarules.mk rules.mk Log Message: admin server console has been moved to top level admservconsole --- build.properties DELETED --- --- build.xml DELETED --- --- javarules.mk DELETED --- --- rules.mk DELETED --- From fedora-directory-commits at redhat.com Fri Jun 2 15:39:11 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 08:39:11 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console/src/com/netscape/management/admserv/config ActionMonitorPanel.java, 1.3, NONE BaseConfigPanel.java, 1.3, NONE ButtonBar.java, 1.3, NONE ConfigErrorDialog.java, 1.3, NONE ConfigInfoDialog.java, 1.3, NONE ConfigPanelException.java, 1.3, NONE EditMonitor.java, 1.3, NONE FilteredInputDocument.java, 1.3, NONE GBC.java, 1.3, NONE IConfigDataModel.java, 1.3, NONE IPluginConfigPanel.java, 1.3, NONE PluginConfigPanel.java, 1.3, NONE RemoteRequestException.java, 1.3, NONE TabbedConfigPanel.java, 1.3, NONE ValidationException.java, 1.3, NONE config.properties, 1.3, NONE Message-ID: <200606021539.k52FdBLj002670@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/adminserver/admserv/console/src/com/netscape/management/admserv/config In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2575/adminserver/admserv/console/src/com/netscape/management/admserv/config Removed Files: ActionMonitorPanel.java BaseConfigPanel.java ButtonBar.java ConfigErrorDialog.java ConfigInfoDialog.java ConfigPanelException.java EditMonitor.java FilteredInputDocument.java GBC.java IConfigDataModel.java IPluginConfigPanel.java PluginConfigPanel.java RemoteRequestException.java TabbedConfigPanel.java ValidationException.java config.properties Log Message: admin server console has been moved to top level admservconsole --- ActionMonitorPanel.java DELETED --- --- BaseConfigPanel.java DELETED --- --- ButtonBar.java DELETED --- --- ConfigErrorDialog.java DELETED --- --- ConfigInfoDialog.java DELETED --- --- ConfigPanelException.java DELETED --- --- EditMonitor.java DELETED --- --- FilteredInputDocument.java DELETED --- --- GBC.java DELETED --- --- IConfigDataModel.java DELETED --- --- IPluginConfigPanel.java DELETED --- --- PluginConfigPanel.java DELETED --- --- RemoteRequestException.java DELETED --- --- TabbedConfigPanel.java DELETED --- --- ValidationException.java DELETED --- --- config.properties DELETED --- From fedora-directory-commits at redhat.com Fri Jun 2 15:39:11 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 08:39:11 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console/src/com/netscape/management/admserv/images AdminServer.gif, 1.1.1.1, NONE AdminServerL.gif, 1.1.1.1, NONE admin.gif, 1.4, NONE admin50.gif, 1.1.1.1, NONE Message-ID: <200606021539.k52FdBhc002676@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/adminserver/admserv/console/src/com/netscape/management/admserv/images In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2575/adminserver/admserv/console/src/com/netscape/management/admserv/images Removed Files: AdminServer.gif AdminServerL.gif admin.gif admin50.gif Log Message: admin server console has been moved to top level admservconsole From fedora-directory-commits at redhat.com Fri Jun 2 15:39:12 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 08:39:12 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console/src/com/netscape/management/admserv/logging AccessLogViewerModel.java, 1.3, NONE ErrorLogViewerModel.java, 1.3, NONE Message-ID: <200606021539.k52FdC9T002681@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/adminserver/admserv/console/src/com/netscape/management/admserv/logging In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2575/adminserver/admserv/console/src/com/netscape/management/admserv/logging Removed Files: AccessLogViewerModel.java ErrorLogViewerModel.java Log Message: admin server console has been moved to top level admservconsole --- AccessLogViewerModel.java DELETED --- --- ErrorLogViewerModel.java DELETED --- From fedora-directory-commits at redhat.com Fri Jun 2 15:39:09 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 08:39:09 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console/src/com/netscape/management/admserv AdminFrameworkInitializer.java, 1.4, NONE AdminResourceModel.java, 1.4, NONE AdminServer.java, 1.4, NONE AdminServerNode.java, 1.3, NONE AdminServerProduct.java, 1.5, NONE LoggingNode.java, 1.3, NONE SNMPNode.java, 1.3, NONE admserv.properties, 1.6, NONE classes.env, 1.6, NONE Message-ID: <200606021539.k52Fd9hZ002643@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/adminserver/admserv/console/src/com/netscape/management/admserv In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2575/adminserver/admserv/console/src/com/netscape/management/admserv Removed Files: AdminFrameworkInitializer.java AdminResourceModel.java AdminServer.java AdminServerNode.java AdminServerProduct.java LoggingNode.java SNMPNode.java admserv.properties classes.env Log Message: admin server console has been moved to top level admservconsole --- AdminFrameworkInitializer.java DELETED --- --- AdminResourceModel.java DELETED --- --- AdminServer.java DELETED --- --- AdminServerNode.java DELETED --- --- AdminServerProduct.java DELETED --- --- LoggingNode.java DELETED --- --- SNMPNode.java DELETED --- --- admserv.properties DELETED --- --- classes.env DELETED --- From fedora-directory-commits at redhat.com Fri Jun 2 15:39:13 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 08:39:13 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console/src/com/netscape/management/admserv/panel AccessConfigPanel.java, 1.3, NONE AdminConfigData.java, 1.3, NONE AdminConfigPanel.java, 1.3, NONE AdminOperation.java, 1.3, NONE AttrNames.java, 1.3, NONE CGIAccessSetup.java, 1.3, NONE CGIAggregateDataModel.java, 1.3, NONE CGIDataModel.java, 1.3, NONE CGIDirectorySetup.java, 1.3, NONE CGILoggingSetup.java, 1.3, NONE CGISNMPSetup.java, 1.3, NONE CGIServerSetup.java, 1.3, NONE CGIUGDirectorySetup.java, 1.3, NONE DialogFrame.java, 1.3, NONE DirectoryConfigPanel.java, 1.3, NONE EditableList.java, 1.3, NONE IAdminOperationListener.java, 1.3, NONE IRestartControl.java, 1.3, NONE LoggingConfigPanel.java, 1.3, NONE NetworkConfigPanel.java, 1.3, NONE RestartOperation.java, 1.3, NONE SNMPCommunityPanel.java, 1.3, NONE SNMPConfigPanel.java, 1.3, NONE SNMPManagerPanel.java, 1.3, NONE SNMPStatusPanel.java, 1.3, NONE StopOperation.java, 1.3, NONE TurnOnSSL.java, 1.3, NONE UGDirectoryConfigPanel.java, 1.4, NONE panel.properties, 1.4, NONE Message-ID: <200606021539.k52FdDXd002686@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/adminserver/admserv/console/src/com/netscape/management/admserv/panel In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2575/adminserver/admserv/console/src/com/netscape/management/admserv/panel Removed Files: AccessConfigPanel.java AdminConfigData.java AdminConfigPanel.java AdminOperation.java AttrNames.java CGIAccessSetup.java CGIAggregateDataModel.java CGIDataModel.java CGIDirectorySetup.java CGILoggingSetup.java CGISNMPSetup.java CGIServerSetup.java CGIUGDirectorySetup.java DialogFrame.java DirectoryConfigPanel.java EditableList.java IAdminOperationListener.java IRestartControl.java LoggingConfigPanel.java NetworkConfigPanel.java RestartOperation.java SNMPCommunityPanel.java SNMPConfigPanel.java SNMPManagerPanel.java SNMPStatusPanel.java StopOperation.java TurnOnSSL.java UGDirectoryConfigPanel.java panel.properties Log Message: admin server console has been moved to top level admservconsole --- AccessConfigPanel.java DELETED --- --- AdminConfigData.java DELETED --- --- AdminConfigPanel.java DELETED --- --- AdminOperation.java DELETED --- --- AttrNames.java DELETED --- --- CGIAccessSetup.java DELETED --- --- CGIAggregateDataModel.java DELETED --- --- CGIDataModel.java DELETED --- --- CGIDirectorySetup.java DELETED --- --- CGILoggingSetup.java DELETED --- --- CGISNMPSetup.java DELETED --- --- CGIServerSetup.java DELETED --- --- CGIUGDirectorySetup.java DELETED --- --- DialogFrame.java DELETED --- --- DirectoryConfigPanel.java DELETED --- --- EditableList.java DELETED --- --- IAdminOperationListener.java DELETED --- --- IRestartControl.java DELETED --- --- LoggingConfigPanel.java DELETED --- --- NetworkConfigPanel.java DELETED --- --- RestartOperation.java DELETED --- --- SNMPCommunityPanel.java DELETED --- --- SNMPConfigPanel.java DELETED --- --- SNMPManagerPanel.java DELETED --- --- SNMPStatusPanel.java DELETED --- --- StopOperation.java DELETED --- --- TurnOnSSL.java DELETED --- --- UGDirectoryConfigPanel.java DELETED --- --- panel.properties DELETED --- From fedora-directory-commits at redhat.com Fri Jun 2 15:39:18 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 08:39:18 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console/src/com/netscape/management/admserv/task AdminTaskObject.java, 1.3, NONE CertSetup.java, 1.3, NONE Logging.java, 1.3, NONE Restart.java, 1.3, NONE SNMPSetup.java, 1.3, NONE ServerSetup.java, 1.3, NONE Stop.java, 1.3, NONE Message-ID: <200606021539.k52FdIqG002700@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/adminserver/admserv/console/src/com/netscape/management/admserv/task In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2575/adminserver/admserv/console/src/com/netscape/management/admserv/task Removed Files: AdminTaskObject.java CertSetup.java Logging.java Restart.java SNMPSetup.java ServerSetup.java Stop.java Log Message: admin server console has been moved to top level admservconsole --- AdminTaskObject.java DELETED --- --- CertSetup.java DELETED --- --- Logging.java DELETED --- --- Restart.java DELETED --- --- SNMPSetup.java DELETED --- --- ServerSetup.java DELETED --- --- Stop.java DELETED --- From fedora-directory-commits at redhat.com Fri Jun 2 15:39:10 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 08:39:10 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console/src/com/netscape/management/admserv/cmdln AdmpwTask.java, 1.3, NONE CommandLine.java, 1.3, NONE CountLogEntriesTask.java, 1.3, NONE ViewLogEntriesTask.java, 1.3, NONE admconfig.dat, 1.1.1.1, NONE sample-nt-options, 1.1.1.1, NONE sample-unix-options, 1.1.1.1, NONE version.dat, 1.2, NONE Message-ID: <200606021539.k52FdA9Y002657@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/adminserver/admserv/console/src/com/netscape/management/admserv/cmdln In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2575/adminserver/admserv/console/src/com/netscape/management/admserv/cmdln Removed Files: AdmpwTask.java CommandLine.java CountLogEntriesTask.java ViewLogEntriesTask.java admconfig.dat sample-nt-options sample-unix-options version.dat Log Message: admin server console has been moved to top level admservconsole --- AdmpwTask.java DELETED --- --- CommandLine.java DELETED --- --- CountLogEntriesTask.java DELETED --- --- ViewLogEntriesTask.java DELETED --- --- admconfig.dat DELETED --- --- sample-nt-options DELETED --- --- sample-unix-options DELETED --- --- version.dat DELETED --- From fedora-directory-commits at redhat.com Fri Jun 2 22:57:20 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 15:57:20 -0700 Subject: [Fedora-directory-commits] dsgw Makefile.am, 1.1.1.1, 1.2 Makefile.in, 1.1.1.1, 1.2 README, 1.1.1.1, 1.2 configure, 1.1.1.1, 1.2 configure.ac, 1.1.1.1, 1.2 dsgw-httpd.conf.in, 1.1.1.1, 1.2 setup.in, 1.1.1.1, 1.2 Message-ID: <200606022257.k52MvK97022547@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/dsgw In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22509 Modified Files: Makefile.am Makefile.in README configure configure.ac dsgw-httpd.conf.in setup.in Log Message: cleaned up build and setup scripts Index: Makefile.am =================================================================== RCS file: /cvs/dirsec/dsgw/Makefile.am,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Makefile.am 1 Jun 2006 19:43:39 -0000 1.1.1.1 +++ Makefile.am 2 Jun 2006 22:57:17 -0000 1.2 @@ -146,12 +146,13 @@ pbconfig/display-room.html \ pbconfig/dsgwfilter.conf pbconfig/pb.tmpl -nodist_context_DATA = setup +nodist_context_DATA = dsgw-httpd.conf +nodist_context_SCRIPTS = setup # add more here for localized bundles nodist_property_DATA = dsgw_root.res -MOSTLYCLEANFILES = dsgw.conf dsgw_root.res dsgw.properties +MOSTLYCLEANFILES = dsgw.conf dsgw_root.res dsgw.properties setup dsgw-httpd.conf # Resource Bundle Compiler if WINNT Index: Makefile.in =================================================================== RCS file: /cvs/dirsec/dsgw/Makefile.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Makefile.in 1 Jun 2006 19:43:47 -0000 1.1.1.1 +++ Makefile.in 2 Jun 2006 22:57:17 -0000 1.2 @@ -35,6 +35,7 @@ # END COPYRIGHT BLOCK + srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -64,9 +65,9 @@ DIST_COMMON = README $(am__configure_deps) $(dist_config_DATA) \ $(dist_html_DATA) $(dist_pbconfig_DATA) $(dist_pbhtml_DATA) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/config-h.in $(srcdir)/setup.in \ - $(top_srcdir)/configure AUTHORS ChangeLog NEWS depcomp \ - install-sh missing + $(srcdir)/config-h.in $(srcdir)/dsgw-httpd.conf.in \ + $(srcdir)/setup.in $(top_srcdir)/configure AUTHORS ChangeLog \ + NEWS depcomp install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/httpd.m4 \ $(top_srcdir)/m4/nspr.m4 $(top_srcdir)/m4/nss.m4 \ @@ -78,13 +79,13 @@ configure.lineno configure.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = setup +CONFIG_CLEAN_FILES = setup dsgw-httpd.conf am__EXEEXT_1 = unauth$(EXEEXT) search$(EXEEXT) csearch$(EXEEXT) \ newentry$(EXEEXT) tutor$(EXEEXT) lang$(EXEEXT) -am__installdirs = "$(DESTDIR)$(cgibindir)" "$(DESTDIR)$(configdir)" \ - "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(pbconfigdir)" \ - "$(DESTDIR)$(pbhtmldir)" "$(DESTDIR)$(contextdir)" \ - "$(DESTDIR)$(propertydir)" +am__installdirs = "$(DESTDIR)$(cgibindir)" "$(DESTDIR)$(contextdir)" \ + "$(DESTDIR)$(configdir)" "$(DESTDIR)$(htmldir)" \ + "$(DESTDIR)$(pbconfigdir)" "$(DESTDIR)$(pbhtmldir)" \ + "$(DESTDIR)$(contextdir)" "$(DESTDIR)$(propertydir)" cgibinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(cgibin_PROGRAMS) $(noinst_PROGRAMS) am__auth_SOURCES_DIST = auth.c htmlout.c htmlparse.c error.c cgiutil.c \ @@ -185,6 +186,8 @@ secglue.$(OBJEXT) unauth_OBJECTS = $(am_unauth_OBJECTS) unauth_LDADD = $(LDADD) +nodist_contextSCRIPT_INSTALL = $(INSTALL_SCRIPT) +SCRIPTS = $(nodist_context_SCRIPTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I. depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -297,6 +300,7 @@ bindir = @bindir@ build_alias = @build_alias@ cgibindir = @cgibindir@ +cgiuri = @cgiuri@ # config is a bit of a misnomer - these are really configurable templates configdir = @configdir@ # the context dir is where the application specific config files go @@ -306,6 +310,7 @@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ +httpdconf = @httpdconf@ icu_bin = @icu_bin@ icu_inc = @icu_inc@ icu_lib = @icu_lib@ @@ -435,11 +440,12 @@ pbconfig/display-room.html \ pbconfig/dsgwfilter.conf pbconfig/pb.tmpl -nodist_context_DATA = setup +nodist_context_DATA = dsgw-httpd.conf +nodist_context_SCRIPTS = setup # add more here for localized bundles nodist_property_DATA = dsgw_root.res -MOSTLYCLEANFILES = dsgw.conf dsgw_root.res dsgw.properties +MOSTLYCLEANFILES = dsgw.conf dsgw_root.res dsgw.properties setup dsgw-httpd.conf @WINNT_FALSE at ICU_GENRB = sh genrb_wrapper.sh @icu_bin@ @icu_lib@ # Resource Bundle Compiler @@ -512,6 +518,8 @@ -rm -f config.h stamp-h1 setup: $(top_builddir)/config.status $(srcdir)/setup.in cd $(top_builddir) && $(SHELL) ./config.status $@ +dsgw-httpd.conf: $(top_builddir)/config.status $(srcdir)/dsgw-httpd.conf.in + cd $(top_builddir) && $(SHELL) ./config.status $@ install-cgibinPROGRAMS: $(cgibin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(cgibindir)" || $(mkdir_p) "$(DESTDIR)$(cgibindir)" @@ -577,6 +585,25 @@ unauth$(EXEEXT): $(unauth_OBJECTS) $(unauth_DEPENDENCIES) @rm -f unauth$(EXEEXT) $(LINK) $(unauth_LDFLAGS) $(unauth_OBJECTS) $(unauth_LDADD) $(LIBS) +install-nodist_contextSCRIPTS: $(nodist_context_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(contextdir)" || $(mkdir_p) "$(DESTDIR)$(contextdir)" + @list='$(nodist_context_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(nodist_contextSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(contextdir)/$$f'"; \ + $(nodist_contextSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(contextdir)/$$f"; \ + else :; fi; \ + done + +uninstall-nodist_contextSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_context_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f '$(DESTDIR)$(contextdir)/$$f'"; \ + rm -f "$(DESTDIR)$(contextdir)/$$f"; \ + done mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -911,9 +938,9 @@ exit 1; } >&2 check-am: all-am check: check-am -all-am: Makefile $(PROGRAMS) $(DATA) config.h +all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(DATA) config.h installdirs: - for dir in "$(DESTDIR)$(cgibindir)" "$(DESTDIR)$(configdir)" "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(pbconfigdir)" "$(DESTDIR)$(pbhtmldir)" "$(DESTDIR)$(contextdir)" "$(DESTDIR)$(propertydir)"; do \ + for dir in "$(DESTDIR)$(cgibindir)" "$(DESTDIR)$(contextdir)" "$(DESTDIR)$(configdir)" "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(pbconfigdir)" "$(DESTDIR)$(pbhtmldir)" "$(DESTDIR)$(contextdir)" "$(DESTDIR)$(propertydir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-am @@ -966,7 +993,7 @@ install-data-am: install-cgibinPROGRAMS install-dist_configDATA \ install-dist_htmlDATA install-dist_pbconfigDATA \ install-dist_pbhtmlDATA install-nodist_contextDATA \ - install-nodist_propertyDATA + install-nodist_contextSCRIPTS install-nodist_propertyDATA install-exec-am: @@ -998,7 +1025,8 @@ uninstall-am: uninstall-cgibinPROGRAMS uninstall-dist_configDATA \ uninstall-dist_htmlDATA uninstall-dist_pbconfigDATA \ uninstall-dist_pbhtmlDATA uninstall-info-am \ - uninstall-nodist_contextDATA uninstall-nodist_propertyDATA + uninstall-nodist_contextDATA uninstall-nodist_contextSCRIPTS \ + uninstall-nodist_propertyDATA .PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ clean-cgibinPROGRAMS clean-generic clean-noinstPROGRAMS ctags \ @@ -1010,15 +1038,16 @@ install-data-am install-dist_configDATA install-dist_htmlDATA \ install-dist_pbconfigDATA install-dist_pbhtmlDATA install-exec \ install-exec-am install-info install-info-am install-man \ - install-nodist_contextDATA install-nodist_propertyDATA \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-cgibinPROGRAMS \ + install-nodist_contextDATA install-nodist_contextSCRIPTS \ + install-nodist_propertyDATA install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-cgibinPROGRAMS \ uninstall-dist_configDATA uninstall-dist_htmlDATA \ uninstall-dist_pbconfigDATA uninstall-dist_pbhtmlDATA \ uninstall-info-am uninstall-nodist_contextDATA \ - uninstall-nodist_propertyDATA + uninstall-nodist_contextSCRIPTS uninstall-nodist_propertyDATA # By default create only the default root bundle (english). Index: README =================================================================== RCS file: /cvs/dirsec/dsgw/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- README 1 Jun 2006 19:43:40 -0000 1.1.1.1 +++ README 2 Jun 2006 22:57:17 -0000 1.2 @@ -3,18 +3,52 @@ * Building - standard autotools - Do not edit configure or Makefile or Makefile.in - Instead, change Makefile.am or configure.ac, then run autoreconf -fvi - do not attempt to run aclocal or automake or autoconf - only use autoreconf -fvi - this - also applies to the files in m4/ + also applies to the files in m4/, that is, if you modify them, you must run + autoreconf -fvi + +* configure - DSGW requires NSPR, NSS, Mozilla LDAP C SDK, ICU, and AdminUtil - these + can be specified to configure (e.g.--with-nspr=/path), or configure will attempt + to find these components on the OS using pkg-config or icu-config + You can also specify --with-admserv=/path/to/admserv to make a DSGW package that + is compatible with the Admin Server (e.g. installs in clients/dsgw). * Build process 0. Properties are in dbtdsgw.h - this file is used to generate the resource bundles - and is also used in the source code to refer to the resource key + and is also used in the source code to refer to the property by its key 1. build propmaker 2. use propmaker to parse dbtdsgw.h and generate dsgw.properties 3. use genrb_wrapper.sh to "compile" dsgw.properties into dsgw_root.res 4. build the executable CGI programs 5. For a make install, copy the files to their desired directories - if you just want to see how the files with be laid out in the file system, use - make DESTDIR=built/ install # create destination directory structure under built/ + make DESTDIR=built install # create destination directory structure under built/ OR - make DESTDIR=/tmp/dsgwbuild/ # create dest dir under /tmp/dsgwbuild/ + make DESTDIR=/tmp/dsgwbuild # create dest dir under /tmp/dsgwbuild/ rpmbuild will typically do something like the latter + +* Setup +1. The configure/make process creates a shell script called setup which is + installed in the configdir (e.g. clients/dsgw/context or /etc/dsgw). This + should be run after installation (e.g. after rpm -i) and must be supplied + with the LDAP server host, port, suffix (for user entries) and directory + manager DN. You can also use a .inf file (in setuputil format) in silent + mode, so that you could do an install of directory server like this: + setup -k + then use that install.inf to setup dsgw like so: + rpm -i dsgw-1.1-..... + cd /etc/dsgw + ./setup -s -f /opt/fedora-ds/setup/install.inf + +2. The old Admin Server had the DSGW (Directory Server Express and + Directory Server Gateway) hard coded in start-console.html - we now replace + this during setup - the file has this information commented out - during + setup, if we find that file, we uncomment out the relevant sections and + change the URL appropriately (e.g. replace @cgiuri@ with the real one) + +3. We need to add some information to the httpd.conf file - to enable cgi-bin + execution, provide access to our HTML pages, and to set the environment + variable pointing to the config directory - The config directory will + usually be set during build/packaging, but can be overridden by SetEnv - + The setup process will copy the file dsgw-httpd.conf into the Apache + config directory (e.g. /etc/httpd/conf) and change httpd.conf to Include + the file Index: configure =================================================================== RCS file: /cvs/dirsec/dsgw/configure,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- configure 1 Jun 2006 19:43:42 -0000 1.1.1.1 +++ configure 2 Jun 2006 22:57:17 -0000 1.2 @@ -311,7 +311,7 @@ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBOBJS POW_LIB HTTPD PKG_CONFIG ICU_CONFIG nspr_inc nspr_lib nss_inc nss_lib ldapsdk_inc ldapsdk_lib adminutil_inc adminutil_lib adminutil_ver icu_lib icu_inc icu_bin cgibindir propertydir htmldir pbhtmldir configdir pbconfigdir contextdir! securitydir cookiedir NEED_LDIF_TRUE NEED_LDIF_FALSE WINNT_TRUE WINNT_FALSE LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBOBJS POW_LIB HTTPD PKG_CONFIG ICU_CONFIG nspr_inc nspr_lib nss_inc nss_lib ldapsdk_inc ldapsdk_lib adminutil_inc adminutil_lib adminutil_ver icu_lib icu_inc icu_bin cgibindir cgiuri propertydir htmldir pbhtmldir configdir pbconfigdir con! textdir securitydir cookiedir httpdconf NEED_LDIF_TRUE NEED_LDIF_FALSE WINNT_TRUE WINNT_FALSE LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -6023,6 +6023,7 @@ manualuri="/manual" cgiuri="/clients/dsgw/bin/" cookiedir="$basedir/cookies" + httpdconf="$withval/admin-serv/config/admserv.conf" else echo { { echo "$as_me:$LINENO: error: $withval not found" >&5 @@ -6087,27 +6088,27 @@ httpd_conf_rel=`$HTTPD -V | grep SERVER_CONFIG_FILE | cut -f2 -d=` httpd_conf_rel=`eval echo $httpd_conf_rel` - httpd_conf=${httpd_root}/${httpd_conf_rel} + httpdconf=${httpd_root}/${httpd_conf_rel} - htmlbasedir=`grep \^DocumentRoot $httpd_conf|awk '{print $2}'` + htmlbasedir=`grep \^DocumentRoot $httpdconf|awk '{print $2}'` htmlbasedir=`eval echo $htmlbasedir` # these directories are html based htmldir="$htmlbasedir/dsgw/html" pbhtmldir="$htmlbasedir/dsgw/pbhtml" configdir="$htmlbasedir/dsgw/config" pbconfigdir="$htmlbasedir/dsgw/pbconfig" - manualuri="/dirsvr/manual" + manualuri="/dsgw/manual" # CGI program directory - cgibindir=`grep '^ScriptAlias.*/cgi-bin/' $httpd_conf|awk '{print $3}'` + cgibindir=`grep '^ScriptAlias.*/cgi-bin/' $httpdconf|awk '{print $3}'` cgibindir=`eval echo $cgibindir` - cgiuri=`grep '^ScriptAlias.*/cgi-bin/' $httpd_conf|awk '{print $2}'` + cgiuri=`grep '^ScriptAlias.*/cgi-bin/' $httpdconf|awk '{print $2}'` # configuration files and etc. - contextdir=/etc/dsgw + contextdir=$sysconfdir/dsgw propertydir=$contextdir securitydir=$contextdir - cookiedir=/var/run/dsgw/cookies + cookiedir=$localstatedir/run/dsgw/cookies fi @@ -6922,6 +6923,8 @@ + + # need a check here to see if the ldif functions are exported from libldap # for now, just assume they are not @@ -6947,7 +6950,7 @@ fi - ac_config_files="$ac_config_files Makefile setup" + ac_config_files="$ac_config_files Makefile setup dsgw-httpd.conf" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -7514,6 +7517,7 @@ # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "setup" ) CONFIG_FILES="$CONFIG_FILES setup" ;; + "dsgw-httpd.conf" ) CONFIG_FILES="$CONFIG_FILES dsgw-httpd.conf" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config-h.in" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 @@ -7659,6 +7663,7 @@ s, at icu_inc@,$icu_inc,;t t s, at icu_bin@,$icu_bin,;t t s, at cgibindir@,$cgibindir,;t t +s, at cgiuri@,$cgiuri,;t t s, at propertydir@,$propertydir,;t t s, at htmldir@,$htmldir,;t t s, at pbhtmldir@,$pbhtmldir,;t t @@ -7667,6 +7672,7 @@ s, at contextdir@,$contextdir,;t t s, at securitydir@,$securitydir,;t t s, at cookiedir@,$cookiedir,;t t +s, at httpdconf@,$httpdconf,;t t s, at NEED_LDIF_TRUE@,$NEED_LDIF_TRUE,;t t s, at NEED_LDIF_FALSE@,$NEED_LDIF_FALSE,;t t s, at WINNT_TRUE@,$WINNT_TRUE,;t t Index: configure.ac =================================================================== RCS file: /cvs/dirsec/dsgw/configure.ac,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- configure.ac 1 Jun 2006 19:43:45 -0000 1.1.1.1 +++ configure.ac 2 Jun 2006 22:57:17 -0000 1.2 @@ -96,6 +96,7 @@ # write out paths for data/config files AC_SUBST(cgibindir) +AC_SUBST(cgiuri) AC_SUBST(propertydir) AC_SUBST(htmldir) AC_SUBST(pbhtmldir) @@ -104,6 +105,7 @@ AC_SUBST(contextdir) AC_SUBST(securitydir) AC_SUBST(cookiedir) +AC_SUBST(httpdconf) # need a check here to see if the ldif functions are exported from libldap # for now, just assume they are not @@ -112,5 +114,5 @@ # cygnus, mingw, or the like and using cmd.exe as the shell AM_CONDITIONAL([WINNT], false) -AC_CONFIG_FILES([Makefile setup]) +AC_CONFIG_FILES([Makefile setup dsgw-httpd.conf]) AC_OUTPUT Index: dsgw-httpd.conf.in =================================================================== RCS file: /cvs/dirsec/dsgw/dsgw-httpd.conf.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- dsgw-httpd.conf.in 1 Jun 2006 19:43:42 -0000 1.1.1.1 +++ dsgw-httpd.conf.in 2 Jun 2006 22:57:17 -0000 1.2 @@ -16,14 +16,19 @@ # END COPYRIGHT BLOCK # # This file is the Apache config file that can be dropped into -# the /etc/httpd/conf.d directory to enable the dsgw. It uses ScriptAlias to -# enable incoming requests for CGIs in @cgiurl@ to execute CGIs in @cgibindir@ -# It then uses access control to allow clients to access files in the html -# directory @htmldir@, the html template directory @configdir@, and the -# CGI bin directory @cgibindir@ +# the /etc/httpd/conf.d directory, or Include'd by httpd.conf, to enable the +# dsgw. It uses ScriptAlias to enable incoming requests for CGIs in @cgiurl@ +# to execute CGIs in @cgibindir at . It then uses access control to allow clients +# to access files in the html directory @htmldir@, the html template directory +# @configdir@, and the CGI bin directory @cgibindir@ +# Tell CGI progs where to find the config files +SetEnv DSGW_CONTEXT_DIR "@contextdir@" + +# Enable CGI execution for these uris in this directory ScriptAlias @cgiuri@ "@cgibindir@" +# Allow access to the dsgw html files AllowOverride None Options None @@ -31,6 +36,15 @@ Allow from all +# Allow access to the pb html files + + AllowOverride None + Options None + Order allow,deny + Allow from all + + +# Allow access to the dsgw html templates AllowOverride None Options None @@ -38,6 +52,15 @@ Allow from all +# Allow access to the pb html templates + + AllowOverride None + Options None + Order allow,deny + Allow from all + + +# Allow access to the cgi programs AllowOverride None Options None Index: setup.in =================================================================== RCS file: /cvs/dirsec/dsgw/setup.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- setup.in 1 Jun 2006 19:43:44 -0000 1.1.1.1 +++ setup.in 2 Jun 2006 22:57:17 -0000 1.2 @@ -113,7 +113,7 @@ getValFromInf() { cattr=$1 cfile=$2 - rval=`grep -i ^$cattr $cfile | head -1 | sed -e 's/^.*=[ ]*//'` + rval=`grep -i ^$cattr $cfile | head -1 | sed -e "s/^$cattr[ ]*=[ ]*//"` echo $rval } @@ -240,20 +240,35 @@ fi # generate dsgw.conf and pb.conf and default.conf in the @contextdir@ directory -sed -e "s, at host@,$hostname,g" \ - -e "s, at port@,$port,g" \ - -e "s, at suffix@,$suffix,g" \ - -e "s, at dirmgr@,$dirmgr,g" \ - -e "s,\@contextdir\@, at contextdir@,g" \ +sed -e "s#@host@#$hostname#g" \ + -e "s#@port@#$port#g" \ + -e "s#@suffix@#$suffix#g" \ + -e "s#@dirmgr@#$dirmgr#g" \ + -e "s#\@contextdir\@#@contextdir@#g" \ @configdir@/dsgw.tmpl > @contextdir@/dsgw.conf -sed -e "s, at host@,$hostname,g" \ - -e "s, at port@,$port,g" \ - -e "s, at suffix@,$suffix,g" \ - -e "s, at dirmgr@,$dirmgr,g" \ - -e "s,\@contextdir\@, at contextdir@,g" \ +sed -e "s#@host@#$hostname#g" \ + -e "s#@port@#$port#g" \ + -e "s#@suffix@#$suffix#g" \ + -e "s#@dirmgr@#$dirmgr#g" \ + -e "s#\@contextdir\@#@contextdir@#g" \ @pbconfigdir@/pb.tmpl > @contextdir@/pb.conf +# the default.conf is just a copy of dsgw.conf cp @contextdir@/dsgw.conf @contextdir@/default.conf +# tell Apache about the dsgw - must restart Apache +grep dsgw-httpd.conf "@httpdconf@" > /dev/null 2>&1 || (echo "" ; echo "# DSGW configuration" ; echo "Include @contextdir@/dsgw-httpd.conf") >> @httpdconf@ + +echo "The DSGW has been successfully configured." +if [ $isAdmServ ] ; then + echo "Please restart the Admin Server - /path/to/start-admin " +else + echo "Please restart Apache e.g." + echo " service httpd restart" + echo " OR" + echo " apachectl restart" + echo "or however you restart apache on this system." +fi + exit 0 From fedora-directory-commits at redhat.com Fri Jun 2 22:57:21 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Fri, 2 Jun 2006 15:57:21 -0700 Subject: [Fedora-directory-commits] dsgw/m4 httpd.m4,1.1.1.1,1.2 Message-ID: <200606022257.k52MvLll022557@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/dsgw/m4 In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22509/m4 Modified Files: httpd.m4 Log Message: cleaned up build and setup scripts Index: httpd.m4 =================================================================== RCS file: /cvs/dirsec/dsgw/m4/httpd.m4,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- httpd.m4 1 Jun 2006 19:43:50 -0000 1.1.1.1 +++ httpd.m4 2 Jun 2006 22:57:18 -0000 1.2 @@ -36,6 +36,7 @@ manualuri="/manual" cgiuri="/clients/dsgw/bin/" cookiedir="$basedir/cookies" + httpdconf="$withval/admin-serv/config/admserv.conf" else echo AC_MSG_ERROR([$withval not found]) @@ -55,25 +56,25 @@ httpd_conf_rel=`$HTTPD -V | grep SERVER_CONFIG_FILE | cut -f2 -d=` httpd_conf_rel=`eval echo $httpd_conf_rel` - httpd_conf=${httpd_root}/${httpd_conf_rel} + httpdconf=${httpd_root}/${httpd_conf_rel} - htmlbasedir=`grep \^DocumentRoot $httpd_conf|awk '{print $2}'` + htmlbasedir=`grep \^DocumentRoot $httpdconf|awk '{print $2}'` htmlbasedir=`eval echo $htmlbasedir` # these directories are html based htmldir="$htmlbasedir/dsgw/html" pbhtmldir="$htmlbasedir/dsgw/pbhtml" configdir="$htmlbasedir/dsgw/config" pbconfigdir="$htmlbasedir/dsgw/pbconfig" - manualuri="/dirsvr/manual" + manualuri="/dsgw/manual" # CGI program directory - cgibindir=`grep '^ScriptAlias.*/cgi-bin/' $httpd_conf|awk '{print $3}'` + cgibindir=`grep '^ScriptAlias.*/cgi-bin/' $httpdconf|awk '{print $3}'` cgibindir=`eval echo $cgibindir` - cgiuri=`grep '^ScriptAlias.*/cgi-bin/' $httpd_conf|awk '{print $2}'` + cgiuri=`grep '^ScriptAlias.*/cgi-bin/' $httpdconf|awk '{print $2}'` # configuration files and etc. - contextdir=/etc/dsgw + contextdir=$sysconfdir/dsgw propertydir=$contextdir securitydir=$contextdir - cookiedir=/var/run/dsgw/cookies + cookiedir=$localstatedir/run/dsgw/cookies fi From fedora-directory-commits at redhat.com Fri Jun 9 18:31:44 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 11:31:44 -0700 Subject: [Fedora-directory-commits] coolkey - Imported sources Message-ID: <200606091831.k59IVitk001552@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1535 Log Message: Initial import of coolkey Status: Vendor Tag: redhat Release Tags: initial N coolkey/config.guess N coolkey/install-sh N coolkey/acinclude.m4 N coolkey/Makefile.in N coolkey/aclocal.m4 N coolkey/ltmain.sh N coolkey/config.h.in N coolkey/depcomp N coolkey/compile N coolkey/ChangeLog N coolkey/LICENSE N coolkey/missing N coolkey/configure.in N coolkey/coolkey.spec N coolkey/libtool N coolkey/Makefile.am N coolkey/config.h N coolkey/configure N coolkey/config.status N coolkey/config.sub N coolkey/src/coollkey/pkcs11.h N coolkey/src/coollkey/Makefile.in N coolkey/src/coollkey/config.mk N coolkey/src/coollkey/dllmain.cpp N coolkey/src/coollkey/coolkeypk11.rc N coolkey/src/coollkey/machdep.cpp N coolkey/src/coollkey/pkcs11n.h N coolkey/src/coollkey/log.h N coolkey/src/coollkey/coolkeypk11.def N coolkey/src/coollkey/pkcs11f.h N coolkey/src/coollkey/object.h N coolkey/src/coollkey/test.cpp N coolkey/src/coollkey/slot.cpp N coolkey/src/coollkey/locking.cpp N coolkey/src/coollkey/params.h N coolkey/src/coollkey/locking.h N coolkey/src/coollkey/PKCS11Exception.h N coolkey/src/coollkey/log.cpp N coolkey/src/coollkey/PKCS11Exception.cpp N coolkey/src/coollkey/Makefile.am N coolkey/src/coollkey/coolkey.cpp N coolkey/src/coollkey/manifest.mn N coolkey/src/coollkey/machdep.h N coolkey/src/coollkey/pkcs11t.h N coolkey/src/coollkey/mypkcs11.h N coolkey/src/coollkey/slot.h N coolkey/src/coollkey/object.cpp N coolkey/src/coollkey/.deps/libcoolkeypk11_la-slot.Plo N coolkey/src/coollkey/.deps/libcoolkeypk11_la-locking.Plo N coolkey/src/coollkey/.deps/libcoolkeypk11_la-machdep.Plo N coolkey/src/coollkey/.deps/libcoolkeypk11_la-dllmain.Plo N coolkey/src/coollkey/.deps/libcoolkeypk11_la-log.Plo N coolkey/src/coollkey/.deps/libcoolkeypk11_la-object.Plo N coolkey/src/coollkey/.deps/libcoolkeypk11_la-coolkey.Plo N coolkey/src/coollkey/.deps/libcoolkeypk11_la-PKCS11Exception.Plo N coolkey/src/libckapplet/Makefile.in N coolkey/src/libckapplet/config.mk N coolkey/src/libckapplet/cky_list.h N coolkey/src/libckapplet/dynlink.c N coolkey/src/libckapplet/cky_basei.h N coolkey/src/libckapplet/cky_base.c N coolkey/src/libckapplet/cky_applet.h N coolkey/src/libckapplet/dynlink_win.c N coolkey/src/libckapplet/cky_list.i N coolkey/src/libckapplet/cky_factory.h N coolkey/src/libckapplet/dynlink_mac.c N coolkey/src/libckapplet/cky_factory.c N coolkey/src/libckapplet/dynlink.h N coolkey/src/libckapplet/cky_applet.c N coolkey/src/libckapplet/cky_base.h N coolkey/src/libckapplet/cky_card.c N coolkey/src/libckapplet/Makefile.am N coolkey/src/libckapplet/manifest.mn N coolkey/src/libckapplet/dynlink_unix.c N coolkey/src/libckapplet/cky_card.h N coolkey/src/libckapplet/.deps/libckyapplet_la-cky_card.Plo N coolkey/src/libckapplet/.deps/libckyapplet_la-cky_applet.Plo N coolkey/src/libckapplet/.deps/libckyapplet_la-cky_factory.Plo N coolkey/src/libckapplet/.deps/libckyapplet_la-cky_base.Plo N coolkey/src/libckapplet/.deps/libckyapplet_la-dynlink.Plo N coolkey/aclocal/Makefile.in N coolkey/aclocal/acx_pthread.m4 N coolkey/aclocal/Makefile N coolkey/aclocal/Makefile.am No conflicts created by this import From fedora-directory-commits at redhat.com Fri Jun 9 18:35:16 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 11:35:16 -0700 Subject: [Fedora-directory-commits] coolkey/src/coolkey - New directory Message-ID: <200606091835.k59IZGe1001610@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/coolkey In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1595/coolkey Log Message: Directory /cvs/dirsec/coolkey/src/coolkey added to the repository From fedora-directory-commits at redhat.com Fri Jun 9 18:39:13 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 11:39:13 -0700 Subject: [Fedora-directory-commits] coolkey/src/coolkey Makefile.am, NONE, 1.1 Makefile.in, NONE, 1.1 PKCS11Exception.cpp, NONE, 1.1 PKCS11Exception.h, NONE, 1.1 config.mk, NONE, 1.1 coolkey.cpp, NONE, 1.1 coolkeypk11.def, NONE, 1.1 coolkeypk11.rc, NONE, 1.1 dllmain.cpp, NONE, 1.1 locking.cpp, NONE, 1.1 locking.h, NONE, 1.1 log.cpp, NONE, 1.1 log.h, NONE, 1.1 machdep.cpp, NONE, 1.1 machdep.h, NONE, 1.1 manifest.mn, NONE, 1.1 mypkcs11.h, NONE, 1.1 object.cpp, NONE, 1.1 object.h, NONE, 1.1 params.h, NONE, 1.1 pkcs11.h, NONE, 1.1 pkcs11f.h, NONE, 1.1 pkcs11n.h, NONE, 1.1 pkcs11t.h, NONE, 1.1 slot.cpp, NONE, 1.1 slot.h, NONE, 1.1 test.cpp, NONE, 1.1 Message-ID: <200606091839.k59IdDgm001680@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/coolkey In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1638/coolkey Added Files: Makefile.am Makefile.in PKCS11Exception.cpp PKCS11Exception.h config.mk coolkey.cpp coolkeypk11.def coolkeypk11.rc dllmain.cpp locking.cpp locking.h log.cpp log.h machdep.cpp machdep.h manifest.mn mypkcs11.h object.cpp object.h params.h pkcs11.h pkcs11f.h pkcs11n.h pkcs11t.h slot.cpp slot.h test.cpp Log Message: coolkey was check in with the wrong name initially --- NEW FILE Makefile.am --- # ***** BEGIN COPYRIGHT BLOCK ***** # Copyright (C) 2005 Red Hat, Inc. # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation version # 2.1 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ***** END COPYRIGHT BLOCK ***** # Process this file with automake to create Makefile.in SUBDIRS = AM_CPP_FLAGS = pkcs11dir = $(libdir)/pkcs11 pkcs11_LTLIBRARIES = libcoolkeypk11.la libcoolkeypk11_la_SOURCES = \ coolkey.cpp \ dllmain.cpp \ locking.cpp \ log.cpp \ machdep.cpp \ object.cpp \ PKCS11Exception.cpp \ slot.cpp \ config.h \ locking.h \ log.h \ machdep.h \ mypkcs11.h \ object.h \ params.h \ PKCS11Exception.h \ pkcs11f.h \ pkcs11.h \ pkcs11n.h \ pkcs11t.h \ slot.h \ $(NULL) libcoolkeypk11_la_LDFLAGS = -module -avoid-version -export-symbols coolkeypk11.sym libcoolkeypk11_la_CPPFLAGS = $(CPPFLAGS) -DNSS_HIDE_NONSTANDARD_OBJECTS=1 -I$(top_srcdir)/clib $(PCSC_CFLAGS) libcoolkeypk11_la_DEPENDENCIES = coolkeypk11.sym libcoolkeypk11_la_LIBADD = @LIBCKYAPPLET@ # # sigh, libtool doesn't maintain Linux and Solaris versioning info in # their .def file. So convert a very general, easy to work an any platform # coreconf .def file to a simplistic but acceptable libtool .sym file # coolkeypk11.sym: coolkeypk11.def grep -v ';+' $< | grep -v ';-' | sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' > $@ clean-generic: rm -f coolkeypk11.sym #MODULE = coolkeypk11 #REQUIRES = ckyapplet zlib #USE_STATIC_RTL=1 #BASE_LIBRARY_NAME = coolkeypk11 #LIBRARY_NAME = $(BASE_LIBRARY_NAME) #MAPFILE = $(OBJDIR)/coolkeypk11.def #DEFINES += -DSHLIB_SUFFIX=\"$(DLL_SUFFIX)\" -DSHLIB_PREFIX=\"$(DLL_PREFIX)\" \ # -DPKCS11_LIB_NAME=\"$(notdir $(SHARED_LIBRARY))\" #DEFINES += -DNSS_HIDE_NONSTANDARD_OBJECTS=1 #pcdir = $(libdir)/pkgconfig #pc_DATA = libcoolkey.pc --- NEW FILE Makefile.in --- # Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program 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. @SET_MAKE@ # ***** BEGIN COPYRIGHT BLOCK ***** # Copyright (C) 2005 Red Hat, Inc. # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation version # 2.1 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ***** END COPYRIGHT BLOCK ***** # Process this file with automake to create Makefile.in srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = pkcs11/smartcard DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(pkcs11dir)" pkcs11LTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(pkcs11_LTLIBRARIES) am_libcoolkeypk11_la_OBJECTS = libcoolkeypk11_la-coolkey.lo \ libcoolkeypk11_la-dllmain.lo libcoolkeypk11_la-locking.lo \ libcoolkeypk11_la-log.lo libcoolkeypk11_la-machdep.lo \ libcoolkeypk11_la-object.lo \ libcoolkeypk11_la-PKCS11Exception.lo libcoolkeypk11_la-slot.lo libcoolkeypk11_la_OBJECTS = $(am_libcoolkeypk11_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libcoolkeypk11_la_SOURCES) DIST_SOURCES = $(libcoolkeypk11_la_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-exec-recursive install-info-recursive \ install-recursive installcheck-recursive installdirs-recursive \ pdf-recursive ps-recursive uninstall-info-recursive \ uninstall-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ F77 = @F77@ FFLAGS = @FFLAGS@ HAVE_PCSC_FALSE = @HAVE_PCSC_FALSE@ HAVE_PCSC_TRUE = @HAVE_PCSC_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBCKYAPPLET = @LIBCKYAPPLET@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PCSC_CFLAGS = @PCSC_CFLAGS@ PCSC_LIBS = @PCSC_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ SCARD_LIB_NAME = @SCARD_LIB_NAME@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_F77 = @ac_ct_F77@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ prefix = @prefix@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ SUBDIRS = AM_CPP_FLAGS = pkcs11dir = $(libdir)/pkcs11 pkcs11_LTLIBRARIES = libcoolkeypk11.la libcoolkeypk11_la_SOURCES = \ coolkey.cpp \ dllmain.cpp \ locking.cpp \ log.cpp \ machdep.cpp \ object.cpp \ PKCS11Exception.cpp \ slot.cpp \ config.h \ locking.h \ log.h \ machdep.h \ mypkcs11.h \ object.h \ params.h \ PKCS11Exception.h \ pkcs11f.h \ pkcs11.h \ pkcs11n.h \ pkcs11t.h \ slot.h \ $(NULL) libcoolkeypk11_la_LDFLAGS = -module -avoid-version -export-symbols coolkeypk11.sym libcoolkeypk11_la_CPPFLAGS = $(CPPFLAGS) -DNSS_HIDE_NONSTANDARD_OBJECTS=1 -I$(top_srcdir)/clib $(PCSC_CFLAGS) libcoolkeypk11_la_DEPENDENCIES = coolkeypk11.sym libcoolkeypk11_la_LIBADD = @LIBCKYAPPLET@ all: all-recursive .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu pkcs11/smartcard/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu pkcs11/smartcard/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-pkcs11LTLIBRARIES: $(pkcs11_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(pkcs11dir)" || $(mkdir_p) "$(DESTDIR)$(pkcs11dir)" @list='$(pkcs11_LTLIBRARIES)'; for p in $$list; do \ if test -f $$p; then \ f=$(am__strip_dir) \ echo " $(LIBTOOL) --mode=install $(pkcs11LTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkcs11dir)/$$f'"; \ $(LIBTOOL) --mode=install $(pkcs11LTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkcs11dir)/$$f"; \ else :; fi; \ done uninstall-pkcs11LTLIBRARIES: @$(NORMAL_UNINSTALL) @set -x; list='$(pkcs11_LTLIBRARIES)'; for p in $$list; do \ p=$(am__strip_dir) \ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkcs11dir)/$$p'"; \ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkcs11dir)/$$p"; \ done clean-pkcs11LTLIBRARIES: -test -z "$(pkcs11_LTLIBRARIES)" || rm -f $(pkcs11_LTLIBRARIES) @list='$(pkcs11_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libcoolkeypk11.la: $(libcoolkeypk11_la_OBJECTS) $(libcoolkeypk11_la_DEPENDENCIES) $(CXXLINK) -rpath $(pkcs11dir) $(libcoolkeypk11_la_LDFLAGS) $(libcoolkeypk11_la_OBJECTS) $(libcoolkeypk11_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcoolkeypk11_la-PKCS11Exception.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcoolkeypk11_la-coolkey.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcoolkeypk11_la-dllmain.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcoolkeypk11_la-locking.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcoolkeypk11_la-log.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcoolkeypk11_la-machdep.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcoolkeypk11_la-object.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcoolkeypk11_la-slot.Plo at am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< libcoolkeypk11_la-coolkey.lo: coolkey.cpp @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libcoolkeypk11_la-coolkey.lo -MD -MP -MF "$(DEPDIR)/libcoolkeypk11_la-coolkey.Tpo" -c -o libcoolkeypk11_la-coolkey.lo `test -f 'coolkey.cpp' || echo '$(srcdir)/'`coolkey.cpp; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libcoolkeypk11_la-coolkey.Tpo" "$(DEPDIR)/libcoolkeypk11_la-coolkey.Plo"; else rm -f "$(DEPDIR)/libcoolkeypk11_la-coolkey.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='coolkey.cpp' object='libcoolkeypk11_la-coolkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libcoolkeypk11_la-coolkey.lo `test -f 'coolkey.cpp' || echo '$(srcdir)/'`coolkey.cpp libcoolkeypk11_la-dllmain.lo: dllmain.cpp @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libcoolkeypk11_la-dllmain.lo -MD -MP -MF "$(DEPDIR)/libcoolkeypk11_la-dllmain.Tpo" -c -o libcoolkeypk11_la-dllmain.lo `test -f 'dllmain.cpp' || echo '$(srcdir)/'`dllmain.cpp; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libcoolkeypk11_la-dllmain.Tpo" "$(DEPDIR)/libcoolkeypk11_la-dllmain.Plo"; else rm -f "$(DEPDIR)/libcoolkeypk11_la-dllmain.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='dllmain.cpp' object='libcoolkeypk11_la-dllmain.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libcoolkeypk11_la-dllmain.lo `test -f 'dllmain.cpp' || echo '$(srcdir)/'`dllmain.cpp libcoolkeypk11_la-locking.lo: locking.cpp @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libcoolkeypk11_la-locking.lo -MD -MP -MF "$(DEPDIR)/libcoolkeypk11_la-locking.Tpo" -c -o libcoolkeypk11_la-locking.lo `test -f 'locking.cpp' || echo '$(srcdir)/'`locking.cpp; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libcoolkeypk11_la-locking.Tpo" "$(DEPDIR)/libcoolkeypk11_la-locking.Plo"; else rm -f "$(DEPDIR)/libcoolkeypk11_la-locking.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='locking.cpp' object='libcoolkeypk11_la-locking.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libcoolkeypk11_la-locking.lo `test -f 'locking.cpp' || echo '$(srcdir)/'`locking.cpp libcoolkeypk11_la-log.lo: log.cpp @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libcoolkeypk11_la-log.lo -MD -MP -MF "$(DEPDIR)/libcoolkeypk11_la-log.Tpo" -c -o libcoolkeypk11_la-log.lo `test -f 'log.cpp' || echo '$(srcdir)/'`log.cpp; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libcoolkeypk11_la-log.Tpo" "$(DEPDIR)/libcoolkeypk11_la-log.Plo"; else rm -f "$(DEPDIR)/libcoolkeypk11_la-log.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='log.cpp' object='libcoolkeypk11_la-log.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libcoolkeypk11_la-log.lo `test -f 'log.cpp' || echo '$(srcdir)/'`log.cpp libcoolkeypk11_la-machdep.lo: machdep.cpp @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libcoolkeypk11_la-machdep.lo -MD -MP -MF "$(DEPDIR)/libcoolkeypk11_la-machdep.Tpo" -c -o libcoolkeypk11_la-machdep.lo `test -f 'machdep.cpp' || echo '$(srcdir)/'`machdep.cpp; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libcoolkeypk11_la-machdep.Tpo" "$(DEPDIR)/libcoolkeypk11_la-machdep.Plo"; else rm -f "$(DEPDIR)/libcoolkeypk11_la-machdep.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='machdep.cpp' object='libcoolkeypk11_la-machdep.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libcoolkeypk11_la-machdep.lo `test -f 'machdep.cpp' || echo '$(srcdir)/'`machdep.cpp libcoolkeypk11_la-object.lo: object.cpp @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libcoolkeypk11_la-object.lo -MD -MP -MF "$(DEPDIR)/libcoolkeypk11_la-object.Tpo" -c -o libcoolkeypk11_la-object.lo `test -f 'object.cpp' || echo '$(srcdir)/'`object.cpp; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libcoolkeypk11_la-object.Tpo" "$(DEPDIR)/libcoolkeypk11_la-object.Plo"; else rm -f "$(DEPDIR)/libcoolkeypk11_la-object.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='object.cpp' object='libcoolkeypk11_la-object.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libcoolkeypk11_la-object.lo `test -f 'object.cpp' || echo '$(srcdir)/'`object.cpp libcoolkeypk11_la-PKCS11Exception.lo: PKCS11Exception.cpp @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libcoolkeypk11_la-PKCS11Exception.lo -MD -MP -MF "$(DEPDIR)/libcoolkeypk11_la-PKCS11Exception.Tpo" -c -o libcoolkeypk11_la-PKCS11Exception.lo `test -f 'PKCS11Exception.cpp' || echo '$(srcdir)/'`PKCS11Exception.cpp; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libcoolkeypk11_la-PKCS11Exception.Tpo" "$(DEPDIR)/libcoolkeypk11_la-PKCS11Exception.Plo"; else rm -f "$(DEPDIR)/libcoolkeypk11_la-PKCS11Exception.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='PKCS11Exception.cpp' object='libcoolkeypk11_la-PKCS11Exception.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libcoolkeypk11_la-PKCS11Exception.lo `test -f 'PKCS11Exception.cpp' || echo '$(srcdir)/'`PKCS11Exception.cpp libcoolkeypk11_la-slot.lo: slot.cpp @am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libcoolkeypk11_la-slot.lo -MD -MP -MF "$(DEPDIR)/libcoolkeypk11_la-slot.Tpo" -c -o libcoolkeypk11_la-slot.lo `test -f 'slot.cpp' || echo '$(srcdir)/'`slot.cpp; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libcoolkeypk11_la-slot.Tpo" "$(DEPDIR)/libcoolkeypk11_la-slot.Plo"; else rm -f "$(DEPDIR)/libcoolkeypk11_la-slot.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='slot.cpp' object='libcoolkeypk11_la-slot.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcoolkeypk11_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libcoolkeypk11_la-slot.lo `test -f 'slot.cpp' || echo '$(srcdir)/'`slot.cpp mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(mkdir_p) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LTLIBRARIES) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(pkcs11dir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool clean-pkcs11LTLIBRARIES \ mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-pkcs11LTLIBRARIES install-exec-am: install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-info-am uninstall-pkcs11LTLIBRARIES uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ clean clean-generic clean-libtool clean-pkcs11LTLIBRARIES \ clean-recursive ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-recursive distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-pkcs11LTLIBRARIES \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ maintainer-clean-recursive mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-info-am uninstall-pkcs11LTLIBRARIES # # sigh, libtool doesn't maintain Linux and Solaris versioning info in # their .def file. So convert a very general, easy to work an any platform # coreconf .def file to a simplistic but acceptable libtool .sym file # coolkeypk11.sym: coolkeypk11.def grep -v ';+' $< | grep -v ';-' | sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' > $@ clean-generic: rm -f coolkeypk11.sym #MODULE = coolkeypk11 #REQUIRES = ckyapplet zlib #USE_STATIC_RTL=1 #BASE_LIBRARY_NAME = coolkeypk11 #LIBRARY_NAME = $(BASE_LIBRARY_NAME) #MAPFILE = $(OBJDIR)/coolkeypk11.def #DEFINES += -DSHLIB_SUFFIX=\"$(DLL_SUFFIX)\" -DSHLIB_PREFIX=\"$(DLL_PREFIX)\" \ # -DPKCS11_LIB_NAME=\"$(notdir $(SHARED_LIBRARY))\" #DEFINES += -DNSS_HIDE_NONSTANDARD_OBJECTS=1 #pcdir = $(libdir)/pkgconfig #pc_DATA = libcoolkey.pc # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: --- NEW FILE PKCS11Exception.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #include "mypkcs11.h" #include #include #include #include "log.h" #include "PKCS11Exception.h" #ifdef WIN32 #define vsnprintf _vsnprintf #endif PKCS11Exception::PKCS11Exception(CK_RV crv_, const char *format, ...) { va_list args; va_start(args, format); makeMessage(format, args); va_end(args); crv = crv_; } void PKCS11Exception::log(Log *log) const { log->log("Error 0x%08x: %s\n", crv, getMessageStr()); } void PKCS11Exception::makeMessage(const char *format, va_list args) { char buf[BUFSIZE]; vsnprintf(buf, BUFSIZE, format, args); message = string(buf); } --- NEW FILE PKCS11Exception.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifndef COOLKEY_PKCS11EXCEPTION_H #define COOLKEY_PKCS11EXCEPTION_H #include "mypkcs11.h" #include #include #include "log.h" using std::string; class PKCS11Exception { private: enum { BUFSIZE = 1024 }; CK_RV crv; string message; void makeMessage(const char *format, va_list args); public: PKCS11Exception(CK_RV crv_) : crv(crv_) { } PKCS11Exception(CK_RV crv_, string message_) : crv(crv_), message(message_) { } PKCS11Exception(CK_RV crv_, const char *format, ...); CK_RV getReturnValue() const { return crv; } CK_RV getCRV() const { return crv; } string getMessage() const { return message; } const char *getMessageStr() const { return message.c_str(); } void log(Log *l) const; }; #endif --- NEW FILE config.mk --- # ***** BEGIN COPYRIGHT BLOCK ***** # Copyright (C) 2005 Red Hat, Inc. # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation version # 2.1 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ***** END COPYRIGHT BLOCK ***** LIB_RTL_SUFFIX= ifeq (,$(filter-out WIN%,$(OS_TARGET))) ifdef USE_STATIC_RTL LIB_RTL_SUFFIX=_srtl endif endif EXTRA_LIBS += \ $(DIST)/lib/$(LIB_PREFIX)ckyapplet$(LIB_RTL_SUFFIX).$(LIB_SUFFIX) \ $(DIST)/lib/$(LIB_PREFIX)zlib$(LIB_RTL_SUFFIX).$(LIB_SUFFIX) \ $(NULL) # can't do this in manifest.mn because OS_TARGET isn't defined there. ifeq (,$(filter-out WIN%,$(OS_TARGET))) # don't want the 32 in the shared library name SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX) IMPORT_LIBRARY = $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(IMPORT_LIB_SUFFIX) RES = $(OBJDIR)/$(LIBRARY_NAME).res RESNAME = $(LIBRARY_NAME).rc ifdef NS_USE_GCC EXTRA_SHARED_LIBS += \ -L$(DIST)/lib \ $(NULL) else # ! NS_USE_GCC EXTRA_SHARED_LIBS += \ $(NULL) endif # NS_USE_GCC else # $(PROGRAM) has NO explicit dependencies on $(EXTRA_SHARED_LIBS) # $(EXTRA_SHARED_LIBS) come before $(OS_LIBS), except on AIX. EXTRA_SHARED_LIBS += \ -L$(DIST)/lib/ \ $(NULL) endif ifeq ($(OS_TARGET),SunOS) ifndef USE_64 ifeq ($(CPU_ARCH),sparc) # The -R '$ORIGIN' linker option instructs libsoftokn3.so to search for its # dependencies (libfreebl_*.so) in the same directory where it resides. MKSHLIB += -R '$$ORIGIN' endif endif endif ifeq ($(OS_TARGET),WINCE) DEFINES += -DDBM_USING_NSPR endif ifeq ($(OS_TARGET),Linux) CC=g++ EXTRA_SHARED_LIBS += -ldl -lpthread #ifdef USE_STATIC_RTL #MKSHLIB += -static-libgcc #endif endif --- NEW FILE coolkey.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #include "mypkcs11.h" #include #include #include #include #include #include "log.h" #include "PKCS11Exception.h" #ifdef _WIN32 #include #endif #include #include "slot.h" #include "cky_base.h" #include "params.h" #define NULL 0 /* static module data -------------------------------- */ static Log *log = NULL; static SlotList *slotList = NULL; static OSLock finalizeLock(false); static CK_BBOOL initialized = FALSE; static CK_BBOOL finalizing = FALSE; static CK_BBOOL waitEvent = FALSE; char *Params::params = NULL; // manufacturerID and libraryDescription should not be NULL-terminated, // so the last character is overwritten with a blank in C_GetInfo(). static CK_INFO ckInfo = { {2, 11}, "Mozilla Foundation ", 0, "CoolKey PKCS #11 Module ", {1, 0} }; typedef struct { CK_MECHANISM_TYPE mech; CK_MECHANISM_INFO info; } MechInfo; /********************************************************************** ************************** MECHANISM TABLE *************************** **********************************************************************/ static MechInfo mechanismList[] = { {CKM_RSA_PKCS, { 1024, 4096, CKF_HW | CKF_SIGN | CKF_DECRYPT } } }; static unsigned int numMechanisms = sizeof(mechanismList)/sizeof(MechInfo); /* ------------------------------------------------------------ */ void dumpTemplates(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) { // no try here, let caller catch it. try { unsigned long i; if (!pTemplate) return; for (i = 0; i < ulCount; ++i) { CK_ATTRIBUTE_PTR pT = pTemplate + i; if (pT->pValue && pT->ulValueLen == 4) { log->log( "template [%02lu] type: %04lx, pValue: %08lx, ulValueLen: %08lx, value: %lu\n", i, pT->type, pT->pValue, pT->ulValueLen, *(CK_ULONG_PTR)pT->pValue); } else log->log("template [%02lu] type: %04lx, pValue: %08lx, ulValueLen: %08lx\n", i, pT->type, pT->pValue, pT->ulValueLen); } } /* PKCS11 defined functions ----------------------------------- */ #define NOTSUPPORTED(name, args) \ CK_RV name args \ { \ log->log(#name " called (notSupported)\n"); \ return CKR_FUNCTION_NOT_SUPPORTED; \ } #define SUPPORTED(name, name2, dec_args, use_args) \ CK_RV name dec_args \ { \ if( ! initialized ) { \ return CKR_CRYPTOKI_NOT_INITIALIZED; \ } \ try { \ log->log(#name " called\n"); \ slotList->name2 use_args ; \ return CKR_OK; \ } catch(PKCS11Exception& e) { \ e.log(log); \ return e.getCRV(); \ } \ } extern "C" { NOTSUPPORTED(C_InitToken,(CK_SLOT_ID, CK_CHAR_PTR, CK_ULONG, CK_UTF8CHAR_PTR)) NOTSUPPORTED(C_InitPIN, (CK_SESSION_HANDLE, CK_CHAR_PTR, CK_ULONG)) NOTSUPPORTED(C_SetPIN, (CK_SESSION_HANDLE, CK_CHAR_PTR, CK_ULONG, CK_CHAR_PTR, CK_ULONG)) NOTSUPPORTED(C_GetOperationState, (CK_SESSION_HANDLE, CK_BYTE_PTR, CK_ULONG_PTR)) NOTSUPPORTED(C_SetOperationState, (CK_SESSION_HANDLE, CK_BYTE_PTR, CK_ULONG, CK_OBJECT_HANDLE, CK_OBJECT_HANDLE)) NOTSUPPORTED(C_CreateObject, (CK_SESSION_HANDLE, CK_ATTRIBUTE_PTR, CK_ULONG, CK_OBJECT_HANDLE_PTR)) NOTSUPPORTED(C_CopyObject, (CK_SESSION_HANDLE,CK_OBJECT_HANDLE,CK_ATTRIBUTE_PTR,CK_ULONG,CK_OBJECT_HANDLE_PTR)) NOTSUPPORTED(C_DestroyObject, (CK_SESSION_HANDLE, CK_OBJECT_HANDLE)) NOTSUPPORTED(C_GetObjectSize, (CK_SESSION_HANDLE,CK_OBJECT_HANDLE,CK_ULONG_PTR)) NOTSUPPORTED(C_SetAttributeValue, (CK_SESSION_HANDLE,CK_OBJECT_HANDLE,CK_ATTRIBUTE_PTR,CK_ULONG)) NOTSUPPORTED(C_EncryptInit, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE)) NOTSUPPORTED(C_Encrypt, (CK_SESSION_HANDLE, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, CK_ULONG_PTR)) NOTSUPPORTED(C_EncryptUpdate, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_EncryptFinal, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_DecryptUpdate,(CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_DecryptFinal, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_DigestInit, (CK_SESSION_HANDLE,CK_MECHANISM_PTR)) NOTSUPPORTED(C_Digest, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_DigestUpdate, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG)) NOTSUPPORTED(C_DigestKey, (CK_SESSION_HANDLE,CK_OBJECT_HANDLE)) NOTSUPPORTED(C_DigestFinal, (CK_SESSION_HANDLE, CK_BYTE_PTR, CK_ULONG_PTR)) NOTSUPPORTED(C_SignUpdate, (CK_SESSION_HANDLE, CK_BYTE_PTR, CK_ULONG)) NOTSUPPORTED(C_SignFinal, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_SignRecoverInit, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE)) NOTSUPPORTED(C_SignRecover, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_VerifyInit, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE)) NOTSUPPORTED(C_Verify, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG)) NOTSUPPORTED(C_VerifyUpdate, (CK_SESSION_HANDLE, CK_BYTE_PTR, CK_ULONG)) NOTSUPPORTED(C_VerifyFinal, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG)) NOTSUPPORTED(C_VerifyRecoverInit, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE)) NOTSUPPORTED(C_VerifyRecover, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_DigestEncryptUpdate, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_DecryptDigestUpdate, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_SignEncryptUpdate, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_DecryptVerifyUpdate, (CK_SESSION_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_GenerateKey, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_ATTRIBUTE_PTR,CK_ULONG,CK_OBJECT_HANDLE_PTR)) NOTSUPPORTED(C_GenerateKeyPair, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_ATTRIBUTE_PTR,CK_ULONG,CK_ATTRIBUTE_PTR,CK_ULONG,CK_OBJECT_HANDLE_PTR,CK_OBJECT_HANDLE_PTR)) NOTSUPPORTED(C_WrapKey, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE,CK_OBJECT_HANDLE,CK_BYTE_PTR,CK_ULONG_PTR)) NOTSUPPORTED(C_UnwrapKey, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_ATTRIBUTE_PTR,CK_ULONG,CK_OBJECT_HANDLE_PTR)) NOTSUPPORTED(C_DeriveKey, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE,CK_ATTRIBUTE_PTR,CK_ULONG,CK_OBJECT_HANDLE_PTR)) NOTSUPPORTED(C_GetFunctionStatus, (CK_SESSION_HANDLE)) NOTSUPPORTED(C_CancelFunction, (CK_SESSION_HANDLE)) /* non-specialized functions supported with the slotList object */ SUPPORTED(C_GetSlotList, getSlotList, (CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount), (tokenPresent, pSlotList, pulCount)) SUPPORTED(C_GetSessionInfo, getSessionInfo, (CK_SESSION_HANDLE hSession, CK_SESSION_INFO_PTR pInfo), (hSession, pInfo) ) SUPPORTED(C_Logout, logout, (CK_SESSION_HANDLE hSession), (hSession)) SUPPORTED(C_Decrypt, decrypt, (CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pDecryptedData, CK_ULONG_PTR pulDecryptedDataLen), (hSession, pData, ulDataLen, pDecryptedData, pulDecryptedDataLen)) SUPPORTED(C_DecryptInit, decryptInit, (CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey), (hSession, pMechanism, hKey)) SUPPORTED(C_SignInit, signInit, (CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey), (hSession, pMechanism, hKey)) SUPPORTED(C_Sign, sign, (CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen), (hSession, pData, ulDataLen, pSignature, pulSignatureLen)) SUPPORTED(C_SeedRandom, seedRandom, (CK_SESSION_HANDLE hSession ,CK_BYTE_PTR data,CK_ULONG dataLen), (hSession, data, dataLen)) SUPPORTED(C_GenerateRandom, generateRandom, (CK_SESSION_HANDLE hSession ,CK_BYTE_PTR data,CK_ULONG dataLen), (hSession, data, dataLen)) /* non-specialized functions supported with the slot directly */ CK_RV C_Initialize(CK_VOID_PTR pInitArgs) { try { if( initialized ) { return CKR_CRYPTOKI_ALREADY_INITIALIZED; } if (!finalizeLock.isValid()) { return CKR_CANT_LOCK; } CK_C_INITIALIZE_ARGS* initArgs = (CK_C_INITIALIZE_ARGS*) pInitArgs; if( initArgs != NULL ) { /* work around a bug in NSS where the library parameters are only * send if locking is requested */ if (initArgs->LibraryParameters) { Params::SetParams(strdup((char *)initArgs->LibraryParameters)); } else { Params::ClearParams(); } if( (initArgs->flags & CKF_OS_LOCKING_OK) || initArgs->LockMutex ){ throw PKCS11Exception(CKR_CANT_LOCK); } } char * logFileName = getenv("COOL_KEY_LOG_FILE"); if (logFileName) log = new FileLog(logFileName); else log = new DummyLog(); log->log("Initialize called, hello %d\n", 5); CKY_SetName("coolkey"); slotList = new SlotList(log); initialized = TRUE; return CKR_OK; } catch(PKCS11Exception &e) { if( log ) e.log(log); return e.getReturnValue(); } } CK_RV C_Finalize(CK_VOID_PTR pReserved) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } // XXX cleanup all data structures !!! //delete sessionManager; log->log("Finalizing...\n"); // don't race the setting of finalizing. If C_WaitEvent gets passed // the finalizing call first, we know it will set waitEvent before // we can get the lock, so we only need to protect setting finalizing // to true. finalizeLock.getLock(); finalizing = TRUE; finalizeLock.releaseLock(); if (waitEvent) { /* we're waiting on a slot event, shutdown first to allow * the wait function to complete before we pull the rug out. */ slotList->shutdown(); while (waitEvent) { OSSleep(500); } } delete slotList; delete log; finalizeLock.getLock(); finalizing = FALSE; initialized = FALSE; finalizeLock.releaseLock(); return CKR_OK; } CK_RV C_GetInfo(CK_INFO_PTR p) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } log->log("C_GetInfo called\n"); ckInfo.manufacturerID[31] = ' '; ckInfo.libraryDescription[31] = ' '; *p = ckInfo; return CKR_OK; } CK_RV C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pSlotInfo) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("Called C_GetSlotInfo\n"); slotList->validateSlotID(slotID); return slotList->getSlot( slotIDToIndex(slotID))->getSlotInfo(pSlotInfo); } catch( PKCS11Exception &excep ) { excep.log(log); return excep.getCRV(); } } CK_RV C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pTokenInfo) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_GetTokenInfo called\n"); slotList->validateSlotID(slotID); return slotList->getSlot( slotIDToIndex(slotID))->getTokenInfo(pTokenInfo); } catch( PKCS11Exception &excep ) { excep.log(log); return excep.getCRV(); } } CK_RV C_GetMechanismList(CK_SLOT_ID slotID, CK_MECHANISM_TYPE_PTR pMechanismList, CK_ULONG_PTR pulCount) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { CK_RV rv = CKR_OK; log->log("C_GetMechanismList called\n"); if( pulCount == NULL ) { throw PKCS11Exception(CKR_ARGUMENTS_BAD); } slotList->validateSlotID(slotID); if( ! slotList->getSlot( slotIDToIndex(slotID))->isTokenPresent() ) { return CKR_TOKEN_NOT_PRESENT; } if( pMechanismList != NULL ) { if( *pulCount < numMechanisms ) { rv = CKR_BUFFER_TOO_SMALL; } else { for(unsigned int i=0; i < numMechanisms; ++i ) { pMechanismList[i] = mechanismList[i].mech; } } } *pulCount = numMechanisms; log->log("C_GetMechanismList returning %d\n", rv); return rv; } catch(PKCS11Exception &excep ) { excep.log(log); return excep.getCRV(); } } CK_RV C_GetMechanismInfo(CK_SLOT_ID slotID, CK_MECHANISM_TYPE type, CK_MECHANISM_INFO_PTR pInfo) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_GetMechanismInfo called\n"); if( pInfo == NULL ) { throw PKCS11Exception(CKR_ARGUMENTS_BAD); } slotList->validateSlotID(slotID); if( ! slotList->getSlot(slotIDToIndex(slotID))->isTokenPresent() ) { return CKR_TOKEN_NOT_PRESENT; } for(unsigned int i=0; i < numMechanisms; ++i ) { if( mechanismList[i].mech == type ) { *pInfo = mechanismList[i].info; log->log("C_GetMechanismInfo got info about %d\n", type); return CKR_OK; } } log->log("C_GetMechanismInfo failed to find info about %d\n", type); return CKR_MECHANISM_INVALID; // mechanism not in the list } catch(PKCS11Exception &e) { e.log(log); return e.getCRV(); } } CK_RV C_OpenSession(CK_SLOT_ID slotID, CK_FLAGS flags, CK_VOID_PTR pApplication, CK_NOTIFY notify, CK_SESSION_HANDLE_PTR phSession) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_OpenSession called\n"); slotList->validateSlotID(slotID); #ifdef LATER // the CSP isn't setting this bit right now. if( ! (flags & CKF_SERIAL_SESSION) ) { throw PKCS11Exception(CKR_SESSION_PARALLEL_NOT_SUPPORTED); } #endif if( phSession == NULL ) { throw PKCS11Exception(CKR_ARGUMENTS_BAD); } Session::Type sessionType = (flags & CKF_RW_SESSION) ? Session::RW : Session::RO; slotList->openSession(sessionType, slotID, phSession); return CKR_OK; } catch(PKCS11Exception &e) { e.log(log); return e.getCRV(); } } CK_RV C_CloseSession(CK_SESSION_HANDLE hSession) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_CloseSession(0x%x) called\n", hSession); // !!!XXX Hack // If nothing else, we need to logout the token when all // its sessions are closed. return CKR_OK; } catch(PKCS11Exception &e) { e.log(log); return e.getCRV(); } } CK_RV C_CloseAllSessions(CK_SLOT_ID slotID) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_CloseAllSessions(0x%x) called\n", slotID); slotList->validateSlotID(slotID); // !!!XXX Hack // If nothing else, we need to logout the token when all // its sessions are closed. return CKR_OK; } catch(PKCS11Exception &e) { e.log(log); return e.getCRV(); } } CK_RV C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_FindObjectsInit called, %lu templates\n", ulCount); dumpTemplates(pTemplate, ulCount); if( pTemplate == NULL && ulCount != 0 ) { throw PKCS11Exception(CKR_ARGUMENTS_BAD); } slotList->findObjectsInit(hSession, pTemplate, ulCount); return CKR_OK; } catch(PKCS11Exception &e) { e.log(log); return e.getCRV(); } } CK_RV C_FindObjects(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phObject, CK_ULONG ulMaxObjectCount, CK_ULONG_PTR pulObjectCount) { CK_ULONG count = 0; if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_FindObjects called, max objects = %lu\n", ulMaxObjectCount ); if( phObject == NULL && ulMaxObjectCount != 0 ) { throw PKCS11Exception(CKR_ARGUMENTS_BAD); } slotList->findObjects(hSession, phObject, ulMaxObjectCount, pulObjectCount); count = *pulObjectCount; log->log("returned %lu objects:", count ); CK_ULONG i; for (i = 0; i < count; ++i) { log->log(" 0x%08lx", phObject[i]); } log->log("\n" ); return CKR_OK; } catch(PKCS11Exception &e) { e.log(log); return e.getCRV(); } } CK_RV C_FindObjectsFinal(CK_SESSION_HANDLE hSession) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } // we don't need to do any cleaup. We could check the session handle. return CKR_OK; } CK_RV C_Login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_Login called\n"); if( userType != CKU_USER ) { throw PKCS11Exception(CKR_USER_TYPE_INVALID); } if( pPin == NULL ) { throw PKCS11Exception(CKR_ARGUMENTS_BAD); } slotList->login(hSession, pPin, ulPinLen); return CKR_OK; } catch(PKCS11Exception &e) { e.log(log); return e.getCRV(); } } CK_RV C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) { if( ! initialized ) { return CKR_CRYPTOKI_NOT_INITIALIZED; } try { log->log("C_GetAttributeValue called, %lu templates for object 0x%08lx\n", ulCount, hObject); dumpTemplates(pTemplate, ulCount); if( pTemplate == NULL && ulCount != 0 ) { throw PKCS11Exception(CKR_ARGUMENTS_BAD); } slotList->getAttributeValue(hSession, hObject, pTemplate, ulCount); dumpTemplates(pTemplate, ulCount); return CKR_OK; } catch(PKCS11Exception& e) { CK_RV rv = e.getCRV(); e.log(log); if (rv == CKR_ATTRIBUTE_TYPE_INVALID || rv == CKR_BUFFER_TOO_SMALL) { dumpTemplates(pTemplate, ulCount); } return rv; } } /* * While the rest of the C_ calls are protected by the callers lock, * C_WaitForSlotEvent is guaranteed to be on a separate thread. * Make sure we are locking with C_Finalize, which is likely to be racing * with this function */ CK_RV C_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved) { finalizeLock.getLock(); if( ! initialized ) { finalizeLock.releaseLock(); return CKR_CRYPTOKI_NOT_INITIALIZED; } if (finalizing) { finalizeLock.releaseLock(); return CKR_CRYPTOKI_NOT_INITIALIZED; } waitEvent = TRUE; finalizeLock.releaseLock(); try { log->log("C_WaitForSlotEvent called\n"); slotList->waitForSlotEvent(flags, pSlot, pReserved); waitEvent = FALSE; return CKR_OK; } catch(PKCS11Exception& e) { e.log(log); waitEvent = FALSE; return e.getCRV(); } } CK_RV C_GetFunctionList(CK_FUNCTION_LIST_PTR_PTR pPtr); #undef CK_NEED_ARG_LIST #undef CK_PKCS11_FUNCTION_INFO #define CK_PKCS11_FUNCTION_INFO(func) (CK_##func) func, static CK_FUNCTION_LIST functionList = { {2, 20}, // PKCS #11 spec version we support #include "pkcs11f.h" }; CK_RV C_GetFunctionList(CK_FUNCTION_LIST_PTR_PTR pPtr) { if( pPtr == NULL ) { return CKR_ARGUMENTS_BAD; } *pPtr = &functionList; return CKR_OK; } } // end extern C --- NEW FILE coolkeypk11.def --- ;+# ***** BEGIN COPYRIGHT BLOCK ***** ;+# Copyright (C) 2005 Red Hat, Inc. ;+# All rights reserved. ;+# ;+# This library is free software; you can redistribute it and/or ;+# modify it under the terms of the GNU Lesser General Public ;+# License as published by the Free Software Foundation version ;+# 2.1 of the License. ;+# ;+# This library is distributed in the hope that it will be useful, ;+# but WITHOUT ANY WARRANTY; without even the implied warranty of ;+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;+# Lesser General Public License for more details. ;+# ;+# You should have received a copy of the GNU Lesser General Public ;+# License along with this library; if not, write to the Free Software ;+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ;+# ***** END COPYRIGHT BLOCK ***** ;+# ;+# Coreconf smart .def file. ;+# This .def file has encoded in it enough information so it can easily be ;+# converted to an appropriate export symbol file an just about any platform. ;+# ;+# To add new symbols to this file, be sure to enclose those symbols in the ;+# appropriate shared library version number. These version numbers are parsed ;+# by Linux and Solaris. These commands should be prefixed with the ;+# appropriate ';+' ;+# ;+# general comments are prefixed by ';+#' ;+# ;+# Windows & OS/2 key words should not be prefixed. The would contain the ;+# the line ';-' somewhere in the line. This file will be fed 'AS IS' to ;+# Windows and OS/2 with no processing. Anything following a ';' on these ;+# platforms are already treated as a comment. ;+# ;+# As meantioned above, Linux and Solaris commands should be prefixed with ';+' ;+# The ;+ will be removed, as well as any line that has ";-". The " DATA " ;+# keyword will also be removed. The '#' is a comment on these platforms. ;+# ;+# A simple list of export symbols (needed for some platforms like AIX or ;+# libtool can be generated by running the following command: ;+# grep -v ';+' $(DEF_FILE) | grep -v ';-' | \ ;+# sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' > $(SYM_LIST) ;+# ;+# Some platforms take symbols in the form of a sym list with some prefix, ;+# for instance the MAC symbol table can be processed with the above command ;+# plus an extra -e 's,^,_,' to the sed command above. HP symbols can be ;+# processed by adding an extra -e 's,^,-e ,'. ;+# ;+COOLKEY_2.10 { # Cool Key 2.10 is the PKCS #11 spec version ;+ global: LIBRARY coolkey ;- EXPORTS ;- C_GetFunctionList ;+# Make this function like a real PKCS #11 module as well C_CancelFunction; C_CloseAllSessions; C_CloseSession; C_CopyObject; C_CreateObject; C_Decrypt; C_DecryptDigestUpdate; C_DecryptFinal; C_DecryptInit; C_DecryptUpdate; C_DecryptVerifyUpdate; C_DeriveKey; C_DestroyObject; C_Digest; C_DigestEncryptUpdate; C_DigestFinal; C_DigestInit; C_DigestKey; C_DigestUpdate; C_Encrypt; C_EncryptFinal; C_EncryptInit; C_EncryptUpdate; C_Finalize; C_FindObjects; C_FindObjectsFinal; C_FindObjectsInit; C_GenerateKey; C_GenerateKeyPair; C_GenerateRandom; C_GetAttributeValue; C_GetFunctionStatus; C_GetInfo; C_GetMechanismInfo; C_GetMechanismList; C_GetObjectSize; C_GetOperationState; C_GetSessionInfo; C_GetSlotInfo; C_GetSlotList; C_GetTokenInfo; C_Initialize; C_InitPIN; C_InitToken; ;+ local: ;+ *; ;+}; --- NEW FILE coolkeypk11.rc --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #define COOLKEY_VERSION "beta" #define COOLKEY_VMAJOR 0 #define COOLKEY_VMINOR 9 #define COOLKEY_VPATCH 0 #define COOLKEY_BETA PR_TRUE #include #define MY_LIBNAME "coolkeypk11" #define MY_FILEDESCRIPTION "CoolKey PKCS #11 Library" #define STRINGIZE(x) #x #define STRINGIZE2(x) STRINGIZE(x) #define COOLKEY_VMAJOR_STR STRINGIZE2(COOLKEY_VMAJOR) #ifdef _DEBUG #define MY_DEBUG_STR " (debug)" #define MY_FILEFLAGS_1 VS_FF_DEBUG #else #define MY_DEBUG_STR "" #define MY_FILEFLAGS_1 0x0L #endif #if COOLKEY_BETA #define MY_FILEFLAGS_2 MY_FILEFLAGS_1|VS_FF_PRERELEASE #else #define MY_FILEFLAGS_2 MY_FILEFLAGS_1 #endif #ifdef WINNT #define MY_FILEOS VOS_NT_WINDOWS32 #else #define MY_FILEOS VOS__WINDOWS32 #endif #define MY_INTERNAL_NAME MY_LIBNAME COOLKEY_VMAJOR_STR ///////////////////////////////////////////////////////////////////////////// // // Version-information resource // VS_VERSION_INFO VERSIONINFO FILEVERSION COOLKEY_VMAJOR,COOLKEY_VMINOR,COOLKEY_VPATCH,0 PRODUCTVERSION COOLKEY_VMAJOR,COOLKEY_VMINOR,COOLKEY_VPATCH,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS MY_FILEFLAGS_2 FILEOS MY_FILEOS FILETYPE VFT_DLL FILESUBTYPE 0x0L // not used BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904B0" // Lang=US English, CharSet=Unicode BEGIN VALUE "CompanyName", "Mozilla Foundation\0" VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0" VALUE "FileVersion", COOLKEY_VERSION "\0" VALUE "InternalName", MY_INTERNAL_NAME "\0" VALUE "LegalCopyright", "Copyright \251 2005 Red Hat, Inc.\0" VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0" VALUE "ProductName", "CoolKey\0" VALUE "ProductVersion", COOLKEY_VERSION "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END --- NEW FILE dllmain.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifdef WIN32 #include BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: break; } return TRUE; } #endif --- NEW FILE locking.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #include #include "mypkcs11.h" #include #include "locking.h" #include "log.h" #include "PKCS11Exception.h" class BasicMutex : public Mutex { public: BasicMutex(CK_C_INITIALIZE_ARGS *initArgs); virtual ~BasicMutex(); virtual void lock(); virtual void unlock(); private: void *mutex; CK_C_INITIALIZE_ARGS *initArgs; }; class DummyMutex : public Mutex { public: virtual ~DummyMutex() { } virtual void lock() { } virtual void unlock() { } }; BasicMutex::BasicMutex(CK_C_INITIALIZE_ARGS *initArgs_) : initArgs(initArgs_) { assert( initArgs->CreateMutex != NULL ); assert( initArgs->DestroyMutex != NULL ); assert( initArgs->LockMutex != NULL ); assert( initArgs->UnlockMutex != NULL ); CK_RV crv = initArgs->CreateMutex(&mutex); if( crv != CKR_OK ) { throw PKCS11Exception(crv, "CreateMutex"); } } BasicMutex::~BasicMutex() { CK_RV crv = initArgs->DestroyMutex(mutex); if( crv != CKR_OK ) { throw PKCS11Exception(crv, "DestroyMutex"); } } void BasicMutex::lock() { CK_RV crv = initArgs->LockMutex(mutex); assert(crv != CKR_MUTEX_BAD); if( crv != CKR_OK ) { throw PKCS11Exception(crv, "LockMutex"); } } void BasicMutex::unlock() { CK_RV crv = initArgs->UnlockMutex(mutex); assert(crv != CKR_MUTEX_BAD); assert(crv != CKR_MUTEX_NOT_LOCKED); if( crv != CKR_OK ) { throw PKCS11Exception(crv, "UnlockMutex"); } } MutexFactory::MutexFactory(const CK_C_INITIALIZE_ARGS* initArgs_) : initArgs(NULL) { if( initArgs_ != NULL ) { if( initArgs_->CreateMutex == NULL || initArgs_->DestroyMutex == NULL || initArgs_->LockMutex == NULL || initArgs_->UnlockMutex == NULL ) { if( initArgs_->flags & CKF_OS_LOCKING_OK ) { // application wants us to lock with OS primitives, which // we can't do throw PKCS11Exception(CKR_CANT_LOCK, "Library cannot use OS locking primitives"); } else { // Application is single threaded, so we won't do any // locking. Leave initArgs == NULL. } } else { // use the provided primitives for locking initArgs = new CK_C_INITIALIZE_ARGS(*initArgs_); } } } MutexFactory::~MutexFactory() { if( initArgs != NULL ) { delete initArgs; } } Mutex* MutexFactory::createMutex() const { if( initArgs == NULL ) { return new DummyMutex(); } else { return new BasicMutex(initArgs); } } --- NEW FILE locking.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifndef COOLKEY_LOCKING_H #define COOLKEY_LOCKING_H #include "mypkcs11.h" #include class Mutex { public: virtual ~Mutex() { } virtual void lock()=0; virtual void unlock()=0; }; class MutexFactory { public: MutexFactory(const CK_C_INITIALIZE_ARGS* initArgs); ~MutexFactory(); Mutex* createMutex() const; private: CK_C_INITIALIZE_ARGS *initArgs; }; class Guardable; class Guard { public: Guard(Mutex& mutex_) : mutex(&mutex_) { mutex->lock(); } Guard(Mutex* mutex_) : mutex(mutex_) { mutex->lock(); } Guard(Guardable& g); Guard(Guardable* g); ~Guard() { if( mutex ) mutex->unlock(); } Guard(Guard& g) { mutex = g.mutex; g.mutex = 0; } Guard& operator=(Guard&g) { mutex = g.mutex; g.mutex = 0; return *this; } void unlock() { if( mutex ) mutex->unlock(); mutex = 0; } private: Mutex* mutex; }; class Guardable { private: friend class Guard; Mutex *mutex; public: Guardable(const MutexFactory* mutexFactory) { mutex = mutexFactory->createMutex(); } ~Guardable() { delete mutex; } }; inline Guard::Guard(Guardable& g) { mutex = g.mutex; mutex->lock(); } inline Guard::Guard(Guardable* g) { mutex = g->mutex; mutex->lock(); } #endif --- NEW FILE log.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #include #include "mypkcs11.h" #include #include #include "log.h" #include #include "PKCS11Exception.h" FileLog::FileLog(const char *filename ) { file = fopen(filename, "at"); if( file == NULL ) { throw PKCS11Exception(CKR_GENERAL_ERROR, "Failed to open logfile"); } } void FileLog::log(const char *msg, ...) { va_list ap; va_start(ap, msg); vfprintf(file, msg, ap); fflush(file); va_end(ap); } #define ROW_LENGTH 16 // dump the contents of an CKYBuffer, both in hex and 'ascii'. // change ROW_LENGTH above to change how many bytes are printed on a single // line void Log::dump(CKYBuffer *buf) { CKYSize i; CKYSize size = CKYBuffer_Size(buf); char string[ROW_LENGTH+1]; char *bp = &string[0]; CKYByte c; for (i=0; i < size; i++) { if (i && ((i % (ROW_LENGTH-1)) == 0) ) { *bp = 0; log(" %s\n",string); bp = &string[0]; } c = CKYBuffer_GetChar(buf, i); log("%02x ",c); *bp++ = (c < ' ') ? '.' : ((c & 0x80) ? '*' : c); } *bp = 0; for (i= (i % (ROW_LENGTH-1)); i && (i < ROW_LENGTH); i++) { log(" "); } log(" %s\n",string); } FileLog::~FileLog() { fclose(file); } --- NEW FILE log.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifndef COOLKEY_LOG_H #define COOLKEY_LOG_H #include #include #include class Log { public: virtual void log(const char *msg, ...) = 0; virtual void dump(CKYBuffer *buf); virtual ~Log() { } }; class DummyLog : public Log { public: DummyLog() { } void log(const char *msg, ...) { } void dump(CKYBuffer *buf) {} ~DummyLog() { } }; class FileLog : public Log { private: FILE *file; // not allowed FileLog(FileLog &) { } FileLog& operator=(FileLog&) { return *this; } public: FileLog(const char *filename); void log(const char *msg, ...); virtual ~FileLog(); }; #endif --- NEW FILE machdep.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #include "machdep.h" #include "mypkcs11.h" #include "PKCS11Exception.h" #ifdef _WIN32 #include #include #else #include #include #include #include #include #include #include #include #include #endif #ifdef _WIN32 // // Windows functions to grab a named shared memory segment of a specific size, // return whether or not it has been initialized, return it's size and address, // release it when done. // struct SHMemData { char *addr; HANDLE map; int size; SHMemData() : addr(0), map(0), size(0) {} }; SHMem::SHMem(): shmemData(0) {} SHMem * SHMem::initSegment(const char *name, int size, bool &init) { bool needInit; init = 0; SHMemData *shmemData = new SHMemData; if (!shmemData ) { // applications know we failed because they will get a NULL address // from getSHMemAddr. return NULL; } shmemData->map = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, name); if (!shmemData->map) { delete shmemData; return NULL; } needInit = (GetLastError() != ERROR_ALREADY_EXISTS); shmemData->addr = (char *)MapViewOfFile(shmemData->map, FILE_MAP_WRITE, 0, 0, 0 ); if (!shmemData->addr) { CloseHandle(shmemData->map); delete shmemData; return NULL; } shmemData->size = size; init = needInit; SHMem *memseg; memseg = new SHMem(); if (memseg) { memseg->shmemData = shmemData; } return memseg; } SHMem::~SHMem() { if (!shmemData) { return; } if (shmemData->addr) { UnmapViewOfFile(shmemData->addr); } if (shmemData->map) { CloseHandle(shmemData->map); } delete shmemData; } char * SHMem::getSHMemAddr() { return shmemData ? shmemData->addr : NULL; } int SHMem::getSHMemSize() { return shmemData ? shmemData->size : 0; } struct OSLockData { CRITICAL_SECTION mutex; }; OSLock::OSLock(bool exceptionAllowed) { lockData = new OSLockData; if (lockData) { InitializeCriticalSection(&lockData->mutex); } if (exceptionAllowed && !lockData) { throw PKCS11Exception(CKR_HOST_MEMORY, "lock allocation failed"); } } OSLock::~OSLock() { if (lockData) { DeleteCriticalSection(&lockData->mutex); delete lockData; } } bool OSLock::isValid() { return (bool) (lockData != NULL); } void OSLock::getLock() { if (lockData) { EnterCriticalSection(&lockData->mutex); } } void OSLock::releaseLock() { if (lockData) { LeaveCriticalSection(&lockData->mutex); } } OSTime OSTimeNow(void) { return GetTickCount(); } void OSSleep(int time) { Sleep(time); } #else // // MAC/Unix functions to grab a named shared memory segment of a specific size, // return whether or not it has been initialized, return it's size and address, // release it when done. // #ifdef O_EXLOCK #define FULL_CLEANUP #else /* if we can't lock on open, don't use locking for now */ #define O_EXLOCK 0 #endif #ifndef MAP_INHERIT #define MAP_INHERIT 0 #endif #ifdef FULL_CLEANUP #define RESERVED_OFFSET 256 #define MEMSEGPATH "/tmp/.pk11ipc" #else #define RESERVED_OFFSET 0 #define MEMSEGPATH "/tmp/.pk11ipc1" #endif struct SHMemData { char *path; char *addr; int fd; int size; SHMemData() : path(0), addr(0), fd(-1), size(0) {} ~SHMemData() ; }; SHMemData::~SHMemData() { if (addr) { /* memory adder implies the fd and path are valid as well */ #ifdef FULL_CLEANUP flock(fd,LOCK_EX); unsigned long ref = --(*(unsigned long *)addr); if (ref == 0) { unlink(path); } flock(fd, LOCK_UN); #endif munmap(addr,size+RESERVED_OFFSET); } if (fd > 0) { close(fd); } if (path) { delete [] path; } } SHMem::SHMem(): shmemData(0) {} SHMem * SHMem::initSegment(const char *name, int size, bool &init) { bool needInit = true; init = 0; SHMemData *shmemData = new SHMemData; if (!shmemData ) { // applications know we failed because they will get a NULL address // from getSHMemAddr. return NULL; } int ret = mkdir (MEMSEGPATH, 0755); if ((ret == -1) && (errno != EEXIST)) { delete shmemData; return NULL; } shmemData->path = new char [sizeof(MEMSEGPATH)+strlen(name)+2]; if (shmemData->path == NULL) { delete shmemData; return NULL; } memcpy(shmemData->path,MEMSEGPATH, sizeof(MEMSEGPATH)); shmemData->path[sizeof(MEMSEGPATH)-1] = '/'; strcpy(&shmemData->path[sizeof(MEMSEGPATH)],name); shmemData->fd = open(shmemData->path, O_CREAT|O_RDWR|O_EXCL|O_APPEND|O_EXLOCK, 0700); if (shmemData->fd < 0) { needInit = false; shmemData->fd = open(shmemData->path,O_RDWR|O_EXLOCK, 0700); } else { char *buf; int len = size+RESERVED_OFFSET; buf = (char *)calloc(1,len); if (!buf) { unlink(shmemData->path); #ifdef FULL_CLEANUP flock(shmemData->fd, LOCK_UN); #endif delete shmemData; return NULL; } write(shmemData->fd,buf,len); free(buf); } if (shmemData->fd < 0) { delete shmemData; return NULL; } shmemData->addr = (char *) mmap(0, size+RESERVED_OFFSET, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED|MAP_INHERIT, shmemData->fd, 0); if (shmemData->addr == NULL) { if (needInit) { unlink(shmemData->path); } #ifdef FULL_CLEANUP flock(shmemData->fd, LOCK_UN); #endif delete shmemData; return NULL; } shmemData->size = size; #ifdef FULL_CLEANUP (*(unsigned long *)shmemData->addr)++; flock(shmemData->fd, LOCK_UN); #endif init = needInit; SHMem *memseg; memseg = new SHMem(); if (!memseg) { delete shmemData; return NULL; } memseg->shmemData = shmemData; return memseg; } SHMem::~SHMem() { if (!shmemData) { return; } delete shmemData; } char * SHMem::getSHMemAddr() { return shmemData ? shmemData->addr+RESERVED_OFFSET : NULL; } int SHMem::getSHMemSize() { return shmemData ? shmemData->size : 0; } struct OSLockData { pthread_mutex_t mutex; }; static pthread_mutexattr_t OSLock_attr; static int OSLock_attr_init = 0; OSLock::OSLock(bool exceptionAllowed) { int rc; lockData = NULL; if (!OSLock_attr_init) { rc = pthread_mutexattr_init(&OSLock_attr); if (rc < 0) { if (exceptionAllowed) { throw PKCS11Exception(CKR_DEVICE_ERROR, "lock init failed"); } else { return; } } OSLock_attr_init = 1; } lockData = new OSLockData; if (lockData) { rc = pthread_mutex_init(&lockData->mutex, &OSLock_attr); if (rc < 0) { delete lockData; lockData = NULL; } } if (exceptionAllowed && !lockData) { throw PKCS11Exception(CKR_HOST_MEMORY, "lock allocation failed"); } } OSLock::~OSLock() { if (lockData) { pthread_mutex_destroy(&lockData->mutex); delete lockData; } } bool OSLock::isValid() { return (bool) (lockData != NULL); } void OSLock::getLock() { if (lockData) { pthread_mutex_lock(&lockData->mutex); } } void OSLock::releaseLock() { if (lockData) { pthread_mutex_unlock(&lockData->mutex); } } #ifdef USE_CLOCK OSTime OSTimeNow(void) { OSTime ostime; clock_t time; #if CLOCKS_PER_SEC < 1000 ostime = time * (1000/CLOCKS_PER_SEC); #else ostime = time / (CLOCKS_PER_SEC/1000); #endif return ostime; } #else OSTime OSTimeNow(void) { OSTime ostime; struct timeval tv; gettimeofday(&tv, NULL); ostime = tv.tv_usec/1000 + tv.tv_sec*1000; return ostime; } #endif void OSSleep(int time) { usleep(time); } #endif /* _WINDOWS */ --- NEW FILE machdep.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifndef COOLKEY_MACHDEP_H #define COOLKEY_MACHDEP_H /* * abstract away os dependencies in shared memory system */ struct SHMemData; class SHMem { private: SHMemData *shmemData; SHMem(); public: ~SHMem(); char *getSHMemAddr(); int getSHMemSize(); static SHMem *initSegment(const char *name, int size, bool &init); }; struct OSLockData; class OSLock { private: OSLockData *lockData; public: OSLock(bool exceptionAllowed = true); ~OSLock(); bool isValid(); void getLock(); void releaseLock(); }; typedef unsigned long OSTime; OSTime OSTimeNow(void); void OSSleep(int time); #define USE_SHMEM #endif --- NEW FILE manifest.mn --- # ***** BEGIN COPYRIGHT BLOCK ***** # Copyright (C) 2005 Red Hat, Inc. # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation version # 2.1 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ***** END COPYRIGHT BLOCK ***** CORE_DEPTH = ../.. MODULE = coolkeypk11 REQUIRES = ckyapplet zlib USE_STATIC_RTL=1 BASE_LIBRARY_NAME = coolkeypk11 LIBRARY_NAME = $(BASE_LIBRARY_NAME) MAPFILE = $(OBJDIR)/coolkeypk11.def DEFINES += -DSHLIB_SUFFIX=\"$(DLL_SUFFIX)\" -DSHLIB_PREFIX=\"$(DLL_PREFIX)\" \ -DPKCS11_LIB_NAME=\"$(notdir $(SHARED_LIBRARY))\" DEFINES += -DNSS_HIDE_NONSTANDARD_OBJECTS=1 CPPSRCS = \ coolkey.cpp \ dllmain.cpp \ locking.cpp \ log.cpp \ machdep.cpp \ object.cpp \ PKCS11Exception.cpp \ slot.cpp \ $(NULL) --- NEW FILE mypkcs11.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifndef COOLKEY_MYPKCS11_H #define COOLKEY_MYPKCS11_H #if defined(_WIN32) #define CK_PTR * #define CK_DECLARE_FUNCTION(rv,func) rv __declspec(dllexport) func #define CK_DECLARE_FUNCTION_POINTER(rv,func) rv (* func) #define CK_CALLBACK_FUNCTION(rv,func) rv (* func) #define CK_NULL_PTR 0 #else #define CK_PTR * #define CK_DECLARE_FUNCTION(rv,func) rv func #define CK_DECLARE_FUNCTION_POINTER(rv,func) rv (* func) #define CK_CALLBACK_FUNCTION(rv,func) rv (* func) #define CK_NULL_PTR 0 #endif #if defined(_WIN32) #pragma warning(disable:4103) #pragma pack(push, cryptoki, 1) #endif #include "pkcs11.h" #include "pkcs11n.h" #if defined (_WIN32) #pragma warning(disable:4103) #pragma pack(pop, cryptoki) #endif #endif --- NEW FILE object.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #include "mypkcs11.h" #include "PKCS11Exception.h" #include "object.h" #include using std::find_if; bool AttributeMatch::operator()(const PKCS11Attribute& cmp) { return (attr->type == cmp.getType()) && CKYBuffer_DataIsEqual(cmp.getValue(), (const CKYByte *)attr->pValue, attr->ulValueLen); } class AttributeTypeMatch { private: CK_ATTRIBUTE_TYPE type; public: AttributeTypeMatch(CK_ATTRIBUTE_TYPE type_) : type(type_) { } bool operator()(const PKCS11Attribute& cmp) { return cmp.getType() == type; } }; PKCS11Object::PKCS11Object(unsigned long muscleObjID_,CK_OBJECT_HANDLE handle_) : muscleObjID(muscleObjID_), handle(handle_), label(NULL), name(NULL) { CKYBuffer_InitEmpty(&pubKey); } PKCS11Object::PKCS11Object(unsigned long muscleObjID_, const CKYBuffer *data, CK_OBJECT_HANDLE handle_) : muscleObjID(muscleObjID_), handle(handle_), label(NULL), name(NULL) { CKYBuffer_InitEmpty(&pubKey); CKYByte type = CKYBuffer_GetChar(data,0); // verify object ID is what we think it is if( CKYBuffer_GetLong(data,1) != muscleObjID ) { throw PKCS11Exception(CKR_DEVICE_ERROR, "PKCS #11 actual object id does not match stated id"); } if (type == 0) { parseOldObject(data); } else if (type == 1) { parseNewObject(data); } } void PKCS11Object::parseOldObject(const CKYBuffer *data) { if( CKYBuffer_Size(data) < 7 ) { throw PKCS11Exception(CKR_DEVICE_ERROR, "Invalid PKCS#11 object size %d", CKYBuffer_Size(data)); } // get the amount of attribute data, make sure it makes sense unsigned int attrDataLen = CKYBuffer_GetShort(data, 5); if( CKYBuffer_Size(data) != attrDataLen + 7 ) { throw PKCS11Exception(CKR_DEVICE_ERROR, "PKCS #11 actual attribute data length %d does not match" " stated length %d", CKYBuffer_Size(data)-7, attrDataLen); } unsigned int idx = 7; while( idx < CKYBuffer_Size(data) ) { if( idx - CKYBuffer_Size(data) < 6 ) { throw PKCS11Exception(CKR_DEVICE_ERROR, "Error parsing attribute"); } PKCS11Attribute attrib; attrib.setType(CKYBuffer_GetLong(data, idx)); idx += 4; unsigned int attrLen = CKYBuffer_GetShort(data, idx); idx += 2; if( attrLen > CKYBuffer_Size(data) || (idx + attrLen > CKYBuffer_Size(data)) ) { throw PKCS11Exception(CKR_DEVICE_ERROR, "Invalid attribute length %d\n", attrLen); } /* these two types are ints, read them back from * the card in host order */ if ((attrib.getType() == CKA_CLASS) || (attrib.getType() == CKA_CERTIFICATE_TYPE) || (attrib.getType() == CKA_KEY_TYPE)) { if (attrLen != sizeof (CK_ULONG)) { throw PKCS11Exception(CKR_DEVICE_ERROR, "Invalid attribute length %d\n", attrLen); } CK_ULONG value = makeLEUInt(data,idx); attrib.setValue((const CKYByte *)&value, sizeof(CK_ULONG)); } else { attrib.setValue(CKYBuffer_Data(data)+idx, attrLen); } idx += attrLen; attributes.push_back(attrib); } } // // masks which determine the valid flag bits for specific objects // // objects are : flags are: // 0 CKO_DATA PRIVATE, MODIFIABLE, TOKEN // 1 CKO_CERTIFICATE PRIVATE, MODIFIABLE, TOKEN // 2 CKO_PUBLIC_KEY PRIVATE, MODIFIABLE, TOKEN // DERIVE, LOCAL, ENCRYPT, WRAP // VERIFY, VERIFY_RECOVER // 3 CKO_PRIVATE_KEY PRIVATE, MODIFIABLE, TOKEN // DERIVE, LOCAL, DECRYPT, UNWRAP // SIGN, SIGN_RECOVER, SENSITIVE, // ALWAYS_SENSITIVE, EXTRACTABLE, // NEVER_EXTRACTABLE // 4 CKO_SECRET_KEY PRIVATE, MODIFIABLE, TOKEN // DERIVE, LOCAL, ENCRYPT, DECRYPT, // WRAP, UNWRAP, SIGN, VERIFY, // SENSITIVE, ALWAYS_SENSITIVE, // EXTRACTABLE, NEVER_EXTRACTABLE // 5-7 RESERVED NONE // const unsigned long boolMask[8] = { 0x00000380, 0x00000380, 0x000c5f80, 0x00f3af80, 0x00f5ff80, 0x00000000, 0x00000000, 0x00000000 }; // // map a mask bit position to CKA_ flag value. // const CK_ATTRIBUTE_TYPE boolType[32] = { 0, 0, 0, 0, 0, 0, 0, CKA_TOKEN, CKA_PRIVATE, CKA_MODIFIABLE, CKA_DERIVE, CKA_LOCAL, CKA_ENCRYPT, CKA_DECRYPT, CKA_WRAP, CKA_UNWRAP, CKA_SIGN, CKA_SIGN_RECOVER, CKA_VERIFY, CKA_VERIFY_RECOVER, CKA_SENSITIVE, CKA_ALWAYS_SENSITIVE, CKA_EXTRACTABLE, CKA_NEVER_EXTRACTABLE, 0, 0, 0, 0, 0, 0, 0, 0, }; void PKCS11Object::expandAttributes(unsigned long fixedAttrs) { CKYByte cka_id = (CKYByte) (fixedAttrs & 0xf); CK_OBJECT_CLASS objectType = (fixedAttrs >> 4) & 0x7; unsigned long mask = boolMask[objectType]; unsigned long i; if (!attributeExists(CKA_ID)) { PKCS11Attribute attrib; attrib.setType(CKA_ID); attrib.setValue(&cka_id, 1); attributes.push_back(attrib); } /* unpack the class */ if (!attributeExists(CKA_CLASS)) { PKCS11Attribute attrib; attrib.setType(CKA_CLASS); attrib.setValue((CKYByte *)&objectType, 4); attributes.push_back(attrib); } /* unpack the boolean flags. Note, the default mask is based on * the class specified in fixedAttrs, not on the real class */ for (i=1; i < sizeof(unsigned long)*8; i++) { unsigned long iMask = 1<< i; if ((mask & iMask) == 0) { continue; } if (attributeExists(boolType[i])) { continue; } PKCS11Attribute attrib; CKYByte bVal = (fixedAttrs & iMask) != 0; attrib.setType(boolType[i]); attrib.setValue(&bVal, 1); attributes.push_back(attrib); } } void PKCS11Object::parseNewObject(const CKYBuffer *data) { if( CKYBuffer_Size(data) < 11 ) { throw PKCS11Exception(CKR_DEVICE_ERROR, "Invalid PKCS#11 object size %d", CKYBuffer_Size(data)); } unsigned short attributeCount = CKYBuffer_GetShort(data, 9); unsigned long fixedAttrs = CKYBuffer_GetLong(data, 5); unsigned long offset = 11; CKYSize size = CKYBuffer_Size(data); int j; // load up the explicit attributes first for (j=0, offset = 11; j < attributeCount && offset < size; j++) { PKCS11Attribute attrib; CKYByte attributeDataType = CKYBuffer_GetChar(data, offset+4); unsigned int attrLen = 0; attrib.setType(CKYBuffer_GetLong(data, offset)); offset += 5; switch(attributeDataType) { case DATATYPE_STRING: attrLen = CKYBuffer_GetShort(data, offset); offset += 2; if (attrLen > CKYBuffer_Size(data) || (offset + attrLen > CKYBuffer_Size(data)) ) { throw PKCS11Exception(CKR_DEVICE_ERROR, "Invalid attribute length %d\n", attrLen); } attrib.setValue(CKYBuffer_Data(data)+offset, attrLen); break; case DATATYPE_BOOL_FALSE: case DATATYPE_BOOL_TRUE: { CKYByte bval = attributeDataType & 1; attrib.setValue(&bval, 1); } break; case DATATYPE_INTEGER: { CK_ULONG value = CKYBuffer_GetLong(data, offset); attrLen = 4; attrib.setValue((const CKYByte *)&value, sizeof(CK_ULONG)); } break; default: throw PKCS11Exception(CKR_DEVICE_ERROR, "Invalid attribute Data Type %d\n", attributeDataType); } offset += attrLen; attributes.push_back(attrib); } expandAttributes(fixedAttrs); } #if defined( NSS_HIDE_NONSTANDARD_OBJECTS ) static const CK_OBJECT_CLASS rdr_class = CKO_MOZ_READER; static const CK_BBOOL rdr_true = TRUE; static const CK_ATTRIBUTE rdr_template[] = { {CKA_CLASS, (void *)&rdr_class, sizeof rdr_class }, {CKA_MOZ_IS_COOL_KEY, (void *)&rdr_true, sizeof rdr_true } }; #endif bool PKCS11Object::matchesTemplate(const CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) const { unsigned int i; typedef std::list::const_iterator iterator; #if defined( NSS_HIDE_NONSTANDARD_OBJECTS ) if (!ulCount) { // exclude MOZ reader objects from searches for all objects. // To find an MOZ reader object, one must search for it by // some matching attribute, such as class. iterator iter = find_if(attributes.begin(), attributes.end(), AttributeMatch(&rdr_template[0])); return (iter == attributes.end()) ? true : false; } #endif // loop over all attributes in the template for( i = 0; i < ulCount; ++i ) { // lookup this attribute in our object iterator iter = find_if(attributes.begin(), attributes.end(), AttributeMatch(pTemplate+i)); if( iter == attributes.end() ) { // attribute not found. Template does not match. return false; } } // all attributes found. template matches. return true; } bool PKCS11Object::attributeExists(CK_ATTRIBUTE_TYPE type) const { // find matching attribute AttributeConstIter iter = find_if(attributes.begin(), attributes.end(), AttributeTypeMatch(type)); return (bool)(iter != attributes.end()); } const CKYBuffer * PKCS11Object::getAttribute(CK_ATTRIBUTE_TYPE type) const { AttributeConstIter iter = find_if(attributes.begin(), attributes.end(), AttributeTypeMatch(type)); if( iter == attributes.end() ) { return NULL; } return iter->getValue(); } void PKCS11Object::getAttributeValue(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, Log* log) const { // keep track if these error conditions are true for any attribute bool attrTypeInvalid = false; bool bufferTooSmall = false; unsigned int i; // loop over all attributes in the template for( i = 0; i < ulCount; ++i ) { // find matching attribute AttributeConstIter iter = find_if(attributes.begin(), attributes.end(), AttributeTypeMatch(pTemplate[i].type)); if( iter == attributes.end() ) { // no attribute of this type attrTypeInvalid = true; log->log("GetAttributeValue: invalid type 0x%08x on object %x\n", pTemplate[i].type, muscleObjID); pTemplate[i].ulValueLen = (CK_ULONG)-1; continue; } if( pTemplate[i].pValue == NULL ) { // Buffer not supplied for this attribute. We just set the length. pTemplate[i].ulValueLen = CKYBuffer_Size(iter->getValue()); continue; } if( pTemplate[i].ulValueLen < CKYBuffer_Size(iter->getValue()) ) { // supplied buffer is not large enough. pTemplate[i].ulValueLen = (CK_ULONG)-1; bufferTooSmall = true; continue; } // the buffer is large enough. return the value and set the exact // length. memcpy(pTemplate[i].pValue, CKYBuffer_Data(iter->getValue()), CKYBuffer_Size(iter->getValue())); pTemplate[i].ulValueLen = CKYBuffer_Size(iter->getValue()); } if( attrTypeInvalid ) { // At least one of the attribute types was invalid. // Return CKR_ATTRIBUTE_TYPE_INVALID. This is not really an // error condition. throw PKCS11Exception(CKR_ATTRIBUTE_TYPE_INVALID); } if( bufferTooSmall ) { // At least one of the supplied buffers was too small. // Return CKR_BUFFER_TOO_SMALL. This is not really an error // condition. throw PKCS11Exception(CKR_BUFFER_TOO_SMALL); } // no problems, just return CKR_OK } const char * PKCS11Object::getLabel() { // clean up old one if (label) { delete label; label = NULL; } // find matching attribute AttributeConstIter iter = find_if(attributes.begin(), attributes.end(), AttributeTypeMatch(CKA_LABEL)); // none found if( iter == attributes.end() ) { return ""; } int size = CKYBuffer_Size(iter->getValue()); label = new char [ size + 1 ]; if (!label) { return ""; } memcpy(label, CKYBuffer_Data(iter->getValue()), size); label[size] = 0; return label; } CK_OBJECT_CLASS PKCS11Object::getClass() { CK_OBJECT_CLASS objClass; // find matching attribute AttributeConstIter iter = find_if(attributes.begin(), attributes.end(), AttributeTypeMatch(CKA_CLASS)); // none found */ if( iter == attributes.end() ) { return (CK_OBJECT_CLASS) -1; } int size = CKYBuffer_Size(iter->getValue()); if (size != sizeof(objClass)) { return (CK_OBJECT_CLASS) -1; } memcpy(&objClass, CKYBuffer_Data(iter->getValue()), size); return objClass; } void PKCS11Object::setAttribute(CK_ATTRIBUTE_TYPE type, const CKYBuffer *value) { AttributeIter iter; iter = find_if(attributes.begin(), attributes.end(), AttributeTypeMatch(type)); if( iter != attributes.end() ) { iter->setValue( CKYBuffer_Data(value), CKYBuffer_Size(value)); } else { attributes.push_back(PKCS11Attribute(type, value)); } } void PKCS11Object::setAttribute(CK_ATTRIBUTE_TYPE type, const char *string) { CKYBuffer buf; CKYBuffer_InitFromData(&buf, (const CKYByte *)string, strlen(string)); setAttribute(type, &buf); CKYBuffer_FreeData(&buf); } void PKCS11Object::setAttributeBool(CK_ATTRIBUTE_TYPE type, CK_BBOOL value) { CKYBuffer buf; CKYBuffer_InitFromData(&buf, &value, sizeof(CK_BBOOL)); setAttribute(type,&buf); CKYBuffer_FreeData(&buf); } void PKCS11Object::setAttributeULong(CK_ATTRIBUTE_TYPE type, CK_ULONG value) { CKYBuffer buf; CKYBuffer_InitFromData(&buf, (const CKYByte *)&value, sizeof(CK_ULONG)); setAttribute(type, &buf); CKYBuffer_FreeData(&buf); } typedef struct { const CKYByte*data; unsigned int len; } CCItem; typedef enum { SECSuccess=0, SECFailure=1 } SECStatus; static const CKYByte* dataStart(const CKYByte *buf, unsigned int length, unsigned int *data_length, bool includeTag) { unsigned char tag; unsigned int used_length= 0; tag = buf[used_length++]; /* blow out when we come to the end */ if (tag == 0) { return NULL; } *data_length = buf[used_length++]; if (*data_length&0x80) { int len_count = *data_length & 0x7f; *data_length = 0; while (len_count-- > 0) { *data_length = (*data_length << 8) | buf[used_length++]; } } if (*data_length > (length-used_length) ) { *data_length = length-used_length; return NULL; } if (includeTag) *data_length += used_length; return (buf + (includeTag ? 0 : used_length)); } static const CKYByte * unwrapBitString(const CKYByte *buf, unsigned int len, unsigned int *retLen) { /* for RSA, bit string always has byte number of bits */ if (buf[0] != 0) { return NULL; } if (len < 1) { return NULL; } *retLen = len -1; return buf+1; } static SECStatus GetKeyFieldItems(const CKYByte *spki_data,unsigned int spki_length, CCItem *modulus, CCItem *exponent) { const CKYByte *buf = spki_data; unsigned int buf_length = spki_length; const CKYByte*dummy; unsigned int dummylen; /* skip past the algorithm id */ dummy = dataStart(buf,buf_length,&dummylen,false); if (dummy == NULL) return SECFailure; buf_length -= (dummy-buf) + dummylen; buf = dummy + dummylen; /* unwrap the public key info */ buf = dataStart(buf,buf_length,&buf_length,false); if (buf == NULL) return SECFailure; buf = unwrapBitString(buf,buf_length,&buf_length); if (buf == NULL) return SECFailure; buf = dataStart(buf,buf_length,&buf_length, false); if (buf == NULL) return SECFailure; /* read the modulus */ modulus->data = dataStart(buf,buf_length,&modulus->len,false); if (modulus->data == NULL) return SECFailure; buf_length -= (modulus->data-buf) + modulus->len; buf = modulus->data + modulus->len; /* read the exponent */ exponent->data = dataStart(buf,buf_length,&exponent->len,false); if (exponent->data == NULL) return SECFailure; buf_length -= (exponent->data-buf) + exponent->len; buf = exponent->data + exponent->len; return SECSuccess; } static void GetKeyFields(const CKYBuffer *spki, CKYBuffer *modulus, CKYBuffer *exponent) { SECStatus rv; CCItem modulusItem, exponentItem; rv = GetKeyFieldItems(CKYBuffer_Data(spki), CKYBuffer_Size(spki), &modulusItem, &exponentItem); if( rv != SECSuccess ) { throw PKCS11Exception(CKR_FUNCTION_FAILED, "Failed to decode certificate Subject Public Key Info"); } CKYBuffer_Replace(modulus, 0, modulusItem.data, modulusItem.len); CKYBuffer_Replace(exponent, 0, exponentItem.data, exponentItem.len); } Key::Key(unsigned long muscleObjID, const CKYBuffer *data, CK_OBJECT_HANDLE handle) : PKCS11Object(muscleObjID, data, handle) { // infer key attributes CK_OBJECT_CLASS objClass = getClass(); CKYBuffer empty; CKYBuffer_InitEmpty(&empty); if ((objClass == CKO_PUBLIC_KEY) || (objClass == CKO_PRIVATE_KEY)) { /* only CKK_RSA is supported */ setAttributeULong(CKA_KEY_TYPE, CKK_RSA); } else if (objClass == CKO_SECRET_KEY) { if (!attributeExists(CKA_LABEL)) { setAttribute(CKA_LABEL, &empty); } if (!attributeExists(CKA_KEY_TYPE)) { /* default to DES3 */ setAttributeULong(CKA_KEY_TYPE, CKK_DES3); } } if (!attributeExists(CKA_START_DATE)) { setAttribute(CKA_START_DATE, &empty); } if (!attributeExists(CKA_END_DATE)) { setAttribute(CKA_END_DATE, &empty); } } void Key::completeKey(const PKCS11Object &cert) { // infer key attributes from cert bool modulusExists, exponentExists; CKYBuffer modulus; CKYBuffer_InitEmpty(&modulus); CKYBuffer exponent; CKYBuffer_InitEmpty(&exponent); if (!attributeExists(CKA_LABEL)) { setAttribute(CKA_LABEL, cert.getAttribute(CKA_LABEL)); } try { modulusExists = attributeExists(CKA_MODULUS); exponentExists = attributeExists(CKA_PUBLIC_EXPONENT); if (!modulusExists || !exponentExists) { const CKYBuffer *key = cert.getPubKey(); GetKeyFields(key, &modulus, &exponent); if (!modulusExists) { setAttribute(CKA_MODULUS, &modulus); } if (!exponentExists) { setAttribute(CKA_PUBLIC_EXPONENT, &exponent); } } } catch (PKCS11Exception &e) { CKYBuffer_FreeData(&modulus); CKYBuffer_FreeData(&exponent); throw e; } CKYBuffer_FreeData(&modulus); CKYBuffer_FreeData(&exponent); } static SECStatus GetCertFieldItems(const CKYByte *dercert,unsigned int cert_length, CCItem *issuer, CCItem *serial, CCItem *derSN, CCItem *subject, CCItem *valid, CCItem *subjkey) { const CKYByte *buf; unsigned int buf_length; const CKYByte*dummy; unsigned int dummylen; /* get past the signature wrap */ buf = dataStart(dercert,cert_length,&buf_length, false); if (buf == NULL) return SECFailure; /* get into the raw cert data */ buf = dataStart(buf,buf_length,&buf_length,false); if (buf == NULL) return SECFailure; /* skip past any optional version number */ if ((buf[0] & 0xa0) == 0xa0) { dummy = dataStart(buf,buf_length,&dummylen,false); if (dummy == NULL) return SECFailure; buf_length -= (dummy-buf) + dummylen; buf = dummy + dummylen; } /* serial number */ if (derSN) { derSN->data=dataStart(buf,buf_length,&derSN->len,true); } serial->data = dataStart(buf,buf_length,&serial->len,false); if (serial->data == NULL) return SECFailure; buf_length -= (serial->data-buf) + serial->len; buf = serial->data + serial->len; /* skip the OID */ dummy = dataStart(buf,buf_length,&dummylen,false); if (dummy == NULL) return SECFailure; buf_length -= (dummy-buf) + dummylen; buf = dummy + dummylen; /* issuer */ issuer->data = dataStart(buf,buf_length,&issuer->len,true); if (issuer->data == NULL) return SECFailure; buf_length -= (issuer->data-buf) + issuer->len; buf = issuer->data + issuer->len; /* validity */ valid->data = dataStart(buf,buf_length,&valid->len,false); if (valid->data == NULL) return SECFailure; buf_length -= (valid->data-buf) + valid->len; buf = valid->data + valid->len; /*subject */ subject->data=dataStart(buf,buf_length,&subject->len,true); if (subject->data == NULL) return SECFailure; buf_length -= (subject->data-buf) + subject->len; buf = subject->data + subject->len; /* subject key info */ subjkey->data=dataStart(buf,buf_length,&subjkey->len,false); if (subjkey->data == NULL) return SECFailure; buf_length -= (subjkey->data-buf) + subjkey->len; buf = subjkey->data + subjkey->len; return SECSuccess; } static void GetCertFields(const CKYBuffer *derCert, CKYBuffer *derSerial, CKYBuffer *derSubject, CKYBuffer *derIssuer, CKYBuffer *subjectKey) { SECStatus rv; CCItem issuerItem, serialItem, derSerialItem, subjectItem, validityItem, subjectKeyItem; rv = GetCertFieldItems(CKYBuffer_Data(derCert), CKYBuffer_Size(derCert), &issuerItem, &serialItem, &derSerialItem, &subjectItem, &validityItem, &subjectKeyItem); if( rv != SECSuccess ) { throw PKCS11Exception(CKR_FUNCTION_FAILED, "Failed to decode DER certificate"); } CKYBuffer_Replace(derSerial, 0, derSerialItem.data, derSerialItem.len); CKYBuffer_Replace(derIssuer, 0, issuerItem.data, issuerItem.len); CKYBuffer_Replace(derSubject, 0, subjectItem.data, subjectItem.len); CKYBuffer_Replace(subjectKey, 0, subjectKeyItem.data, subjectKeyItem.len); } Cert::Cert(unsigned long muscleObjID, const CKYBuffer *data, CK_OBJECT_HANDLE handle, const CKYBuffer *derCert) : PKCS11Object(muscleObjID, data, handle) { CKYBuffer derSerial; CKYBuffer_InitEmpty(&derSerial); CKYBuffer derSubject; CKYBuffer_InitEmpty(&derSubject); CKYBuffer derIssuer; CKYBuffer_InitEmpty(&derIssuer); CKYBuffer certType; CK_ULONG certTypeValue = CKC_X_509; CKYBuffer_InitFromData(&certType, (CKYByte *)&certTypeValue, sizeof(certTypeValue)); CKYBuffer_Resize(&pubKey,0); try { setAttribute(CKA_CERTIFICATE_TYPE, &certType); if (!attributeExists(CKA_VALUE)) { if (derCert) { setAttribute(CKA_VALUE, derCert); } else { throw PKCS11Exception(CKR_DEVICE_ERROR, "Missing certificate data from token"); } } if (!derCert) { derCert = getAttribute(CKA_VALUE); if (!derCert) { // paranoia, should never happen since we verify the // attribute exists above throw PKCS11Exception(CKR_DEVICE_ERROR, "Missing certificate data from token"); } } // infer cert attributes GetCertFields(derCert, &derSerial, &derSubject, &derIssuer, &pubKey); if (!attributeExists(CKA_SERIAL_NUMBER)) { setAttribute(CKA_SERIAL_NUMBER, &derSerial); } if (!attributeExists(CKA_SUBJECT)) { setAttribute(CKA_SUBJECT, &derSubject); } if (!attributeExists(CKA_ISSUER)) { setAttribute(CKA_ISSUER, &derIssuer); } } catch (PKCS11Exception &e) { CKYBuffer_FreeData(&certType); CKYBuffer_FreeData(&derSerial); CKYBuffer_FreeData(&derSubject); CKYBuffer_FreeData(&derIssuer); throw e; } CKYBuffer_FreeData(&certType); CKYBuffer_FreeData(&derSerial); CKYBuffer_FreeData(&derSubject); CKYBuffer_FreeData(&derIssuer); } Reader::Reader(unsigned long muscleObjID, CK_OBJECT_HANDLE handle, const char *reader, const CKYBuffer *cardATR, bool isCoolkey) : PKCS11Object(muscleObjID, handle) { setAttributeULong(CKA_CLASS, CKO_MOZ_READER); setAttribute(CKA_LABEL, reader); setAttributeBool(CKA_TOKEN, TRUE); setAttributeBool(CKA_PRIVATE, FALSE); setAttributeBool(CKA_MODIFIABLE, FALSE); setAttributeBool(CKA_MOZ_IS_COOL_KEY, isCoolkey ? TRUE : FALSE); setAttribute(CKA_MOZ_ATR, cardATR); } CACPrivKey::CACPrivKey(CKYByte instance, const PKCS11Object &cert) : PKCS11Object( ((int)'k') << 24 | ((int)instance+'0') << 16, instance | 0x400) { CKYBuffer id; CKYBuffer empty; CK_BBOOL decrypt = FALSE; /* So we know what the key is supposed to be used for based on * the instance */ if (instance == 2) { decrypt = TRUE; } CKYBuffer_InitEmpty(&empty); setAttributeULong(CKA_CLASS, CKO_PRIVATE_KEY); setAttributeBool(CKA_TOKEN, TRUE); setAttributeBool(CKA_PRIVATE, FALSE); setAttribute(CKA_LABEL, cert.getAttribute(CKA_LABEL)); setAttributeBool(CKA_MODIFIABLE, FALSE); CKYBuffer_InitFromLen(&id, 1); CKYBuffer_SetChar(&id, 1, instance+1); setAttribute(CKA_ID, &id); CKYBuffer_FreeData(&id); setAttribute(CKA_START_DATE, &empty); setAttribute(CKA_END_DATE, &empty); setAttributeBool(CKA_DERIVE, FALSE); setAttributeBool(CKA_LOCAL, TRUE); setAttributeULong(CKA_KEY_TYPE, CKK_RSA); setAttributeBool(CKA_DECRYPT, decrypt); setAttributeBool(CKA_SIGN, !decrypt); setAttributeBool(CKA_SIGN_RECOVER, !decrypt); setAttributeBool(CKA_UNWRAP, FALSE); setAttributeBool(CKA_SENSITIVE, TRUE); setAttributeBool(CKA_EXTRACTABLE, FALSE); CKYBuffer modulus; CKYBuffer_InitEmpty(&modulus); CKYBuffer exponent; CKYBuffer_InitEmpty(&exponent); try { const CKYBuffer *key = cert.getPubKey(); GetKeyFields(key, &modulus, &exponent); setAttribute(CKA_MODULUS, &modulus); setAttribute(CKA_PUBLIC_EXPONENT, &exponent); } catch (PKCS11Exception &e) { CKYBuffer_FreeData(&modulus); CKYBuffer_FreeData(&exponent); throw e; } CKYBuffer_FreeData(&modulus); CKYBuffer_FreeData(&exponent); } CACPubKey::CACPubKey(CKYByte instance, const PKCS11Object &cert) : PKCS11Object( ((int)'k') << 24 | ((int)(instance+'5')) << 16, instance | 0x500) { CKYBuffer id; CKYBuffer empty; CK_BBOOL encrypt = FALSE; /* So we know what the key is supposed to be used for based on * the instance */ if (instance == 2) { encrypt = TRUE; } CKYBuffer_InitEmpty(&empty); setAttributeULong(CKA_CLASS, CKO_PUBLIC_KEY); setAttributeBool(CKA_TOKEN, TRUE); setAttributeBool(CKA_PRIVATE, FALSE); setAttribute(CKA_LABEL, cert.getAttribute(CKA_LABEL)); setAttributeBool(CKA_MODIFIABLE, FALSE); CKYBuffer_InitFromLen(&id, 1); CKYBuffer_SetChar(&id, 1, instance+1); setAttribute(CKA_ID, &id); CKYBuffer_FreeData(&id); setAttribute(CKA_START_DATE, &empty); setAttribute(CKA_END_DATE, &empty); setAttributeBool(CKA_DERIVE, FALSE); setAttributeBool(CKA_LOCAL, TRUE); setAttributeULong(CKA_KEY_TYPE, CKK_RSA); setAttributeBool(CKA_ENCRYPT, encrypt); setAttributeBool(CKA_VERIFY, !encrypt); setAttributeBool(CKA_VERIFY_RECOVER, !encrypt); setAttributeBool(CKA_WRAP, FALSE); CKYBuffer modulus; CKYBuffer_InitEmpty(&modulus); CKYBuffer exponent; CKYBuffer_InitEmpty(&exponent); try { const CKYBuffer *key = cert.getPubKey(); GetKeyFields(key, &modulus, &exponent); setAttribute(CKA_MODULUS, &modulus); setAttribute(CKA_PUBLIC_EXPONENT, &exponent); } catch (PKCS11Exception &e) { CKYBuffer_FreeData(&modulus); CKYBuffer_FreeData(&exponent); throw e; } CKYBuffer_FreeData(&modulus); CKYBuffer_FreeData(&exponent); } static const char *CAC_Label[] = { "CAC ID Certificate", "CAC Email Signature Certificate", "CAC Email Encryption Certificate", }; static const unsigned char CN_DATA[] = { 0x55, 0x4, 0x3 }; const unsigned int CN_LENGTH = sizeof(CN_DATA); static SECStatus GetCN(const CKYByte *dn, unsigned int dn_length, CCItem *cn) { const CKYByte *buf; unsigned int buf_length; /* unwrap the sequence */ buf = dataStart(dn,dn_length,&buf_length, false); if (buf == NULL) return SECFailure; while (buf_length) { const CKYByte *name; unsigned int name_length; const CKYByte *oid; unsigned int oid_length; /* unwrap the set */ name = dataStart(buf, buf_length, &name_length, false); /* advance to next set */ buf_length -= (name-buf) + name_length; buf = name + name_length; /* unwrap the Sequence */ name = dataStart(name, name_length, &name_length, false); /* unwrap the oid */ oid = dataStart(name, name_length, &oid_length, false); /* test the oid */ if (oid_length != CN_LENGTH) { continue; } if (memcmp(oid, CN_DATA, CN_LENGTH) != 0) { continue; } /* advance to CN */ name_length -= (oid-name) + oid_length; name = oid + oid_length; /* unwrap the CN */ cn->data = dataStart(name, name_length, &cn->len, false); return SECSuccess; } return SECFailure; } static char * GetUserName(const CKYBuffer *dn) { SECStatus rv; CCItem cn; char *string; rv = GetCN(CKYBuffer_Data(dn), CKYBuffer_Size(dn) , &cn); if( rv != SECSuccess ) { return NULL; } string = new char [ cn.len + 1 ]; if (string == NULL) { return NULL; } memcpy(string, cn.data, cn.len); string[cn.len] = 0; return string; } CACCert::CACCert(CKYByte instance, const CKYBuffer *derCert) : PKCS11Object( ((int)'c') << 24 | ((int)instance+'0') << 16, instance | 0x600) { CKYBuffer id; CKYBuffer empty; CK_BBOOL decrypt = FALSE; /* So we know what the key is supposed to be used for based on * the instance */ if (instance == 2) { decrypt = TRUE; } CKYBuffer_InitEmpty(&empty); setAttributeULong(CKA_CLASS, CKO_CERTIFICATE); setAttributeBool(CKA_TOKEN, TRUE); setAttributeBool(CKA_PRIVATE, FALSE); setAttributeBool(CKA_MODIFIABLE, FALSE); CKYBuffer_InitFromLen(&id, 1); CKYBuffer_SetChar(&id, 1, instance+1); setAttribute(CKA_ID, &id); CKYBuffer_FreeData(&id); setAttributeULong(CKA_CERTIFICATE_TYPE, CKC_X_509); setAttribute(CKA_LABEL, CAC_Label[instance]); CKYBuffer derSerial; CKYBuffer_InitEmpty(&derSerial); CKYBuffer derSubject; CKYBuffer_InitEmpty(&derSubject); CKYBuffer derIssuer; CKYBuffer_InitEmpty(&derIssuer); CKYBuffer_Resize(&pubKey,0); try { setAttribute(CKA_VALUE, derCert); // infer cert attributes GetCertFields(derCert, &derSerial, &derSubject, &derIssuer, &pubKey); setAttribute(CKA_SERIAL_NUMBER, &derSerial); setAttribute(CKA_SUBJECT, &derSubject); setAttribute(CKA_ISSUER, &derIssuer); } catch (PKCS11Exception &e) { CKYBuffer_FreeData(&derSerial); CKYBuffer_FreeData(&derSubject); CKYBuffer_FreeData(&derIssuer); throw e; } name = GetUserName(&derSubject); /* adopt */ CKYBuffer_FreeData(&derSerial); CKYBuffer_FreeData(&derSubject); CKYBuffer_FreeData(&derIssuer); } --- NEW FILE object.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifndef COOLKEY_OBJECT_H #define COOLKEY_OBJECT_H #include "mypkcs11.h" #include "cky_base.h" #include #include "log.h" using std::list; class PKCS11Attribute { private: CK_ATTRIBUTE_TYPE type; CKYBuffer value; public: const CKYBuffer *getValue() const { return &value; } CK_ATTRIBUTE_TYPE getType() const {return type; } void setValue(const CKYByte *data, CKYSize size) { CKYBuffer_Replace(&value, 0, data, size); } void setType(CK_ATTRIBUTE_TYPE type_) { type = type_; } PKCS11Attribute(const PKCS11Attribute &cpy) { type = cpy.type; CKYBuffer_InitFromCopy(&value, &cpy.value); } PKCS11Attribute &operator=(PKCS11Attribute &cpy) { type = cpy.type; CKYBuffer_Replace(&value, 0, CKYBuffer_Data(&cpy.value), CKYBuffer_Size(&cpy.value)); return *this; } PKCS11Attribute() { CKYBuffer_InitEmpty(&value); } PKCS11Attribute(CK_ATTRIBUTE_TYPE type_, const CKYBuffer *value_) : type(type_) { CKYBuffer_InitFromCopy(&value, value_); } ~PKCS11Attribute() { CKYBuffer_FreeData(&value); } }; class PKCS11Object { public: typedef list AttributeList; typedef AttributeList::iterator AttributeIter; typedef AttributeList::const_iterator AttributeConstIter; private: AttributeList attributes; unsigned long muscleObjID; CK_OBJECT_HANDLE handle; char *label; void parseOldObject(const CKYBuffer *data); void parseNewObject(const CKYBuffer *data); void expandAttributes(unsigned long fixedAttrs); PKCS11Object &operator=(PKCS11Object &cpy) { return *this; } //Disallow protected : CKYBuffer pubKey; char *name; public: PKCS11Object(unsigned long muscleObjID, CK_OBJECT_HANDLE handle); PKCS11Object(unsigned long muscleObjID, const CKYBuffer *data, CK_OBJECT_HANDLE handle); ~PKCS11Object() { delete label; delete name; CKYBuffer_FreeData(&pubKey); } PKCS11Object(const PKCS11Object& cpy) : attributes(cpy.attributes), muscleObjID(cpy.muscleObjID), handle(cpy.handle), label(NULL), name(NULL) { CKYBuffer_InitFromCopy(&pubKey,&cpy.pubKey); } unsigned long getMuscleObjID() const { return muscleObjID; } const CK_OBJECT_HANDLE getHandle() const { return handle; } /* PKCS11Attribute* getAttribute(CK_ATTRIBUTE_TYPE type); */ const char *getLabel(); CK_OBJECT_CLASS getClass(); const char *getName() { return name; } void setAttribute(CK_ATTRIBUTE_TYPE type, const CKYBuffer *value); void setAttribute(CK_ATTRIBUTE_TYPE type, const char *); /* bools and ulongs are too close, don't abuse function overloading * for these cases */ void setAttributeBool(CK_ATTRIBUTE_TYPE type, CK_BBOOL); void setAttributeULong(CK_ATTRIBUTE_TYPE type, CK_ULONG); void removeAttribute(CK_ATTRIBUTE_TYPE type); bool matchesTemplate(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG count) const; const CKYBuffer *getAttribute(CK_ATTRIBUTE_TYPE type) const; void getAttributeValue(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, Log* log) const; bool attributeExists(CK_ATTRIBUTE_TYPE type) const; const CKYBuffer *getPubKey(void) const { return &pubKey; } }; class Key : public PKCS11Object { public: Key(unsigned long muscleObjID, const CKYBuffer *data, CK_OBJECT_HANDLE handle); void completeKey(const PKCS11Object &cert); }; class Cert : public PKCS11Object { public: Cert(unsigned long muscleObjID, const CKYBuffer *data, CK_OBJECT_HANDLE handle, const CKYBuffer *derCert); }; class CACPrivKey : public PKCS11Object { public: CACPrivKey(CKYByte instance, const PKCS11Object &cert); }; class CACPubKey : public PKCS11Object { public: CACPubKey(CKYByte instance, const PKCS11Object &cert); }; class CACCert : public PKCS11Object { public: CACCert(CKYByte instance, const CKYBuffer *derCert); }; class Reader : public PKCS11Object { public: Reader(unsigned long muscleObjID, CK_OBJECT_HANDLE handle, const char *reader, const CKYBuffer *cardATR, bool isCoolkey); }; class AttributeMatch { private: const CK_ATTRIBUTE *attr; public: AttributeMatch( const CK_ATTRIBUTE *attr_) : attr(attr_) { } bool operator()(const PKCS11Attribute& cmp); }; inline unsigned int makeLEUInt(const CKYBuffer *buf, unsigned int offset) { /* assert( offset + 4 <= CKYBuffer_Size(buf) ); */ const CKYByte *b = CKYBuffer_Data(buf); return (b[offset+3] << 24) | (b[offset+2] << 16) | (b[offset+1] << 8) | (b[offset+0] << 0) ; } // fixed object ID constants #define READER_ID 0x72300000 /* 'r0\0\0' */ #define COMBINED_ID 0x7a300000 /* 'z0\0\0' */ const CKYByte COMP_NONE=0; const CKYByte COMP_ZLIB=1; const CKYByte DATATYPE_STRING=0; const CKYByte DATATYPE_INTEGER=1; const CKYByte DATATYPE_BOOL_FALSE=2; const CKYByte DATATYPE_BOOL_TRUE=3; // relative to the header const CKYOffset OBJ_FORMAT_VERSION_OFFSET = 0; const CKYOffset OBJ_OBJECT_VERSION_OFFSET = 2; const CKYOffset OBJ_CUID_OFFSET = 4; const CKYSize OBJ_CUID_SIZE = 10; const CKYOffset OBJ_COMP_TYPE_OFFSET = 14; const CKYOffset OBJ_COMP_SIZE_OFFSET = 16; const CKYOffset OBJ_COMP_OFFSET_OFFSET = 18; const CKYSize OBJ_HEADER_SIZE = 20; // relative to the start of the decompressed block const CKYOffset OBJ_OBJECT_OFFSET_OFFSET = 0; const CKYOffset OBJ_OBJECT_COUNT_OFFSET = 2; const CKYOffset OBJ_TOKENNAME_SIZE_OFFSET = 4; const CKYOffset OBJ_TOKENNAME_OFFSET = 5; #endif --- NEW FILE params.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifndef COOLKEY_PARAMS_H #define COOLKEY_PARAMS_H class Params { private: static char *params; public: static void SetParams(const char *_params) { ClearParams(); params = strdup(_params); }; static void ClearParams() { if (params) free (params); params = NULL; }; static char *hasParam(const char *key) { char * index; if (!params) return NULL; index = strstr(params, key); if (!index) return NULL; index += strlen(key); if (*index == '=') { return index+1; } return NULL; }; }; #endif --- NEW FILE pkcs11.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ /* pkcs11.h include file for PKCS #11. 2001 June 25 */ #ifndef _PKCS11_H_ #define _PKCS11_H_ 1 #ifdef __cplusplus extern "C" { #endif /* Before including this file (pkcs11.h) (or pkcs11t.h by * itself), 6 platform-specific macros must be defined. These * macros are described below, and typical definitions for them * are also given. Be advised that these definitions can depend * on both the platform and the compiler used (and possibly also * on whether a Cryptoki library is linked statically or * dynamically). * * In addition to defining these 6 macros, the packing convention * for Cryptoki structures should be set. The Cryptoki * convention on packing is that structures should be 1-byte * aligned. * * If you're using Microsoft Developer Studio 5.0 to produce * Win32 stuff, this might be done by using the following * preprocessor directive before including pkcs11.h or pkcs11t.h: * * #pragma pack(push, cryptoki, 1) * * and using the following preprocessor directive after including * pkcs11.h or pkcs11t.h: * * #pragma pack(pop, cryptoki) * * If you're using an earlier version of Microsoft Developer * Studio to produce Win16 stuff, this might be done by using * the following preprocessor directive before including * pkcs11.h or pkcs11t.h: * * #pragma pack(1) * * In a UNIX environment, you're on your own for this. You might * not need to do (or be able to do!) anything. * * * Now for the macros: * * * 1. CK_PTR: The indirection string for making a pointer to an * object. It can be used like this: * * typedef CK_BYTE CK_PTR CK_BYTE_PTR; * * If you're using Microsoft Developer Studio 5.0 to produce * Win32 stuff, it might be defined by: * * #define CK_PTR * * * If you're using an earlier version of Microsoft Developer * Studio to produce Win16 stuff, it might be defined by: * * #define CK_PTR far * * * In a typical UNIX environment, it might be defined by: * * #define CK_PTR * * * * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes * an exportable Cryptoki library function definition out of a * return type and a function name. It should be used in the * following fashion to define the exposed Cryptoki functions in * a Cryptoki library: * * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)( * CK_VOID_PTR pReserved * ) * { * ... * } * * If you're using Microsoft Developer Studio 5.0 to define a * function in a Win32 Cryptoki .dll, it might be defined by: * * #define CK_DEFINE_FUNCTION(returnType, name) \ * returnType __declspec(dllexport) name * * If you're using an earlier version of Microsoft Developer * Studio to define a function in a Win16 Cryptoki .dll, it * might be defined by: * * #define CK_DEFINE_FUNCTION(returnType, name) \ * returnType __export _far _pascal name * * In a UNIX environment, it might be defined by: * * #define CK_DEFINE_FUNCTION(returnType, name) \ * returnType name * * * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes * an importable Cryptoki library function declaration out of a * return type and a function name. It should be used in the * following fashion: * * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)( * CK_VOID_PTR pReserved * ); * * If you're using Microsoft Developer Studio 5.0 to declare a * function in a Win32 Cryptoki .dll, it might be defined by: * * #define CK_DECLARE_FUNCTION(returnType, name) \ * returnType __declspec(dllimport) name * * If you're using an earlier version of Microsoft Developer * Studio to declare a function in a Win16 Cryptoki .dll, it * might be defined by: * * #define CK_DECLARE_FUNCTION(returnType, name) \ * returnType __export _far _pascal name * * In a UNIX environment, it might be defined by: * * #define CK_DECLARE_FUNCTION(returnType, name) \ * returnType name * * * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro * which makes a Cryptoki API function pointer declaration or * function pointer type declaration out of a return type and a * function name. It should be used in the following fashion: * * // Define funcPtr to be a pointer to a Cryptoki API function * // taking arguments args and returning CK_RV. * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args); * * or * * // Define funcPtrType to be the type of a pointer to a * // Cryptoki API function taking arguments args and returning * // CK_RV, and then define funcPtr to be a variable of type * // funcPtrType. * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args); * funcPtrType funcPtr; * * If you're using Microsoft Developer Studio 5.0 to access * functions in a Win32 Cryptoki .dll, in might be defined by: * * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ * returnType __declspec(dllimport) (* name) * * If you're using an earlier version of Microsoft Developer * Studio to access functions in a Win16 Cryptoki .dll, it might * be defined by: * * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ * returnType __export _far _pascal (* name) * * In a UNIX environment, it might be defined by: * * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ * returnType (* name) * * * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes * a function pointer type for an application callback out of * a return type for the callback and a name for the callback. * It should be used in the following fashion: * * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args); * * to declare a function pointer, myCallback, to a callback * which takes arguments args and returns a CK_RV. It can also * be used like this: * * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args); * myCallbackType myCallback; * * If you're using Microsoft Developer Studio 5.0 to do Win32 * Cryptoki development, it might be defined by: * * #define CK_CALLBACK_FUNCTION(returnType, name) \ * returnType (* name) * * If you're using an earlier version of Microsoft Developer * Studio to do Win16 development, it might be defined by: * * #define CK_CALLBACK_FUNCTION(returnType, name) \ * returnType _far _pascal (* name) * * In a UNIX environment, it might be defined by: * * #define CK_CALLBACK_FUNCTION(returnType, name) \ * returnType (* name) * * * 6. NULL_PTR: This macro is the value of a NULL pointer. * * In any ANSI/ISO C environment (and in many others as well), * this should best be defined by * * #ifndef NULL_PTR * #define NULL_PTR 0 * #endif */ /* All the various Cryptoki types and #define'd values are in the * file pkcs11t.h. */ #include "pkcs11t.h" #define __PASTE(x,y) x##y /* ============================================================== * Define the "extern" form of all the entry points. * ============================================================== */ #define CK_NEED_ARG_LIST 1 #define CK_PKCS11_FUNCTION_INFO(name) \ CK_DECLARE_FUNCTION(CK_RV, name) /* pkcs11f.h has all the information about the Cryptoki * function prototypes. */ #include "pkcs11f.h" #undef CK_NEED_ARG_LIST #undef CK_PKCS11_FUNCTION_INFO /* ============================================================== * Define the typedef form of all the entry points. That is, for * each Cryptoki function C_XXX, define a type CK_C_XXX which is * a pointer to that kind of function. * ============================================================== */ #define CK_NEED_ARG_LIST 1 #define CK_PKCS11_FUNCTION_INFO(name) \ typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name)) /* pkcs11f.h has all the information about the Cryptoki * function prototypes. */ #include "pkcs11f.h" #undef CK_NEED_ARG_LIST #undef CK_PKCS11_FUNCTION_INFO /* ============================================================== * Define structed vector of entry points. A CK_FUNCTION_LIST * contains a CK_VERSION indicating a library's Cryptoki version * and then a whole slew of function pointers to the routines in * the library. This type was declared, but not defined, in * pkcs11t.h. * ============================================================== */ #define CK_PKCS11_FUNCTION_INFO(name) \ __PASTE(CK_,name) name; struct CK_FUNCTION_LIST { CK_VERSION version; /* Cryptoki version */ /* Pile all the function pointers into the CK_FUNCTION_LIST. */ /* pkcs11f.h has all the information about the Cryptoki * function prototypes. */ #include "pkcs11f.h" }; #undef CK_PKCS11_FUNCTION_INFO #undef __PASTE #ifdef __cplusplus } #endif #endif --- NEW FILE pkcs11f.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ /* pkcs11f.h include file for PKCS #11. 2001 June 25 */ /* This function contains pretty much everything about all the */ /* Cryptoki function prototypes. Because this information is */ /* used for more than just declaring function prototypes, the */ /* order of the functions appearing herein is important, and */ /* should not be altered. */ /* General-purpose */ /* C_Initialize initializes the Cryptoki library. */ CK_PKCS11_FUNCTION_INFO(C_Initialize) #ifdef CK_NEED_ARG_LIST ( CK_VOID_PTR pInitArgs /* if this is not NULL_PTR, it gets * cast to CK_C_INITIALIZE_ARGS_PTR * and dereferenced */ ); #endif /* C_Finalize indicates that an application is done with the * Cryptoki library. */ CK_PKCS11_FUNCTION_INFO(C_Finalize) #ifdef CK_NEED_ARG_LIST ( CK_VOID_PTR pReserved /* reserved. Should be NULL_PTR */ ); #endif /* C_GetInfo returns general information about Cryptoki. */ CK_PKCS11_FUNCTION_INFO(C_GetInfo) #ifdef CK_NEED_ARG_LIST ( CK_INFO_PTR pInfo /* location that receives information */ ); #endif /* C_GetFunctionList returns the function list. */ CK_PKCS11_FUNCTION_INFO(C_GetFunctionList) #ifdef CK_NEED_ARG_LIST ( CK_FUNCTION_LIST_PTR_PTR ppFunctionList /* receives pointer to * function list */ ); #endif /* Slot and token management */ /* C_GetSlotList obtains a list of slots in the system. */ CK_PKCS11_FUNCTION_INFO(C_GetSlotList) #ifdef CK_NEED_ARG_LIST ( CK_BBOOL tokenPresent, /* only slots with tokens? */ CK_SLOT_ID_PTR pSlotList, /* receives array of slot IDs */ CK_ULONG_PTR pulCount /* receives number of slots */ ); #endif /* C_GetSlotInfo obtains information about a particular slot in * the system. */ CK_PKCS11_FUNCTION_INFO(C_GetSlotInfo) #ifdef CK_NEED_ARG_LIST ( CK_SLOT_ID slotID, /* the ID of the slot */ CK_SLOT_INFO_PTR pInfo /* receives the slot information */ ); #endif /* C_GetTokenInfo obtains information about a particular token * in the system. */ CK_PKCS11_FUNCTION_INFO(C_GetTokenInfo) #ifdef CK_NEED_ARG_LIST ( CK_SLOT_ID slotID, /* ID of the token's slot */ CK_TOKEN_INFO_PTR pInfo /* receives the token information */ ); #endif /* C_GetMechanismList obtains a list of mechanism types * supported by a token. */ CK_PKCS11_FUNCTION_INFO(C_GetMechanismList) #ifdef CK_NEED_ARG_LIST ( CK_SLOT_ID slotID, /* ID of token's slot */ CK_MECHANISM_TYPE_PTR pMechanismList, /* gets mech. array */ CK_ULONG_PTR pulCount /* gets # of mechs. */ ); #endif /* C_GetMechanismInfo obtains information about a particular * mechanism possibly supported by a token. */ CK_PKCS11_FUNCTION_INFO(C_GetMechanismInfo) #ifdef CK_NEED_ARG_LIST ( CK_SLOT_ID slotID, /* ID of the token's slot */ CK_MECHANISM_TYPE type, /* type of mechanism */ CK_MECHANISM_INFO_PTR pInfo /* receives mechanism info */ ); #endif /* C_InitToken initializes a token. */ CK_PKCS11_FUNCTION_INFO(C_InitToken) #ifdef CK_NEED_ARG_LIST /* pLabel changed from CK_CHAR_PTR to CK_UTF8CHAR_PTR for v2.10 */ ( CK_SLOT_ID slotID, /* ID of the token's slot */ CK_UTF8CHAR_PTR pPin, /* the SO's initial PIN */ CK_ULONG ulPinLen, /* length in bytes of the PIN */ CK_UTF8CHAR_PTR pLabel /* 32-byte token label (blank padded) */ ); #endif /* C_InitPIN initializes the normal user's PIN. */ CK_PKCS11_FUNCTION_INFO(C_InitPIN) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_UTF8CHAR_PTR pPin, /* the normal user's PIN */ CK_ULONG ulPinLen /* length in bytes of the PIN */ ); #endif /* C_SetPIN modifies the PIN of the user who is logged in. */ CK_PKCS11_FUNCTION_INFO(C_SetPIN) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_UTF8CHAR_PTR pOldPin, /* the old PIN */ CK_ULONG ulOldLen, /* length of the old PIN */ CK_UTF8CHAR_PTR pNewPin, /* the new PIN */ CK_ULONG ulNewLen /* length of the new PIN */ ); #endif /* Session management */ /* C_OpenSession opens a session between an application and a * token. */ CK_PKCS11_FUNCTION_INFO(C_OpenSession) #ifdef CK_NEED_ARG_LIST ( CK_SLOT_ID slotID, /* the slot's ID */ CK_FLAGS flags, /* from CK_SESSION_INFO */ CK_VOID_PTR pApplication, /* passed to callback */ CK_NOTIFY Notify, /* callback function */ CK_SESSION_HANDLE_PTR phSession /* gets session handle */ ); #endif /* C_CloseSession closes a session between an application and a * token. */ CK_PKCS11_FUNCTION_INFO(C_CloseSession) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession /* the session's handle */ ); #endif /* C_CloseAllSessions closes all sessions with a token. */ CK_PKCS11_FUNCTION_INFO(C_CloseAllSessions) #ifdef CK_NEED_ARG_LIST ( CK_SLOT_ID slotID /* the token's slot */ ); #endif /* C_GetSessionInfo obtains information about the session. */ CK_PKCS11_FUNCTION_INFO(C_GetSessionInfo) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_SESSION_INFO_PTR pInfo /* receives session info */ ); #endif /* C_GetOperationState obtains the state of the cryptographic operation * in a session. */ CK_PKCS11_FUNCTION_INFO(C_GetOperationState) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pOperationState, /* gets state */ CK_ULONG_PTR pulOperationStateLen /* gets state length */ ); #endif /* C_SetOperationState restores the state of the cryptographic * operation in a session. */ CK_PKCS11_FUNCTION_INFO(C_SetOperationState) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pOperationState, /* holds state */ CK_ULONG ulOperationStateLen, /* holds state length */ CK_OBJECT_HANDLE hEncryptionKey, /* en/decryption key */ CK_OBJECT_HANDLE hAuthenticationKey /* sign/verify key */ ); #endif /* C_Login logs a user into a token. */ CK_PKCS11_FUNCTION_INFO(C_Login) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_USER_TYPE userType, /* the user type */ CK_UTF8CHAR_PTR pPin, /* the user's PIN */ CK_ULONG ulPinLen /* the length of the PIN */ ); #endif /* C_Logout logs a user out from a token. */ CK_PKCS11_FUNCTION_INFO(C_Logout) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession /* the session's handle */ ); #endif /* Object management */ /* C_CreateObject creates a new object. */ CK_PKCS11_FUNCTION_INFO(C_CreateObject) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_ATTRIBUTE_PTR pTemplate, /* the object's template */ CK_ULONG ulCount, /* attributes in template */ CK_OBJECT_HANDLE_PTR phObject /* gets new object's handle. */ ); #endif /* C_CopyObject copies an object, creating a new object for the * copy. */ CK_PKCS11_FUNCTION_INFO(C_CopyObject) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_OBJECT_HANDLE hObject, /* the object's handle */ CK_ATTRIBUTE_PTR pTemplate, /* template for new object */ CK_ULONG ulCount, /* attributes in template */ CK_OBJECT_HANDLE_PTR phNewObject /* receives handle of copy */ ); #endif /* C_DestroyObject destroys an object. */ CK_PKCS11_FUNCTION_INFO(C_DestroyObject) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_OBJECT_HANDLE hObject /* the object's handle */ ); #endif /* C_GetObjectSize gets the size of an object in bytes. */ CK_PKCS11_FUNCTION_INFO(C_GetObjectSize) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_OBJECT_HANDLE hObject, /* the object's handle */ CK_ULONG_PTR pulSize /* receives size of object */ ); #endif /* C_GetAttributeValue obtains the value of one or more object * attributes. */ CK_PKCS11_FUNCTION_INFO(C_GetAttributeValue) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_OBJECT_HANDLE hObject, /* the object's handle */ CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs; gets vals */ CK_ULONG ulCount /* attributes in template */ ); #endif /* C_SetAttributeValue modifies the value of one or more object * attributes */ CK_PKCS11_FUNCTION_INFO(C_SetAttributeValue) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_OBJECT_HANDLE hObject, /* the object's handle */ CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs and values */ CK_ULONG ulCount /* attributes in template */ ); #endif /* C_FindObjectsInit initializes a search for token and session * objects that match a template. */ CK_PKCS11_FUNCTION_INFO(C_FindObjectsInit) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_ATTRIBUTE_PTR pTemplate, /* attribute values to match */ CK_ULONG ulCount /* attrs in search template */ ); #endif /* C_FindObjects continues a search for token and session * objects that match a template, obtaining additional object * handles. */ CK_PKCS11_FUNCTION_INFO(C_FindObjects) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_OBJECT_HANDLE_PTR phObject, /* gets obj. handles */ CK_ULONG ulMaxObjectCount, /* max handles to get */ CK_ULONG_PTR pulObjectCount /* actual # returned */ ); #endif /* C_FindObjectsFinal finishes a search for token and session * objects. */ CK_PKCS11_FUNCTION_INFO(C_FindObjectsFinal) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession /* the session's handle */ ); #endif /* Encryption and decryption */ /* C_EncryptInit initializes an encryption operation. */ CK_PKCS11_FUNCTION_INFO(C_EncryptInit) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism, /* the encryption mechanism */ CK_OBJECT_HANDLE hKey /* handle of encryption key */ ); #endif /* C_Encrypt encrypts single-part data. */ CK_PKCS11_FUNCTION_INFO(C_Encrypt) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pData, /* the plaintext data */ CK_ULONG ulDataLen, /* bytes of plaintext */ CK_BYTE_PTR pEncryptedData, /* gets ciphertext */ CK_ULONG_PTR pulEncryptedDataLen /* gets c-text size */ ); #endif /* C_EncryptUpdate continues a multiple-part encryption * operation. */ CK_PKCS11_FUNCTION_INFO(C_EncryptUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pPart, /* the plaintext data */ CK_ULONG ulPartLen, /* plaintext data len */ CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ CK_ULONG_PTR pulEncryptedPartLen /* gets c-text size */ ); #endif /* C_EncryptFinal finishes a multiple-part encryption * operation. */ CK_PKCS11_FUNCTION_INFO(C_EncryptFinal) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session handle */ CK_BYTE_PTR pLastEncryptedPart, /* last c-text */ CK_ULONG_PTR pulLastEncryptedPartLen /* gets last size */ ); #endif /* C_DecryptInit initializes a decryption operation. */ CK_PKCS11_FUNCTION_INFO(C_DecryptInit) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism, /* the decryption mechanism */ CK_OBJECT_HANDLE hKey /* handle of decryption key */ ); #endif /* C_Decrypt decrypts encrypted data in a single part. */ CK_PKCS11_FUNCTION_INFO(C_Decrypt) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pEncryptedData, /* ciphertext */ CK_ULONG ulEncryptedDataLen, /* ciphertext length */ CK_BYTE_PTR pData, /* gets plaintext */ CK_ULONG_PTR pulDataLen /* gets p-text size */ ); #endif /* C_DecryptUpdate continues a multiple-part decryption * operation. */ CK_PKCS11_FUNCTION_INFO(C_DecryptUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pEncryptedPart, /* encrypted data */ CK_ULONG ulEncryptedPartLen, /* input length */ CK_BYTE_PTR pPart, /* gets plaintext */ CK_ULONG_PTR pulPartLen /* p-text size */ ); #endif /* C_DecryptFinal finishes a multiple-part decryption * operation. */ CK_PKCS11_FUNCTION_INFO(C_DecryptFinal) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pLastPart, /* gets plaintext */ CK_ULONG_PTR pulLastPartLen /* p-text size */ ); #endif /* Message digesting */ /* C_DigestInit initializes a message-digesting operation. */ CK_PKCS11_FUNCTION_INFO(C_DigestInit) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism /* the digesting mechanism */ ); #endif /* C_Digest digests data in a single part. */ CK_PKCS11_FUNCTION_INFO(C_Digest) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pData, /* data to be digested */ CK_ULONG ulDataLen, /* bytes of data to digest */ CK_BYTE_PTR pDigest, /* gets the message digest */ CK_ULONG_PTR pulDigestLen /* gets digest length */ ); #endif /* C_DigestUpdate continues a multiple-part message-digesting * operation. */ CK_PKCS11_FUNCTION_INFO(C_DigestUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pPart, /* data to be digested */ CK_ULONG ulPartLen /* bytes of data to be digested */ ); #endif /* C_DigestKey continues a multi-part message-digesting * operation, by digesting the value of a secret key as part of * the data already digested. */ CK_PKCS11_FUNCTION_INFO(C_DigestKey) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_OBJECT_HANDLE hKey /* secret key to digest */ ); #endif /* C_DigestFinal finishes a multiple-part message-digesting * operation. */ CK_PKCS11_FUNCTION_INFO(C_DigestFinal) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pDigest, /* gets the message digest */ CK_ULONG_PTR pulDigestLen /* gets byte count of digest */ ); #endif /* Signing and MACing */ /* C_SignInit initializes a signature (private key encryption) * operation, where the signature is (will be) an appendix to * the data, and plaintext cannot be recovered from the *signature. */ CK_PKCS11_FUNCTION_INFO(C_SignInit) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism, /* the signature mechanism */ CK_OBJECT_HANDLE hKey /* handle of signature key */ ); #endif /* C_Sign signs (encrypts with private key) data in a single * part, where the signature is (will be) an appendix to the * data, and plaintext cannot be recovered from the signature. */ CK_PKCS11_FUNCTION_INFO(C_Sign) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pData, /* the data to sign */ CK_ULONG ulDataLen, /* count of bytes to sign */ CK_BYTE_PTR pSignature, /* gets the signature */ CK_ULONG_PTR pulSignatureLen /* gets signature length */ ); #endif /* C_SignUpdate continues a multiple-part signature operation, * where the signature is (will be) an appendix to the data, * and plaintext cannot be recovered from the signature. */ CK_PKCS11_FUNCTION_INFO(C_SignUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pPart, /* the data to sign */ CK_ULONG ulPartLen /* count of bytes to sign */ ); #endif /* C_SignFinal finishes a multiple-part signature operation, * returning the signature. */ CK_PKCS11_FUNCTION_INFO(C_SignFinal) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pSignature, /* gets the signature */ CK_ULONG_PTR pulSignatureLen /* gets signature length */ ); #endif /* C_SignRecoverInit initializes a signature operation, where * the data can be recovered from the signature. */ CK_PKCS11_FUNCTION_INFO(C_SignRecoverInit) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism, /* the signature mechanism */ CK_OBJECT_HANDLE hKey /* handle of the signature key */ ); #endif /* C_SignRecover signs data in a single operation, where the * data can be recovered from the signature. */ CK_PKCS11_FUNCTION_INFO(C_SignRecover) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pData, /* the data to sign */ CK_ULONG ulDataLen, /* count of bytes to sign */ CK_BYTE_PTR pSignature, /* gets the signature */ CK_ULONG_PTR pulSignatureLen /* gets signature length */ ); #endif /* Verifying signatures and MACs */ /* C_VerifyInit initializes a verification operation, where the * signature is an appendix to the data, and plaintext cannot * cannot be recovered from the signature (e.g. DSA). */ CK_PKCS11_FUNCTION_INFO(C_VerifyInit) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism, /* the verification mechanism */ CK_OBJECT_HANDLE hKey /* verification key */ ); #endif /* C_Verify verifies a signature in a single-part operation, * where the signature is an appendix to the data, and plaintext * cannot be recovered from the signature. */ CK_PKCS11_FUNCTION_INFO(C_Verify) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pData, /* signed data */ CK_ULONG ulDataLen, /* length of signed data */ CK_BYTE_PTR pSignature, /* signature */ CK_ULONG ulSignatureLen /* signature length*/ ); #endif /* C_VerifyUpdate continues a multiple-part verification * operation, where the signature is an appendix to the data, * and plaintext cannot be recovered from the signature. */ CK_PKCS11_FUNCTION_INFO(C_VerifyUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pPart, /* signed data */ CK_ULONG ulPartLen /* length of signed data */ ); #endif /* C_VerifyFinal finishes a multiple-part verification * operation, checking the signature. */ CK_PKCS11_FUNCTION_INFO(C_VerifyFinal) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pSignature, /* signature to verify */ CK_ULONG ulSignatureLen /* signature length */ ); #endif /* C_VerifyRecoverInit initializes a signature verification * operation, where the data is recovered from the signature. */ CK_PKCS11_FUNCTION_INFO(C_VerifyRecoverInit) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism, /* the verification mechanism */ CK_OBJECT_HANDLE hKey /* verification key */ ); #endif /* C_VerifyRecover verifies a signature in a single-part * operation, where the data is recovered from the signature. */ CK_PKCS11_FUNCTION_INFO(C_VerifyRecover) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pSignature, /* signature to verify */ CK_ULONG ulSignatureLen, /* signature length */ CK_BYTE_PTR pData, /* gets signed data */ CK_ULONG_PTR pulDataLen /* gets signed data len */ ); #endif /* Dual-function cryptographic operations */ /* C_DigestEncryptUpdate continues a multiple-part digesting * and encryption operation. */ CK_PKCS11_FUNCTION_INFO(C_DigestEncryptUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pPart, /* the plaintext data */ CK_ULONG ulPartLen, /* plaintext length */ CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */ ); #endif /* C_DecryptDigestUpdate continues a multiple-part decryption and * digesting operation. */ CK_PKCS11_FUNCTION_INFO(C_DecryptDigestUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pEncryptedPart, /* ciphertext */ CK_ULONG ulEncryptedPartLen, /* ciphertext length */ CK_BYTE_PTR pPart, /* gets plaintext */ CK_ULONG_PTR pulPartLen /* gets plaintext len */ ); #endif /* C_SignEncryptUpdate continues a multiple-part signing and * encryption operation. */ CK_PKCS11_FUNCTION_INFO(C_SignEncryptUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pPart, /* the plaintext data */ CK_ULONG ulPartLen, /* plaintext length */ CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */ ); #endif /* C_DecryptVerifyUpdate continues a multiple-part decryption and * verify operation. */ CK_PKCS11_FUNCTION_INFO(C_DecryptVerifyUpdate) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_BYTE_PTR pEncryptedPart, /* ciphertext */ CK_ULONG ulEncryptedPartLen, /* ciphertext length */ CK_BYTE_PTR pPart, /* gets plaintext */ CK_ULONG_PTR pulPartLen /* gets p-text length */ ); #endif /* Key management */ /* C_GenerateKey generates a secret key, creating a new key * object. */ CK_PKCS11_FUNCTION_INFO(C_GenerateKey) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism, /* key generation mech. */ CK_ATTRIBUTE_PTR pTemplate, /* template for new key */ CK_ULONG ulCount, /* # of attrs in template */ CK_OBJECT_HANDLE_PTR phKey /* gets handle of new key */ ); #endif /* C_GenerateKeyPair generates a public-key/private-key pair, * creating new key objects. */ CK_PKCS11_FUNCTION_INFO(C_GenerateKeyPair) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session * handle */ CK_MECHANISM_PTR pMechanism, /* key-gen * mech. */ CK_ATTRIBUTE_PTR pPublicKeyTemplate, /* template * for pub. * key */ CK_ULONG ulPublicKeyAttributeCount, /* # pub. * attrs. */ CK_ATTRIBUTE_PTR pPrivateKeyTemplate, /* template * for priv. * key */ CK_ULONG ulPrivateKeyAttributeCount, /* # priv. * attrs. */ CK_OBJECT_HANDLE_PTR phPublicKey, /* gets pub. * key * handle */ CK_OBJECT_HANDLE_PTR phPrivateKey /* gets * priv. key * handle */ ); #endif /* C_WrapKey wraps (i.e., encrypts) a key. */ CK_PKCS11_FUNCTION_INFO(C_WrapKey) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_MECHANISM_PTR pMechanism, /* the wrapping mechanism */ CK_OBJECT_HANDLE hWrappingKey, /* wrapping key */ CK_OBJECT_HANDLE hKey, /* key to be wrapped */ CK_BYTE_PTR pWrappedKey, /* gets wrapped key */ CK_ULONG_PTR pulWrappedKeyLen /* gets wrapped key size */ ); #endif /* C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new * key object. */ CK_PKCS11_FUNCTION_INFO(C_UnwrapKey) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_MECHANISM_PTR pMechanism, /* unwrapping mech. */ CK_OBJECT_HANDLE hUnwrappingKey, /* unwrapping key */ CK_BYTE_PTR pWrappedKey, /* the wrapped key */ CK_ULONG ulWrappedKeyLen, /* wrapped key len */ CK_ATTRIBUTE_PTR pTemplate, /* new key template */ CK_ULONG ulAttributeCount, /* template length */ CK_OBJECT_HANDLE_PTR phKey /* gets new handle */ ); #endif /* C_DeriveKey derives a key from a base key, creating a new key * object. */ CK_PKCS11_FUNCTION_INFO(C_DeriveKey) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* session's handle */ CK_MECHANISM_PTR pMechanism, /* key deriv. mech. */ CK_OBJECT_HANDLE hBaseKey, /* base key */ CK_ATTRIBUTE_PTR pTemplate, /* new key template */ CK_ULONG ulAttributeCount, /* template length */ CK_OBJECT_HANDLE_PTR phKey /* gets new handle */ ); #endif /* Random number generation */ /* C_SeedRandom mixes additional seed material into the token's * random number generator. */ CK_PKCS11_FUNCTION_INFO(C_SeedRandom) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR pSeed, /* the seed material */ CK_ULONG ulSeedLen /* length of seed material */ ); #endif /* C_GenerateRandom generates random data. */ CK_PKCS11_FUNCTION_INFO(C_GenerateRandom) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_BYTE_PTR RandomData, /* receives the random data */ CK_ULONG ulRandomLen /* # of bytes to generate */ ); #endif /* Parallel function management */ /* C_GetFunctionStatus is a legacy function; it obtains an * updated status of a function running in parallel with an * application. */ CK_PKCS11_FUNCTION_INFO(C_GetFunctionStatus) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession /* the session's handle */ ); #endif /* C_CancelFunction is a legacy function; it cancels a function * running in parallel. */ CK_PKCS11_FUNCTION_INFO(C_CancelFunction) #ifdef CK_NEED_ARG_LIST ( CK_SESSION_HANDLE hSession /* the session's handle */ ); #endif /* Functions added in for Cryptoki Version 2.01 or later */ /* C_WaitForSlotEvent waits for a slot event (token insertion, * removal, etc.) to occur. */ CK_PKCS11_FUNCTION_INFO(C_WaitForSlotEvent) #ifdef CK_NEED_ARG_LIST ( CK_FLAGS flags, /* blocking/nonblocking flag */ CK_SLOT_ID_PTR pSlot, /* location that receives the slot ID */ CK_VOID_PTR pRserved /* reserved. Should be NULL_PTR */ ); #endif ***** Error reading new file: [Errno 2] No such file or directory: 'pkcs11n.h' --- NEW FILE pkcs11t.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ /* pkcs11t.h include file for PKCS #11. 2001 June 25 */ /* See top of pkcs11.h for information about the macros that * must be defined and the structure-packing conventions that * must be set before including this file. */ #ifndef _PKCS11T_H_ #define _PKCS11T_H_ 1 #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE (!FALSE) #endif /* an unsigned 8-bit value */ typedef unsigned char CK_BYTE; /* an unsigned 8-bit character */ typedef CK_BYTE CK_CHAR; /* an 8-bit UTF-8 character */ typedef CK_BYTE CK_UTF8CHAR; /* a BYTE-sized Boolean flag */ typedef CK_BYTE CK_BBOOL; /* an unsigned value, at least 32 bits long */ typedef unsigned long int CK_ULONG; /* a signed value, the same size as a CK_ULONG */ /* CK_LONG is new for v2.0 */ typedef long int CK_LONG; /* at least 32 bits; each bit is a Boolean flag */ typedef CK_ULONG CK_FLAGS; /* some special values for certain CK_ULONG variables */ #define CK_UNAVAILABLE_INFORMATION (~0UL) #define CK_EFFECTIVELY_INFINITE 0 typedef CK_BYTE CK_PTR CK_BYTE_PTR; typedef CK_CHAR CK_PTR CK_CHAR_PTR; typedef CK_UTF8CHAR CK_PTR CK_UTF8CHAR_PTR; typedef CK_ULONG CK_PTR CK_ULONG_PTR; typedef void CK_PTR CK_VOID_PTR; /* Pointer to a CK_VOID_PTR-- i.e., pointer to pointer to void */ typedef CK_VOID_PTR CK_PTR CK_VOID_PTR_PTR; /* The following value is always invalid if used as a session */ /* handle or object handle */ #define CK_INVALID_HANDLE 0 typedef struct CK_VERSION { CK_BYTE major; /* integer portion of version number */ CK_BYTE minor; /* 1/100ths portion of version number */ } CK_VERSION; typedef CK_VERSION CK_PTR CK_VERSION_PTR; typedef struct CK_INFO { /* manufacturerID and libraryDecription have been changed from * CK_CHAR to CK_UTF8CHAR for v2.10 */ CK_VERSION cryptokiVersion; /* Cryptoki interface ver */ CK_UTF8CHAR manufacturerID[32]; /* blank padded */ CK_FLAGS flags; /* must be zero */ /* libraryDescription and libraryVersion are new for v2.0 */ CK_UTF8CHAR libraryDescription[32]; /* blank padded */ CK_VERSION libraryVersion; /* version of library */ } CK_INFO; typedef CK_INFO CK_PTR CK_INFO_PTR; /* CK_NOTIFICATION enumerates the types of notifications that * Cryptoki provides to an application */ /* CK_NOTIFICATION has been changed from an enum to a CK_ULONG * for v2.0 */ typedef CK_ULONG CK_NOTIFICATION; #define CKN_SURRENDER 0 typedef CK_ULONG CK_SLOT_ID; typedef CK_SLOT_ID CK_PTR CK_SLOT_ID_PTR; /* CK_SLOT_INFO provides information about a slot */ typedef struct CK_SLOT_INFO { /* slotDescription and manufacturerID have been changed from * CK_CHAR to CK_UTF8CHAR for v2.10 */ CK_UTF8CHAR slotDescription[64]; /* blank padded */ CK_UTF8CHAR manufacturerID[32]; /* blank padded */ CK_FLAGS flags; /* hardwareVersion and firmwareVersion are new for v2.0 */ CK_VERSION hardwareVersion; /* version of hardware */ CK_VERSION firmwareVersion; /* version of firmware */ } CK_SLOT_INFO; /* flags: bit flags that provide capabilities of the slot * Bit Flag Mask Meaning */ #define CKF_TOKEN_PRESENT 0x00000001 /* a token is there */ #define CKF_REMOVABLE_DEVICE 0x00000002 /* removable devices*/ #define CKF_HW_SLOT 0x00000004 /* hardware slot */ typedef CK_SLOT_INFO CK_PTR CK_SLOT_INFO_PTR; /* CK_TOKEN_INFO provides information about a token */ typedef struct CK_TOKEN_INFO { /* label, manufacturerID, and model have been changed from * CK_CHAR to CK_UTF8CHAR for v2.10 */ CK_UTF8CHAR label[32]; /* blank padded */ CK_UTF8CHAR manufacturerID[32]; /* blank padded */ CK_UTF8CHAR model[16]; /* blank padded */ CK_CHAR serialNumber[16]; /* blank padded */ CK_FLAGS flags; /* see below */ /* ulMaxSessionCount, ulSessionCount, ulMaxRwSessionCount, * ulRwSessionCount, ulMaxPinLen, and ulMinPinLen have all been * changed from CK_USHORT to CK_ULONG for v2.0 */ CK_ULONG ulMaxSessionCount; /* max open sessions */ CK_ULONG ulSessionCount; /* sess. now open */ CK_ULONG ulMaxRwSessionCount; /* max R/W sessions */ CK_ULONG ulRwSessionCount; /* R/W sess. now open */ CK_ULONG ulMaxPinLen; /* in bytes */ CK_ULONG ulMinPinLen; /* in bytes */ CK_ULONG ulTotalPublicMemory; /* in bytes */ CK_ULONG ulFreePublicMemory; /* in bytes */ CK_ULONG ulTotalPrivateMemory; /* in bytes */ CK_ULONG ulFreePrivateMemory; /* in bytes */ /* hardwareVersion, firmwareVersion, and time are new for * v2.0 */ CK_VERSION hardwareVersion; /* version of hardware */ CK_VERSION firmwareVersion; /* version of firmware */ CK_CHAR utcTime[16]; /* time */ } CK_TOKEN_INFO; /* The flags parameter is defined as follows: * Bit Flag Mask Meaning */ #define CKF_RNG 0x00000001 /* has random # * generator */ #define CKF_WRITE_PROTECTED 0x00000002 /* token is * write- * protected */ #define CKF_LOGIN_REQUIRED 0x00000004 /* user must * login */ #define CKF_USER_PIN_INITIALIZED 0x00000008 /* normal user's * PIN is set */ /* CKF_RESTORE_KEY_NOT_NEEDED is new for v2.0. If it is set, * that means that *every* time the state of cryptographic * operations of a session is successfully saved, all keys * needed to continue those operations are stored in the state */ #define CKF_RESTORE_KEY_NOT_NEEDED 0x00000020 /* CKF_CLOCK_ON_TOKEN is new for v2.0. If it is set, that means * that the token has some sort of clock. The time on that * clock is returned in the token info structure */ #define CKF_CLOCK_ON_TOKEN 0x00000040 /* CKF_PROTECTED_AUTHENTICATION_PATH is new for v2.0. If it is * set, that means that there is some way for the user to login * without sending a PIN through the Cryptoki library itself */ #define CKF_PROTECTED_AUTHENTICATION_PATH 0x00000100 /* CKF_DUAL_CRYPTO_OPERATIONS is new for v2.0. If it is true, * that means that a single session with the token can perform * dual simultaneous cryptographic operations (digest and * encrypt; decrypt and digest; sign and encrypt; and decrypt * and sign) */ #define CKF_DUAL_CRYPTO_OPERATIONS 0x00000200 /* CKF_TOKEN_INITIALIZED if new for v2.10. If it is true, the * token has been initialized using C_InitializeToken or an * equivalent mechanism outside the scope of PKCS #11. * Calling C_InitializeToken when this flag is set will cause * the token to be reinitialized. */ #define CKF_TOKEN_INITIALIZED 0x00000400 /* CKF_SECONDARY_AUTHENTICATION if new for v2.10. If it is * true, the token supports secondary authentication for * private key objects. */ #define CKF_SECONDARY_AUTHENTICATION 0x00000800 /* CKF_USER_PIN_COUNT_LOW if new for v2.10. If it is true, an * incorrect user login PIN has been entered at least once * since the last successful authentication. */ #define CKF_USER_PIN_COUNT_LOW 0x00010000 /* CKF_USER_PIN_FINAL_TRY if new for v2.10. If it is true, * supplying an incorrect user PIN will it to become locked. */ #define CKF_USER_PIN_FINAL_TRY 0x00020000 /* CKF_USER_PIN_LOCKED if new for v2.10. If it is true, the * user PIN has been locked. User login to the token is not * possible. */ #define CKF_USER_PIN_LOCKED 0x00040000 /* CKF_USER_PIN_TO_BE_CHANGED if new for v2.10. If it is true, * the user PIN value is the default value set by token * initialization or manufacturing, or the PIN has been * expired by the card. */ #define CKF_USER_PIN_TO_BE_CHANGED 0x00080000 /* CKF_SO_PIN_COUNT_LOW if new for v2.10. If it is true, an * incorrect SO login PIN has been entered at least once since * the last successful authentication. */ #define CKF_SO_PIN_COUNT_LOW 0x00100000 /* CKF_SO_PIN_FINAL_TRY if new for v2.10. If it is true, * supplying an incorrect SO PIN will it to become locked. */ #define CKF_SO_PIN_FINAL_TRY 0x00200000 /* CKF_SO_PIN_LOCKED if new for v2.10. If it is true, the SO * PIN has been locked. SO login to the token is not possible. */ #define CKF_SO_PIN_LOCKED 0x00400000 /* CKF_SO_PIN_TO_BE_CHANGED if new for v2.10. If it is true, * the SO PIN value is the default value set by token * initialization or manufacturing, or the PIN has been * expired by the card. */ #define CKF_SO_PIN_TO_BE_CHANGED 0x00800000 typedef CK_TOKEN_INFO CK_PTR CK_TOKEN_INFO_PTR; /* CK_SESSION_HANDLE is a Cryptoki-assigned value that * identifies a session */ typedef CK_ULONG CK_SESSION_HANDLE; typedef CK_SESSION_HANDLE CK_PTR CK_SESSION_HANDLE_PTR; /* CK_USER_TYPE enumerates the types of Cryptoki users */ /* CK_USER_TYPE has been changed from an enum to a CK_ULONG for * v2.0 */ typedef CK_ULONG CK_USER_TYPE; /* Security Officer */ #define CKU_SO 0 /* Normal user */ #define CKU_USER 1 /* CK_STATE enumerates the session states */ /* CK_STATE has been changed from an enum to a CK_ULONG for * v2.0 */ typedef CK_ULONG CK_STATE; #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 /* CK_SESSION_INFO provides information about a session */ typedef struct CK_SESSION_INFO { CK_SLOT_ID slotID; CK_STATE state; CK_FLAGS flags; /* see below */ /* ulDeviceError was changed from CK_USHORT to CK_ULONG for * v2.0 */ CK_ULONG ulDeviceError; /* device-dependent error code */ } CK_SESSION_INFO; /* The flags are defined in the following table: * Bit Flag Mask Meaning */ #define CKF_RW_SESSION 0x00000002 /* session is r/w */ #define CKF_SERIAL_SESSION 0x00000004 /* no parallel */ typedef CK_SESSION_INFO CK_PTR CK_SESSION_INFO_PTR; /* CK_OBJECT_HANDLE is a token-specific identifier for an * object */ typedef CK_ULONG CK_OBJECT_HANDLE; typedef CK_OBJECT_HANDLE CK_PTR CK_OBJECT_HANDLE_PTR; /* CK_OBJECT_CLASS is a value that identifies the classes (or * types) of objects that Cryptoki recognizes. It is defined * as follows: */ /* CK_OBJECT_CLASS was changed from CK_USHORT to CK_ULONG for * v2.0 */ typedef CK_ULONG CK_OBJECT_CLASS; /* The following classes of objects are defined: */ /* CKO_HW_FEATURE is new for v2.10 */ /* CKO_DOMAIN_PARAMETERS is new for v2.11 */ #define CKO_DATA 0x00000000 #define CKO_CERTIFICATE 0x00000001 #define CKO_PUBLIC_KEY 0x00000002 #define CKO_PRIVATE_KEY 0x00000003 #define CKO_SECRET_KEY 0x00000004 #define CKO_HW_FEATURE 0x00000005 #define CKO_DOMAIN_PARAMETERS 0x00000006 #define CKO_VENDOR_DEFINED 0x80000000 typedef CK_OBJECT_CLASS CK_PTR CK_OBJECT_CLASS_PTR; /* CK_HW_FEATURE_TYPE is new for v2.10. CK_HW_FEATURE_TYPE is a * value that identifies the hardware feature type of an object * with CK_OBJECT_CLASS equal to CKO_HW_FEATURE. */ typedef CK_ULONG CK_HW_FEATURE_TYPE; /* The following hardware feature types are defined */ #define CKH_MONOTONIC_COUNTER 0x00000001 #define CKH_CLOCK 0x00000002 #define CKH_VENDOR_DEFINED 0x80000000 /* CK_KEY_TYPE is a value that identifies a key type */ /* CK_KEY_TYPE was changed from CK_USHORT to CK_ULONG for v2.0 */ typedef CK_ULONG CK_KEY_TYPE; /* the following key types are defined: */ #define CKK_RSA 0x00000000 #define CKK_DSA 0x00000001 #define CKK_DH 0x00000002 /* CKK_ECDSA and CKK_KEA are new for v2.0 */ /* CKK_ECDSA is deprecated in v2.11, CKK_EC is preferred. */ #define CKK_ECDSA 0x00000003 #define CKK_EC 0x00000003 #define CKK_X9_42_DH 0x00000004 #define CKK_KEA 0x00000005 #define CKK_GENERIC_SECRET 0x00000010 #define CKK_RC2 0x00000011 #define CKK_RC4 0x00000012 #define CKK_DES 0x00000013 #define CKK_DES2 0x00000014 #define CKK_DES3 0x00000015 /* all these key types are new for v2.0 */ #define CKK_CAST 0x00000016 #define CKK_CAST3 0x00000017 /* CKK_CAST5 is deprecated in v2.11, CKK_CAST128 is preferred. */ #define CKK_CAST5 0x00000018 #define CKK_CAST128 0x00000018 #define CKK_RC5 0x00000019 #define CKK_IDEA 0x0000001A #define CKK_SKIPJACK 0x0000001B #define CKK_BATON 0x0000001C #define CKK_JUNIPER 0x0000001D #define CKK_CDMF 0x0000001E #define CKK_AES 0x0000001F #define CKK_VENDOR_DEFINED 0x80000000 /* CK_CERTIFICATE_TYPE is a value that identifies a certificate * type */ /* CK_CERTIFICATE_TYPE was changed from CK_USHORT to CK_ULONG * for v2.0 */ typedef CK_ULONG CK_CERTIFICATE_TYPE; /* The following certificate types are defined: */ /* CKC_X_509_ATTR_CERT is new for v2.10 */ #define CKC_X_509 0x00000000 #define CKC_X_509_ATTR_CERT 0x00000001 #define CKC_VENDOR_DEFINED 0x80000000 /* CK_ATTRIBUTE_TYPE is a value that identifies an attribute * type */ /* CK_ATTRIBUTE_TYPE was changed from CK_USHORT to CK_ULONG for * v2.0 */ typedef CK_ULONG CK_ATTRIBUTE_TYPE; /* The following attribute types are defined: */ #define CKA_CLASS 0x00000000 #define CKA_TOKEN 0x00000001 #define CKA_PRIVATE 0x00000002 #define CKA_LABEL 0x00000003 #define CKA_APPLICATION 0x00000010 #define CKA_VALUE 0x00000011 /* CKA_OBJECT_ID is new for v2.10 */ #define CKA_OBJECT_ID 0x00000012 #define CKA_CERTIFICATE_TYPE 0x00000080 #define CKA_ISSUER 0x00000081 #define CKA_SERIAL_NUMBER 0x00000082 /* CKA_AC_ISSUER, CKA_OWNER, and CKA_ATTR_TYPES are new * for v2.10 */ #define CKA_AC_ISSUER 0x00000083 #define CKA_OWNER 0x00000084 #define CKA_ATTR_TYPES 0x00000085 /* CKA_TRUSTED is new for v2.11 */ #define CKA_TRUSTED 0x00000086 #define CKA_KEY_TYPE 0x00000100 #define CKA_SUBJECT 0x00000101 #define CKA_ID 0x00000102 #define CKA_SENSITIVE 0x00000103 #define CKA_ENCRYPT 0x00000104 #define CKA_DECRYPT 0x00000105 #define CKA_WRAP 0x00000106 #define CKA_UNWRAP 0x00000107 #define CKA_SIGN 0x00000108 #define CKA_SIGN_RECOVER 0x00000109 #define CKA_VERIFY 0x0000010A #define CKA_VERIFY_RECOVER 0x0000010B #define CKA_DERIVE 0x0000010C #define CKA_START_DATE 0x00000110 #define CKA_END_DATE 0x00000111 #define CKA_MODULUS 0x00000120 #define CKA_MODULUS_BITS 0x00000121 #define CKA_PUBLIC_EXPONENT 0x00000122 #define CKA_PRIVATE_EXPONENT 0x00000123 #define CKA_PRIME_1 0x00000124 #define CKA_PRIME_2 0x00000125 #define CKA_EXPONENT_1 0x00000126 #define CKA_EXPONENT_2 0x00000127 #define CKA_COEFFICIENT 0x00000128 #define CKA_PRIME 0x00000130 #define CKA_SUBPRIME 0x00000131 #define CKA_BASE 0x00000132 /* CKA_PRIME_BITS and CKA_SUB_PRIME_BITS are new for v2.11 */ #define CKA_PRIME_BITS 0x00000133 #define CKA_SUB_PRIME_BITS 0x00000134 #define CKA_VALUE_BITS 0x00000160 #define CKA_VALUE_LEN 0x00000161 /* CKA_EXTRACTABLE, CKA_LOCAL, CKA_NEVER_EXTRACTABLE, * CKA_ALWAYS_SENSITIVE, CKA_MODIFIABLE, CKA_ECDSA_PARAMS, * and CKA_EC_POINT are new for v2.0 */ #define CKA_EXTRACTABLE 0x00000162 #define CKA_LOCAL 0x00000163 #define CKA_NEVER_EXTRACTABLE 0x00000164 #define CKA_ALWAYS_SENSITIVE 0x00000165 /* CKA_KEY_GEN_MECHANISM is new for v2.11 */ #define CKA_KEY_GEN_MECHANISM 0x00000166 #define CKA_MODIFIABLE 0x00000170 /* CKA_ECDSA_PARAMS is deprecated in v2.11, * CKA_EC_PARAMS is preferred. */ #define CKA_ECDSA_PARAMS 0x00000180 #define CKA_EC_PARAMS 0x00000180 #define CKA_EC_POINT 0x00000181 /* CKA_SECONDARY_AUTH, CKA_AUTH_PIN_FLAGS, * CKA_HW_FEATURE_TYPE, CKA_RESET_ON_INIT, and CKA_HAS_RESET * are new for v2.10 */ #define CKA_SECONDARY_AUTH 0x00000200 #define CKA_AUTH_PIN_FLAGS 0x00000201 #define CKA_HW_FEATURE_TYPE 0x00000300 #define CKA_RESET_ON_INIT 0x00000301 #define CKA_HAS_RESET 0x00000302 #define CKA_VENDOR_DEFINED 0x80000000 /* CK_ATTRIBUTE is a structure that includes the type, length * and value of an attribute */ typedef struct CK_ATTRIBUTE { CK_ATTRIBUTE_TYPE type; CK_VOID_PTR pValue; /* ulValueLen went from CK_USHORT to CK_ULONG for v2.0 */ CK_ULONG ulValueLen; /* in bytes */ } CK_ATTRIBUTE; typedef CK_ATTRIBUTE CK_PTR CK_ATTRIBUTE_PTR; /* CK_DATE is a structure that defines a date */ typedef struct CK_DATE{ CK_CHAR year[4]; /* the year ("1900" - "9999") */ CK_CHAR month[2]; /* the month ("01" - "12") */ CK_CHAR day[2]; /* the day ("01" - "31") */ } CK_DATE; /* CK_MECHANISM_TYPE is a value that identifies a mechanism * type */ /* CK_MECHANISM_TYPE was changed from CK_USHORT to CK_ULONG for * v2.0 */ typedef CK_ULONG CK_MECHANISM_TYPE; /* the following mechanism types are defined: */ #define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000 #define CKM_RSA_PKCS 0x00000001 #define CKM_RSA_9796 0x00000002 #define CKM_RSA_X_509 0x00000003 /* CKM_MD2_RSA_PKCS, CKM_MD5_RSA_PKCS, and CKM_SHA1_RSA_PKCS * are new for v2.0. They are mechanisms which hash and sign */ #define CKM_MD2_RSA_PKCS 0x00000004 #define CKM_MD5_RSA_PKCS 0x00000005 #define CKM_SHA1_RSA_PKCS 0x00000006 /* CKM_RIPEMD128_RSA_PKCS, CKM_RIPEMD160_RSA_PKCS, and * CKM_RSA_PKCS_OAEP are new for v2.10 */ #define CKM_RIPEMD128_RSA_PKCS 0x00000007 #define CKM_RIPEMD160_RSA_PKCS 0x00000008 #define CKM_RSA_PKCS_OAEP 0x00000009 /* CKM_RSA_X9_31_KEY_PAIR_GEN, CKM_RSA_X9_31, CKM_SHA1_RSA_X9_31, * CKM_RSA_PKCS_PSS, and CKM_SHA1_RSA_PKCS_PSS are new for v2.11 */ #define CKM_RSA_X9_31_KEY_PAIR_GEN 0x0000000A #define CKM_RSA_X9_31 0x0000000B #define CKM_SHA1_RSA_X9_31 0x0000000C #define CKM_RSA_PKCS_PSS 0x0000000D #define CKM_SHA1_RSA_PKCS_PSS 0x0000000E #define CKM_DSA_KEY_PAIR_GEN 0x00000010 #define CKM_DSA 0x00000011 #define CKM_DSA_SHA1 0x00000012 #define CKM_DH_PKCS_KEY_PAIR_GEN 0x00000020 #define CKM_DH_PKCS_DERIVE 0x00000021 /* CKM_X9_42_DH_KEY_PAIR_GEN, CKM_X9_42_DH_DERIVE, * CKM_X9_42_DH_HYBRID_DERIVE, and CKM_X9_42_MQV_DERIVE are new for * v2.11 */ #define CKM_X9_42_DH_KEY_PAIR_GEN 0x00000030 #define CKM_X9_42_DH_DERIVE 0x00000031 #define CKM_X9_42_DH_HYBRID_DERIVE 0x00000032 #define CKM_X9_42_MQV_DERIVE 0x00000033 #define CKM_RC2_KEY_GEN 0x00000100 #define CKM_RC2_ECB 0x00000101 #define CKM_RC2_CBC 0x00000102 #define CKM_RC2_MAC 0x00000103 /* CKM_RC2_MAC_GENERAL and CKM_RC2_CBC_PAD are new for v2.0 */ #define CKM_RC2_MAC_GENERAL 0x00000104 #define CKM_RC2_CBC_PAD 0x00000105 #define CKM_RC4_KEY_GEN 0x00000110 #define CKM_RC4 0x00000111 #define CKM_DES_KEY_GEN 0x00000120 #define CKM_DES_ECB 0x00000121 #define CKM_DES_CBC 0x00000122 #define CKM_DES_MAC 0x00000123 /* CKM_DES_MAC_GENERAL and CKM_DES_CBC_PAD are new for v2.0 */ #define CKM_DES_MAC_GENERAL 0x00000124 #define CKM_DES_CBC_PAD 0x00000125 #define CKM_DES2_KEY_GEN 0x00000130 #define CKM_DES3_KEY_GEN 0x00000131 #define CKM_DES3_ECB 0x00000132 #define CKM_DES3_CBC 0x00000133 #define CKM_DES3_MAC 0x00000134 /* CKM_DES3_MAC_GENERAL, CKM_DES3_CBC_PAD, CKM_CDMF_KEY_GEN, * CKM_CDMF_ECB, CKM_CDMF_CBC, CKM_CDMF_MAC, * CKM_CDMF_MAC_GENERAL, and CKM_CDMF_CBC_PAD are new for v2.0 */ #define CKM_DES3_MAC_GENERAL 0x00000135 #define CKM_DES3_CBC_PAD 0x00000136 #define CKM_CDMF_KEY_GEN 0x00000140 #define CKM_CDMF_ECB 0x00000141 #define CKM_CDMF_CBC 0x00000142 #define CKM_CDMF_MAC 0x00000143 #define CKM_CDMF_MAC_GENERAL 0x00000144 #define CKM_CDMF_CBC_PAD 0x00000145 #define CKM_MD2 0x00000200 /* CKM_MD2_HMAC and CKM_MD2_HMAC_GENERAL are new for v2.0 */ #define CKM_MD2_HMAC 0x00000201 #define CKM_MD2_HMAC_GENERAL 0x00000202 #define CKM_MD5 0x00000210 /* CKM_MD5_HMAC and CKM_MD5_HMAC_GENERAL are new for v2.0 */ #define CKM_MD5_HMAC 0x00000211 #define CKM_MD5_HMAC_GENERAL 0x00000212 #define CKM_SHA_1 0x00000220 /* CKM_SHA_1_HMAC and CKM_SHA_1_HMAC_GENERAL are new for v2.0 */ #define CKM_SHA_1_HMAC 0x00000221 #define CKM_SHA_1_HMAC_GENERAL 0x00000222 /* CKM_RIPEMD128, CKM_RIPEMD128_HMAC, * CKM_RIPEMD128_HMAC_GENERAL, CKM_RIPEMD160, CKM_RIPEMD160_HMAC, * and CKM_RIPEMD160_HMAC_GENERAL are new for v2.10 */ #define CKM_RIPEMD128 0x00000230 #define CKM_RIPEMD128_HMAC 0x00000231 #define CKM_RIPEMD128_HMAC_GENERAL 0x00000232 #define CKM_RIPEMD160 0x00000240 #define CKM_RIPEMD160_HMAC 0x00000241 #define CKM_RIPEMD160_HMAC_GENERAL 0x00000242 /* All of the following mechanisms are new for v2.0 */ /* Note that CAST128 and CAST5 are the same algorithm */ #define CKM_CAST_KEY_GEN 0x00000300 #define CKM_CAST_ECB 0x00000301 #define CKM_CAST_CBC 0x00000302 #define CKM_CAST_MAC 0x00000303 #define CKM_CAST_MAC_GENERAL 0x00000304 #define CKM_CAST_CBC_PAD 0x00000305 #define CKM_CAST3_KEY_GEN 0x00000310 #define CKM_CAST3_ECB 0x00000311 #define CKM_CAST3_CBC 0x00000312 #define CKM_CAST3_MAC 0x00000313 #define CKM_CAST3_MAC_GENERAL 0x00000314 #define CKM_CAST3_CBC_PAD 0x00000315 #define CKM_CAST5_KEY_GEN 0x00000320 #define CKM_CAST128_KEY_GEN 0x00000320 #define CKM_CAST5_ECB 0x00000321 #define CKM_CAST128_ECB 0x00000321 #define CKM_CAST5_CBC 0x00000322 #define CKM_CAST128_CBC 0x00000322 #define CKM_CAST5_MAC 0x00000323 #define CKM_CAST128_MAC 0x00000323 #define CKM_CAST5_MAC_GENERAL 0x00000324 #define CKM_CAST128_MAC_GENERAL 0x00000324 #define CKM_CAST5_CBC_PAD 0x00000325 #define CKM_CAST128_CBC_PAD 0x00000325 #define CKM_RC5_KEY_GEN 0x00000330 #define CKM_RC5_ECB 0x00000331 #define CKM_RC5_CBC 0x00000332 #define CKM_RC5_MAC 0x00000333 #define CKM_RC5_MAC_GENERAL 0x00000334 #define CKM_RC5_CBC_PAD 0x00000335 #define CKM_IDEA_KEY_GEN 0x00000340 #define CKM_IDEA_ECB 0x00000341 #define CKM_IDEA_CBC 0x00000342 #define CKM_IDEA_MAC 0x00000343 #define CKM_IDEA_MAC_GENERAL 0x00000344 #define CKM_IDEA_CBC_PAD 0x00000345 #define CKM_GENERIC_SECRET_KEY_GEN 0x00000350 #define CKM_CONCATENATE_BASE_AND_KEY 0x00000360 #define CKM_CONCATENATE_BASE_AND_DATA 0x00000362 #define CKM_CONCATENATE_DATA_AND_BASE 0x00000363 #define CKM_XOR_BASE_AND_DATA 0x00000364 #define CKM_EXTRACT_KEY_FROM_KEY 0x00000365 #define CKM_SSL3_PRE_MASTER_KEY_GEN 0x00000370 #define CKM_SSL3_MASTER_KEY_DERIVE 0x00000371 #define CKM_SSL3_KEY_AND_MAC_DERIVE 0x00000372 /* CKM_SSL3_MASTER_KEY_DERIVE_DH, CKM_TLS_PRE_MASTER_KEY_GEN, * CKM_TLS_MASTER_KEY_DERIVE, CKM_TLS_KEY_AND_MAC_DERIVE, and * CKM_TLS_MASTER_KEY_DERIVE_DH are new for v2.11 */ #define CKM_SSL3_MASTER_KEY_DERIVE_DH 0x00000373 #define CKM_TLS_PRE_MASTER_KEY_GEN 0x00000374 #define CKM_TLS_MASTER_KEY_DERIVE 0x00000375 #define CKM_TLS_KEY_AND_MAC_DERIVE 0x00000376 #define CKM_TLS_MASTER_KEY_DERIVE_DH 0x00000377 #define CKM_SSL3_MD5_MAC 0x00000380 #define CKM_SSL3_SHA1_MAC 0x00000381 #define CKM_MD5_KEY_DERIVATION 0x00000390 #define CKM_MD2_KEY_DERIVATION 0x00000391 #define CKM_SHA1_KEY_DERIVATION 0x00000392 #define CKM_PBE_MD2_DES_CBC 0x000003A0 #define CKM_PBE_MD5_DES_CBC 0x000003A1 #define CKM_PBE_MD5_CAST_CBC 0x000003A2 #define CKM_PBE_MD5_CAST3_CBC 0x000003A3 #define CKM_PBE_MD5_CAST5_CBC 0x000003A4 #define CKM_PBE_MD5_CAST128_CBC 0x000003A4 #define CKM_PBE_SHA1_CAST5_CBC 0x000003A5 #define CKM_PBE_SHA1_CAST128_CBC 0x000003A5 #define CKM_PBE_SHA1_RC4_128 0x000003A6 #define CKM_PBE_SHA1_RC4_40 0x000003A7 #define CKM_PBE_SHA1_DES3_EDE_CBC 0x000003A8 #define CKM_PBE_SHA1_DES2_EDE_CBC 0x000003A9 #define CKM_PBE_SHA1_RC2_128_CBC 0x000003AA #define CKM_PBE_SHA1_RC2_40_CBC 0x000003AB /* CKM_PKCS5_PBKD2 is new for v2.10 */ #define CKM_PKCS5_PBKD2 0x000003B0 #define CKM_PBA_SHA1_WITH_SHA1_HMAC 0x000003C0 #define CKM_KEY_WRAP_LYNKS 0x00000400 #define CKM_KEY_WRAP_SET_OAEP 0x00000401 /* Fortezza mechanisms */ #define CKM_SKIPJACK_KEY_GEN 0x00001000 #define CKM_SKIPJACK_ECB64 0x00001001 #define CKM_SKIPJACK_CBC64 0x00001002 #define CKM_SKIPJACK_OFB64 0x00001003 #define CKM_SKIPJACK_CFB64 0x00001004 #define CKM_SKIPJACK_CFB32 0x00001005 #define CKM_SKIPJACK_CFB16 0x00001006 #define CKM_SKIPJACK_CFB8 0x00001007 #define CKM_SKIPJACK_WRAP 0x00001008 #define CKM_SKIPJACK_PRIVATE_WRAP 0x00001009 #define CKM_SKIPJACK_RELAYX 0x0000100a #define CKM_KEA_KEY_PAIR_GEN 0x00001010 #define CKM_KEA_KEY_DERIVE 0x00001011 #define CKM_FORTEZZA_TIMESTAMP 0x00001020 #define CKM_BATON_KEY_GEN 0x00001030 #define CKM_BATON_ECB128 0x00001031 #define CKM_BATON_ECB96 0x00001032 #define CKM_BATON_CBC128 0x00001033 #define CKM_BATON_COUNTER 0x00001034 #define CKM_BATON_SHUFFLE 0x00001035 #define CKM_BATON_WRAP 0x00001036 /* CKM_ECDSA_KEY_PAIR_GEN is deprecated in v2.11, * CKM_EC_KEY_PAIR_GEN is preferred */ #define CKM_ECDSA_KEY_PAIR_GEN 0x00001040 #define CKM_EC_KEY_PAIR_GEN 0x00001040 #define CKM_ECDSA 0x00001041 #define CKM_ECDSA_SHA1 0x00001042 /* CKM_ECDH1_DERIVE, CKM_ECDH1_COFACTOR_DERIVE, and CKM_ECMQV_DERIVE * are new for v2.11 */ #define CKM_ECDH1_DERIVE 0x00001050 #define CKM_ECDH1_COFACTOR_DERIVE 0x00001051 #define CKM_ECMQV_DERIVE 0x00001052 #define CKM_JUNIPER_KEY_GEN 0x00001060 #define CKM_JUNIPER_ECB128 0x00001061 #define CKM_JUNIPER_CBC128 0x00001062 #define CKM_JUNIPER_COUNTER 0x00001063 #define CKM_JUNIPER_SHUFFLE 0x00001064 #define CKM_JUNIPER_WRAP 0x00001065 #define CKM_FASTHASH 0x00001070 /* CKM_AES_KEY_GEN, CKM_AES_ECB, CKM_AES_CBC, CKM_AES_MAC, * CKM_AES_MAC_GENERAL, CKM_AES_CBC_PAD, CKM_DSA_PARAMETER_GEN, * CKM_DH_PKCS_PARAMETER_GEN, and CKM_X9_42_DH_PARAMETER_GEN are * new for v2.11 */ #define CKM_AES_KEY_GEN 0x00001080 #define CKM_AES_ECB 0x00001081 #define CKM_AES_CBC 0x00001082 #define CKM_AES_MAC 0x00001083 #define CKM_AES_MAC_GENERAL 0x00001084 #define CKM_AES_CBC_PAD 0x00001085 #define CKM_DSA_PARAMETER_GEN 0x00002000 #define CKM_DH_PKCS_PARAMETER_GEN 0x00002001 #define CKM_X9_42_DH_PARAMETER_GEN 0x00002002 #define CKM_VENDOR_DEFINED 0x80000000 typedef CK_MECHANISM_TYPE CK_PTR CK_MECHANISM_TYPE_PTR; /* CK_MECHANISM is a structure that specifies a particular * mechanism */ typedef struct CK_MECHANISM { CK_MECHANISM_TYPE mechanism; CK_VOID_PTR pParameter; /* ulParameterLen was changed from CK_USHORT to CK_ULONG for * v2.0 */ CK_ULONG ulParameterLen; /* in bytes */ } CK_MECHANISM; typedef CK_MECHANISM CK_PTR CK_MECHANISM_PTR; /* CK_MECHANISM_INFO provides information about a particular * mechanism */ typedef struct CK_MECHANISM_INFO { CK_ULONG ulMinKeySize; CK_ULONG ulMaxKeySize; CK_FLAGS flags; } CK_MECHANISM_INFO; /* The flags are defined as follows: * Bit Flag Mask Meaning */ #define CKF_HW 0x00000001 /* performed by HW */ /* The flags CKF_ENCRYPT, CKF_DECRYPT, CKF_DIGEST, CKF_SIGN, * CKG_SIGN_RECOVER, CKF_VERIFY, CKF_VERIFY_RECOVER, * CKF_GENERATE, CKF_GENERATE_KEY_PAIR, CKF_WRAP, CKF_UNWRAP, * and CKF_DERIVE are new for v2.0. They specify whether or not * a mechanism can be used for a particular task */ #define CKF_ENCRYPT 0x00000100 #define CKF_DECRYPT 0x00000200 #define CKF_DIGEST 0x00000400 #define CKF_SIGN 0x00000800 #define CKF_SIGN_RECOVER 0x00001000 #define CKF_VERIFY 0x00002000 #define CKF_VERIFY_RECOVER 0x00004000 #define CKF_GENERATE 0x00008000 #define CKF_GENERATE_KEY_PAIR 0x00010000 #define CKF_WRAP 0x00020000 #define CKF_UNWRAP 0x00040000 #define CKF_DERIVE 0x00080000 /* CKF_EC_F_P, CKF_EC_F_2M, CKF_EC_ECPARAMETERS, CKF_EC_NAMEDCURVE, * CKF_EC_UNCOMPRESS, and CKF_EC_COMPRESS are new for v2.11. They * describe a token's EC capabilities not available in mechanism * information. */ #define CKF_EC_F_P 0x00100000 #define CKF_EC_F_2M 0x00200000 #define CKF_EC_ECPARAMETERS 0x00400000 #define CKF_EC_NAMEDCURVE 0x00800000 #define CKF_EC_UNCOMPRESS 0x01000000 #define CKF_EC_COMPRESS 0x02000000 #define CKF_EXTENSION 0x80000000 /* FALSE for 2.01 */ typedef CK_MECHANISM_INFO CK_PTR CK_MECHANISM_INFO_PTR; /* CK_RV is a value that identifies the return value of a * Cryptoki function */ /* CK_RV was changed from CK_USHORT to CK_ULONG for v2.0 */ typedef CK_ULONG CK_RV; #define CKR_OK 0x00000000 #define CKR_CANCEL 0x00000001 #define CKR_HOST_MEMORY 0x00000002 #define CKR_SLOT_ID_INVALID 0x00000003 /* CKR_FLAGS_INVALID was removed for v2.0 */ /* CKR_GENERAL_ERROR and CKR_FUNCTION_FAILED are new for v2.0 */ #define CKR_GENERAL_ERROR 0x00000005 #define CKR_FUNCTION_FAILED 0x00000006 /* CKR_ARGUMENTS_BAD, CKR_NO_EVENT, CKR_NEED_TO_CREATE_THREADS, * and CKR_CANT_LOCK are new for v2.01 */ #define CKR_ARGUMENTS_BAD 0x00000007 #define CKR_NO_EVENT 0x00000008 #define CKR_NEED_TO_CREATE_THREADS 0x00000009 #define CKR_CANT_LOCK 0x0000000A #define CKR_ATTRIBUTE_READ_ONLY 0x00000010 #define CKR_ATTRIBUTE_SENSITIVE 0x00000011 #define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012 #define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013 #define CKR_DATA_INVALID 0x00000020 #define CKR_DATA_LEN_RANGE 0x00000021 #define CKR_DEVICE_ERROR 0x00000030 #define CKR_DEVICE_MEMORY 0x00000031 #define CKR_DEVICE_REMOVED 0x00000032 #define CKR_ENCRYPTED_DATA_INVALID 0x00000040 #define CKR_ENCRYPTED_DATA_LEN_RANGE 0x00000041 #define CKR_FUNCTION_CANCELED 0x00000050 #define CKR_FUNCTION_NOT_PARALLEL 0x00000051 /* CKR_FUNCTION_NOT_SUPPORTED is new for v2.0 */ #define CKR_FUNCTION_NOT_SUPPORTED 0x00000054 #define CKR_KEY_HANDLE_INVALID 0x00000060 /* CKR_KEY_SENSITIVE was removed for v2.0 */ #define CKR_KEY_SIZE_RANGE 0x00000062 #define CKR_KEY_TYPE_INCONSISTENT 0x00000063 /* CKR_KEY_NOT_NEEDED, CKR_KEY_CHANGED, CKR_KEY_NEEDED, * CKR_KEY_INDIGESTIBLE, CKR_KEY_FUNCTION_NOT_PERMITTED, * CKR_KEY_NOT_WRAPPABLE, and CKR_KEY_UNEXTRACTABLE are new for * v2.0 */ #define CKR_KEY_NOT_NEEDED 0x00000064 #define CKR_KEY_CHANGED 0x00000065 #define CKR_KEY_NEEDED 0x00000066 #define CKR_KEY_INDIGESTIBLE 0x00000067 #define CKR_KEY_FUNCTION_NOT_PERMITTED 0x00000068 #define CKR_KEY_NOT_WRAPPABLE 0x00000069 #define CKR_KEY_UNEXTRACTABLE 0x0000006A #define CKR_MECHANISM_INVALID 0x00000070 #define CKR_MECHANISM_PARAM_INVALID 0x00000071 /* CKR_OBJECT_CLASS_INCONSISTENT and CKR_OBJECT_CLASS_INVALID * were removed for v2.0 */ #define CKR_OBJECT_HANDLE_INVALID 0x00000082 #define CKR_OPERATION_ACTIVE 0x00000090 #define CKR_OPERATION_NOT_INITIALIZED 0x00000091 #define CKR_PIN_INCORRECT 0x000000A0 #define CKR_PIN_INVALID 0x000000A1 #define CKR_PIN_LEN_RANGE 0x000000A2 /* CKR_PIN_EXPIRED and CKR_PIN_LOCKED are new for v2.0 */ #define CKR_PIN_EXPIRED 0x000000A3 #define CKR_PIN_LOCKED 0x000000A4 #define CKR_SESSION_CLOSED 0x000000B0 #define CKR_SESSION_COUNT 0x000000B1 #define CKR_SESSION_HANDLE_INVALID 0x000000B3 #define CKR_SESSION_PARALLEL_NOT_SUPPORTED 0x000000B4 #define CKR_SESSION_READ_ONLY 0x000000B5 #define CKR_SESSION_EXISTS 0x000000B6 /* CKR_SESSION_READ_ONLY_EXISTS and * CKR_SESSION_READ_WRITE_SO_EXISTS are new for v2.0 */ #define CKR_SESSION_READ_ONLY_EXISTS 0x000000B7 #define CKR_SESSION_READ_WRITE_SO_EXISTS 0x000000B8 #define CKR_SIGNATURE_INVALID 0x000000C0 #define CKR_SIGNATURE_LEN_RANGE 0x000000C1 #define CKR_TEMPLATE_INCOMPLETE 0x000000D0 #define CKR_TEMPLATE_INCONSISTENT 0x000000D1 #define CKR_TOKEN_NOT_PRESENT 0x000000E0 #define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1 #define CKR_TOKEN_WRITE_PROTECTED 0x000000E2 #define CKR_UNWRAPPING_KEY_HANDLE_INVALID 0x000000F0 #define CKR_UNWRAPPING_KEY_SIZE_RANGE 0x000000F1 #define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT 0x000000F2 #define CKR_USER_ALREADY_LOGGED_IN 0x00000100 #define CKR_USER_NOT_LOGGED_IN 0x00000101 #define CKR_USER_PIN_NOT_INITIALIZED 0x00000102 #define CKR_USER_TYPE_INVALID 0x00000103 /* CKR_USER_ANOTHER_ALREADY_LOGGED_IN and CKR_USER_TOO_MANY_TYPES * are new to v2.01 */ #define CKR_USER_ANOTHER_ALREADY_LOGGED_IN 0x00000104 #define CKR_USER_TOO_MANY_TYPES 0x00000105 #define CKR_WRAPPED_KEY_INVALID 0x00000110 #define CKR_WRAPPED_KEY_LEN_RANGE 0x00000112 #define CKR_WRAPPING_KEY_HANDLE_INVALID 0x00000113 #define CKR_WRAPPING_KEY_SIZE_RANGE 0x00000114 #define CKR_WRAPPING_KEY_TYPE_INCONSISTENT 0x00000115 #define CKR_RANDOM_SEED_NOT_SUPPORTED 0x00000120 /* These are new to v2.0 */ #define CKR_RANDOM_NO_RNG 0x00000121 /* These are new to v2.11 */ #define CKR_DOMAIN_PARAMS_INVALID 0x00000130 /* These are new to v2.0 */ #define CKR_BUFFER_TOO_SMALL 0x00000150 #define CKR_SAVED_STATE_INVALID 0x00000160 #define CKR_INFORMATION_SENSITIVE 0x00000170 #define CKR_STATE_UNSAVEABLE 0x00000180 /* These are new to v2.01 */ #define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190 #define CKR_CRYPTOKI_ALREADY_INITIALIZED 0x00000191 #define CKR_MUTEX_BAD 0x000001A0 #define CKR_MUTEX_NOT_LOCKED 0x000001A1 #define CKR_VENDOR_DEFINED 0x80000000 /* CK_NOTIFY is an application callback that processes events */ typedef CK_CALLBACK_FUNCTION(CK_RV, CK_NOTIFY)( CK_SESSION_HANDLE hSession, /* the session's handle */ CK_NOTIFICATION event, CK_VOID_PTR pApplication /* passed to C_OpenSession */ ); /* CK_FUNCTION_LIST is a structure holding a Cryptoki spec * version and pointers of appropriate types to all the * Cryptoki functions */ /* CK_FUNCTION_LIST is new for v2.0 */ typedef struct CK_FUNCTION_LIST CK_FUNCTION_LIST; typedef CK_FUNCTION_LIST CK_PTR CK_FUNCTION_LIST_PTR; typedef CK_FUNCTION_LIST_PTR CK_PTR CK_FUNCTION_LIST_PTR_PTR; /* CK_CREATEMUTEX is an application callback for creating a * mutex object */ typedef CK_CALLBACK_FUNCTION(CK_RV, CK_CREATEMUTEX)( CK_VOID_PTR_PTR ppMutex /* location to receive ptr to mutex */ ); /* CK_DESTROYMUTEX is an application callback for destroying a * mutex object */ typedef CK_CALLBACK_FUNCTION(CK_RV, CK_DESTROYMUTEX)( CK_VOID_PTR pMutex /* pointer to mutex */ ); /* CK_LOCKMUTEX is an application callback for locking a mutex */ typedef CK_CALLBACK_FUNCTION(CK_RV, CK_LOCKMUTEX)( CK_VOID_PTR pMutex /* pointer to mutex */ ); /* CK_UNLOCKMUTEX is an application callback for unlocking a * mutex */ typedef CK_CALLBACK_FUNCTION(CK_RV, CK_UNLOCKMUTEX)( CK_VOID_PTR pMutex /* pointer to mutex */ ); /* CK_C_INITIALIZE_ARGS provides the optional arguments to * C_Initialize */ typedef struct CK_C_INITIALIZE_ARGS { CK_CREATEMUTEX CreateMutex; CK_DESTROYMUTEX DestroyMutex; CK_LOCKMUTEX LockMutex; CK_UNLOCKMUTEX UnlockMutex; CK_FLAGS flags; CK_VOID_PTR LibraryParameters; CK_VOID_PTR pReserved; } CK_C_INITIALIZE_ARGS; /* flags: bit flags that provide capabilities of the slot * Bit Flag Mask Meaning */ #define CKF_LIBRARY_CANT_CREATE_OS_THREADS 0x00000001 #define CKF_OS_LOCKING_OK 0x00000002 typedef CK_C_INITIALIZE_ARGS CK_PTR CK_C_INITIALIZE_ARGS_PTR; /* additional flags for parameters to functions */ /* CKF_DONT_BLOCK is for the function C_WaitForSlotEvent */ #define CKF_DONT_BLOCK 1 /* CK_RSA_PKCS_OAEP_MGF_TYPE is new for v2.10. * CK_RSA_PKCS_OAEP_MGF_TYPE is used to indicate the Message * Generation Function (MGF) applied to a message block when * formatting a message block for the PKCS #1 OAEP encryption * scheme. */ typedef CK_ULONG CK_RSA_PKCS_MGF_TYPE; typedef CK_RSA_PKCS_MGF_TYPE CK_PTR CK_RSA_PKCS_MGF_TYPE_PTR; /* The following MGFs are defined */ #define CKG_MGF1_SHA1 0x00000001 /* CK_RSA_PKCS_OAEP_SOURCE_TYPE is new for v2.10. * CK_RSA_PKCS_OAEP_SOURCE_TYPE is used to indicate the source * of the encoding parameter when formatting a message block * for the PKCS #1 OAEP encryption scheme. */ typedef CK_ULONG CK_RSA_PKCS_OAEP_SOURCE_TYPE; typedef CK_RSA_PKCS_OAEP_SOURCE_TYPE CK_PTR CK_RSA_PKCS_OAEP_SOURCE_TYPE_PTR; /* The following encoding parameter sources are defined */ #define CKZ_DATA_SPECIFIED 0x00000001 /* CK_RSA_PKCS_OAEP_PARAMS is new for v2.10. * CK_RSA_PKCS_OAEP_PARAMS provides the parameters to the * CKM_RSA_PKCS_OAEP mechanism. */ typedef struct CK_RSA_PKCS_OAEP_PARAMS { CK_MECHANISM_TYPE hashAlg; CK_RSA_PKCS_MGF_TYPE mgf; CK_RSA_PKCS_OAEP_SOURCE_TYPE source; CK_VOID_PTR pSourceData; CK_ULONG ulSourceDataLen; } CK_RSA_PKCS_OAEP_PARAMS; typedef CK_RSA_PKCS_OAEP_PARAMS CK_PTR CK_RSA_PKCS_OAEP_PARAMS_PTR; /* CK_RSA_PKCS_PSS_PARAMS is new for v2.11. * CK_RSA_PKCS_PSS_PARAMS provides the parameters to the * CKM_RSA_PKCS_PSS mechanism(s). */ typedef struct CK_RSA_PKCS_PSS_PARAMS { CK_MECHANISM_TYPE hashAlg; CK_RSA_PKCS_MGF_TYPE mgf; CK_ULONG sLen; } CK_RSA_PKCS_PSS_PARAMS; /* CK_KEA_DERIVE_PARAMS provides the parameters to the * CKM_KEA_DERIVE mechanism */ /* CK_KEA_DERIVE_PARAMS is new for v2.0 */ typedef struct CK_KEA_DERIVE_PARAMS { CK_BBOOL isSender; CK_ULONG ulRandomLen; CK_BYTE_PTR pRandomA; CK_BYTE_PTR pRandomB; CK_ULONG ulPublicDataLen; CK_BYTE_PTR pPublicData; } CK_KEA_DERIVE_PARAMS; typedef CK_KEA_DERIVE_PARAMS CK_PTR CK_KEA_DERIVE_PARAMS_PTR; /* CK_RC2_PARAMS provides the parameters to the CKM_RC2_ECB and * CKM_RC2_MAC mechanisms. An instance of CK_RC2_PARAMS just * holds the effective keysize */ typedef CK_ULONG CK_RC2_PARAMS; typedef CK_RC2_PARAMS CK_PTR CK_RC2_PARAMS_PTR; /* CK_RC2_CBC_PARAMS provides the parameters to the CKM_RC2_CBC * mechanism */ typedef struct CK_RC2_CBC_PARAMS { /* ulEffectiveBits was changed from CK_USHORT to CK_ULONG for * v2.0 */ CK_ULONG ulEffectiveBits; /* effective bits (1-1024) */ CK_BYTE iv[8]; /* IV for CBC mode */ } CK_RC2_CBC_PARAMS; typedef CK_RC2_CBC_PARAMS CK_PTR CK_RC2_CBC_PARAMS_PTR; /* CK_RC2_MAC_GENERAL_PARAMS provides the parameters for the * CKM_RC2_MAC_GENERAL mechanism */ /* CK_RC2_MAC_GENERAL_PARAMS is new for v2.0 */ typedef struct CK_RC2_MAC_GENERAL_PARAMS { CK_ULONG ulEffectiveBits; /* effective bits (1-1024) */ CK_ULONG ulMacLength; /* Length of MAC in bytes */ } CK_RC2_MAC_GENERAL_PARAMS; typedef CK_RC2_MAC_GENERAL_PARAMS CK_PTR \ CK_RC2_MAC_GENERAL_PARAMS_PTR; /* CK_RC5_PARAMS provides the parameters to the CKM_RC5_ECB and * CKM_RC5_MAC mechanisms */ /* CK_RC5_PARAMS is new for v2.0 */ typedef struct CK_RC5_PARAMS { CK_ULONG ulWordsize; /* wordsize in bits */ CK_ULONG ulRounds; /* number of rounds */ } CK_RC5_PARAMS; typedef CK_RC5_PARAMS CK_PTR CK_RC5_PARAMS_PTR; /* CK_RC5_CBC_PARAMS provides the parameters to the CKM_RC5_CBC * mechanism */ /* CK_RC5_CBC_PARAMS is new for v2.0 */ typedef struct CK_RC5_CBC_PARAMS { CK_ULONG ulWordsize; /* wordsize in bits */ CK_ULONG ulRounds; /* number of rounds */ CK_BYTE_PTR pIv; /* pointer to IV */ CK_ULONG ulIvLen; /* length of IV in bytes */ } CK_RC5_CBC_PARAMS; typedef CK_RC5_CBC_PARAMS CK_PTR CK_RC5_CBC_PARAMS_PTR; /* CK_RC5_MAC_GENERAL_PARAMS provides the parameters for the * CKM_RC5_MAC_GENERAL mechanism */ /* CK_RC5_MAC_GENERAL_PARAMS is new for v2.0 */ typedef struct CK_RC5_MAC_GENERAL_PARAMS { CK_ULONG ulWordsize; /* wordsize in bits */ CK_ULONG ulRounds; /* number of rounds */ CK_ULONG ulMacLength; /* Length of MAC in bytes */ } CK_RC5_MAC_GENERAL_PARAMS; typedef CK_RC5_MAC_GENERAL_PARAMS CK_PTR \ CK_RC5_MAC_GENERAL_PARAMS_PTR; /* CK_MAC_GENERAL_PARAMS provides the parameters to most block * ciphers' MAC_GENERAL mechanisms. Its value is the length of * the MAC */ /* CK_MAC_GENERAL_PARAMS is new for v2.0 */ typedef CK_ULONG CK_MAC_GENERAL_PARAMS; typedef CK_MAC_GENERAL_PARAMS CK_PTR CK_MAC_GENERAL_PARAMS_PTR; /* CK_SKIPJACK_PRIVATE_WRAP_PARAMS provides the parameters to the * CKM_SKIPJACK_PRIVATE_WRAP mechanism */ /* CK_SKIPJACK_PRIVATE_WRAP_PARAMS is new for v2.0 */ typedef struct CK_SKIPJACK_PRIVATE_WRAP_PARAMS { CK_ULONG ulPasswordLen; CK_BYTE_PTR pPassword; CK_ULONG ulPublicDataLen; CK_BYTE_PTR pPublicData; CK_ULONG ulPAndGLen; CK_ULONG ulQLen; CK_ULONG ulRandomLen; CK_BYTE_PTR pRandomA; CK_BYTE_PTR pPrimeP; CK_BYTE_PTR pBaseG; CK_BYTE_PTR pSubprimeQ; } CK_SKIPJACK_PRIVATE_WRAP_PARAMS; typedef CK_SKIPJACK_PRIVATE_WRAP_PARAMS CK_PTR \ CK_SKIPJACK_PRIVATE_WRAP_PTR; /* CK_SKIPJACK_RELAYX_PARAMS provides the parameters to the * CKM_SKIPJACK_RELAYX mechanism */ /* CK_SKIPJACK_RELAYX_PARAMS is new for v2.0 */ typedef struct CK_SKIPJACK_RELAYX_PARAMS { CK_ULONG ulOldWrappedXLen; CK_BYTE_PTR pOldWrappedX; CK_ULONG ulOldPasswordLen; CK_BYTE_PTR pOldPassword; CK_ULONG ulOldPublicDataLen; CK_BYTE_PTR pOldPublicData; CK_ULONG ulOldRandomLen; CK_BYTE_PTR pOldRandomA; CK_ULONG ulNewPasswordLen; CK_BYTE_PTR pNewPassword; CK_ULONG ulNewPublicDataLen; CK_BYTE_PTR pNewPublicData; CK_ULONG ulNewRandomLen; CK_BYTE_PTR pNewRandomA; } CK_SKIPJACK_RELAYX_PARAMS; typedef CK_SKIPJACK_RELAYX_PARAMS CK_PTR \ CK_SKIPJACK_RELAYX_PARAMS_PTR; typedef struct CK_PBE_PARAMS { CK_BYTE_PTR pInitVector; CK_UTF8CHAR_PTR pPassword; CK_ULONG ulPasswordLen; CK_BYTE_PTR pSalt; CK_ULONG ulSaltLen; CK_ULONG ulIteration; } CK_PBE_PARAMS; typedef CK_PBE_PARAMS CK_PTR CK_PBE_PARAMS_PTR; /* CK_KEY_WRAP_SET_OAEP_PARAMS provides the parameters to the * CKM_KEY_WRAP_SET_OAEP mechanism */ /* CK_KEY_WRAP_SET_OAEP_PARAMS is new for v2.0 */ typedef struct CK_KEY_WRAP_SET_OAEP_PARAMS { CK_BYTE bBC; /* block contents byte */ CK_BYTE_PTR pX; /* extra data */ CK_ULONG ulXLen; /* length of extra data in bytes */ } CK_KEY_WRAP_SET_OAEP_PARAMS; typedef CK_KEY_WRAP_SET_OAEP_PARAMS CK_PTR \ CK_KEY_WRAP_SET_OAEP_PARAMS_PTR; typedef struct CK_SSL3_RANDOM_DATA { CK_BYTE_PTR pClientRandom; CK_ULONG ulClientRandomLen; CK_BYTE_PTR pServerRandom; CK_ULONG ulServerRandomLen; } CK_SSL3_RANDOM_DATA; typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS { CK_SSL3_RANDOM_DATA RandomInfo; CK_VERSION_PTR pVersion; } CK_SSL3_MASTER_KEY_DERIVE_PARAMS; typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS CK_PTR \ CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR; typedef struct CK_SSL3_KEY_MAT_OUT { CK_OBJECT_HANDLE hClientMacSecret; CK_OBJECT_HANDLE hServerMacSecret; CK_OBJECT_HANDLE hClientKey; CK_OBJECT_HANDLE hServerKey; CK_BYTE_PTR pIVClient; CK_BYTE_PTR pIVServer; } CK_SSL3_KEY_MAT_OUT; typedef CK_SSL3_KEY_MAT_OUT CK_PTR CK_SSL3_KEY_MAT_OUT_PTR; typedef struct CK_SSL3_KEY_MAT_PARAMS { CK_ULONG ulMacSizeInBits; CK_ULONG ulKeySizeInBits; CK_ULONG ulIVSizeInBits; CK_BBOOL bIsExport; CK_SSL3_RANDOM_DATA RandomInfo; CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; } CK_SSL3_KEY_MAT_PARAMS; typedef CK_SSL3_KEY_MAT_PARAMS CK_PTR CK_SSL3_KEY_MAT_PARAMS_PTR; typedef struct CK_KEY_DERIVATION_STRING_DATA { CK_BYTE_PTR pData; CK_ULONG ulLen; } CK_KEY_DERIVATION_STRING_DATA; typedef CK_KEY_DERIVATION_STRING_DATA CK_PTR \ CK_KEY_DERIVATION_STRING_DATA_PTR; /* The CK_EXTRACT_PARAMS is used for the * CKM_EXTRACT_KEY_FROM_KEY mechanism. It specifies which bit * of the base key should be used as the first bit of the * derived key */ /* CK_EXTRACT_PARAMS is new for v2.0 */ typedef CK_ULONG CK_EXTRACT_PARAMS; typedef CK_EXTRACT_PARAMS CK_PTR CK_EXTRACT_PARAMS_PTR; /* CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is new for v2.10. * CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is used to * indicate the Pseudo-Random Function (PRF) used to generate * key bits using PKCS #5 PBKDF2. */ typedef CK_ULONG CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE; typedef CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE CK_PTR CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE_PTR; /* The following PRFs are defined in PKCS #5 v2.0. */ #define CKP_PKCS5_PBKD2_HMAC_SHA1 0x00000001 /* CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is new for v2.10. * CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is used to indicate the * source of the salt value when deriving a key using PKCS #5 * PBKDF2. */ typedef CK_ULONG CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE; typedef CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE CK_PTR CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE_PTR; /* The following salt value sources are defined in PKCS #5 v2.0. */ #define CKZ_SALT_SPECIFIED 0x00000001 /* CK_PKCS5_PBKD2_PARAMS is new for v2.10. * CK_PKCS5_PBKD2_PARAMS is a structure that provides the * parameters to the CKM_PKCS5_PBKD2 mechanism. */ typedef struct CK_PKCS5_PBKD2_PARAMS { CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE saltSource; CK_VOID_PTR pSaltSourceData; CK_ULONG ulSaltSourceDataLen; CK_ULONG iterations; CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf; CK_VOID_PTR pPrfData; CK_ULONG ulPrfDataLen; CK_UTF8CHAR_PTR pPassword; CK_ULONG_PTR ulPasswordLen; } CK_PKCS5_PBKD2_PARAMS; typedef CK_PKCS5_PBKD2_PARAMS CK_PTR CK_PKCS5_PBKD2_PARAMS_PTR; #endif --- NEW FILE slot.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #include #include "mypkcs11.h" #include #include #include "log.h" #include "PKCS11Exception.h" #include #include "slot.h" #include #include "zlib.h" #include "params.h" #include "machdep.h" #define MIN(x, y) ((x) < (y) ? (x) : (y)) using std::auto_ptr; #ifdef DEBUG #define PRINTF(args) printf args #else #define PRINTF(args) #endif // #define DISPLAY_WHOLE_GET_DATA 1 // The Cyberflex Access 32k egate ATR const CKYByte ATR[] = { 0x3b, 0x75, 0x94, 0x00, 0x00, 0x62, 0x02, 0x02, 0x02, 0x01 }; const CKYByte ATR1[] = { 0x3b, 0x75, 0x94, 0x00, 0x00, 0x62, 0x02, 0x02, 0x03, 0x01 }; const CKYByte ATR3[] = { 0x3b, 0x76, 0x94, 0x00, 0x00, 0xff, 0x62, 0x76, 0x01, 0x00, 0x00 }; /* RSA SecurID */ const CKYByte ATR2[] = { 0x3B, 0x6F, 0x00, 0xFF, 0x52, 0x53, 0x41, 0x53, 0x65, 0x63, 0x75, 0x72, 0x49, 0x44, 0x28, 0x52, 0x29, 0x31, 0x30 }; SlotList::SlotList(Log *log_) : log(log_) { // initialize things to NULL so we can recover from an exception slots = NULL; numSlots = 0; readerStates = NULL; numReaders = 0; context = NULL; shuttingDown = FALSE; try { context = CKYCardContext_Create(SCARD_SCOPE_USER); if( context == NULL) { throw PKCS11Exception(CKR_GENERAL_ERROR, "Failed to create card context\n"); } updateSlotList(); } catch( PKCS11Exception &) { CKYCardContext_Destroy(context); if (readerStates) { CKYReader_DestroyArray(readerStates, numReaders); } throw; } } SlotList::~SlotList() { if( slots ) { assert( numSlots > 0 ); for( unsigned int i=0; i < numSlots; ++i ) { delete slots[i]; } delete [] slots; slots = NULL; numSlots = 0; } if (readerStates) { CKYReader_DestroyArray(readerStates, numReaders); readerStates = NULL; numReaders = 0; } if (context) { CKYCardContext_Destroy(context); context = NULL; } } void SlotList::shutdown() { shuttingDown = TRUE; CKYCardContext_Cancel(context); } void SlotList::updateSlotList() { Slot **newSlots = NULL; Slot **oldSlots = NULL; readerListLock.getLock(); updateReaderList(); if (numSlots == numReaders) { readerListLock.releaseLock(); return; } assert(numSlots < numReaders); if (numSlots > numReaders) { readerListLock.releaseLock(); throw PKCS11Exception(CKR_GENERAL_ERROR, "Reader and slot count inconsistant\n"); } try { newSlots = new Slot*[numReaders]; if (newSlots == NULL ) throw PKCS11Exception(CKR_HOST_MEMORY); memset(newSlots, 0, numReaders*sizeof(Slot*)); memcpy(newSlots, slots, sizeof(slots[0]) * numSlots); for (unsigned int i=numSlots; i < numReaders; i++) { newSlots[i] = new Slot(CKYReader_GetReaderName(&readerStates[i]), log, context); } oldSlots = slots; slots = newSlots; // update the pointer first numSlots = numReaders; // now update the count if (oldSlots) { // ok we can free the old value now delete [] oldSlots; } } catch( PKCS11Exception &) { // Recover by deleting everything that was created. if( newSlots ) { assert(numSlots < numReaders ); for( unsigned int i=numSlots; i < numReaders; ++i ) { if( newSlots[i] ) { delete newSlots[i]; } } delete [] newSlots; } readerListLock.releaseLock(); throw; } readerListLock.releaseLock(); } bool SlotList::readerExists(const char *readerName, unsigned int *hint) { unsigned int start = 0; unsigned int i; if (hint && (*hint < numReaders)) { start = *hint; } /* * We use 'hint' as a way of deciding where to * start. This way we can handle the normal case where the name list * and the readerState matches one for one with a single string compare. */ for (i=start; i < numReaders; i++) { if (strcmp(CKYReader_GetReaderName(&readerStates[i]),readerName) == 0) { if (hint) { *hint = i+1; } return TRUE; } } /* we guessed wrong, check the first part of the reader states */ for (i=0; i < start; i++) { if (strcmp(CKYReader_GetReaderName(&readerStates[i]),readerName) == 0) { if (hint) { *hint = i+1; [...2793 lines suppressed...] if( pInput == NULL || ulInputLen == 0) { throw PKCS11Exception(CKR_DATA_LEN_RANGE); } // OK, this is gross. We should get our own C++ like buffer // management at this point. This code has nothing to do with // the applet, it shouldn't be using applet specific buffers. CKYBuffer input; CKYBuffer inputPad; CKYBuffer output; CKYBuffer_InitEmpty(&output); CKYBuffer_InitEmpty(&inputPad); CKYStatus status = CKYBuffer_InitFromData(&input, pInput, ulInputLen); if (status != CKYSUCCESS) { throw PKCS11Exception(CKR_HOST_MEMORY); } try { params.padInput(&inputPad, &input); performRSAOp(&output, &inputPad, keyNum, params.getDirection()); params.unpadOutput(result, &output); CKYBuffer_FreeData(&input); CKYBuffer_FreeData(&inputPad); CKYBuffer_FreeData(&output); } catch(PKCS11Exception& e) { CKYBuffer_FreeData(&input); CKYBuffer_FreeData(&inputPad); CKYBuffer_FreeData(&output); throw(e); } } if( pulOutputLen == NULL ) { throw PKCS11Exception(CKR_DATA_INVALID, "output length is NULL"); } if( pOutput != NULL ) { if( *pulOutputLen < CKYBuffer_Size(result) ) { *pulOutputLen = CKYBuffer_Size(result); throw PKCS11Exception(CKR_BUFFER_TOO_SMALL); } memcpy(pOutput, CKYBuffer_Data(result), CKYBuffer_Size(result)); } *pulOutputLen = CKYBuffer_Size(result); } const CKYBuffer * Slot::getNonce() { if (!isVersion1Key) { return NULL; } return &nonce; } void Slot::performRSAOp(CKYBuffer *output, const CKYBuffer *input, CKYByte keyNum, CKYByte direction) { // // establish a transaction // Transaction trans; CKYStatus status = trans.begin(conn); if( status != CKYSUCCESS ) handleConnectionError(); // // select the applet // if (state & CAC_CARD) { selectCACApplet(keyNum); } else { selectApplet(); } CKYISOStatus result; int loginAttempted = 0; retry: if (state & CAC_CARD) { status = CACApplet_SignDecrypt(conn, input, output, &result); } else { status = CKYApplet_ComputeCrypt(conn, keyNum, CKY_RSA_NO_PAD, direction, input, NULL, output, getNonce(), &result); } if (status != CKYSUCCESS) { if ( status == CKYSCARDERR ) { handleConnectionError(); } if (result == CKYISO_DATA_INVALID) { throw PKCS11Exception(CKR_DATA_INVALID); } // version0 keys could be logged out in the middle by someone else, // reauthenticate... This code can go away when we depricate. // version0 applets. if (!isVersion1Key && !loginAttempted && (result == CKYISO_UNAUTHORIZED)) { // try to reauthenticate try { oldAttemptLogin(); } catch(PKCS11Exception& ) { // attemptLogin can throw things like CKR_PIN_INCORRECT // that don't make sense from a crypto operation. This is // a result of pin caching. We will reformat any login // exception to a CKR_DEVICE_ERROR. throw PKCS11Exception(CKR_DEVICE_ERROR); } loginAttempted = true; goto retry; // easier to understand than a while loop in this case. } throw PKCS11Exception( result == CKYISO_UNAUTHORIZED ? CKR_USER_NOT_LOGGED_IN : CKR_DEVICE_ERROR); } } void Slot::seedRandom(SessionHandleSuffix suffix, CK_BYTE_PTR pData, CK_ULONG ulDataLen) { if (state & CAC_CARD) { /* should throw unsupported */ throw PKCS11Exception(CKR_DEVICE_ERROR); } Transaction trans; CKYStatus status = trans.begin(conn); if( status != CKYSUCCESS ) handleConnectionError(); CKYBuffer random; CKYBuffer seed; CKYOffset offset = 0; CKYISOStatus result; int i; CKYBuffer_InitEmpty(&random); CKYBuffer_InitFromData(&seed, pData, ulDataLen); while (ulDataLen) { CKYByte len = (CKYByte) MIN(ulDataLen, 0xff); status = CKYApplet_GetRandom(conn, &random, len, &result); if (status != CKYSUCCESS) break; for (i=0; i < len ; i++) { CKYBuffer_SetChar(&random, i, CKYBuffer_GetChar(&random,i) ^ CKYBuffer_GetChar(&seed,i+offset)); } status = CKYApplet_SeedRandom(conn, &random, &result); if (status != CKYSUCCESS) break; ulDataLen -= (unsigned char)len; offset += (unsigned char)len; } CKYBuffer_FreeData(&random); CKYBuffer_FreeData(&seed); if (status != CKYSUCCESS) { if ( status == CKYSCARDERR ) { handleConnectionError(); } throw PKCS11Exception(CKR_DEVICE_ERROR); } } void Slot::generateRandom(SessionHandleSuffix suffix, const CK_BYTE_PTR pData, CK_ULONG ulDataLen) { if (state & CAC_CARD) { /* should throw unsupported */ throw PKCS11Exception(CKR_DEVICE_ERROR); } Transaction trans; CKYStatus status = trans.begin(conn); if( status != CKYSUCCESS ) handleConnectionError(); CKYBuffer random; CKYBuffer_InitEmpty(&random); CKYISOStatus result; while (ulDataLen) { CKYByte len = (CKYByte) MIN(ulDataLen, 0xff); status = CKYApplet_GetRandomAppend(conn, &random, len, &result); if (status != CKYSUCCESS) break; ulDataLen -= (unsigned char)len; } CKYBuffer_FreeData(&random); if (status != CKYSUCCESS) { if ( status == CKYSCARDERR ) { handleConnectionError(); } throw PKCS11Exception(CKR_DEVICE_ERROR); } } --- NEW FILE slot.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #ifndef COOLKEY_SLOT_H #define COOLKEY_SLOT_H #include "locking.h" #include "log.h" #include "cky_applet.h" #include #include #include "object.h" #include "machdep.h" #include using std::list; using std::find; using std::find_if; class Transaction { private: CKYCardConnection *conn; Transaction(const Transaction&) {} // not allowed Transaction& operator=(const Transaction&) {return *this;} // not allowed public: Transaction() : conn(0) { } CKYStatus begin(CKYCardConnection *conn_) { CKYStatus status; status = CKYCardConnection_BeginTransaction(conn_); if (status == CKYSUCCESS) { conn = conn_; } return status; } CKYStatus end() { CKYStatus status = CKYSUCCESS; CKYCardConnection *conn_ = conn; conn = NULL; if (conn_) { status = CKYCardConnection_EndTransaction(conn_); } return status; } ~Transaction() { if (conn) end(); } }; #ifdef USE_SHMEM #define SHMEM_VERSION 0x0100 // 1.0 class SlotMemSegment { private: char *segmentAddr; int segmentSize; SHMem *segment; // machine independed shared memory object public: SlotMemSegment(const char *readerName); ~SlotMemSegment(); bool CUIDIsEqual(const CKYBuffer *cuid) const; unsigned short getVersion() const; unsigned short getDataVersion() const; void setCUID(const CKYBuffer *cuid); void setVersion(unsigned short version); void setDataVersion(unsigned short version); bool isValid() const; int size() const; const unsigned char *getCUID() const; void readHeader(CKYBuffer *data) const; void writeHeader(const CKYBuffer *data); void setSize(int size); void readData(CKYBuffer *data) const; void writeData(const CKYBuffer *data); void readCACCert(CKYBuffer *data, CKYByte instance) const; void writeCACCert(const CKYBuffer *data, CKYByte instance); void clearValid(CKYByte instance); void setValid(); }; #endif struct ListObjectInfo { CKYAppletRespListObjects obj; CKYBuffer data; ListObjectInfo(const ListObjectInfo &cpy) { obj = cpy.obj; CKYBuffer_InitFromCopy(&data,&cpy.data); } ListObjectInfo &operator=(const ListObjectInfo& cpy ) { obj = cpy.obj; CKYBuffer_Replace(&data, 0, CKYBuffer_Data(&cpy.data), CKYBuffer_Size(&cpy.data)); return *this; } bool operator==(const ListObjectInfo& cmp) const { if( obj.objectID != cmp.obj.objectID ) return false; if( obj.objectSize!=cmp.obj.objectSize ) return false; if( obj.readACL != cmp.obj.readACL ) return false; if( obj.writeACL != cmp.obj.writeACL ) return false; if( obj.deleteACL != cmp.obj.deleteACL ) return false; if( !CKYBuffer_IsEqual(&data,&cmp.data) ) return false; return true; } ListObjectInfo(void) { memset(&obj, 0, sizeof(obj)); CKYBuffer_InitEmpty(&data); } ~ListObjectInfo() { CKYBuffer_FreeData(&data); } }; // // The most significant byte of a session handle is the slot ID. // The three most significant bytes, the SessionHandleSuffix, are controlled // by the slot itself. // class SessionHandleSuffix { private: CK_SESSION_HANDLE value; public: SessionHandleSuffix() : value(0) { } SessionHandleSuffix(CK_SESSION_HANDLE val) { value = val & 0x00ffffff; } operator CK_SESSION_HANDLE() { return value; } SessionHandleSuffix& operator=(CK_SESSION_HANDLE val) { value = val & 0x00ffffff; return *this; } bool operator==(const SessionHandleSuffix&cmp) const { return value == cmp.value; } }; struct PinCache { private: CKYBuffer cachedPin; bool valid; PinCache(const PinCache &cpy) {} // not allowed PinCache &operator=(const PinCache &cpy) { return *this ; } // not allowed public: PinCache() : valid(false) { CKYBuffer_InitEmpty(&cachedPin); } ~PinCache() { CKYBuffer_Zero(&cachedPin); /* zero buffer before freeing it so * we don't get passwords on the heap */ CKYBuffer_FreeData(&cachedPin); } void set(const char *newPin, unsigned long pinLen) { CKYBuffer_Zero(&cachedPin); CKYBuffer_Replace(&cachedPin, 0, (const CKYByte *)newPin, pinLen); CKYBuffer_AppendChar(&cachedPin, 0); } void clearPin() { CKYBuffer_Zero(&cachedPin); } void invalidate() { valid = false; } void validate() { valid = true; } const CKYBuffer *get() const { return &cachedPin; } bool isValid() const { return valid; } }; inline unsigned int slotIDToIndex(CK_SLOT_ID slotID) { return slotID - 1; } inline CK_SLOT_ID slotIndexToID(unsigned int index) { return index + 1; } typedef list ObjectList; typedef ObjectList::iterator ObjectIter; typedef ObjectList::const_iterator ObjectConstIter; typedef list ObjectHandleList; typedef ObjectHandleList::iterator ObjectHandleIter; class CryptOpState { public: enum State { NOT_INITIALIZED, IN_PROCESS, FINALIZED }; State state; CKYByte keyNum; CKYBuffer result; CryptOpState() : state(NOT_INITIALIZED), keyNum(0) { CKYBuffer_InitEmpty(&result); } CryptOpState(const CryptOpState &cpy) : state(cpy.state), keyNum(cpy.keyNum) { CKYBuffer_InitFromCopy(&result, &cpy.result); } CryptOpState &operator=(const CryptOpState &cpy) { state = cpy.state, keyNum = cpy.keyNum; CKYBuffer_Replace(&result, 0, CKYBuffer_Data(&cpy.result), CKYBuffer_Size(&cpy.result)); return *this; } ~CryptOpState() { CKYBuffer_FreeData(&result); } void initialize(CKYByte keyNum) { state = IN_PROCESS; this->keyNum = keyNum; CKYBuffer_Resize(&result, 0); } }; class Session { public: enum Type { RO, RW }; private: SessionHandleSuffix handleSuffix; Type type; public: Session(SessionHandleSuffix h, Type t) : handleSuffix(h), type(t) { } ~Session() { } SessionHandleSuffix getHandleSuffix() const { return handleSuffix; } Type getType() const { return type; } bool operator==(const Session& cmp) const { return handleSuffix == cmp.handleSuffix; } // the results of FindObjectsInit() are stored here and passed out // to FindObjects(). ObjectHandleList foundObjects; ObjectHandleIter curFoundObject; CryptOpState signatureState; CryptOpState decryptionState; }; typedef list SessionList; typedef SessionList::iterator SessionIter; typedef SessionList::const_iterator SessionConstIter; class CryptParams { private: unsigned int keySize; // in bits protected: unsigned int getKeySize() const { return keySize; } public: // !!!XXX hack. The right way to get the key size is to get all the // key information from the token with MSCListKeys, the same way // we get all the object information with MSCListObjects. enum { FIXED_KEY_SIZE = 1024 }; CryptParams(unsigned int keySize_) : keySize(keySize_) { } virtual ~CryptParams() { } // returns the Muscle 'direction' constant for the operation, // required for the MSCComputeCrypt command virtual CKYByte getDirection() const = 0; // pulls the proper state object out of a session. virtual CryptOpState& getOpState(Session& session) const = 0; // performs any padding required on the input to the operation virtual void padInput(CKYBuffer *paddedOutput, const CKYBuffer *unpaddedInput) const = 0; // performs any unpadding required on the output from the operation virtual void unpadOutput(CKYBuffer *unpaddedInout, const CKYBuffer *paddedOutput) const = 0; }; class Slot { public: enum SlotState { UNKNOWN = 0x01, CARD_PRESENT = 0x02, ATR_MATCH = 0x04, APPLET_SELECTABLE = 0x08, APPLET_PERSONALIZED = 0x10, CAC_CARD = 0x20 }; enum { NONCE_SIZE = 8 }; private: Log *log; char *readerName; char *personName; char *manufacturer; //char *model; CK_VERSION hwVersion; CK_VERSION tokenFWVersion; bool slotInfoFound; CKYCardContext* context; CKYCardConnection* conn; unsigned long state; // = UNKNOWN PinCache pinCache; bool loggedIn; bool reverify; bool nonceValid; CKYBuffer nonce; CKYBuffer cardATR; CKYBuffer mCUID; bool isVersion1Key; bool needLogin; long publicFree; long publicTotal; long privateFree; bool fullTokenName; bool mCoolkey; //enum { RW_SESSION_HANDLE = 1, RO_SESSION_HANDLE = 2 }; #ifdef USE_SHMEM SlotMemSegment shmem; #endif SessionList sessions; unsigned int sessionHandleCounter; ObjectList tokenObjects; CK_OBJECT_HANDLE objectHandleCounter; CK_OBJECT_HANDLE generateUnusedObjectHandle(); SessionIter findSession(SessionHandleSuffix suffix); SessionConstIter findConstSession(SessionHandleSuffix suffix) const; void closeAllSessions(); SessionHandleSuffix generateNewSession(Session::Type type); bool cardStateMayHaveChanged(); void connectToToken(); void refreshTokenState(); void disconnect(); void handleConnectionError(); void ensureTokenPresent(); void readSlotInfo(); void readCUID(); void initEmpty(); // formatting helpers // data will be formated to fit in the supplied buffers, padded with // ascii blanks. size of the buffers is specifed by maxSize. // void makeLabelString(char *man, int maxSize, const unsigned char *cuid); void makeManufacturerString(char *man, int maxSize, const unsigned char *cuid); void makeModelString(char *man, int maxSize, const unsigned char *cuid); void makeSerialString(char *man, int maxSize, const unsigned char *cuid); void makeCUIDString(char *man, int maxSize, const unsigned char *cuid); // login helpers void invalidateLogin(bool hard); const CKYBuffer *getNonce(); const CKYBuffer *getATR(); bool isLoggedIn(); bool needLoggedIn(); void testNonce(); void addKeyObject(list& objectList, const ListObjectInfo& info, CK_OBJECT_HANDLE handle, bool isCombined); void addCertObject(list& objectList, const ListObjectInfo& certAttrs, const CKYBuffer *derCert, CK_OBJECT_HANDLE handle); void addObject(list& objectList, const ListObjectInfo& info, CK_OBJECT_HANDLE handle); void ensureValidSession(SessionHandleSuffix suffix); list getObjectList(); list fetchCombinedObjects(const CKYBuffer *header); list fetchSeparateObjects(); void selectApplet(); void selectCACApplet(CKYByte instance); void unloadObjects(); void loadCACObjects(); void loadCACCert(CKYByte instance); void loadObjects(); void loadReaderObject(); void attemptLogin(const char *pin); void attemptCACLogin(); void oldAttemptLogin(); void oldLogout(void); void CACLogout(void); void readMuscleObject(CKYBuffer *obj, unsigned long objID, unsigned int objSize); void performSignature(CKYBuffer *sig, const CKYBuffer *unpaddedInput, CKYByte keyNum); void performDecryption(CKYBuffer *data, const CKYBuffer *input, CKYByte keyNum); void cryptRSA(SessionHandleSuffix suffix, CK_BYTE_PTR pInput, CK_ULONG ulInputLen, CK_BYTE_PTR pOutput, CK_ULONG_PTR pulOutputLen, const CryptParams& params); void performRSAOp(CKYBuffer *out, const CKYBuffer *input, CKYByte keyNum, CKYByte direction); void processComputeCrypt(CKYBuffer *result, const CKYAPDU *apdu); CKYByte objectHandleToKeyNum(CK_OBJECT_HANDLE hKey); Slot(const Slot &cpy) #ifdef USE_SHMEM : shmem(readerName) #endif {} // not allowed Slot &operator=(const Slot &cpy) { return *this; } // not allowed public: Slot(const char *readerName, Log *log, CKYCardContext* context); ~Slot(); // Returns TRUE if the token is present from the point of view of PKCS #11. // This will occur if a card is present, our applet is selectable, // and the applet is in a personalized state. bool isTokenPresent(); CK_RV getSlotInfo(CK_SLOT_INFO_PTR pSlotInfo); CK_RV getTokenInfo(CK_TOKEN_INFO_PTR pTokenInfo); // future versions may have different defintions of object classes // this function may need to look a applet or protocol version // to parse things correctly. Right now the class is a single character // in the top byte of the objectID. the index is the second byte // in bdc ascii (values 0-9). char getObjectClass(unsigned long objectID) const { return (char) (objectID >> 24) & 0xff; } unsigned short getObjectIndex(unsigned long objectID) const { return (char )((objectID >> 16) & 0xff) - '0'; } SessionHandleSuffix openSession(Session::Type type); void closeSession(SessionHandleSuffix handleSuffix); bool isValidSession(SessionHandleSuffix handleSuffix) const; void getSessionInfo(SessionHandleSuffix handleSuffix, CK_SESSION_INFO_PTR pInfo); void login(SessionHandleSuffix handleSuffix, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen); void logout(SessionHandleSuffix suffix); void findObjectsInit(SessionHandleSuffix handleSuffix, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount); void findObjects(SessionHandleSuffix suffix, CK_OBJECT_HANDLE_PTR phObject, CK_ULONG ulMaxObjectCount, CK_ULONG_PTR pulObjectCount); void getAttributeValue(SessionHandleSuffix suffix, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount); void signInit(SessionHandleSuffix suffix, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey); void sign(SessionHandleSuffix suffix, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen); void decryptInit(SessionHandleSuffix suffix, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey); void decrypt(SessionHandleSuffix suffix, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pDecryptedData, CK_ULONG_PTR pulDecryptedDataLen); void seedRandom(SessionHandleSuffix suffix, CK_BYTE_PTR data, CK_ULONG len); void generateRandom(SessionHandleSuffix suffix, CK_BYTE_PTR data, CK_ULONG len); }; class SlotList { private: Slot **slots; unsigned int numSlots; Log *log; CKYCardContext *context; SCARD_READERSTATE *readerStates; unsigned int numReaders; OSLock readerListLock; bool shuttingDown; void decomposeSessionHandle(CK_SESSION_HANDLE hSession, CK_SLOT_ID& slotID, SessionHandleSuffix& suffix) const; /* the slot list is the list the outside world sees */ void updateSlotList(); /* the reader list is the internal list we keep. It is possible that * the reader list has more readers on it than the slot list reflects. * This is because we can only update the slot list if the application * has called 'C_GetSlotList' with a NULL parameter */ void updateReaderList(); bool readerExists(const char *readerName, unsigned int *hint = 0); public: SlotList(Log *log); ~SlotList(); void shutdown(); // close our connection so waits will return. int getNumSlots() const { return numSlots; } Slot* getSlot(unsigned int index) const { assert( index >= 0 && index < numSlots ); return slots[index]; } CK_RV getSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount); CK_RV getInfo(CK_SLOT_INFO_PTR pSlotInfo) const; void validateSlotID(CK_SLOT_ID id) const; void waitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved); void openSession(Session::Type type, CK_SLOT_ID slotID, CK_SESSION_HANDLE_PTR phSession); void closeSession(CK_SESSION_HANDLE sessionHandle); bool isValidSession(CK_SESSION_HANDLE sessionID) const; void getSessionInfo(CK_SESSION_HANDLE sessionHandle, CK_SESSION_INFO_PTR pInfo); void login(CK_SESSION_HANDLE hSession, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen); void logout(CK_SESSION_HANDLE hSession); void findObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount); void findObjects(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phObject, CK_ULONG ulMaxObjectCount, CK_ULONG_PTR pulObjectCount); void getAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) const; void signInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey); void sign(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen); void decryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey); void decrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pDecryptedData, CK_ULONG_PTR pulDecryptedDataLen); void generateRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen); void seedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen); }; #endif --- NEW FILE test.cpp --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK *****/ #include "list.h" #include #include #include #include using std::list; using std::string; void* operator new(unsigned int len) { void* p = malloc(len); printf("operator new(%d) returns 0x%08x\n", len, p); return p; } void operator delete(void *p) { printf("operator delete(0x%08x)\n", p); } void mylist() { List intlist; List::Iterator iter; iter = intlist.begin(); intlist.insert(iter, 5); iter++; intlist.insert(iter, 7); iter = intlist.find_item(intlist.begin(), intlist.end(), 7); intlist.insert(iter, 9); List stringlist; List::Iterator siter; siter = stringlist.begin(); string bob("hello, world"); bob += "5"; stringlist.insert(siter, bob); siter = stringlist.begin(); string boo = *siter; printf("boo is %s\n", boo.c_str()); stringlist.remove(siter); } void stllist() { list intlist; std::list::iterator iter; iter = intlist.begin(); intlist.insert(iter, 5); iter++; intlist.insert(iter, 7); intlist.insert(iter, 9); list stringlist; std::list::iterator siter; siter = stringlist.begin(); stringlist.insert(siter, "hello, world"); } int main(int argc, char *argv[]) { printf("Doing mylist\n"); mylist(); printf("Doing stllist\n"); stllist(); return 0; } From fedora-directory-commits at redhat.com Fri Jun 9 18:42:48 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 11:42:48 -0700 Subject: [Fedora-directory-commits] coolkey/src/libckyapplet - New directory Message-ID: <200606091842.k59Igm0a001874@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/libckyapplet In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1859/libckyapplet Log Message: Directory /cvs/dirsec/coolkey/src/libckyapplet added to the repository From fedora-directory-commits at redhat.com Fri Jun 9 18:44:19 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 11:44:19 -0700 Subject: [Fedora-directory-commits] coolkey/src/libckyapplet Makefile.am, NONE, 1.1 Makefile.in, NONE, 1.1 cky_applet.c, NONE, 1.1 cky_applet.h, NONE, 1.1 cky_base.c, NONE, 1.1 cky_base.h, NONE, 1.1 cky_basei.h, NONE, 1.1 cky_card.c, NONE, 1.1 cky_card.h, NONE, 1.1 cky_factory.c, NONE, 1.1 cky_factory.h, NONE, 1.1 cky_list.h, NONE, 1.1 cky_list.i, NONE, 1.1 config.mk, NONE, 1.1 dynlink.c, NONE, 1.1 dynlink.h, NONE, 1.1 dynlink_mac.c, NONE, 1.1 dynlink_unix.c, NONE, 1.1 dynlink_win.c, NONE, 1.1 manifest.mn, NONE, 1.1 Message-ID: <200606091844.k59IiJY7002014@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/libckyapplet In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1977/libckyapplet Added Files: Makefile.am Makefile.in cky_applet.c cky_applet.h cky_base.c cky_base.h cky_basei.h cky_card.c cky_card.h cky_factory.c cky_factory.h cky_list.h cky_list.i config.mk dynlink.c dynlink.h dynlink_mac.c dynlink_unix.c dynlink_win.c manifest.mn Log Message: libckyapplet was also misnamed. --- NEW FILE Makefile.am --- # ***** BEGIN COPYRIGHT BLOCK ***** # Copyright (C) 2005 Red Hat, Inc. # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation version # 2.1 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ***** END COPYRIGHT BLOCK ***** # Process this file with automake to create Makefile.in SUBDIRS = AM_CFLAGS = # bleh what do I add just to get static but pic libraries? noinst_LTLIBRARIES = libckyapplet.la libckyapplet_la_SOURCES = \ cky_applet.c \ cky_base.c \ cky_card.c \ cky_factory.c \ dynlink.c quote=\" libckyapplet_la_LDFLAGS = -avoid-version libckyapplet_la_CFLAGS = $(CFLAGS) -DSCARD_LIB_NAME=$(quote)$(SCARD_LIB_NAME)$(quote) $(PCSC_CFLAGS) nobase_include_HEADERS = \ cky_base.h \ cky_card.h \ cky_factory.h \ cky_list.h \ cky_applet.h noinst_HEADERS = \ cky_basei.h \ dynlink.h #pcdir = $(libdir)/pkgconfig #pc_DATA = libckyapplet.pc --- NEW FILE Makefile.in --- # Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program 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. @SET_MAKE@ # ***** BEGIN COPYRIGHT BLOCK ***** # Copyright (C) 2005 Red Hat, Inc. # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation version # 2.1 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ***** END COPYRIGHT BLOCK ***** # Process this file with automake to create Makefile.in srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = clib DIST_COMMON = $(nobase_include_HEADERS) $(noinst_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libckyapplet_la_LIBADD = am_libckyapplet_la_OBJECTS = libckyapplet_la-cky_applet.lo \ libckyapplet_la-cky_base.lo libckyapplet_la-cky_card.lo \ libckyapplet_la-cky_factory.lo libckyapplet_la-dynlink.lo libckyapplet_la_OBJECTS = $(am_libckyapplet_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libckyapplet_la_SOURCES) DIST_SOURCES = $(libckyapplet_la_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-exec-recursive install-info-recursive \ install-recursive installcheck-recursive installdirs-recursive \ pdf-recursive ps-recursive uninstall-info-recursive \ uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(includedir)" nobase_includeHEADERS_INSTALL = $(install_sh_DATA) HEADERS = $(nobase_include_HEADERS) $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ F77 = @F77@ FFLAGS = @FFLAGS@ HAVE_PCSC_FALSE = @HAVE_PCSC_FALSE@ HAVE_PCSC_TRUE = @HAVE_PCSC_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBCKYAPPLET = @LIBCKYAPPLET@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PCSC_CFLAGS = @PCSC_CFLAGS@ PCSC_LIBS = @PCSC_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ SCARD_LIB_NAME = @SCARD_LIB_NAME@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_F77 = @ac_ct_F77@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ prefix = @prefix@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ SUBDIRS = AM_CFLAGS = # bleh what do I add just to get static but pic libraries? noinst_LTLIBRARIES = libckyapplet.la libckyapplet_la_SOURCES = \ cky_applet.c \ cky_base.c \ cky_card.c \ cky_factory.c \ dynlink.c quote = \" libckyapplet_la_LDFLAGS = -avoid-version libckyapplet_la_CFLAGS = $(CFLAGS) -DSCARD_LIB_NAME=$(quote)$(SCARD_LIB_NAME)$(quote) $(PCSC_CFLAGS) nobase_include_HEADERS = \ cky_base.h \ cky_card.h \ cky_factory.h \ cky_list.h \ cky_applet.h noinst_HEADERS = \ cky_basei.h \ dynlink.h all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu clib/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu clib/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libckyapplet.la: $(libckyapplet_la_OBJECTS) $(libckyapplet_la_DEPENDENCIES) $(LINK) $(libckyapplet_la_LDFLAGS) $(libckyapplet_la_OBJECTS) $(libckyapplet_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libckyapplet_la-cky_applet.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libckyapplet_la-cky_base.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libckyapplet_la-cky_card.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libckyapplet_la-cky_factory.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libckyapplet_la-dynlink.Plo at am__quote@ .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< libckyapplet_la-cky_applet.lo: cky_applet.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -MT libckyapplet_la-cky_applet.lo -MD -MP -MF "$(DEPDIR)/libckyapplet_la-cky_applet.Tpo" -c -o libckyapplet_la-cky_applet.lo `test -f 'cky_applet.c' || echo '$(srcdir)/'`cky_applet.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libckyapplet_la-cky_applet.Tpo" "$(DEPDIR)/libckyapplet_la-cky_applet.Plo"; else rm -f "$(DEPDIR)/libckyapplet_la-cky_applet.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cky_applet.c' object='libckyapplet_la-cky_applet.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -c -o libckyapplet_la-cky_applet.lo `test -f 'cky_applet.c' || echo '$(srcdir)/'`cky_applet.c libckyapplet_la-cky_base.lo: cky_base.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -MT libckyapplet_la-cky_base.lo -MD -MP -MF "$(DEPDIR)/libckyapplet_la-cky_base.Tpo" -c -o libckyapplet_la-cky_base.lo `test -f 'cky_base.c' || echo '$(srcdir)/'`cky_base.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libckyapplet_la-cky_base.Tpo" "$(DEPDIR)/libckyapplet_la-cky_base.Plo"; else rm -f "$(DEPDIR)/libckyapplet_la-cky_base.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cky_base.c' object='libckyapplet_la-cky_base.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -c -o libckyapplet_la-cky_base.lo `test -f 'cky_base.c' || echo '$(srcdir)/'`cky_base.c libckyapplet_la-cky_card.lo: cky_card.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -MT libckyapplet_la-cky_card.lo -MD -MP -MF "$(DEPDIR)/libckyapplet_la-cky_card.Tpo" -c -o libckyapplet_la-cky_card.lo `test -f 'cky_card.c' || echo '$(srcdir)/'`cky_card.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libckyapplet_la-cky_card.Tpo" "$(DEPDIR)/libckyapplet_la-cky_card.Plo"; else rm -f "$(DEPDIR)/libckyapplet_la-cky_card.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cky_card.c' object='libckyapplet_la-cky_card.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -c -o libckyapplet_la-cky_card.lo `test -f 'cky_card.c' || echo '$(srcdir)/'`cky_card.c libckyapplet_la-cky_factory.lo: cky_factory.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -MT libckyapplet_la-cky_factory.lo -MD -MP -MF "$(DEPDIR)/libckyapplet_la-cky_factory.Tpo" -c -o libckyapplet_la-cky_factory.lo `test -f 'cky_factory.c' || echo '$(srcdir)/'`cky_factory.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libckyapplet_la-cky_factory.Tpo" "$(DEPDIR)/libckyapplet_la-cky_factory.Plo"; else rm -f "$(DEPDIR)/libckyapplet_la-cky_factory.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cky_factory.c' object='libckyapplet_la-cky_factory.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -c -o libckyapplet_la-cky_factory.lo `test -f 'cky_factory.c' || echo '$(srcdir)/'`cky_factory.c libckyapplet_la-dynlink.lo: dynlink.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -MT libckyapplet_la-dynlink.lo -MD -MP -MF "$(DEPDIR)/libckyapplet_la-dynlink.Tpo" -c -o libckyapplet_la-dynlink.lo `test -f 'dynlink.c' || echo '$(srcdir)/'`dynlink.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libckyapplet_la-dynlink.Tpo" "$(DEPDIR)/libckyapplet_la-dynlink.Plo"; else rm -f "$(DEPDIR)/libckyapplet_la-dynlink.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dynlink.c' object='libckyapplet_la-dynlink.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libckyapplet_la_CFLAGS) $(CFLAGS) -c -o libckyapplet_la-dynlink.lo `test -f 'dynlink.c' || echo '$(srcdir)/'`dynlink.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: install-nobase_includeHEADERS: $(nobase_include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)" @$(am__vpath_adj_setup) \ list='$(nobase_include_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ $(am__vpath_adj) \ echo " $(nobase_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ $(nobase_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ done uninstall-nobase_includeHEADERS: @$(NORMAL_UNINSTALL) @$(am__vpath_adj_setup) \ list='$(nobase_include_HEADERS)'; for p in $$list; do \ $(am__vpath_adj) \ echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ rm -f "$(DESTDIR)$(includedir)/$$f"; \ done # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(mkdir_p) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-nobase_includeHEADERS install-exec-am: install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-info-am uninstall-nobase_includeHEADERS uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ clean clean-generic clean-libtool clean-noinstLTLIBRARIES \ clean-recursive ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-recursive distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-nobase_includeHEADERS \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ maintainer-clean-recursive mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-info-am uninstall-nobase_includeHEADERS #pcdir = $(libdir)/pkgconfig #pc_DATA = libckyapplet.pc # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: --- NEW FILE cky_applet.c --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #include #include "cky_applet.h" #define MIN(x, y) ((x) < (y) ? (x) : (y)) /***************************************************************** * * Generic factorys are used by the generic APDU processing * to customize the formatting of APDU. Typically APDUs are formatted * using parameterized calls of the form CKYAPDUFactory_ADPUNAME. * The generic processing code, however needs calls with a common * Signature. To accomplish the conversion, we build generic versions * which take a void * parameter. Trivial APDU's can pass NULL or a pointer * to the single parameter that they need. More complicated APDU's use * CKYAppletArg* data structures defined above to pass more arguments. * * Generic factorys then call the standard CKYAPDUFactor_ADPUNAME() functions * to build the APDUs. These functions are intended only as arguments * to the generic ADPU calls, and not to be called directly. * *****************************************************************/ CKYStatus CKYAppletFactory_SelectFile(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_SelectFile(apdu,(const CKYBuffer *)param); } CKYStatus CKYAppletFactory_SelectCardManager(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_SelectCardManager(apdu); } CKYStatus CKYAppletFactory_GetCPLCData(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_GetCPLCData(apdu); } CKYStatus CKYAppletFactory_ListKeys(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_ListKeys(apdu, *( CKYByte *)param); } CKYStatus CKYAppletFactory_ComputeCryptInit(CKYAPDU *apdu, const void *param) { const CKYAppletArgComputeCrypt *ccs=(const CKYAppletArgComputeCrypt *)param; return CKYAPDUFactory_ComputeCryptInit(apdu, ccs->keyNumber, ccs->mode, ccs->direction, ccs->location); } CKYStatus CKYAppletFactory_ComputeCryptProcess(CKYAPDU *apdu, const void *param) { const CKYAppletArgComputeCrypt *ccs=(const CKYAppletArgComputeCrypt *)param; return CKYAPDUFactory_ComputeCryptProcess(apdu, ccs->keyNumber, ccs->location, ccs->data); } CKYStatus CKYAppletFactory_ComputeCryptFinal(CKYAPDU *apdu, const void *param) { const CKYAppletArgComputeCrypt *ccs=(const CKYAppletArgComputeCrypt *)param; return CKYAPDUFactory_ComputeCryptFinal(apdu, ccs->keyNumber, ccs->location, ccs->data, ccs->sig); } CKYStatus CKYAppletFactory_ComputeCryptOneStep(CKYAPDU *apdu, const void *param) { const CKYAppletArgComputeCrypt *ccs=(const CKYAppletArgComputeCrypt *)param; return CKYAPDUFactory_ComputeCryptOneStep(apdu, ccs->keyNumber,ccs->mode, ccs->direction, ccs->location, ccs->data, ccs->sig); } CKYStatus CKYAppletFactory_CreatePIN(CKYAPDU *apdu, const void *param) { const CKYAppletArgCreatePIN *cps = (const CKYAppletArgCreatePIN *)param; return CKYAPDUFactory_CreatePIN(apdu, cps->pinNumber, cps->maxAttempts, cps->pinValue); } CKYStatus CKYAppletFactory_VerifyPIN(CKYAPDU *apdu, const void *param) { const CKYAppletArgVerifyPIN *vps = (const CKYAppletArgVerifyPIN *)param; return CKYAPDUFactory_VerifyPIN(apdu, vps->pinNumber, vps->pinValue); } CKYStatus CKYAppletFactory_ChangePIN(CKYAPDU *apdu, const void *param) { const CKYAppletArgChangePIN *cps = (const CKYAppletArgChangePIN *)param; return CKYAPDUFactory_ChangePIN(apdu, cps->pinNumber, cps->oldPin, cps->newPin); } CKYStatus CKYAppletFactory_ListPINs(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_ListPINs(apdu); } CKYStatus CKYAppletFactory_Logout(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_Logout(apdu, *(const CKYByte *)param); } /* Future add WriteObject */ CKYStatus CKYAppletFactory_CreateObject(CKYAPDU *apdu, const void *param) { const CKYAppletArgCreateObject *cos=(const CKYAppletArgCreateObject *)param; return CKYAPDUFactory_CreateObject(apdu, cos->objectID, cos->size, cos->readACL, cos->writeACL, cos->deleteACL); } CKYStatus CKYAppletFactory_DeleteObject(CKYAPDU *apdu, const void *param) { const CKYAppletArgDeleteObject *dos=(const CKYAppletArgDeleteObject *)param; return CKYAPDUFactory_DeleteObject(apdu, dos->objectID, dos->zero); } CKYStatus CKYAppletFactory_ReadObject(CKYAPDU *apdu, const void *param) { const CKYAppletArgReadObject *ros = (const CKYAppletArgReadObject *)param; return CKYAPDUFactory_ReadObject(apdu, ros->objectID, ros->offset, ros->size); } CKYStatus CKYAppletFactory_ListObjects(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_ListObjects(apdu, *(const CKYByte *)param); } CKYStatus CKYAppletFactory_GetStatus(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_GetStatus(apdu); } CKYStatus CKYAppletFactory_Noop(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_Noop(apdu); } CKYStatus CKYAppletFactory_GetBuildID(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_GetBuildID(apdu); } CKYStatus CKYAppletFactory_GetLifeCycle(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_GetLifeCycle(apdu); } CKYStatus CKYAppletFactory_GetLifeCycleV2(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_GetLifeCycleV2(apdu); } CKYStatus CKYAppletFactory_GetRandom(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_GetRandom(apdu, *(CKYByte *)param); } CKYStatus CKYAppletFactory_SeedRandom(CKYAPDU *apdu, const void *param) { const CKYBuffer *buf=(CKYBuffer *)param; return CKYAPDUFactory_SeedRandom(apdu, buf); } CKYStatus CKYAppletFactory_GetIssuerInfo(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_GetIssuerInfo(apdu); } CKYStatus CKYAppletFactory_GetBuiltinACL(CKYAPDU *apdu, const void *param) { return CKYAPDUFactory_GetBuiltinACL(apdu); } CKYStatus CACAppletFactory_SignDecrypt(CKYAPDU *apdu, const void *param) { const CKYBuffer *buf=(CKYBuffer *)param; return CACAPDUFactory_SignDecrypt(apdu, buf); } CKYStatus CACAppletFactory_VerifyPIN(CKYAPDU *apdu, const void *param) { const char *pin=(const char *)param; return CACAPDUFactory_VerifyPIN(apdu, pin); } CKYStatus CACAppletFactory_GetCertificate(CKYAPDU *apdu, const void *param) { CKYSize *size=(CKYSize*)param; return CACAPDUFactory_GetCertificate(apdu, *size); } CKYStatus CACAppletFactory_GetProperties(CKYAPDU *apdu, const void *param) { return CACAPDUFactory_GetProperties(apdu); } /* * deprecates 0.x functions */ CKYStatus CKYAppletFactory_LogoutAllV0(CKYAPDU *apdu, const void *param) { CKYByte data[2] = { 0, 0}; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_LOGOUT_ALL); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetSendData(apdu, data, sizeof(data)); } /***************************************************************** * * Generic Fill routines used by several calls in common * and globally accessible * *****************************************************************/ /* a null fill function for those APDU's which do not return data */ CKYStatus CKYAppletFill_Null(const CKYBuffer *response, CKYSize size, void *param) { return CKYSUCCESS; } /* a Buffer Replace fill function for those APDU's which return unformated * chunks of data */ CKYStatus CKYAppletFill_ReplaceBuffer(const CKYBuffer *response, CKYSize size, void *param) { CKYBuffer *buf = (CKYBuffer *)param; if (buf == NULL) { return CKYSUCCESS; } return CKYBuffer_Replace(buf, 0, CKYBuffer_Data(response), CKYBuffer_Size(response) -2); } /* a Buffer Append fill function. Can be used with any APDU that uses Buffer * Replace. Repeated calls continuously fill the buffer. Most useful for read. */ CKYStatus CKYAppletFill_AppendBuffer(const CKYBuffer *response, CKYSize size, void *param) { CKYBuffer *buf = (CKYBuffer *)param; return CKYBuffer_AppendData(buf, CKYBuffer_Data(response), CKYBuffer_Size(response) -2); } CKYStatus CKYAppletFill_Byte(const CKYBuffer *response, CKYSize size, void *param) { CKYByte *v = (CKYByte *)param; *v = CKYBuffer_GetChar(response, 0); return CKYSUCCESS; } CKYStatus CKYAppletFill_Short(const CKYBuffer *response, CKYSize size, void *param) { unsigned short *v = (unsigned short *)param; *v = CKYBuffer_GetShort(response, 0); return CKYSUCCESS; } CKYStatus CKYAppletFill_Long(const CKYBuffer *response, CKYSize size, void *param) { unsigned long *v = (unsigned long *)param; *v = CKYBuffer_GetLong(response, 0); return CKYSUCCESS; } /***************************************************************** * * Utilities shared by all the fetch Cards. * *****************************************************************/ /* * verify the we got a successful response. Responses should include * the expected data returned plus a 2 byte return code. This return * code should be 0x9000 on success. */ CKYBool CKYApplet_VerifyResponse(const CKYBuffer *buf, CKYSize dataSize, CKYISOStatus *apduRC) { CKYSize size = CKYBuffer_Size(buf); CKYISOStatus rc = CKYISO_INVRESPONSE; CKYBool valid = 0; /* is there enough size for the return code ? */ if (size < 2) { goto done; } /* fetch the data */ rc = CKYBuffer_GetShort(buf, size-2); /* is there enough size for the expected data ? */ if ((dataSize != CKY_SIZE_UNKNOWN) && (size != dataSize+2)) { goto done; } /* did we return successfully? */ valid = (rc == CKYISO_SUCCESS) || ((rc & CKYISO_MORE_MASK) == CKYISO_MORE); done: if (apduRC) { *apduRC = rc; } return valid; } /* * most commands have identical operations. Isolate the differences in * call back functions, and create a generic APDU handler which Creates * APDU's, Does the exchange, and fills in the results. */ CKYStatus CKYApplet_HandleAPDU(CKYCardConnection *conn, CKYAppletFactory afFunc, const void *afArg, const CKYBuffer *nonce, CKYSize size, CKYFillFunction fillFunc, void *fillArg, CKYISOStatus *apduRC) { CKYAPDU apdu; CKYBuffer response; CKYStatus ret; if (apduRC) { *apduRC = CKYISO_NORESPONSE; } /* initialize the response and APDU buffers */ CKYBuffer_InitEmpty(&response); ret = CKYAPDU_Init(&apdu); if (ret != CKYSUCCESS) { goto done; } /* fill in the APDU buffer with the correct values */ ret = (*afFunc)(&apdu, afArg); if (ret != CKYSUCCESS) { goto done; } /* if NONCE supplied, add it to the end of the apdu */ if (nonce) { /* * Local Secured commands need the nonce returned from Login to * verify that they are valid. Nonce's are just added to the end * of the APDU much like */ ret = CKYAPDU_AppendSendDataBuffer(&apdu, nonce); if (ret != CKYSUCCESS) { goto done; } } /* send it to the card */ ret = CKYCardConnection_ExchangeAPDU(conn, &apdu, &response); if (ret != CKYSUCCESS) { goto done; } /* verify we got the expected response */ if (!CKYApplet_VerifyResponse(&response, size, apduRC)) { ret = CKYAPDUFAIL; goto done; } /* Fill in our output data structure */ ret = (*fillFunc)(&response, size, fillArg); done: CKYBuffer_FreeData(&response); CKYAPDU_FreeData(&apdu); return ret; } /***************************************************************** * * The following convience functions convert APDU calls * into function calls, with input and output parameters. * The application is still responsible for 1) creating a connection * to the card, 2) Getting a tranaction long, then 3) selecting * the appropriate applet (or Card manager). Except for those * calls that have been noted, the appropriate applet is the CoolKey * applet. * *****************************************************************/ /* * Select an applet. Must happen after we start a transaction and before * we issue any applet specific command. */ CKYStatus CKYApplet_SelectFile(CKYCardConnection *conn, const CKYBuffer *AID, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_SelectFile, AID, NULL, 0, CKYAppletFill_Null, NULL, apduRC); } static CKYByte coolkeyid[] = {0x62, 0x76, 0x01, 0xff, 0x00, 0x00, 0x00 }; /* * Select the CoolKey applet. Must happen after we start a transaction and * before we issue any applet specific command. */ CKYStatus CKYApplet_SelectCoolKeyManager(CKYCardConnection *conn, CKYISOStatus *apduRC) { CKYStatus ret; CKYBuffer COOLKEYAID; CKYBuffer_InitFromData(&COOLKEYAID, coolkeyid, sizeof(coolkeyid)); ret = CKYApplet_HandleAPDU(conn, CKYAppletFactory_SelectFile, &COOLKEYAID, NULL, 0, CKYAppletFill_Null, NULL, apduRC); CKYBuffer_FreeData(&COOLKEYAID); return ret; } static CKYByte CACPKIid[] = {0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 }; /* * Select the CoolKey applet. Must happen after we start a transaction and * before we issue any applet specific command. */ CKYStatus CACApplet_SelectPKI(CKYCardConnection *conn, CKYByte instance, CKYISOStatus *apduRC) { CKYStatus ret; CKYBuffer CACPKIAID; CKYBuffer_InitFromData(&CACPKIAID, CACPKIid, sizeof(CACPKIid)); CKYBuffer_SetChar(&CACPKIAID, 6, instance); ret = CKYApplet_HandleAPDU(conn, CKYAppletFactory_SelectFile, &CACPKIAID, NULL, CKY_SIZE_UNKNOWN, CKYAppletFill_Null, NULL, apduRC); CKYBuffer_FreeData(&CACPKIAID); return ret; } /* * Select the card manager. Must happen after we start a transaction and before * we issue any card manager commands. */ CKYStatus CKYApplet_SelectCardManager(CKYCardConnection *conn, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_SelectCardManager, NULL, NULL, 0, CKYAppletFill_Null, NULL, apduRC); } static CKYByte cacmgrid[] = {0xa0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00 }; CKYStatus CACApplet_SelectCardManager(CKYCardConnection *conn, CKYISOStatus *apduRC) { CKYStatus ret; CKYBuffer CAC_CM_AID; CKYBuffer_InitFromData(&CAC_CM_AID, cacmgrid, sizeof(cacmgrid)); ret = CKYApplet_HandleAPDU(conn, CKYAppletFactory_SelectFile, &CAC_CM_AID, NULL, 0, CKYAppletFill_Null, NULL, apduRC); CKYBuffer_FreeData(&CAC_CM_AID); return ret; } /* * GetCPLC cluster -- must be called with CM selected */ static CKYStatus ckyAppletFill_GetCPLCData(const CKYBuffer *response, CKYSize size, void *param) { CKYAppletRespGetCPLCData *gcdp = (CKYAppletRespGetCPLCData *)param; gcdp->CPLCtag = CKYBuffer_GetShort(response, 0); gcdp->length = CKYBuffer_GetChar(response, 2); gcdp->fabricator = CKYBuffer_GetShort(response, 3); gcdp->romType = CKYBuffer_GetShort(response, 5); gcdp->romOSID = CKYBuffer_GetShort(response, 7); gcdp->romOSDate = CKYBuffer_GetShort(response, 9); gcdp->romOSLevel = CKYBuffer_GetShort(response, 11); gcdp->eepromFabricationDate = CKYBuffer_GetShort(response, 13); gcdp->eepromSerialNumber = CKYBuffer_GetLong(response, 15); gcdp->eepromBatchID = CKYBuffer_GetShort(response, 19); gcdp->eepromModuleFabricator = CKYBuffer_GetShort(response, 21); gcdp->eepromModuleDate = CKYBuffer_GetShort(response, 23); gcdp->eepromICManufacturer = CKYBuffer_GetShort(response, 25); gcdp->eepromEmbeddingDate = CKYBuffer_GetShort(response, 27); gcdp->eepromPrePersonalizer = CKYBuffer_GetShort(response, 29); gcdp->eepromPrePersonalizeDate = CKYBuffer_GetShort(response, 31); gcdp->eepromPrePersonalizeID = CKYBuffer_GetLong(response, 33); gcdp->eepromPersonalizer = CKYBuffer_GetShort(response, 37); gcdp->eepromPersonalizeDate = CKYBuffer_GetShort(response, 39); gcdp->eepromPersonalizeID = CKYBuffer_GetLong(response, 41); return CKYSUCCESS; } CKYStatus CKYApplet_GetCPLCData(CKYCardConnection *conn, CKYAppletRespGetCPLCData *cplc, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetCPLCData, NULL, NULL, CKY_SIZE_GET_CPLCDATA, ckyAppletFill_GetCPLCData, cplc, apduRC); } /* * Get CUID. The CUID exists in the CPLC data. We use the same basic * APDU, but use a differ fill function to collect it. */ static CKYStatus ckyAppletFill_GetCUID(const CKYBuffer *response, CKYSize size, void *param) { CKYBuffer *cuid = (CKYBuffer *)param; CKYStatus ret; ret = CKYBuffer_Resize(cuid,10); if (ret != CKYSUCCESS) { return ret; } /* fabricator 2 bytes */ CKYBuffer_SetChar(cuid, 0, CKYBuffer_GetChar(response, 3)); CKYBuffer_SetChar(cuid, 1, CKYBuffer_GetChar(response, 4)); /* IC Type 2 bytes */ CKYBuffer_SetChar(cuid, 2, CKYBuffer_GetChar(response, 5)); CKYBuffer_SetChar(cuid, 3, CKYBuffer_GetChar(response, 6)); /* Batch ID 2 bytes */ CKYBuffer_SetChar(cuid, 4, CKYBuffer_GetChar(response, 19)); CKYBuffer_SetChar(cuid, 5, CKYBuffer_GetChar(response, 20)); /* IC Serial Number 4 bytes */ CKYBuffer_SetChar(cuid, 6, CKYBuffer_GetChar(response, 15)); CKYBuffer_SetChar(cuid, 7, CKYBuffer_GetChar(response, 16)); CKYBuffer_SetChar(cuid, 8, CKYBuffer_GetChar(response, 17)); CKYBuffer_SetChar(cuid, 9, CKYBuffer_GetChar(response, 18)); return CKYSUCCESS; } CKYStatus CKYApplet_GetCUID(CKYCardConnection *conn, CKYBuffer *cuid, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetCPLCData, NULL, NULL, CKY_SIZE_GET_CPLCDATA, ckyAppletFill_GetCUID, cuid, apduRC); } /* * Get MSN. The MSN exists in the CPLC data. We use the same basic * APDU, but use a differ fill function to collect it. */ static CKYStatus ckyAppletFill_GetMSN(const CKYBuffer *response, CKYSize size, void *param) { unsigned long *msn = (unsigned long *)param; *msn = CKYBuffer_GetLong(response, 41); return CKYSUCCESS; } CKYStatus CKYApplet_GetMSN(CKYCardConnection *conn, unsigned long *msn, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetCPLCData, NULL, NULL, CKY_SIZE_GET_CPLCDATA, ckyAppletFill_GetMSN, msn, apduRC); } /* * ListKeys cluster */ static CKYStatus ckyAppletFill_ListKeys(const CKYBuffer *response, CKYSize size, void *param) { CKYAppletRespListKeys *lkp = (CKYAppletRespListKeys *)param; lkp->keyNum = CKYBuffer_GetChar(response, 0); lkp->keyType = CKYBuffer_GetChar(response, 1); lkp->keyPartner = CKYBuffer_GetChar(response, 2); lkp->keySize = CKYBuffer_GetShort(response, 3); lkp->readACL = CKYBuffer_GetShort(response, 5); lkp->writeACL = CKYBuffer_GetShort(response, 7); lkp->useACL = CKYBuffer_GetShort(response, 9); return CKYSUCCESS; } CKYStatus CKYApplet_ListKeys(CKYCardConnection *conn, CKYByte seq, CKYAppletRespListKeys *lkp, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ListKeys, &seq, NULL, CKY_SIZE_LIST_KEYS, ckyAppletFill_ListKeys, lkp, apduRC); } /* * Compute Crypt Cluster. * * Compute Crypt takes 3 types: Init, Process, Final. * */ CKYStatus CKYApplet_ComputeCryptInit(CKYCardConnection *conn, CKYByte keyNumber, CKYByte mode, CKYByte direction, CKYByte location, const CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYAppletArgComputeCrypt ccd; ccd.keyNumber = keyNumber; ccd.mode = mode; ccd.direction = direction; ccd.location = location; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ComputeCryptInit, &ccd, nonce, 0, CKYAppletFill_Null, NULL, apduRC); } CKYStatus CKYApplet_ComputeCryptProcess(CKYCardConnection *conn, CKYByte keyNumber, CKYByte location, const CKYBuffer *data, const CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYAppletArgComputeCrypt ccd; ccd.keyNumber = keyNumber; ccd.location = location; ccd.data = data; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ComputeCryptProcess, &ccd, nonce, 0, CKYAppletFill_Null, NULL, apduRC); } /* computeCrypt returns data in the form : * len: short * data: byte[len] * This fill routine returns A buffer with a copy of data and a length of len */ static CKYStatus ckyAppletFill_ComputeCryptFinal(const CKYBuffer *response, CKYSize size, void *param) { CKYBuffer *cbuf = (CKYBuffer *)param; CKYSize respSize = CKYBuffer_Size(response); CKYSize dataLen; if (cbuf == 0) { return CKYSUCCESS; /* app didn't want the result */ } /* data response code + length code */ if (respSize < 4) { return CKYAPDUFAIL; } dataLen = CKYBuffer_GetShort(response, 0); if (dataLen > (respSize-4)) { return CKYAPDUFAIL; } return CKYBuffer_Replace(cbuf, 0, CKYBuffer_Data(response)+2, dataLen); } CKYStatus CKYApplet_ComputeCryptFinal(CKYCardConnection *conn, CKYByte keyNumber, CKYByte location, const CKYBuffer *data, CKYBuffer *sig, CKYBuffer *result, const CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYAppletArgComputeCrypt ccd; ccd.keyNumber = keyNumber; ccd.location = location; ccd.data = data; ccd.data = sig; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ComputeCryptFinal, &ccd, nonce, CKY_SIZE_UNKNOWN, ckyAppletFill_ComputeCryptFinal, result, apduRC); } /* * do a complete ComputeCrypt operation * ...look to data size to see if we should read/write the data to * the on card buffer. (future) */ CKYStatus CKYApplet_ComputeCrypt(CKYCardConnection *conn, CKYByte keyNumber, CKYByte mode, CKYByte direction, const CKYBuffer *data, CKYBuffer *sig, CKYBuffer *result, const CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYStatus ret; CKYAppletArgComputeCrypt ccd; CKYBuffer empty; CKYISOStatus status; int use2APDUs = 0; CKYBuffer_InitEmpty(&empty); ccd.keyNumber = keyNumber; ccd.mode = mode; ccd.direction = direction; ccd.location = CKY_DL_APDU; if (!apduRC) apduRC = &status; if (mode == CKY_RSA_NO_PAD) { ccd.data = data; ccd.sig = sig; ret = CKYApplet_HandleAPDU(conn, CKYAppletFactory_ComputeCryptOneStep, &ccd, nonce, CKY_SIZE_UNKNOWN, ckyAppletFill_ComputeCryptFinal, result, apduRC); if (ret == CKYAPDUFAIL && *apduRC == CKYISO_INCORRECT_P2) { use2APDUs = 1; /* maybe it's an old applet */ } } else { use2APDUs = 1; } if (use2APDUs) { /* future, if data is to big write it to the internal object * and set location to DL_OBJECT */ ccd.data = ∅ ccd.sig = sig; ret = CKYApplet_HandleAPDU(conn, CKYAppletFactory_ComputeCryptInit, &ccd, nonce, 0, CKYAppletFill_Null, NULL, apduRC); if (ret == CKYSUCCESS) { ccd.data = data; ret = CKYApplet_HandleAPDU(conn, CKYAppletFactory_ComputeCryptFinal, &ccd, nonce, CKY_SIZE_UNKNOWN, ckyAppletFill_ComputeCryptFinal, result, apduRC); } } return ret; } /* * do a CAC Sign/Decrypt */ CKYStatus CACApplet_SignDecrypt(CKYCardConnection *conn, const CKYBuffer *data, CKYBuffer *result, CKYISOStatus *apduRC) { CKYStatus ret; ret = CKYApplet_HandleAPDU(conn, CACAppletFactory_SignDecrypt, data, NULL, CKYBuffer_Size(data), CKYAppletFill_ReplaceBuffer, result, apduRC); return ret; } /* * do a CAC VerifyPIN */ CKYStatus CACApplet_VerifyPIN(CKYCardConnection *conn, const char *pin, CKYISOStatus *apduRC) { CKYStatus ret; CKYISOStatus status; if (apduRC == NULL) { apduRC = &status; } ret = CKYApplet_HandleAPDU(conn, CACAppletFactory_VerifyPIN, pin, NULL, 0, CKYAppletFill_Null, NULL, apduRC); /* it's unfortunate that the same code that means 'more data to follow' for * GetCertificate also means, auth failure, you only have N more attempts * left in the verify PIN call */ if ((*apduRC & CKYISO_MORE_MASK) == CKYISO_MORE) { ret = CKYAPDUFAIL; } return ret; } /* * Get a CAC Certificate */ CKYStatus CACApplet_GetCertificate(CKYCardConnection *conn, CKYBuffer *cert, CKYISOStatus *apduRC) { CKYStatus ret; CKYISOStatus status; CKYSize size = 100; CKYBuffer_Resize(cert,0); if (apduRC == NULL) { apduRC = &status; } ret = CKYApplet_HandleAPDU(conn, CACAppletFactory_GetCertificate, &size, NULL, CKY_SIZE_UNKNOWN, CKYAppletFill_AppendBuffer, cert, apduRC); while ((*apduRC & CKYISO_MORE_MASK) == CKYISO_MORE) { size = *apduRC & ~CKYISO_MORE_MASK; ret = CKYApplet_HandleAPDU(conn, CACAppletFactory_GetCertificate, &size, NULL, CKY_SIZE_UNKNOWN, CKYAppletFill_AppendBuffer, cert, apduRC); } return ret; } CKYStatus CACApplet_GetCertificateFirst(CKYCardConnection *conn, CKYBuffer *cert, CKYSize *nextSize, CKYISOStatus *apduRC) { CKYStatus ret; CKYISOStatus status; CKYSize size = 100; CKYBuffer_Resize(cert,0); if (apduRC == NULL) { apduRC = &status; } *nextSize = 0; ret = CKYApplet_HandleAPDU(conn, CACAppletFactory_GetCertificate, &size, NULL, CKY_SIZE_UNKNOWN, CKYAppletFill_AppendBuffer, cert, apduRC); if ((*apduRC & CKYISO_MORE_MASK) == CKYISO_MORE) { *nextSize = *apduRC & ~CKYISO_MORE_MASK; } return ret; } CKYStatus CACApplet_GetCertificateAppend(CKYCardConnection *conn, CKYBuffer *cert, CKYSize nextSize, CKYISOStatus *apduRC) { CKYStatus ret; CKYISOStatus status; CKYSize size = nextSize; if (apduRC == NULL) { apduRC = &status; } ret = CKYApplet_HandleAPDU(conn, CACAppletFactory_GetCertificate, &size, NULL, CKY_SIZE_UNKNOWN, CKYAppletFill_AppendBuffer, cert, apduRC); while ((*apduRC & CKYISO_MORE_MASK) == CKYISO_MORE) { size = *apduRC & ~CKYISO_MORE_MASK; ret = CKYApplet_HandleAPDU(conn, CACAppletFactory_GetCertificate, &size, NULL, CKY_SIZE_UNKNOWN, CKYAppletFill_AppendBuffer, cert, apduRC); } return ret; } /* * PIN cluster */ CKYStatus CKYApplet_CreatePIN(CKYCardConnection *conn, CKYByte pinNumber, CKYByte maxAttempts, const char *pinValue, const CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYAppletArgCreatePIN cpd; cpd.pinValue = pinValue; cpd.maxAttempts = maxAttempts; cpd.pinValue = pinValue; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_CreatePIN, &cpd, nonce, 0, CKYAppletFill_Null, NULL, apduRC); } CKYStatus CKYApplet_VerifyPIN(CKYCardConnection *conn, CKYByte pinNumber, const char *pinValue, CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYAppletArgVerifyPIN vpd; vpd.pinValue = pinValue; vpd.pinNumber = pinNumber; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_VerifyPIN, &vpd, NULL, 8, CKYAppletFill_ReplaceBuffer, nonce, apduRC); } CKYStatus CKYApplet_ChangePIN(CKYCardConnection *conn, const char *oldPin, const char *newPin, const CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYAppletArgChangePIN cpd; cpd.oldPin = oldPin; cpd.newPin = newPin; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ChangePIN, &cpd, nonce, 0, CKYAppletFill_Null, NULL, apduRC); } CKYStatus CKYApplet_ListPINs(CKYCardConnection *conn, unsigned short *pins, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ListPINs, NULL, NULL, CKY_SIZE_LIST_PINS, CKYAppletFill_Short, pins, apduRC); } CKYStatus CKYApplet_Logout(CKYCardConnection *conn, CKYByte pinNumber, const CKYBuffer *nonce, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_Logout, &pinNumber, nonce, 0, CKYAppletFill_Null, NULL, apduRC); } CKYStatus CKYApplet_CreateObject(CKYCardConnection *conn, unsigned long objectID, CKYSize size, unsigned short readACL, unsigned short writeACL, unsigned short deleteACL, const CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYAppletArgCreateObject cod; cod.objectID = objectID; cod.size = size; cod.readACL = readACL; cod.writeACL = writeACL; cod.deleteACL = deleteACL; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_CreateObject, &cod, nonce, 0, CKYAppletFill_Null, NULL, apduRC); } CKYStatus CKYApplet_DeleteObject(CKYCardConnection *conn, unsigned long objectID, CKYByte zero, const CKYBuffer *nonce, CKYISOStatus *apduRC) { CKYAppletArgDeleteObject dod; dod.objectID = objectID; dod.zero = zero; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_DeleteObject, &dod, nonce, 0, CKYAppletFill_Null, NULL, apduRC); } /* * Read Object cluster... * This is the raw version that goes issues a single APDU. */ CKYStatus CKYApplet_ReadObject(CKYCardConnection *conn, unsigned long objectID, CKYOffset offset, CKYByte size, const CKYBuffer *nonce, CKYBuffer *data, CKYISOStatus *apduRC) { CKYAppletArgReadObject rod; rod.objectID = objectID; rod.offset = offset; rod.size = size; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ReadObject, &rod, nonce, size, CKYAppletFill_ReplaceBuffer, data, apduRC); } /* * Read Object Append cluster... * This is also issues a single APDU, but appends the resulting data * to an existing buffer. */ CKYStatus CKYApplet_ReadObjectAppend(CKYCardConnection *conn, unsigned long objectID, CKYOffset offset, CKYByte size, const CKYBuffer *nonce, CKYBuffer *data, CKYISOStatus *apduRC) { CKYAppletArgReadObject rod; rod.objectID = objectID; rod.offset = offset; rod.size = size; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ReadObject, &rod, nonce, size, CKYAppletFill_AppendBuffer, data, apduRC); } /* * Read Object * This is makes multiple APDU calls to read the entire object. */ CKYStatus CKYApplet_ReadObjectFull(CKYCardConnection *conn, unsigned long objectID, CKYOffset offset, CKYSize size, const CKYBuffer *nonce, CKYBuffer *data, CKYISOStatus *apduRC) { CKYAppletArgReadObject rod; CKYStatus ret = CKYSUCCESS; rod.objectID = objectID; rod.offset = offset; do { rod.size = (CKYByte) MIN(size, CKY_MAX_READ_CHUNK_SIZE); ret = CKYApplet_HandleAPDU(conn, CKYAppletFactory_ReadObject, &rod, nonce, rod.size, CKYAppletFill_AppendBuffer, data, apduRC); size -= rod.size; rod.offset += rod.size; } while ((size > 0) && (ret == CKYSUCCESS)); return ret; } /* * List Object cluster */ static CKYStatus ckyAppletFill_ListObjects(const CKYBuffer *response, CKYSize size, void *param) { CKYAppletRespListObjects *lop = (CKYAppletRespListObjects *)param; lop->objectID = CKYBuffer_GetLong(response, 0); lop->objectSize = CKYBuffer_GetLong(response, 4); lop->readACL = CKYBuffer_GetShort(response, 8); lop->writeACL = CKYBuffer_GetShort(response, 10); lop->deleteACL = CKYBuffer_GetShort(response, 12); return CKYSUCCESS; } CKYStatus CKYApplet_ListObjects(CKYCardConnection *conn, CKYByte seq, CKYAppletRespListObjects *lop, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_ListObjects, &seq, NULL, CKY_SIZE_LIST_OBJECTS, ckyAppletFill_ListObjects, lop, apduRC); } /* * GetStatus cluster */ static CKYStatus ckyAppletFill_GetStatus(const CKYBuffer *response, CKYSize size, void *param) { CKYAppletRespGetStatus *gsp = (CKYAppletRespGetStatus *)param; gsp->protocolMajorVersion = CKYBuffer_GetChar(response, 0); gsp->protocolMinorVersion = CKYBuffer_GetChar(response, 1); gsp->appletMajorVersion = CKYBuffer_GetChar(response, 2); gsp->appletMinorVersion = CKYBuffer_GetChar(response, 3); gsp->totalObjectMemory = CKYBuffer_GetLong(response, 4); gsp->freeObjectMemory = CKYBuffer_GetLong(response, 8); gsp->numberPins = CKYBuffer_GetChar(response, 12); gsp->numberKeys = CKYBuffer_GetChar(response, 13); gsp->loggedInMask = CKYBuffer_GetShort(response, 14); return CKYSUCCESS; } CKYStatus CKYApplet_GetStatus(CKYCardConnection *conn, CKYAppletRespGetStatus *status, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetStatus, NULL, NULL, CKY_SIZE_GET_STATUS, ckyAppletFill_GetStatus, status, apduRC); } CKYStatus CKYApplet_Noop(CKYCardConnection *conn, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_Noop, NULL, NULL, 0, CKYAppletFill_Null, NULL, apduRC); } CKYStatus CKYApplet_GetBuildID(CKYCardConnection *conn, unsigned long *buildID, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetBuildID, NULL, NULL, CKY_SIZE_GET_BUILDID, CKYAppletFill_Long, buildID, apduRC); } /* * GetLifeCycle cluster */ static CKYStatus ckyAppletFill_GetLifeCycle(const CKYBuffer *response, CKYSize size, void *param) { *(CKYByte *)param= CKYBuffer_GetChar(response,0); return CKYSUCCESS; } CKYStatus CKYApplet_GetLifeCycle(CKYCardConnection *conn, CKYByte *personalized, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetLifeCycle, NULL, NULL, CKY_SIZE_GET_LIFE_CYCLE, ckyAppletFill_GetLifeCycle, personalized, apduRC); } static CKYStatus ckyAppletFill_GetLifeCycleV2(const CKYBuffer *response, CKYSize size, void *param) { CKYAppletRespGetLifeCycleV2 *ext = (CKYAppletRespGetLifeCycleV2 *) param; ext->lifeCycle = CKYBuffer_GetChar(response,0); ext->pinCount = CKYBuffer_GetChar(response,1); ext->protocolMajorVersion = CKYBuffer_GetChar(response,2); ext->protocolMinorVersion = CKYBuffer_GetChar(response,3); return CKYSUCCESS; } /* * GetStatus cluster */ static CKYStatus ckyAppletFill_LifeCycleStatus(const CKYBuffer *response, CKYSize size, void *param) { CKYAppletRespGetLifeCycleV2 *ext = (CKYAppletRespGetLifeCycleV2 *) param; ext->pinCount = CKYBuffer_GetChar(response,12); ext->protocolMajorVersion = CKYBuffer_GetChar(response,0); ext->protocolMinorVersion = CKYBuffer_GetChar(response,1); return CKYSUCCESS; } CKYStatus CKYApplet_GetLifeCycleV2(CKYCardConnection *conn, CKYAppletRespGetLifeCycleV2 *ext, CKYISOStatus *apduRC) { CKYStatus status; status = CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetLifeCycleV2, NULL,NULL, CKY_SIZE_GET_LIFE_CYCLE_V2, ckyAppletFill_GetLifeCycleV2, ext, apduRC); /* Get Life Cycle Version 2 is a new APDU with combines data from * two other APDUs. Older tokens don't have this APDU, so use * the old method to get the data */ if (status == CKYAPDUFAIL) { status = CKYApplet_GetLifeCycle(conn,&ext->lifeCycle, apduRC); if (status != CKYSUCCESS) { return status; } status = CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetStatus, NULL, NULL, CKY_SIZE_GET_STATUS, ckyAppletFill_LifeCycleStatus, ext, apduRC); } return status; } /* * GetBuiltin cluster */ static CKYStatus ckyAppletFill_GetBuiltinACL(const CKYBuffer *response,CKYSize size,void *param) { CKYAppletRespGetBuiltinACL *gba = (CKYAppletRespGetBuiltinACL *) param; gba->create_object_ACL = CKYBuffer_GetShort(response,0); gba->create_object_ACL = CKYBuffer_GetShort(response,2); gba->create_object_ACL = CKYBuffer_GetShort(response,4); gba->enable_ACL_change = CKYBuffer_GetChar(response,6); return CKYSUCCESS; } CKYStatus CKYApplet_GetBuiltinACL(CKYCardConnection *conn, CKYAppletRespGetBuiltinACL *gba, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetBuiltinACL, NULL, NULL, CKY_SIZE_GET_BUILTIN_ACL, ckyAppletFill_GetBuiltinACL, gba, apduRC); } CKYStatus CKYApplet_GetIssuerInfo(CKYCardConnection *conn, CKYBuffer *info, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetIssuerInfo, NULL, NULL, CKY_SIZE_GET_ISSUER_INFO, CKYAppletFill_ReplaceBuffer, info, apduRC); } CKYStatus CKYApplet_GetRandom(CKYCardConnection *conn, CKYBuffer *data, CKYByte len, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetRandom, &len, NULL, len, CKYAppletFill_ReplaceBuffer, data, apduRC); } CKYStatus CKYApplet_GetRandomAppend(CKYCardConnection *conn, CKYBuffer *data, CKYByte len, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_GetRandom, &len, NULL, len, CKYAppletFill_AppendBuffer, data, apduRC); } CKYStatus CKYApplet_SeedRandom(CKYCardConnection *conn, const CKYBuffer *data, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_SeedRandom, data, NULL, 0, CKYAppletFill_Null, NULL, apduRC); } /* * deprecates 0.x functions */ /* old applet verify pin call (no nonce returned) */ CKYStatus CKYApplet_VerifyPinV0(CKYCardConnection *conn, CKYByte pinNumber, const char *pinValue, CKYISOStatus *apduRC) { CKYAppletArgVerifyPIN vpd; vpd.pinValue = pinValue; vpd.pinNumber = pinNumber; vpd.pinValue = pinValue; vpd.pinNumber = pinNumber; return CKYApplet_HandleAPDU(conn, CKYAppletFactory_VerifyPIN, &vpd, NULL, 0, CKYAppletFill_Null, NULL, apduRC); } /* logout all */ CKYStatus CKYApplet_LogoutAllV0(CKYCardConnection *conn, CKYISOStatus *apduRC) { return CKYApplet_HandleAPDU(conn, CKYAppletFactory_LogoutAllV0, NULL, NULL, 0, CKYAppletFill_Null, NULL, apduRC); } --- NEW FILE cky_applet.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #ifndef CKY_APPLET_H #define CKY_APPLET_H 1 #include "cky_base.h" #include "cky_card.h" #include "cky_factory.h" /* * base typdefs */ /* * ISO and applet response codes. */ typedef unsigned short CKYISOStatus; /* applet return status */ /* Psuedo return codes created by the library software */ #define CKYISO_INVRESPONSE 0xffff /* code returned by library to * indicate no valid response * received */ #define CKYISO_NORESPONSE 0x0000 /* code returned by the library if * operation failed before * attempting to read a response */ /* ISO defined Return codes */ #define CKYISO_SUCCESS 0x9000 /* SUCCESS! */ #define CKYISO_MORE_MASK 0xff00 /* More data mask */ #define CKYISO_MORE 0x6300 /* More data available */ #define CKYISO_DATA_INVALID 0x6984 /* Applet Defined Return codes */ #define CKYISO_NO_MEMORY_LEFT 0x9c01 /* There have been memory * problems on the card */ #define CKYISO_AUTH_FAILED 0x9c02 /* Entered PIN is not correct */ #define CKYISO_OPERATION_NOT_ALLOWED 0x9c03 /* Required operation is not * allowed in actual * circumstances */ #define CKYISO_UNSUPPORTED_FEATURE 0x9c05 /* Required feature is not (yet) * supported */ #define CKYISO_UNAUTHORIZED 0x9c06 /* Required operation was not * authorized because of a lack of * privileges */ #define CKYISO_OBJECT_NOT_FOUND 0x9c07 /* Required object is missing */ #define CKYISO_OBJECT_EXISTS 0x9c08 /* New object ID already in use */ #define CKYISO_INCORRECT_ALG 0x9c09 /* Algorithm specified is not * correct */ #define CKYISO_SIGNATURE_INVALID 0x9c0b /* Verify operation detected an * invalid signature */ #define CKYISO_IDENTITY_BLOCKED 0x9c0c /* Operation has been blocked for * security reason */ #define CKYISO_INVALID_PARAMETER 0x9c0f /* Invalid input parameter to * command */ #define CKYISO_INCORRECT_P1 0x9c10 /* Incorrect P1 parameter */ #define CKYISO_INCORRECT_P2 0x9c11 /* Incorrect P2 parameter */ #define CKYISO_SEQUENCE_END 0x9c12 /* No more data available */ #define CKYISO_INTERNAL_ERROR 0x9cff /* Reserved for debugging, * shouldn't happen */ /* * Pin Constants as used by our applet */ #define CKY_OLD_USER_PIN_NUM 1 /* version 0 and earlier */ #define CKY_USER_PIN_NUM 0 /* * special size that tells the Verify Function not to verify the size because * the ADPU can return variable size. */ #define CKY_SIZE_UNKNOWN 0xffffffff /* * structures for returning Applet responses */ typedef struct _CKYAppletRespGetStatus { CKYByte protocolMajorVersion; CKYByte protocolMinorVersion; CKYByte appletMajorVersion; CKYByte appletMinorVersion; unsigned long totalObjectMemory; unsigned long freeObjectMemory; CKYByte numberPins; CKYByte numberKeys; unsigned short loggedInMask; } CKYAppletRespGetStatus; typedef struct _CKYAppletRespGetLifeCycleV2 { CKYByte lifeCycle; CKYByte pinCount; CKYByte protocolMajorVersion; CKYByte protocolMinorVersion; } CKYAppletRespGetLifeCycleV2; typedef struct _CKYAppletRespGetBuiltinACL { unsigned short create_object_ACL; unsigned short create_key_ACL; unsigned short create_pin_ACL; CKYByte enable_ACL_change; } CKYAppletRespGetBuiltinACL; typedef struct _CKYAppletRespGetCPLCData { unsigned short CPLCtag; CKYByte length; unsigned short fabricator; unsigned short romType; unsigned short romOSID; unsigned short romOSDate; unsigned short romOSLevel; unsigned short eepromFabricationDate; unsigned long eepromSerialNumber; unsigned short eepromBatchID; unsigned short eepromModuleFabricator; unsigned short eepromModuleDate; unsigned short eepromICManufacturer; unsigned short eepromEmbeddingDate; unsigned short eepromPrePersonalizer; unsigned short eepromPrePersonalizeDate; unsigned long eepromPrePersonalizeID; unsigned short eepromPersonalizer; unsigned short eepromPersonalizeDate; unsigned long eepromPersonalizeID; } CKYAppletRespGetCPLCData; typedef struct _CKYAppletRespListObjects { unsigned long objectID; CKYSize objectSize; unsigned short readACL; unsigned short writeACL; unsigned short deleteACL; } CKYAppletRespListObjects; typedef struct _CKYAppletRespListKeys { CKYByte keyNum; CKYByte keyType; CKYByte keyPartner; unsigned short keySize; unsigned short readACL; unsigned short writeACL; unsigned short useACL; } CKYAppletRespListKeys; /* * structures for the generic factories */ typedef struct _CKYAppletArgCreatePIN { const char *pinValue; CKYByte pinNumber; CKYByte maxAttempts; } CKYAppletArgCreatePIN; typedef struct _CKYAppletArgVerifyPIN { const char *pinValue; CKYByte pinNumber; } CKYAppletArgVerifyPIN; typedef struct _CKYAppletArgChangePIN { const char *oldPin; const char *newPin; CKYByte pinNumber; } CKYAppletArgChangePIN; typedef struct _CKYAppletArgCreateObject { unsigned long objectID; CKYSize size; unsigned short readACL; unsigned short writeACL; unsigned short deleteACL; } CKYAppletArgCreateObject; typedef struct _CKYAppletArgDeleteObject { unsigned long objectID; CKYByte zero; } CKYAppletArgDeleteObject; typedef struct _CKYAppletArgReadObject { unsigned long objectID; CKYOffset offset; CKYByte size; } CKYAppletArgReadObject; typedef struct _CKYAppletArgComputeCrypt { CKYByte keyNumber; CKYByte mode; CKYByte direction; CKYByte location; const CKYBuffer *data; const CKYBuffer *sig; } CKYAppletArgComputeCrypt; /* fills in an APDU from a structure -- form of all the generic factories*/ typedef CKYStatus (*CKYAppletFactory)(CKYAPDU *apdu, const void *param); /* fills in an a structure from a response -- form of all the fill structures*/ typedef CKYStatus (*CKYFillFunction)(const CKYBuffer *response, CKYSize size, void *param); CKY_BEGIN_PROTOS /***************************************************************** * * Generic factorys are used by the generic APDU processing * to customize the formatting of APDU. The all have the same signature * as CKYAppletFactory. Typically APDUs are formatted * using parameterized calls of the form CKYAPDUFactory_ADPUNAME. * The generic processing code, however needs calls with a common * Signature. To accomplish the conversion, we build generic versions * which take a void * parameter. Trivial APDU's can pass NULL or a pointer * to the single parameter that they need. More complicated APDU's use * CKYAppletArg* data structures defined above to pass more arguments. * * Generic factorys then call the standard CKYAPDUFactor_ADPUNAME() functions * to build the APDUs. These functions are intended only as arguments * to the generic ADPU calls, and not to be called directly. * *****************************************************************/ /* param == CKYBuffer * (AID) */ CKYStatus CKYAppletFactory_SelectFile(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_SelectCardManager(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_GetCPLCData(CKYAPDU *apdu, const void *param); /* param == CKYByte * (pointer to seq) */ CKYStatus CKYAppletFactory_ListKeys(CKYAPDU *apdu, const void *param); /* param == CKYAppletArgComputeCrypt */ CKYStatus CKYAppletFactory_ComputeCryptInit(CKYAPDU *apdu, const void *param); /* param == CKYAppletArgComputeCrypt */ CKYStatus CKYAppletFactory_ComputeCryptProcess(CKYAPDU *apdu, const void *param); /* param == CKYAppletArgComputeCrypt */ CKYStatus CKYAppletFactory_ComputeCryptFinal(CKYAPDU *apdu, const void *param); /* param == CKYAppletArgCreatePIN */ CKYStatus CKYAppletFactory_CreatePIN(CKYAPDU *apdu, const void *param); /* param == CKYAppletArgVeriryPIN */ CKYStatus CKYAppletFactory_VerifyPIN(CKYAPDU *apdu, const void *param); /* param == CKYAppletArgChangePIN */ CKYStatus CKYAppletFactory_ChangePIN(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_ListPINs(CKYAPDU *apdu, const void *param); /* param == CKYByte * (pointer to pinNumber) */ CKYStatus CKYAppletFactory_Logout(CKYAPDU *apdu, const void *param); /* Future add WriteObject */ /* param == CKYAppletArgCreateObject */ CKYStatus CKYAppletFactory_CreateObject(CKYAPDU *apdu, const void *param); /* param == CKYAppletArgDeleteObject */ CKYStatus CKYAppletFactory_DeleteObject(CKYAPDU *apdu, const void *param); /* param == CKYAppletArgReadObject */ CKYStatus CKYAppletFactory_ReadObject(CKYAPDU *apdu, const void *param); /* param == CKYByte * (pointer to seq) */ CKYStatus CKYAppletFactory_ListObjects(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_GetStatus(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_Noop(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_GetBuildID(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_GetLifeCycle(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_GetLifeCycleV2(CKYAPDU *apdu, const void *param); /* param == CKYByte * */ CKYStatus CKYAppletFactory_GetRandom(CKYAPDU *apdu, const void *param); /* param == CKY_Buffer */ CKYStatus CKYAppletFactory_SeedRandom(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_GetIssuerInfo(CKYAPDU *apdu, const void *param); /* param == NULL */ CKYStatus CKYAppletFactory_GetBuiltinACL(CKYAPDU *apdu, const void *param); /* deprecates 0.x functions */ /* param == NULL */ CKYStatus CKYAppletFactory_LogoutAllV0(CKYAPDU *apdu, const void *param); /***************************************************************** * * Generic Fill routines used by the generic APDU processing * to customize how the response data is returned to the application. * generally the param points to some structure which is filled in * by the Fill function from the response data. Each APDU command * can potentially have it's own fill function. Different appearent * functions can be accomplished by calling the same APDU with a different * fill function. The fill functions below are considered globally interesting * to applications that wish to make custom APDU calls using the * applet generic processing. Fill functions are never called directly, * but through callback, and all have the same signature (CKYFillFunction) * *****************************************************************/ /* a null fill function for those APDU's which do not return data */ CKYStatus CKYAppletFill_Null(const CKYBuffer *response, CKYSize size, void *param); /* Buffer Fills: */ /* Replace fill function for those APDU's which return raw data */ /* param == CKYBuffer * */ CKYStatus CKYAppletFill_ReplaceBuffer(const CKYBuffer *response, CKYSize size, void *param); /* Append fill function can be used with any APDU that uses Buffer * Replace. Repeated calls continuously adds more data to the buffer. * Useful for repeated operations like read. */ /* param == CKYBuffer * */ CKYStatus CKYAppletFill_AppendBuffer(const CKYBuffer *response, CKYSize size, void *param); /* Single value fills: Byte, Short, & Long */ /* param == CKYByte * */ CKYStatus CKYAppletFill_Byte(const CKYBuffer *response, CKYSize size, void *param); /* param == CKYByte * */ CKYStatus CKYAppletFill_Short(const CKYBuffer *response, CKYSize size, void *param); CKYStatus CKYAppletFill_Long(const CKYBuffer *response, CKYSize size, void *param); /***************************************************************** * * Utilities shared by all the fetch Cards. * *****************************************************************/ /* * verify the we got a successful response. Responses should include * the expected data returned plus a 2 byte return code. This return * code should be 0x9000 on success. The function copies the return code * to apduRC if apduRC is not NULL. */ CKYBool CKYApplet_VerifyResponse(const CKYBuffer *response, CKYSize dataSize, CKYISOStatus *apduRC); /* * most commands have identical operations. This function * handles these operations, isolating the differences in * call back functions. * It creates the ADPU using afFunc with afArg. * Adds nonce if it exists. * Sends the ADPU to the card through the connection conn. * Checks that the response was valid (returning the responce code in apduRC. * Formats the response data into fillArg with fillFunc * nonce and apduRC can be NULL (no nonce is added, not status returned * legal values for afArg are depened on afFunc. * legal values for fillArg are depened on fillFunc. */ CKYStatus CKYApplet_HandleAPDU(CKYCardConnection *conn, CKYAppletFactory afFunc, const void *afArg, const CKYBuffer *nonce, CKYSize size, CKYFillFunction fillFunc, void *fillArg, CKYISOStatus *apduRC); /***************************************************************** * * The following convience functions convert APDU calls * into function calls, with input and output parameters. * The application is still responsible for * 1) creating a connection to the card, * 2) Getting a tranaction long, then * 3) selecting the appropriate applet (or Card manager). * Except for those calls that have been noted, the appropriate applet * is the CoolKey applet. * *****************************************************************/ /* Select an applet. Can happen with either applet selected */ CKYStatus CKYApplet_SelectFile(CKYCardConnection *conn, const CKYBuffer *AID, CKYISOStatus *apduRC); /* Select the CoolKey applet. Special case of the above command */ /* Can happen with either applet selected */ CKYStatus CKYApplet_SelectCoolKeyManager(CKYCardConnection *conn, CKYISOStatus *apduRC); /* Select the card manager. Can happen with either applet selected */ CKYStatus CKYApplet_SelectCardManager(CKYCardConnection *conn, CKYISOStatus *apduRC); /* GetCPLC data -- must be called with CM selected */ /* fills in cplc */ CKYStatus CKYApplet_GetCPLCData(CKYCardConnection *conn, CKYAppletRespGetCPLCData *cplc, CKYISOStatus *apduRC); /* Get CUID. -- must be called with CM selected */ /* special case of GetCPLCData */ /* fills in cuid */ CKYStatus CKYApplet_GetCUID(CKYCardConnection *conn, CKYBuffer *cuid, CKYISOStatus *apduRC); /* Get MSN. -- must be called with CM selected */ /* special case of GetCPLCData */ /* returns msn */ CKYStatus CKYApplet_GetMSN(CKYCardConnection *conn, unsigned long *msn, CKYISOStatus *apduRC); /* List Keys -- see applet documentation */ CKYStatus CKYApplet_ListKeys(CKYCardConnection *conn, CKYByte seq, CKYAppletRespListKeys *lkp, CKYISOStatus *apduRC); /* * Compute Crypt Cluster. * * Compute Crypt takes 3 phases: Init, Process, Final. * Applications can call each phase separately using: * CKYApplet_ComputeCryptInit * CKYApplet_ComputeCryptProcess * CKYApplet_ComputeCryptFinal * or call all three in one set with: * CKYApplet_ComputeCrypt * Buffer values passed to Compute crypt should be raw data. * The helper functions format the 2 byte length data required by the * applet automatically. */ CKYStatus CKYApplet_ComputeCryptInit(CKYCardConnection *conn, CKYByte keyNumber, CKYByte mode, CKYByte direction, CKYByte location, const CKYBuffer *nonce, CKYISOStatus *apduRC); CKYStatus CKYApplet_ComputeCryptProcess(CKYCardConnection *conn, CKYByte keyNumber, CKYByte location, const CKYBuffer *data, const CKYBuffer *nonce, CKYISOStatus *apduRC); CKYStatus CKYApplet_ComputeCryptFinal(CKYCardConnection *conn, CKYByte keyNumber, CKYByte location, const CKYBuffer *data, CKYBuffer *sig, CKYBuffer *result, const CKYBuffer *nonce, CKYISOStatus *apduRC); /** ...look to data size to see if we should read/write the data to * the on card buffer. (future) */ CKYStatus CKYApplet_ComputeCrypt(CKYCardConnection *conn, CKYByte keyNumber, CKYByte mode, CKYByte direction, const CKYBuffer *data, CKYBuffer *sig, CKYBuffer *result, const CKYBuffer *nonce, CKYISOStatus *apduRC); /* Pin Command -- see applet documentation for use */ CKYStatus CKYApplet_CreatePIN(CKYCardConnection *conn, CKYByte pinNumber, CKYByte maxAttempts, const char *pinValue, const CKYBuffer *nonce, CKYISOStatus *apduRC); CKYStatus CKYApplet_VerifyPIN(CKYCardConnection *conn, CKYByte pinNumber, const char *pinValue, CKYBuffer *nonce, CKYISOStatus *apduRC); CKYStatus CKYApplet_ChangePIN(CKYCardConnection *conn, const char *oldPin, const char *newPin, const CKYBuffer *nonce, CKYISOStatus *apduRC); CKYStatus CKYApplet_ListPINs(CKYCardConnection *conn, unsigned short *pins, CKYISOStatus *apduRC); CKYStatus CKYApplet_Logout(CKYCardConnection *conn, CKYByte pinNumber, const CKYBuffer *nonce, CKYISOStatus *apduRC); /* Object Commands -- see applet documentation for use */ CKYStatus CKYApplet_CreateObject(CKYCardConnection *conn, unsigned long objectID, CKYSize size, unsigned short readACL, unsigned short writeACL, unsigned short deleteACL, const CKYBuffer *nonce, CKYISOStatus *apduRC); CKYStatus CKYApplet_DeleteObject(CKYCardConnection *conn, unsigned long objectID, CKYByte zero, const CKYBuffer *nonce, CKYISOStatus *apduRC); /* CAC commands */ /* Select one of the CAC PKI applets. Special case of CKYApplet_SelectFile */ /* Select the CAC card manager. Can happen with either applet selected */ CKYStatus CACApplet_SelectCardManager(CKYCardConnection *conn, CKYISOStatus *apduRC); /* Can happen with either applet selected */ CKYStatus CACApplet_SelectPKI(CKYCardConnection *conn, CKYByte instance, CKYISOStatus *apduRC); /* must happen with PKI applet selected */ CKYStatus CACApplet_SignDecrypt(CKYCardConnection *conn, const CKYBuffer *data, CKYBuffer *result, CKYISOStatus *apduRC); CKYStatus CACApplet_GetCertificate(CKYCardConnection *conn, CKYBuffer *cert, CKYISOStatus *apduRC); CKYStatus CACApplet_GetCertificateFirst(CKYCardConnection *conn, CKYBuffer *cert, CKYSize *nextSize, CKYISOStatus *apduRC); CKYStatus CACApplet_GetCertificateAppend(CKYCardConnection *conn, CKYBuffer *cert, CKYSize nextSize, CKYISOStatus *apduRC); /*CKYStatus CACApplet_GetProperties(); */ CKYStatus CACApplet_VerifyPIN(CKYCardConnection *conn, const char *pin, CKYISOStatus *apduRC); /* * There are 3 read commands: * * CKYApplet_ReadObject issues a single Read APDU call. Supplied data buffer * is overwritten. This function is limited to reading 240 bytes. * CKYApplet_ReadObjectAppend also issues a single Read APDU call. However, * the result is appended to the data buffer. Again, this function is limited * to reading 240 bytes. * CKYApplet_ReadObjectFull can read an entire data object. It makes multiple * apdu calls in order to read the full amount into the buffer. The buffer * is overwriten. */ CKYStatus CKYApplet_ReadObject(CKYCardConnection *conn, unsigned long objectID, CKYOffset offset, CKYByte size, const CKYBuffer *nonce, CKYBuffer *data, CKYISOStatus *apduRC); CKYStatus CKYApplet_ReadObjectAppend(CKYCardConnection *conn, unsigned long objectID, CKYOffset offset, CKYByte size, const CKYBuffer *nonce, CKYBuffer *data, CKYISOStatus *apduRC); CKYStatus CKYApplet_ReadObjectFull(CKYCardConnection *conn, unsigned long objectID, CKYOffset offset, CKYSize size, const CKYBuffer *nonce, CKYBuffer *data, CKYISOStatus *apduRC); CKYStatus CKYApplet_ListObjects(CKYCardConnection *conn, CKYByte seq, CKYAppletRespListObjects *lop, CKYISOStatus *apduRC); CKYStatus CKYApplet_GetStatus(CKYCardConnection *conn, CKYAppletRespGetStatus *status, CKYISOStatus *apduRC); CKYStatus CKYApplet_Noop(CKYCardConnection *conn, CKYISOStatus *apduRC); CKYStatus CKYApplet_GetBuildID(CKYCardConnection *conn, unsigned long *buildID, CKYISOStatus *apduRC); CKYStatus CKYApplet_GetLifeCycle(CKYCardConnection *conn, CKYByte *personalized, CKYISOStatus *apduRC); CKYStatus CKYApplet_GetLifeCycleV2(CKYCardConnection *conn, CKYAppletRespGetLifeCycleV2 *ext, CKYISOStatus *apduRC); CKYStatus CKYApplet_GetRandom(CKYCardConnection *conn, CKYBuffer *buf, CKYByte len, CKYISOStatus *apduRC); CKYStatus CKYApplet_GetRandomAppend(CKYCardConnection *conn, CKYBuffer *buf, CKYByte len, CKYISOStatus *apduRC); CKYStatus CKYApplet_SeedRandom(CKYCardConnection *conn, const CKYBuffer *buf, CKYISOStatus *apduRC); CKYStatus CKYApplet_GetIssuerInfo(CKYCardConnection *conn, CKYBuffer *buf, CKYISOStatus *apduRC); CKYStatus CKYApplet_GetBuiltinACL(CKYCardConnection *conn, CKYAppletRespGetBuiltinACL *gba, CKYISOStatus *apduRC); /* * deprecates 0.x functions */ /* old applet verify pin call (no nonce returned) */ CKYStatus CKYApplet_VerifyPinV0(CKYCardConnection *conn, CKYByte pinNumber, const char *pinValue, CKYISOStatus *apduRC); /* logout all */ CKYStatus CKYApplet_LogoutAllV0(CKYCardConnection *conn, CKYISOStatus *apduRC); CKY_END_PROTOS #endif /* CKY_APPLET_H */ --- NEW FILE cky_base.c --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #include #include #include #include "cky_basei.h" #include "cky_base.h" #include "dynlink.h" /* * generic buffer management functions * * These functions allow simple buffer management used in the CoolKey * library and it's clients. */ /* initialize a new buffer to a known state */ static void ckyBuffer_initBuffer(CKYBuffer *buf) { #ifdef DEBUG assert(sizeof(CKYBuffer) == sizeof(CKYBufferPublic)); #endif buf->data = NULL; buf->size = 0; buf->len = 0; } /* * Init functions clobbers the current contents and allocates the required * space. Active buffers should call CKYBuffer_FreerData before * calling an init function. All init functions copies the supplied data * into newly allocated space. */ /* init an empty buffer that will later be filled in. */ CKYStatus CKYBuffer_InitEmpty(CKYBuffer *buf) { ckyBuffer_initBuffer(buf); return CKYSUCCESS; } /* Create a buffer of length len all initialized to '0' */ CKYStatus CKYBuffer_InitFromLen(CKYBuffer *buf, CKYSize len) { CKYStatus ret; ckyBuffer_initBuffer(buf); ret = CKYBuffer_Reserve(buf, len); if (ret != CKYSUCCESS) { return ret; } buf->len = len; memset(buf->data, 0, buf->len); return CKYSUCCESS; } static CKYByte fromHex(const char *cp) { if (*cp >= '0' && *cp <= '9') { return (CKYByte) *cp - '0'; } if (*cp >= 'a' && *cp <= 'f') { return (CKYByte) *cp - 'a' + 0xa; } if (*cp >= 'A' && *cp <= 'F') { return (CKYByte) *cp - 'A' + 0xA; } return 0; } /* Create a buffer by decoding a hex string. hexString is NULL terminated. */ CKYStatus CKYBuffer_InitFromHex(CKYBuffer *buf, const char *hexString) { int len = strlen(hexString); int dataHalf = 0; CKYByte lastDigit = 0; CKYByte digit; const char *cp; CKYByte *bp; CKYStatus ret; if (len & 1) { len++; dataHalf++; } ckyBuffer_initBuffer(buf); ret = CKYBuffer_Reserve(buf, len/2); if (ret != CKYSUCCESS) { return ret; } buf->len = len/2; bp = buf->data; for (cp = hexString; *cp; cp++) { digit = fromHex(cp); /* check for error? */ if (dataHalf) { *bp++= lastDigit << 4 | digit; } dataHalf ^= 1; lastDigit = digit; } return CKYSUCCESS; } /* Create a buffer from data */ CKYStatus CKYBuffer_InitFromData(CKYBuffer *buf, const CKYByte *data, CKYSize len) { CKYStatus ret; ckyBuffer_initBuffer(buf); ret = CKYBuffer_Reserve(buf, len); if (ret != CKYSUCCESS) { return ret; } buf->len = len; memcpy(buf->data, data, buf->len); return CKYSUCCESS; } /* Create a buffer from part of another buffer. Start indicates the * offset in the old buffer to start in, and len specifies how many bytes * to copy */ CKYStatus CKYBuffer_InitFromBuffer(CKYBuffer *buf, const CKYBuffer *src, CKYOffset start, CKYSize len) { CKYStatus ret; ckyBuffer_initBuffer(buf); if (src->len < start) { len = 0; } else if (src->len < start+len) { len = src->len -start; } ret = CKYBuffer_Reserve(buf, len); if (ret != CKYSUCCESS) { return ret; } buf->len = len; if (len == 0) { return CKYSUCCESS; } memcpy(buf->data, src->data+start, buf->len); return CKYSUCCESS; } /* Create a buffer from and exact copy of another buffer. */ CKYStatus CKYBuffer_InitFromCopy(CKYBuffer *buf, const CKYBuffer *src) { CKYStatus ret; ckyBuffer_initBuffer(buf); /* src buffer has no length, make sure the dest is empty */ if (src->len == 0) { return CKYSUCCESS; } ret = CKYBuffer_Reserve(buf, src->len); if (ret != CKYSUCCESS) { return ret; } buf->len = src->len; memcpy(buf->data, src->data, buf->len); return CKYSUCCESS; } /* * append functions increase the buffer size if necessary */ CKYStatus CKYBuffer_AppendChar(CKYBuffer *buf, CKYByte val) { CKYStatus ret; ret = CKYBuffer_Reserve(buf, buf->len + 1); if (ret != CKYSUCCESS) { return ret; } buf->data[buf->len] = val; buf->len += 1; return CKYSUCCESS; } /* append a short in network order */ CKYStatus CKYBuffer_AppendShort(CKYBuffer *buf, unsigned short val) { CKYStatus ret; ret = CKYBuffer_Reserve(buf, buf->len + 2); if (ret != CKYSUCCESS) { return ret; } buf->data[buf->len+0] = (CKYByte) ((val >> 8) & 0xff); buf->data[buf->len+1] = (CKYByte) ((val >> 0) & 0xff); buf->len += 2; return CKYSUCCESS; } /* append a long in applet order */ CKYStatus CKYBuffer_AppendLong(CKYBuffer *buf, unsigned long val) { CKYStatus ret; ret = CKYBuffer_Reserve(buf, buf->len + 4); if (ret != CKYSUCCESS) { return ret; } buf->data[buf->len+0] = (CKYByte) ((val >> 24) & 0xff); buf->data[buf->len+1] = (CKYByte) ((val >> 16) & 0xff); buf->data[buf->len+2] = (CKYByte) ((val >> 8) & 0xff); buf->data[buf->len+3] = (CKYByte) ((val >> 0) & 0xff); buf->len += 4; return CKYSUCCESS; } CKYStatus CKYBuffer_Replace(CKYBuffer *buf, CKYOffset offset, const CKYByte *data, CKYSize len) { CKYStatus ret; ret = CKYBuffer_Reserve(buf, offset+len); if (ret != CKYSUCCESS) { return ret; } if (buf->len < offset + len) { buf->len = offset + len; } memcpy(buf->data+offset, data, len); return CKYSUCCESS; } /* append data with length of len bytes */ CKYStatus CKYBuffer_AppendData(CKYBuffer *buf, const CKYByte *data, CKYSize len) { CKYStatus ret; ret = CKYBuffer_Reserve(buf, buf->len + len); if (ret != CKYSUCCESS) { return ret; } memcpy(buf->data+buf->len, data, len); buf->len += len; return CKYSUCCESS; } /* append data with length of len bytes */ CKYStatus CKYBuffer_AppendBuffer(CKYBuffer *buf, const CKYBuffer *src, CKYOffset offset, CKYSize len) { unsigned long maxlen = src->len - offset; if ((maxlen < len) || (src->len < offset)) { return CKYDATATOOLONG; } return CKYBuffer_AppendData(buf, src->data+offset, len); } /* append data with length of len bytes */ CKYStatus CKYBuffer_AppendCopy(CKYBuffer *buf, const CKYBuffer *src) { return CKYBuffer_AppendData(buf, src->data, src->len); } CKYStatus CKYBuffer_Reserve(CKYBuffer *buf, CKYSize newSize) { if (buf->size >= newSize) { return CKYSUCCESS; } buf->data = (CKYByte *)realloc(buf->data, newSize); if (buf->data == NULL) { buf->size = 0; buf->len = 0; return CKYNOMEM; } buf->size = newSize; return CKYSUCCESS; } CKYStatus CKYBuffer_SetChar(CKYBuffer *buf, CKYOffset offset, CKYByte val) { CKYStatus ret; if (buf->len < offset+1) { ret = CKYBuffer_Resize(buf,offset+1); if (ret != CKYSUCCESS) { return ret; } } buf->data[offset] = val; return CKYSUCCESS; } CKYStatus CKYBuffer_SetChars(CKYBuffer *buf, CKYOffset offset, CKYByte val, CKYSize len) { CKYStatus ret; if (buf->len < offset+len) { ret = CKYBuffer_Resize(buf,offset+len); if (ret != CKYSUCCESS) { return ret; } } memset(buf->data+offset,val, len); return CKYSUCCESS; } CKYStatus CKYBuffer_SetShort(CKYBuffer *buf, CKYOffset offset, unsigned short val) { CKYStatus ret; if (buf->len < offset+2) { ret = CKYBuffer_Resize(buf,offset+2); if (ret != CKYSUCCESS) { return ret; } } buf->data[offset+0] = (CKYByte) ((val >> 8) & 0xff); buf->data[offset+1] = (CKYByte) ((val >> 0) & 0xff); return CKYSUCCESS; } CKYStatus CKYBuffer_SetLong(CKYBuffer *buf, CKYOffset offset, unsigned long val) { CKYStatus ret; if (buf->len < offset+4) { ret = CKYBuffer_Resize(buf,offset+4); if (ret != CKYSUCCESS) { return ret; } } buf->data[offset+0] = (CKYByte) ((val >> 24) & 0xff); buf->data[offset+1] = (CKYByte) ((val >> 16) & 0xff); buf->data[offset+2] = (CKYByte) ((val >> 8) & 0xff); buf->data[offset+3] = (CKYByte) ((val >> 0) & 0xff); return CKYSUCCESS; } CKYByte CKYBuffer_GetChar(const CKYBuffer *buf, CKYOffset offset) { if (buf->len < offset+1) { return 0; } return buf->data[offset]; } unsigned short CKYBuffer_GetShort(const CKYBuffer *buf, CKYOffset offset) { unsigned short val; if (buf->len < offset+2) { return 0; } val = ((unsigned short)buf->data[offset+0]) << 8; val |= ((unsigned short)buf->data[offset+1]) << 0; return val; } unsigned long CKYBuffer_GetLong(const CKYBuffer *buf, CKYOffset offset) { unsigned long val; if (buf->len < offset+4) { return 0; } val = ((unsigned long)buf->data[offset+0]) << 24; val |= ((unsigned long)buf->data[offset+1]) << 16; val |= ((unsigned long)buf->data[offset+2]) << 8; val |= ((unsigned long)buf->data[offset+3]) << 0; return val; } CKYStatus CKYBuffer_Resize(CKYBuffer *buf, CKYSize newLen) { CKYStatus ret; if (buf->len < newLen) { ret = CKYBuffer_Reserve(buf, newLen); if (ret != CKYSUCCESS) { return ret; } memset(buf->data+buf->len, 0, newLen - buf->len); } buf->len = newLen; return CKYSUCCESS; } /* clear out a memory buffer... including unallocated space, then * set the buffer length to '0' */ void CKYBuffer_Zero(CKYBuffer *buf) { if (buf->size != 0) { memset(buf->data, 0, buf->size); } buf->len = 0;; } CKYSize CKYBuffer_Size(const CKYBuffer *buf) { return buf->len; } const CKYByte * CKYBuffer_Data(const CKYBuffer *buf) { return buf->data; } CKYBool CKYBuffer_DataIsEqual(const CKYBuffer *buf1, const CKYByte *buf2, CKYSize buf2Len) { if (buf1->len != buf2Len) { return 0; } /* all zero length buffers are equal, whether or not they have pointers * allocated */ if (buf1->len == 0) { return 1; } return memcmp(buf1->data, buf2, buf1->len) == 0; } CKYBool CKYBuffer_IsEqual(const CKYBuffer *buf1, const CKYBuffer *buf2) { return CKYBuffer_DataIsEqual(buf1, buf2->data, buf2->len); } CKYStatus CKYBuffer_FreeData(CKYBuffer *buf) { free(buf->data); ckyBuffer_initBuffer(buf); return CKYSUCCESS; } CKYStatus CKYAPDU_Init(CKYAPDU *apdu) { #ifdef DEBUG assert(sizeof(CKYAPDU) == sizeof(CKYAPDUPublic)); #endif ckyBuffer_initBuffer(&apdu->apduBuf); return CKYBuffer_Resize(&apdu->apduBuf, CKYAPDU_MIN_LEN); } CKYStatus CKYAPDU_InitFromData(CKYAPDU *apdu, const CKYByte *data, CKYSize len) { #ifdef DEBUG assert(sizeof(CKYAPDU) == sizeof(CKYAPDUPublic)); #endif ckyBuffer_initBuffer(&apdu->apduBuf); if (len > CKYAPDU_MAX_DATA_LEN) { return CKYDATATOOLONG; } return CKYBuffer_InitFromData(&apdu->apduBuf, data, len); } CKYStatus CKYAPDU_FreeData(CKYAPDU *apdu) { return CKYBuffer_FreeData(&apdu->apduBuf); } CKYByte CKYAPDU_GetCLA(const CKYAPDU *apdu) { return CKYBuffer_GetChar(&apdu->apduBuf, CKY_CLA_OFFSET); } CKYStatus CKYAPDU_SetCLA(CKYAPDU *apdu, CKYByte b) { return CKYBuffer_SetChar(&apdu->apduBuf, CKY_CLA_OFFSET, b); } CKYByte CKYAPDU_GetINS(const CKYAPDU *apdu) { return CKYBuffer_GetChar(&apdu->apduBuf, CKY_INS_OFFSET); } CKYStatus CKYAPDU_SetINS(CKYAPDU *apdu, CKYByte b) { return CKYBuffer_SetChar(&apdu->apduBuf, CKY_INS_OFFSET, b); } CKYByte CKYAPDU_GetP1(const CKYAPDU *apdu) { return CKYBuffer_GetChar(&apdu->apduBuf, CKY_P1_OFFSET); } CKYStatus CKYAPDU_SetP1(CKYAPDU *apdu, CKYByte b) { return CKYBuffer_SetChar(&apdu->apduBuf, CKY_P1_OFFSET, b); } CKYByte CKYAPDU_GetP2(const CKYAPDU *apdu) { return CKYBuffer_GetChar(&apdu->apduBuf, CKY_P2_OFFSET); } CKYStatus CKYAPDU_SetP2(CKYAPDU *apdu, CKYByte b) { return CKYBuffer_SetChar(&apdu->apduBuf, CKY_P2_OFFSET, b); } CKYStatus CKYAPDU_SetSendData(CKYAPDU *apdu, const CKYByte *data, CKYSize len) { CKYStatus ret; if (len > CKYAPDU_MAX_DATA_LEN) { return CKYDATATOOLONG; } ret = CKYBuffer_Resize(&apdu->apduBuf, len + CKYAPDU_HEADER_LEN); if (ret != CKYSUCCESS) { return ret; } ret = CKYBuffer_SetChar(&apdu->apduBuf, CKY_LC_OFFSET, len == CKYAPDU_MAX_DATA_LEN ? 0: (CKYByte) len); if (ret != CKYSUCCESS) { return ret; } return CKYBuffer_Replace(&apdu->apduBuf, CKYAPDU_HEADER_LEN, data, len); } CKYStatus CKYAPDU_SetSendDataBuffer(CKYAPDU *apdu, const CKYBuffer *buf) { return CKYAPDU_SetSendData(apdu, buf->data, buf->len); } CKYStatus CKYAPDU_AppendSendData(CKYAPDU *apdu, const CKYByte *data, CKYSize len) { CKYStatus ret; CKYSize dataLen; if (CKYBuffer_Size(&apdu->apduBuf) <= CKYAPDU_MIN_LEN) { return CKYAPDU_SetSendData(apdu,data, len); } dataLen = CKYBuffer_Size(&apdu->apduBuf) + len - CKYAPDU_HEADER_LEN; if (dataLen > CKYAPDU_MAX_DATA_LEN) { return CKYDATATOOLONG; } ret = CKYBuffer_AppendData(&apdu->apduBuf, data, len); if (ret != CKYSUCCESS) { return ret; } return CKYBuffer_SetChar(&apdu->apduBuf, CKY_LC_OFFSET, dataLen == CKYAPDU_MAX_DATA_LEN ? 0 : (CKYByte) dataLen); } CKYStatus CKYAPDU_AppendSendDataBuffer(CKYAPDU *apdu, const CKYBuffer *buf) { return CKYAPDU_AppendSendData(apdu, buf->data, buf->len); } CKYStatus CKYAPDU_SetReceiveLen(CKYAPDU *apdu, CKYByte recvlen) { CKYStatus ret; ret = CKYBuffer_Resize(&apdu->apduBuf, CKYAPDU_HEADER_LEN); if (ret != CKYSUCCESS) { return ret; } return CKYBuffer_SetChar(&apdu->apduBuf, CKY_LE_OFFSET, recvlen); } void CKY_SetName(char *p) { } --- NEW FILE cky_base.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #ifndef CKY_BASE_H #define CKY_BASE_H 1 /* * Common types and structs */ /* buffer sizes */ typedef unsigned long CKYSize; /* offsets into buffers are data */ typedef unsigned long CKYOffset; /* bytes, buffers */ typedef unsigned char CKYByte; /* Bool type */ typedef unsigned char CKYBool; #define CKYBUFFER_PUBLIC \ unsigned long reserved1;\ unsigned long reserved2;\ void *reserved3;\ void *reserved4; #define CKYAPDU_PUBLIC \ unsigned long reserved1;\ unsigned long reserved2;\ void *reserved3;\ void *reserved4; \ void *reserved5; typedef struct _CKYBuffer { #ifdef CKYBUFFER_PRIVATE CKYBUFFER_PRIVATE #else CKYBUFFER_PUBLIC #endif } CKYBuffer; typedef struct _CKYAPDU { #ifdef CKYAPDU_PRIVATE CKYAPDU_PRIVATE #else CKYAPDU_PUBLIC #endif } CKYAPDU; /* * the following is just to make sure the sizes match */ #ifdef DEBUG #ifdef CKYBUFFER_PRIVATE typedef struct _CKYBufferPublic { CKYBUFFER_PUBLIC } CKYBufferPublic; typedef struct _CKYAPDUPublic { CKYAPDU_PUBLIC } CKYAPDUPublic; #endif #endif typedef enum { CKYSUCCESS, /* operation completed successfully */ CKYNOMEM, /* failed to allocate memory */ CKYDATATOOLONG, /* index or length exceeded a buffer or device size */ CKYNOSCARD, /* Scard library does not exist */ CKYSCARDERR, /* I/O Error in the SCard interface level. */ /* more specific error values can be queried from * the context or connection with the * GetLastError() call */ CKYLIBFAIL, /* error is shared library. no additional * error is available. Only returned from internal * SHlib calls (not surfaced in public APIs */ CKYAPDUFAIL, /* processing worked, but applet rejected the APDU * (command) sent. ADPUIOStatus has more info on * why the APDU failed */ CKYINVALIDARGS, /* Caller passed in bad args */ } CKYStatus; /* * defines related to APDU's */ #define CKY_CLA_OFFSET 0 #define CKY_INS_OFFSET 1 #define CKY_P1_OFFSET 2 #define CKY_P2_OFFSET 3 #define CKY_P3_OFFSET 4 /* P3 is P3, LC, and LE depending on usage */ #define CKY_LC_OFFSET 4 #define CKY_LE_OFFSET 4 #define CKYAPDU_MAX_DATA_LEN 256 #define CKYAPDU_MIN_LEN 4 #define CKYAPDU_HEADER_LEN 5 #define CKYAPDU_MAX_LEN (CKYAPDU_HEADER_LEN+CKYAPDU_MAX_DATA_LEN) #define CKY_MAX_ATR_LEN 32 #define CKY_OUTRAGEOUS_MALLOC_SIZE (1024*1024) /* * allow direct inclusion in C++ files */ #ifdef __cplusplus #define CKY_BEGIN_PROTOS extern "C" { #define CKY_END_PROTOS } #else #define CKY_BEGIN_PROTOS #define CKY_END_PROTOS #endif CKY_BEGIN_PROTOS /* * generic buffer management functions * * These functions allow simple buffer management used in the CoolKey * library and it's clients. */ /* * Init functions clobbers the current contents and allocates the required * space. * - Active buffers should call CKYBuffer_FreeData before calling an init * function. * - New buffers should call some CKYBuffer_Init function before any use. * - All init functions copies the supplied data into newly allocated space. */ /* Create an empty buffer with no memory allocated to it. This is sufficient * to begin using a buffer. Note that new calls will probably allocate memory. * It is safe to free an empty buffer. */ CKYStatus CKYBuffer_InitEmpty(CKYBuffer *buf); /* Create a buffer of length len all initialized to '0' */ CKYStatus CKYBuffer_InitFromLen(CKYBuffer *buf, CKYSize len); /* Create a buffer by decoding a hex string. hexString is NULL terminated. */ CKYStatus CKYBuffer_InitFromHex(CKYBuffer *buf, const char *hexString); /* Create a buffer from data */ CKYStatus CKYBuffer_InitFromData(CKYBuffer *buf, const CKYByte *data, CKYSize len); /* Create a buffer from part of another buffer. Start indicates the * offset in the old buffer to start in, and len specifies how many bytes * to copy */ CKYStatus CKYBuffer_InitFromBuffer(CKYBuffer *buf, const CKYBuffer *src, CKYOffset start, CKYSize len); /* Create a buffer from an exact copy of another buffer */ CKYStatus CKYBuffer_InitFromCopy(CKYBuffer *buf, const CKYBuffer *src); /* * append functions increase the buffer size if necessary */ /* append a short in applet order */ CKYStatus CKYBuffer_AppendChar(CKYBuffer *buf, CKYByte b); /* append a short in applet order */ CKYStatus CKYBuffer_AppendShort(CKYBuffer *buf, unsigned short val); /* append a long in applet order */ CKYStatus CKYBuffer_AppendLong(CKYBuffer *buf, unsigned long val); /* append data. the data starts at data and extends len bytes */ CKYStatus CKYBuffer_AppendData(CKYBuffer *buf, const CKYByte *data, CKYSize len); /* append buffer fragment. the data starts at buffer[offset] * and extends len bytes */ CKYStatus CKYBuffer_AppendBuffer(CKYBuffer *buf, const CKYBuffer *src, CKYOffset offset, CKYSize len); /* append a full buffer */ CKYStatus CKYBuffer_AppendCopy(CKYBuffer *buf, const CKYBuffer *src ); /* reserve increases the space allocated for the buffer, but does not * increase the actual buffer size. If the buffer already newSize or more * space allocated, Reserve is a no op. */ CKYStatus CKYBuffer_Reserve(CKYBuffer *buf, CKYSize newSize) ; /* resize affects the buffer's size. If the buffer len increases, * the new date will be zero'ed out. If the buffer shrinks, the buffer * is truncated, but the space is not removed. */ CKYStatus CKYBuffer_Resize(CKYBuffer *buf, CKYSize newLen); /* replace bytes starting at 'offset'. If the buffer needs to be extended, * it will be automatically */ CKYStatus CKYBuffer_Replace(CKYBuffer *buf, CKYOffset offset, const CKYByte *data, CKYSize len); /* set byte at ofset. The buffer is extended to offset if necessary */ CKYStatus CKYBuffer_SetChar(CKYBuffer *buf, CKYOffset offset, CKYByte c); /* set several copies of 'c' at from offset to offset+ len */ CKYStatus CKYBuffer_SetChars(CKYBuffer *buf, CKYOffset offset, CKYByte c, CKYSize len); /* These functions work in applet order */ CKYStatus CKYBuffer_SetShort(CKYBuffer *buf, CKYOffset offset, unsigned short val); CKYStatus CKYBuffer_SetLong(CKYBuffer *buf, CKYOffset offset, unsigned long val); /* read a character from offset. If offset is beyond the end of the buffer, * then the function returns '0' */ CKYByte CKYBuffer_GetChar(const CKYBuffer *buf, CKYOffset offset); /* These functions work in applet order */ unsigned short CKYBuffer_GetShort(const CKYBuffer *buf, CKYOffset offset); unsigned long CKYBuffer_GetLong(const CKYBuffer *buf, CKYOffset offset); /* clear out all the data in a buffer */ void CKYBuffer_Zero(CKYBuffer *buf); /* return the size (length) of a buffer. This is only the portion of the * buffer that has valid data set. */ CKYSize CKYBuffer_Size(const CKYBuffer *buf); /* return a pointer to the data buffer */ const CKYByte *CKYBuffer_Data(const CKYBuffer *buf); /* compare two buffers return : * 1 if the two buffers are equal, * 0 if they are not */ CKYBool CKYBuffer_IsEqual(const CKYBuffer *buf1, const CKYBuffer *buf2); /* compares raw data with a buffer or equality */ CKYBool CKYBuffer_DataIsEqual(const CKYBuffer *buf1, const CKYByte *buf2, CKYSize buf2Len); /* free all the data associated with a buffer and initialize the buffer */ CKYStatus CKYBuffer_FreeData(CKYBuffer *buf); /* * APDU's are buffers that know about the APDU structure */ CKYStatus CKYAPDU_Init(CKYAPDU *apdu); CKYStatus CKYAPDU_InitFromData(CKYAPDU *apdu, const CKYByte *data, CKYSize size); CKYStatus CKYAPDU_FreeData(CKYAPDU *apdu); /* Access APDU header bytes */ CKYByte CKYAPDU_GetCLA(const CKYAPDU *apdu); CKYStatus CKYAPDU_SetCLA(CKYAPDU *apdu, CKYByte b); CKYByte CKYAPDU_GetINS(const CKYAPDU *apdu); CKYStatus CKYAPDU_SetINS(CKYAPDU *apdu, CKYByte b); CKYByte CKYAPDU_GetP1(const CKYAPDU *apdu); CKYStatus CKYAPDU_SetP1(CKYAPDU *apdu, CKYByte b); CKYByte CKYAPDU_GetP2(const CKYAPDU *apdu); CKYStatus CKYAPDU_SetP2(CKYAPDU *apdu, CKYByte b); /* add sending date to the APDU */ /* Set resets the buffer, append, adds the data to the end. Lc in * the APDU header is automaticallu updated */ CKYStatus CKYAPDU_SetSendData(CKYAPDU *apdu, const CKYByte *data, CKYSize len); CKYStatus CKYAPDU_SetSendDataBuffer(CKYAPDU *apdu, const CKYBuffer *buf); CKYStatus CKYAPDU_AppendSendData(CKYAPDU *apdu, const CKYByte *data, CKYSize len); CKYStatus CKYAPDU_AppendSendDataBuffer(CKYAPDU *apdu, const CKYBuffer *buf); /* set Le in the APDU header to the amount of bytes expected to be * returned. */ CKYStatus CKYAPDU_SetReceiveLen(CKYAPDU *apdu, CKYByte recvlen); /* set the parent loadmodule name */ void CKY_SetName(char *name); CKY_END_PROTOS #endif /* CKY_BASE_H */ --- NEW FILE cky_basei.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #ifndef CKY_BASE_H #ifndef CKY_BASEI_H #define CKY_BASEI_H 1 #define CKYBUFFER_PRIVATE \ CKYSize len; \ CKYSize size; \ CKYByte *data; \ void *reserved; #define CKYAPDU_PRIVATE \ CKYBuffer apduBuf; \ void *reserved; #endif /* CKY_BASE_H */ #endif /* CKY_BASEI_H */ --- NEW FILE cky_card.c --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #include #include #include #include "cky_basei.h" /* friend class */ #include "cky_base.h" #include "cky_card.h" #include "dynlink.h" #ifndef WINAPI #define WINAPI typedef SCARD_READERSTATE *LPSCARD_READERSTATE; #endif #ifndef SCARD_E_NO_READERS_AVAILABLE #define SCARD_E_NO_READERS_AVAILABLE ((unsigned long)0x8010002EL) #endif #define NEW(type,count) (type *)malloc((count)*sizeof(type)) /* * protect against scard API not being installed. */ typedef long (WINAPI * SCardEstablishContextFn) ( unsigned long dwScope, const void * pvReserved1, const void * pvReserved2, LPSCARDCONTEXT phContext); typedef long (WINAPI * SCardReleaseContextFn) ( SCARDCONTEXT hContext); typedef long (WINAPI * SCardBeginTransactionFn) ( long hCard); typedef long (WINAPI * SCardEndTransactionFn) ( long hCard, unsigned long dwDisposition); typedef long (WINAPI * SCardConnectFn) ( SCARDCONTEXT hContext, const char *szReader, unsigned long dwShareMode, unsigned long dwPreferredProtocols, long *phCard, unsigned long *pdwActiveProtocol); typedef long (WINAPI * SCardDisconnectFn) ( long hCard, unsigned long dwDisposition); typedef long (WINAPI * SCardTransmitFn) ( long hCard, LPCSCARD_IO_REQUEST pioSendPci, const unsigned char *pbSendBuffer, unsigned long cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, unsigned char *pbRecvBuffer, unsigned long *pcbRecvLength); typedef long (WINAPI * SCardReconnectFn) ( long hCard, unsigned long dwShareMode, unsigned long dwPreferredProtocols, unsigned long dwInitialization, unsigned long *pdwActiveProtocol); typedef long (WINAPI * SCardListReadersFn) ( SCARDCONTEXT hContext, const char *mszGroups, char *mszReaders, unsigned long *pcchReaders); typedef long (WINAPI * SCardStatusFn) ( long hCard, char *mszReaderNames, unsigned long *pcchReaderLen, unsigned long *pdwState, unsigned long *pdwProtocol, unsigned char *pbAtr, unsigned long *pcbAtrLen); typedef long (WINAPI * SCardGetAttribFn) ( long hCard, unsigned long dwAttId, char *pbAttr, unsigned long *pchAttrLen); typedef long (WINAPI * SCardGetStatusChangeFn) ( SCARDCONTEXT hContext, unsigned long dwTimeout, LPSCARD_READERSTATE rgReaderStates, unsigned long cReaders); typedef long (WINAPI * SCardCancelFn) ( SCARDCONTEXT hContext); typedef struct _SCard { SCardEstablishContextFn SCardEstablishContext; SCardReleaseContextFn SCardReleaseContext; SCardBeginTransactionFn SCardBeginTransaction; SCardEndTransactionFn SCardEndTransaction; SCardConnectFn SCardConnect; SCardDisconnectFn SCardDisconnect; SCardTransmitFn SCardTransmit; SCardReconnectFn SCardReconnect; SCardListReadersFn SCardListReaders; SCardStatusFn SCardStatus; SCardGetAttribFn SCardGetAttrib; SCardGetStatusChangeFn SCardGetStatusChange; SCardCancelFn SCardCancel; SCARD_IO_REQUEST *SCARD_PCI_T0_; } SCard; #define GET_ADDRESS(library, scard, name) \ status= ckyShLibrary_getAddress(library, \ (void**) &scard->name, MAKE_DLL_SYMBOL(name)); \ if (status != CKYSUCCESS) { \ goto fail; \ } #ifdef WIN32 #define SCARD_LIB_NAME "winscard.dll" #else #ifdef MAC #define SCARD_LIB_NAME "PCSC.Framework/PCSC" #else #ifdef LINUX #define SCARD_LIB_NAME "libpcsclite.so" #else #ifndef SCARD_LIB_NAME #error "define wincard library for this platform" #endif #endif #endif #endif static SCard * ckySCard_Init(void) { ckyShLibrary library; CKYStatus status; SCard *scard = NEW(SCard, 1); if (!scard) { return NULL; } library = ckyShLibrary_open(SCARD_LIB_NAME); if (!library) { goto fail; } GET_ADDRESS(library, scard, SCardEstablishContext); GET_ADDRESS(library, scard, SCardReleaseContext); GET_ADDRESS(library, scard, SCardBeginTransaction); GET_ADDRESS(library, scard, SCardEndTransaction); /* expands to SCardConnectA on Windows */ GET_ADDRESS(library, scard, SCardConnect); GET_ADDRESS(library, scard, SCardDisconnect); GET_ADDRESS(library, scard, SCardTransmit); GET_ADDRESS(library, scard, SCardReconnect); /* expands to SCardListReadersA on Windows */ GET_ADDRESS(library, scard, SCardListReaders); /* expands to SCardStatusA on Windows */ GET_ADDRESS(library, scard, SCardStatus); #ifdef WIN32 GET_ADDRESS(library, scard, SCardGetAttrib); #endif /* SCardGetStatusChangeA */ GET_ADDRESS(library, scard, SCardGetStatusChange); GET_ADDRESS(library, scard, SCardCancel); status = ckyShLibrary_getAddress( library, (void**) &scard->SCARD_PCI_T0_, MAKE_DLL_SYMBOL(g_rgSCardT0Pci)); if( status != CKYSUCCESS ) { goto fail; } return scard; fail: if (library) { ckyShLibrary_close(library); } free(scard); return NULL; } /* * Implement CKYReaderNameLists and CKYCardConnectionLists */ /* make the list code happy */ static void CKYReaderName_Destroy(char *data) { free(data); } #include "cky_list.i" /* implemnentation of the lists define by cky_list.h */ CKYLIST_IMPLEMENT(CKYReaderName, char *) CKYLIST_IMPLEMENT(CKYCardConnection, CKYCardConnection *) /* * CKReader objects represent Readers attached to the system. * The objects themselves are really SCard SCARD_READERSTATE objects. * These objects are used in 2 ways: * 1) the application creates static SCARD_READERSTATE's and use * CKYReader_Init() to initialize the structure. In this case * the application can call any of the reader 'methods' (functions * starting with CKReader) on these objects. When finished the * application is responsible for calling CKYReader_FreeData() to free * any data held by the reader object. * 2) Acquire an array of readers with CKYReader_CreateArray(). In this * case the application can call any method on any particular array member * In the end the Application is responsible for calling * CKYReader_DestroyArray() to free the entire array. */ void CKYReader_Init(SCARD_READERSTATE *reader) { reader->szReader = NULL; reader->pvUserData = 0; reader->cbAtr = 0; reader->dwCurrentState = SCARD_STATE_UNAWARE; } void CKYReader_FreeData(SCARD_READERSTATE *reader) { if (reader->szReader) { free((void *)reader->szReader); } CKYReader_Init(reader); } CKYStatus CKYReader_SetReaderName(SCARD_READERSTATE *reader, const char *name) { free((void *)reader->szReader); reader->szReader = strdup(name); return (reader->szReader)? CKYSUCCESS: CKYNOMEM; } const char * CKYReader_GetReaderName(const SCARD_READERSTATE *reader) { return reader->szReader; } /* see openSC or PCSC for the semantics of Known State and Event States */ CKYStatus CKYReader_SetKnownState(SCARD_READERSTATE *reader, unsigned long state) { reader->dwCurrentState = state; return CKYSUCCESS; } unsigned long CKYReader_GetKnownState(const SCARD_READERSTATE *reader) { return reader->dwCurrentState; } unsigned long CKYReader_GetEventState(const SCARD_READERSTATE *reader) { return reader->dwEventState; } /* Caller must have init'ed the buffer before calling * any data in the existing buffer is overwritten */ CKYStatus CKYReader_GetATR(const SCARD_READERSTATE *reader, CKYBuffer *buf) { CKYStatus ret; ret = CKYBuffer_Resize(buf, reader->cbAtr); if (ret != CKYSUCCESS) { return ret; } return CKYBuffer_Replace(buf, 0, reader->rgbAtr, reader->cbAtr); } SCARD_READERSTATE * CKYReader_CreateArray(const CKYReaderNameList readerNames, unsigned long *returnReaderCount) { unsigned long i,j; unsigned long readerCount; SCARD_READERSTATE *readers; CKYStatus ret; readerCount=CKYReaderNameList_GetCount(readerNames); if (readerCount == 0) { return NULL; } readers = NEW(SCARD_READERSTATE, readerCount); if (readers == NULL) { return NULL; } for (i=0; i < readerCount; i++) { CKYReader_Init(&readers[i]); ret = CKYReader_SetReaderName(&readers[i], CKYReaderNameList_GetValue(readerNames,i)); if (ret != CKYSUCCESS) { break; } } if (ret != CKYSUCCESS) { for (j=0; j < i; j++) { CKYReader_FreeData(&readers[j]); } free(readers); return NULL; } if (returnReaderCount) { *returnReaderCount=readerCount; } return readers; } /* * add more reader states to an existing reader state array. * The existing reader will have a new pointer, which will be updated only * after the new one is complete, and before the old one is freed. The 'add' * array is not modified or freed. */ CKYStatus CKYReader_AppendArray(SCARD_READERSTATE **array, unsigned long arraySize, const char **readerNames, unsigned long numReaderNames) { unsigned long i,j; SCARD_READERSTATE *readers; SCARD_READERSTATE *old; CKYStatus ret = CKYSUCCESS; readers = NEW(SCARD_READERSTATE, arraySize+numReaderNames); if (readers == NULL) { return CKYNOMEM; } /* copy the original readers, inheriting all the pointer memory */ memcpy(readers, *array, arraySize*sizeof(SCARD_READERSTATE)); /* initialize and add the new reader states. */ for (i=0; i < numReaderNames; i++) { CKYReader_Init(&readers[i+arraySize]); ret = CKYReader_SetReaderName(&readers[i+arraySize],readerNames[i]); if (ret != CKYSUCCESS) { break; } } /* we failed, only free the new reader states, ownership of the new * ones will revert back to the original */ if (ret != CKYSUCCESS) { for (j=0; j < i; j++) { CKYReader_FreeData(&readers[j+arraySize]); } free(readers); return ret; } /* Now we swap the readers states */ old = *array; *array = readers; /* it's now safe to free the old one */ free(old); return CKYSUCCESS; } void CKYReader_DestroyArray(SCARD_READERSTATE *reader, unsigned long readerCount) { unsigned long i; for (i=0; i < readerCount; i++) { CKYReader_FreeData(&reader[i]); } free(reader); } /* * CKYCardContexts are wrapped access to the SCard Context, which is * part of the openSC/ Microsoft PCSC interface. Applications will * typically open one context to get access to the SCard Subsystem. * * To protect ourselves from systems without the SCard library installed, * the SCard calls are looked up from the library and called through * a function pointer. */ struct _CKYCardContext { SCARDCONTEXT context; SCard *scard; unsigned long scope; unsigned long lastError; }; static CKYStatus ckyCardContext_init(CKYCardContext *ctx) { static SCard *scard; ctx->lastError = 0; ctx->context = 0; if (!scard) { scard = ckySCard_Init(); if (!scard) { return CKYNOSCARD; } } ctx->scard = scard; return CKYSUCCESS; } static CKYStatus ckyCardContext_release(CKYCardContext *ctx) { unsigned long rv = ctx->scard->SCardReleaseContext(ctx->context); ctx->context = 0; if (rv != SCARD_S_SUCCESS) { ctx->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } static CKYStatus ckyCardContext_establish(CKYCardContext *ctx, unsigned long scope) { unsigned long rv; if (ctx->context) { ckyCardContext_release(ctx); } rv = ctx->scard->SCardEstablishContext(scope, NULL, NULL, &ctx->context); if (rv != SCARD_S_SUCCESS) { ctx->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } CKYCardContext * CKYCardContext_Create(unsigned long scope) { CKYCardContext *ctx; CKYStatus ret; ctx = NEW(CKYCardContext, 1); if (ctx == NULL) { return NULL; } ret = ckyCardContext_init(ctx); if (ret != CKYSUCCESS) { CKYCardContext_Destroy(ctx); return NULL; } ctx->scope = scope; ret = ckyCardContext_establish(ctx, scope); #ifdef MAC /* Apple won't establish a connnection if pcscd is not running. Because of * the way securityd controls pcscd, this may not necessarily be an error * condition. Detect this case and continue. We'll establish the connection * later.. */ if (ctx->lastError == SCARD_F_INTERNAL_ERROR) { ctx->context = 0; /* make sure it's not established */ return ctx; } #endif if (ret != CKYSUCCESS) { CKYCardContext_Destroy(ctx); return NULL; } return ctx; } CKYStatus CKYCardContext_Destroy(CKYCardContext *ctx) { CKYStatus ret = CKYSUCCESS; if (ctx == NULL) { return CKYSUCCESS; } if (ctx->context) { ret = ckyCardContext_release(ctx); } free(ctx); return ret; } SCARDCONTEXT CKYCardContext_GetContext(const CKYCardContext *ctx) { return ctx->context; } CKYStatus CKYCardContext_ListReaders(CKYCardContext *ctx, CKYReaderNameList *readerNames) { unsigned long readerLen; unsigned long rv; char * readerStr = NULL; char *cur; char ** readerList; int count,i; /* return NULL in the case nothing is found, or there is an error */ *readerNames = NULL; /* if we aren't established yet, do so now */ if (!ctx->context) { CKYStatus ret = ckyCardContext_establish(ctx, ctx->scope); if (ret != CKYSUCCESS) { #ifdef MAC if (ctx->lastError == SCARD_F_INTERNAL_ERROR) { /* Still can't establish, just treat it as 'zero' readers */ return CKYSUCCESS; } #endif return ret; } } /* get the initial length */ readerLen = 0; rv = ctx->scard->SCardListReaders(ctx->context, NULL /*groups*/, NULL, &readerLen); /* handle the other errors from SCardListReaders */ if (rv == SCARD_E_NO_READERS_AVAILABLE) { /* not really an error: there are no readers */ return CKYSUCCESS; } if( rv != SCARD_S_SUCCESS ) { ctx->lastError = rv; return CKYSCARDERR; } /* if no readers, return OK and a NULL list */ if (readerLen == 0) { return CKYSUCCESS; } /* * Keep trying to read in the buffer, allowing that the required buffer * length may change between calls to SCardListReaders. */ do { if (readerLen < 1 || readerLen > CKY_OUTRAGEOUS_MALLOC_SIZE) { return CKYNOMEM; } readerStr = NEW(char,readerLen); if (readerStr == NULL) { return CKYNOMEM; } rv = ctx->scard->SCardListReaders(ctx->context, NULL /*groups*/, readerStr, &readerLen); /* we've found it, pop out with readerStr allocated */ if (rv == SCARD_S_SUCCESS) { break; } /* Nope, free the reader we allocated */ free(readerStr); readerStr = NULL; } while( rv == SCARD_E_INSUFFICIENT_BUFFER ); /* handle the other errors from SCardListReaders */ if (rv == SCARD_E_NO_READERS_AVAILABLE) { /* not really an error: there are no readers */ ctx->lastError = SCARD_E_NO_READERS_AVAILABLE; return CKYSUCCESS; } if (rv != SCARD_S_SUCCESS) { /* stash the error and fail */ ctx->lastError = rv; return CKYSCARDERR; } /* * Windows returns the list of readers as a series of null terminated * strings, terminated with an additional NULL. For example, if there * are three readers name "Reader 1", "Reader 2", "Reader 3", the returned * readerStr would look like: "Reader 1\0Reader 2\0Reader N\0\0". * * We need to return a list of ReaderNames. This is currently a pointer * to an array of string pointers, terminated by a NULL. * * +--------------+ * | Reader 1 ptr | -> "Reader 1" * +--------------+ * | Reader 2 ptr | -> "Reader 2" * +--------------+ * | Reader N ptr | -> "Reader N" * +--------------+ * | NULL | * +--------------+ * * NOTE: This code explicitly knows the underlying format for * CKYReaderNameLists defined in cky_list.i. If cky_list.i is changes, * this code will need to be changed as well. */ /* find the count of readers */ for (cur = readerStr, count = 0; *cur; cur += strlen(cur)+1, count++ ) /* Empty */ ; readerList = NEW(char *,count+1); if (readerList == NULL) { goto fail; } /* now copy the readers into the array */ for (i=0, cur=readerStr; i < count ; cur+=strlen(cur) +1, i++) { readerList[i] = strdup(cur); if (readerList[i] == NULL) { goto fail; } } readerList[count] = NULL; free(readerStr);; *readerNames = (CKYReaderNameList) readerList; return CKYSUCCESS; fail: if (readerStr) { free(readerStr); } if (readerList) { CKYReaderNameList_Destroy((CKYReaderNameList) readerList); } return CKYNOMEM; } /* * The original C++ API had to very similiar functions that returned * either reader names or connections based on ATR. This is a single * function that can return both. The exported interface calls this * one with one of the lists set to NULL. * * NOTE: this function "knows" the underlying format for lists and * hand builds the related lists. */ CKYStatus ckyCardContext_findReadersByATR(CKYCardContext *ctx, CKYReaderNameList *returnReaders, CKYCardConnectionList *returnConn, const CKYBuffer *targetATR) { CKYReaderNameList readerNames; CKYBuffer ATR; CKYCardConnection **connList = NULL; CKYCardConnection **connPtr = NULL; char **readerList = NULL; char **readerPtr = NULL; int readerCount, i; CKYStatus ret; CKYBuffer_InitEmpty(&ATR); /* if we aren't established yet, do so now */ if (!ctx->context) { ret = ckyCardContext_establish(ctx, ctx->scope); if (ret != CKYSUCCESS) { return ret; } } /* initialize our returned values to empty */ if (returnReaders) { *returnReaders = NULL; } if (returnConn) { *returnConn = NULL; } ret = CKYCardContext_ListReaders(ctx, &readerNames); if (ret != CKYSUCCESS) { return ret; } readerCount = CKYReaderNameList_GetCount(readerNames); /* none found, return success */ if (readerCount == 0) { CKYReaderNameList_Destroy(readerNames); return CKYSUCCESS; } /* now initialize our name and connection lists */ if (returnConn) { connList = NEW(CKYCardConnection *, readerCount); connPtr = connList; if (connList == NULL) { goto fail; } } if (returnReaders) { readerList = NEW(char *, readerCount); readerPtr = readerList; if (readerList == NULL) { goto fail; } } ret = CKYBuffer_Resize(&ATR, CKY_MAX_ATR_LEN); if (ret != CKYSUCCESS) { goto fail; } /* now walk the reader list trying to get connections */ for (i=0; i < readerCount ; i++) { CKYCardConnection * conn = CKYCardConnection_Create(ctx); unsigned long state; const char *thisReader = CKYReaderNameList_GetValue(readerNames, i); if (!conn) { goto loop; } ret = CKYCardConnection_Connect(conn, thisReader); if (ret != CKYSUCCESS) { goto loop; } ret = CKYCardConnection_GetStatus(conn, &state, &ATR); if (ret != CKYSUCCESS) { goto loop; } if (CKYBuffer_IsEqual(targetATR, &ATR)) { if (connPtr) { *connPtr++ = conn; /* adopt */ conn = NULL; } if (readerPtr) { *readerPtr++ = strdup(thisReader); } } loop: /* must happen each time through the loop */ if (conn) { CKYCardConnection_Destroy(conn); } } /* done with the reader names now */ CKYReaderNameList_Destroy(readerNames); /* and the ATR buffer */ CKYBuffer_FreeData(&ATR); /* terminate out lists and return them */ if (readerPtr) { *readerPtr = NULL; *returnReaders = (CKYReaderNameList) readerList; } if (connPtr) { *connPtr = NULL; *returnConn = (CKYCardConnectionList) connList; } return CKYSUCCESS; fail: if (readerNames) { CKYReaderNameList_Destroy(readerNames); } if (connList) { free(connList); } if (readerList) { free(readerList); } CKYBuffer_FreeData(&ATR); return CKYNOMEM; } CKYStatus CKYCardContext_FindCardsByATR(CKYCardContext *ctx, CKYCardConnectionList *cardList, const CKYBuffer *targetATR) { return ckyCardContext_findReadersByATR(ctx, NULL, cardList, targetATR); } CKYStatus CKYCardContext_FindReadersByATR(CKYCardContext *ctx, CKYReaderNameList *readerNames, const CKYBuffer *targetATR) { return ckyCardContext_findReadersByATR(ctx, readerNames, NULL, targetATR); } CKYCardConnection * CKYCardContext_CreateConnection(CKYCardContext *ctx) { return CKYCardConnection_Create(ctx); } CKYStatus CKYCardContext_WaitForStatusChange(CKYCardContext *ctx, SCARD_READERSTATE *readers, unsigned long readerCount, unsigned long timeout) { unsigned long rv; /* if we aren't established yet, do so now */ if (!ctx->context) { CKYStatus ret = ckyCardContext_establish(ctx, ctx->scope); if (ret != CKYSUCCESS) { return ret; } } rv = ctx->scard->SCardGetStatusChange(ctx->context, timeout, readers, readerCount); if (rv != SCARD_S_SUCCESS) { ctx->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } CKYStatus CKYCardContext_Cancel(CKYCardContext *ctx) { unsigned long rv; /* if we aren't established yet, we can't be in change status then */ if (!ctx->context) { return CKYSUCCESS; } rv = ctx->scard->SCardCancel(ctx->context); if (rv != SCARD_S_SUCCESS) { ctx->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } unsigned long CKYCardContext_GetLastError(const CKYCardContext *ctx) { return ctx->lastError; } /* * Connections represent the connection to the actual smart cards. * Applications usually has one of these for each card inserted in * the system. Connections are where we can get information about * each card, as well as transmit commands (APDU's) to the card. */ /* In the originaly C++ library, lastError was set to the last return * code from any SCARD call. In this C version of the library, lastError * is the last non-successful SCARD call. lastError will be set * if the function returns CKYSCARDERR. */ struct _CKYCardConnection { const CKYCardContext *ctx; SCard *scard; /* cache a copy from the context */ SCARDHANDLE cardHandle; unsigned long lastError; CKYBool inTransaction; }; static void ckyCardConnection_init(CKYCardConnection *conn, const CKYCardContext *ctx) { conn->ctx = ctx; conn->scard = ctx->scard; conn->cardHandle = 0; conn->lastError = 0; conn->inTransaction = 0; } CKYCardConnection * CKYCardConnection_Create(const CKYCardContext *ctx) { CKYCardConnection *conn; /* don't even try if we don't have a Card Context */ if (ctx == NULL) { return NULL; } conn = NEW(CKYCardConnection, 1); if (conn == NULL) { return NULL; } ckyCardConnection_init(conn, ctx); return conn; } CKYStatus CKYCardConnection_Destroy(CKYCardConnection *conn) { if (conn == NULL) { return CKYSUCCESS; } if (conn->inTransaction) { CKYCardConnection_EndTransaction(conn); } CKYCardConnection_Disconnect(conn); free(conn); return CKYSUCCESS; } CKYStatus CKYCardConnection_Connect(CKYCardConnection *conn, const char *readerName) { CKYStatus ret; unsigned long rv; unsigned long protocol; ret = CKYCardConnection_Disconnect(conn); if (ret != CKYSUCCESS) { return ret; } rv = conn->scard->SCardConnect( conn->ctx->context, readerName, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &conn->cardHandle, &protocol); if (rv != SCARD_S_SUCCESS) { conn->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } CKYStatus CKYCardConnection_Disconnect(CKYCardConnection *conn) { unsigned long rv; if (conn->cardHandle == 0) { return CKYSUCCESS; } rv = conn->scard->SCardDisconnect( conn->cardHandle, SCARD_LEAVE_CARD); conn->cardHandle = 0; if (rv != SCARD_S_SUCCESS) { conn->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } CKYBool CKYCardConnection_IsConnected(const CKYCardConnection *conn) { return (conn->cardHandle != 0); } CKYStatus ckyCardConnection_reconnectRaw(CKYCardConnection *conn, unsigned long init) { unsigned long rv; unsigned long protocol; rv = conn->scard->SCardReconnect(conn->cardHandle, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, init, &protocol); if (rv != SCARD_S_SUCCESS) { conn->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } CKYStatus CKYCardConnection_Reconnect(CKYCardConnection *conn) { return ckyCardConnection_reconnectRaw(conn, SCARD_LEAVE_CARD); } CKYStatus CKYCardConnection_Reset(CKYCardConnection *conn) { return ckyCardConnection_reconnectRaw(conn, SCARD_RESET_CARD); } CKYStatus CKYCardConnection_BeginTransaction(CKYCardConnection *conn) { unsigned long rv; rv = conn->scard->SCardBeginTransaction(conn->cardHandle); if (rv != SCARD_S_SUCCESS) { conn->lastError = rv; return CKYSCARDERR; } conn->inTransaction = 1; return CKYSUCCESS; } CKYStatus CKYCardConnection_EndTransaction(CKYCardConnection *conn) { unsigned long rv; if (!conn->inTransaction) { return CKYSUCCESS; /* C++ library returns success in this case, but * it may be better to return an error ? */ } rv = conn->scard->SCardEndTransaction(conn->cardHandle, SCARD_LEAVE_CARD); conn->inTransaction = 0; if (rv != SCARD_S_SUCCESS) { conn->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } CKYStatus CKYCardConnection_TransmitAPDU(CKYCardConnection *conn, CKYAPDU *apdu, CKYBuffer *response) { CKYStatus ret; unsigned long rv; ret = CKYBuffer_Resize(response, CKYAPDU_MAX_LEN); if (ret != CKYSUCCESS) { return ret; } rv = conn->scard->SCardTransmit(conn->cardHandle, conn->scard->SCARD_PCI_T0_, CKYBuffer_Data(&apdu->apduBuf), CKYBuffer_Size(&apdu->apduBuf), NULL, response->data, &response->len); if (rv != SCARD_S_SUCCESS) { conn->lastError =rv; return CKYSCARDERR; } return CKYSUCCESS; } CKYStatus CKYCardConnection_ExchangeAPDU(CKYCardConnection *conn, CKYAPDU *apdu, CKYBuffer *response) { CKYStatus ret; ret = CKYCardConnection_TransmitAPDU(conn, apdu, response); if (ret != CKYSUCCESS) { return ret; } if (CKYBuffer_Size(response) == 2 && CKYBuffer_GetChar(response,0) == 0x61) { /* get the response */ CKYAPDU getResponseAPDU; CKYAPDU_Init(&getResponseAPDU); CKYAPDU_SetCLA(&getResponseAPDU, 0x00); CKYAPDU_SetINS(&getResponseAPDU, 0xc0); CKYAPDU_SetP1(&getResponseAPDU, 0x00); CKYAPDU_SetP2(&getResponseAPDU, 0x00); CKYAPDU_SetReceiveLen(&getResponseAPDU, CKYBuffer_GetChar(response,1)); ret = CKYCardConnection_TransmitAPDU(conn, &getResponseAPDU, response); CKYAPDU_FreeData(&getResponseAPDU); } return ret; } CKYStatus CKYCardConnection_GetStatus(CKYCardConnection *conn, unsigned long *state, CKYBuffer *ATR) { unsigned long readerLen = 0; unsigned long protocol; unsigned long rv; CKYSize atrLen; char *readerStr; CKYStatus ret; /* * Get initial length. We have to do all this because the Muscle * implementation of PCSC requires us to supply a non-NULL argument * for readerName before it will tell us the ATR, which is all we really * care about. */ rv = conn->scard->SCardStatus(conn->cardHandle, NULL /*readerName*/, &readerLen, state, &protocol, NULL, &atrLen); if ( rv != SCARD_S_SUCCESS ) { conn->lastError = rv; return CKYSCARDERR; } do { if (readerLen < 1 || readerLen > CKY_OUTRAGEOUS_MALLOC_SIZE) { return CKYNOMEM; } /* Mac & Linux return '0' or ATR length, just use the max value */ if (atrLen == 0) { atrLen = CKY_MAX_ATR_LEN; } if (atrLen < 1 || atrLen > CKY_OUTRAGEOUS_MALLOC_SIZE) { return CKYNOMEM; } ret = CKYBuffer_Resize(ATR, atrLen); if (ret != CKYSUCCESS) { return ret; } readerStr = NEW(char, readerLen); if (readerStr == NULL) { return CKYNOMEM; } rv = conn->scard->SCardStatus(conn->cardHandle, readerStr, &readerLen, state, &protocol, ATR->data, &atrLen); ATR->len = atrLen; free(readerStr); } while (rv == SCARD_E_INSUFFICIENT_BUFFER); if (rv != SCARD_S_SUCCESS) { conn->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; } CKYStatus CKYCardConnection_GetAttribute(CKYCardConnection *conn, unsigned long attrID, CKYBuffer *attrBuf) { #ifdef WIN32 unsigned long len = 0; unsigned long rv; /* * Get initial length. We have to do all this because the Muscle * implementation of PCSC requires us to supply a non-NULL argument * for readerName before it will tell us the ATR, which is all we really * care about. */ rv = conn->scard->SCardGetAttrib(conn->cardHandle, attrID, NULL, &len); if ( rv != SCARD_S_SUCCESS ) { conn->lastError = rv; return CKYSCARDERR; } CKYBuffer_Resize(attrBuf, len); rv = conn->scard->SCardGetAttrib(conn->cardHandle, attrID, attrBuf->data, &attrBuf->len); if( rv != SCARD_S_SUCCESS ) { conn->lastError = rv; return CKYSCARDERR; } return CKYSUCCESS; #else conn->lastError = -1; return CKYSCARDERR; #endif } const CKYCardContext * CKYCardConnection_GetContext(const CKYCardConnection *conn) { return conn->ctx; } unsigned long CKYCardConnection_GetLastError(const CKYCardConnection *conn) { return conn->lastError; } --- NEW FILE cky_card.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #ifndef CKY_CARD_H #define CKY_CARD_H 1 #include #include "cky_base.h" #include "cky_list.h" /* * hide the structure of CardConnections and CardContexts */ typedef struct _CKYCardContext CKYCardContext; typedef struct _CKYCardConnection CKYCardConnection; /* * define CKYReaderNameList, CKYReaderNameIterator, CKYCardConnectionList, and * CKYCardConnectionIterator, and their associated functions. * See cky_list.h for these functions . */ CKYLIST_DECLARE(CKYReaderName, char *) CKYLIST_DECLARE(CKYCardConnection, CKYCardConnection *) CKY_BEGIN_PROTOS void CKYReader_Init(SCARD_READERSTATE_A *reader); void CKYReader_FreeData(SCARD_READERSTATE_A *reader); /* * "Accessors": for SCARD_READERSTATE_A structure as a class. * These functions take an SCARD_READERSTATE_A which can also be referenced * directly. */ CKYStatus CKYReader_SetReaderName(SCARD_READERSTATE_A *reader, const char *name); const char *CKYReader_GetReaderName(const SCARD_READERSTATE_A *reader); CKYStatus CKYReader_SetKnownState(SCARD_READERSTATE_A *reader, unsigned long state); unsigned long CKYReader_GetKnownState(const SCARD_READERSTATE_A *reader); unsigned long CKYReader_GetEventState(const SCARD_READERSTATE_A *reader); CKYStatus CKYReader_GetATR(const SCARD_READERSTATE_A *reader, CKYBuffer *buf); /* create an array of READERSTATEs from a LIST of Readers */ SCARD_READERSTATE_A *CKYReader_CreateArray(const CKYReaderNameList readerNames, unsigned long *readerCount); /* frees the reader, then the full array */ void CKYReader_DestroyArray(SCARD_READERSTATE *reader, unsigned long count); /* add more elements to a ReaderState array*/ CKYStatus CKYReader_AppendArray(SCARD_READERSTATE **array, unsigned long arraySize, const char **readerNames, unsigned long numReaderNames); /* * card contexts wrap Microsoft's SCARDCONTEXT. */ /* create a new one. SCOPE must be SCOPE_USER */ CKYCardContext *CKYCardContext_Create(unsigned long scope); /* destroy an existing one */ CKYStatus CKYCardContext_Destroy(CKYCardContext *context); /* get the Windows handle associated with this context */ SCARDCONTEXT CKYCardContext_GetContext(const CKYCardContext *context); /* Get a list of the installed readers */ CKYStatus CKYCardContext_ListReaders(CKYCardContext *context, CKYReaderNameList *readerNames); /* get a list of card connections for cards matching our target ATR */ CKYStatus CKYCardContext_FindCardsByATR(CKYCardContext *context, CKYCardConnectionList *cardList, const CKYBuffer *targetATR); /* get a list of readers with attached cards that match our target ATR */ CKYStatus CKYCardContext_FindReadersByATR(CKYCardContext *context, CKYReaderNameList *readerNames, const CKYBuffer *targetATR); /* return if any of the readers in our array has changed in status */ CKYStatus CKYCardContext_WaitForStatusChange(CKYCardContext *context, SCARD_READERSTATE_A *readers, unsigned long readerCount, unsigned long timeout); /* cancel any current operation (such as wait for status change) on this * context */ CKYStatus CKYCardContext_Cancel(CKYCardContext *context); /* get the last underlying Windows SCARD error */ unsigned long CKYCardContext_GetLastError(const CKYCardContext *context); /* * manage the actual connection to a card. */ /* create a connection. A connection is not associated with a reader * until CKYCardConnection_Connect() is called. */ CKYCardConnection *CKYCardConnection_Create(const CKYCardContext *context); CKYStatus CKYCardConnection_Destroy(CKYCardConnection *connection); CKYStatus CKYCardConnection_BeginTransaction(CKYCardConnection *connection); CKYStatus CKYCardConnection_EndTransaction(CKYCardConnection *connection); CKYStatus CKYCardConnection_TransmitAPDU(CKYCardConnection *connection, CKYAPDU *apdu, CKYBuffer *response); CKYStatus CKYCardConnection_ExchangeAPDU(CKYCardConnection *connection, CKYAPDU *apdu, CKYBuffer *response); CKYStatus CKYCardConnection_Connect(CKYCardConnection *connection, const char *readerName); CKYStatus CKYCardConnection_Disconnect(CKYCardConnection *connection); CKYBool CKYCardConnection_IsConnected(const CKYCardConnection *connection); CKYStatus CKYCardConnection_Reconnect(CKYCardConnection *connection); CKYStatus CKYCardConnection_GetStatus(CKYCardConnection *connection, unsigned long *state, CKYBuffer *ATR); CKYStatus CKYCardConnection_GetAttribute(CKYCardConnection *connection, unsigned long attrID, CKYBuffer *attrBuf); CKYStatus CKYCardConnection_Reset(CKYCardConnection *connection); const CKYCardContext *CKYCardConnection_GetContext(const CKYCardConnection *cxt); unsigned long CKYCardConnection_GetLastError(const CKYCardConnection *context); CKY_END_PROTOS #endif /* CKY_CARD_H */ --- NEW FILE cky_factory.c --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #include "string.h" #include "cky_base.h" #include "cky_factory.h" /* * special commands can be issued at any time */ CKYStatus CKYAPDUFactory_SelectFile(CKYAPDU *apdu, const CKYBuffer *AID) { CKYAPDU_SetCLA(apdu, CKY_CLASS_ISO7816); CKYAPDU_SetINS(apdu, CKY_INS_SELECT_FILE); CKYAPDU_SetP1(apdu, 0x04); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetSendDataBuffer(apdu, AID); } CKYStatus CKYAPDUFactory_SelectCardManager(CKYAPDU *apdu) { CKYByte c = 0; CKYAPDU_SetCLA(apdu, CKY_CLASS_ISO7816); CKYAPDU_SetINS(apdu, CKY_INS_SELECT_FILE); CKYAPDU_SetP1(apdu, 0x04); CKYAPDU_SetP2(apdu, 0x00); /* I can't find the documentation for this, but if you pass an empty * AID to SelectFile on the Cyberflex Access 32k, it selects the * CardManager applet. Good thing, because I couldn't find any other * way to accomplish this without knowing the AID of the CardManager. */ return CKYAPDU_SetSendData(apdu,&c,0); } /* * card manager commands must be issued with the card manager selected. */ CKYStatus CKYAPDUFactory_GetCPLCData(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_GLOBAL_PLATFORM); CKYAPDU_SetINS(apdu, CKY_INS_GET_DATA); CKYAPDU_SetP1(apdu, 0x9f); CKYAPDU_SetP2(apdu, 0x7f); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_GET_CPLCDATA); } /* * applet commands must be issued with the appplet selected. */ CKYStatus CKYAPDUFactory_ListKeys(CKYAPDU *apdu, CKYByte sequence) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_LIST_KEYS); CKYAPDU_SetP1(apdu, sequence); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_LIST_KEYS); } CKYStatus CKYAPDUFactory_ComputeCryptInit(CKYAPDU *apdu, CKYByte keyNumber, CKYByte mode, CKYByte direction, CKYByte location) { CKYByte data[5]; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_COMPUTE_CRYPT); CKYAPDU_SetP1(apdu, keyNumber); CKYAPDU_SetP2(apdu, CKY_CIPHER_INIT); data[0] = mode; data[1] = direction; data[2] = location; data[3] = 0; /* future provide for init data */ data[4] = 0; return CKYAPDU_SetSendData(apdu, data, sizeof(data)); } CKYStatus CKYAPDUFactory_ComputeCryptProcess(CKYAPDU *apdu, CKYByte keyNumber, CKYByte location, const CKYBuffer *data) { CKYStatus ret; CKYBuffer buf; CKYBuffer_InitEmpty(&buf); CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_COMPUTE_CRYPT); CKYAPDU_SetP1(apdu, keyNumber); CKYAPDU_SetP2(apdu, CKY_CIPHER_PROCESS); if (data) { ret = CKYBuffer_Reserve(&buf, 3); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendChar(&buf, location); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendShort(&buf, (unsigned short)CKYBuffer_Size(data)); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_SetSendDataBuffer(apdu, &buf); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_AppendSendDataBuffer(apdu, data); } else { ret = CKYAPDU_SetSendData(apdu, &location, 1); } fail: CKYBuffer_FreeData(&buf); return ret; } CKYStatus CKYAPDUFactory_ComputeCryptFinal(CKYAPDU *apdu, CKYByte keyNumber, CKYByte location, const CKYBuffer *data, const CKYBuffer *sig) { CKYStatus ret; CKYBuffer buf; CKYBuffer_InitEmpty(&buf); CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_COMPUTE_CRYPT); CKYAPDU_SetP1(apdu, keyNumber); CKYAPDU_SetP2(apdu, CKY_CIPHER_FINAL); if (data) { ret = CKYBuffer_Reserve(&buf, 3); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendChar(&buf, location); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendShort(&buf, (unsigned short)CKYBuffer_Size(data)); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_SetSendDataBuffer(apdu, &buf); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_AppendSendDataBuffer(apdu, data); if (ret != CKYSUCCESS) { goto fail; } if (sig) { CKYBuffer_Resize(&buf,2); CKYBuffer_SetShort(&buf, 0, (unsigned short)CKYBuffer_Size(sig)); ret = CKYAPDU_AppendSendDataBuffer(apdu, &buf); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_AppendSendDataBuffer(apdu, sig); } } else { ret = CKYAPDU_SetSendData(apdu, &location, 1); } fail: CKYBuffer_FreeData(&buf); return ret; } CKYStatus CKYAPDUFactory_ComputeCryptOneStep(CKYAPDU *apdu, CKYByte keyNumber, CKYByte mode, CKYByte direction, CKYByte location, const CKYBuffer *idata, const CKYBuffer *sig) { CKYStatus ret = CKYINVALIDARGS; CKYSize len; CKYBuffer buf; if (!idata || !(len = CKYBuffer_Size(idata)) || location != CKY_DL_APDU) return ret; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_COMPUTE_CRYPT); CKYAPDU_SetP1(apdu, keyNumber); CKYAPDU_SetP2(apdu, CKY_CIPHER_ONE_STEP); CKYBuffer_InitEmpty(&buf); ret = CKYBuffer_Reserve(&buf, 5); if (ret == CKYSUCCESS) ret = CKYBuffer_AppendChar(&buf, mode); if (ret == CKYSUCCESS) ret = CKYBuffer_AppendChar(&buf, direction); if (ret == CKYSUCCESS) ret = CKYBuffer_AppendChar(&buf, location); if (ret == CKYSUCCESS) ret = CKYBuffer_AppendShort(&buf, (unsigned short)len); if (ret == CKYSUCCESS) ret = CKYAPDU_SetSendDataBuffer(apdu, &buf); if (ret == CKYSUCCESS) ret = CKYAPDU_AppendSendDataBuffer(apdu, idata); if (ret == CKYSUCCESS && sig && 0 < (len = CKYBuffer_Size(sig))) { CKYBuffer_Resize(&buf,2); CKYBuffer_SetShort(&buf, 0, (unsigned short)len); ret = CKYAPDU_AppendSendDataBuffer(apdu, &buf); if (ret == CKYSUCCESS) ret = CKYAPDU_AppendSendDataBuffer(apdu, sig); } CKYBuffer_FreeData(&buf); return ret; } CKYStatus CKYAPDUFactory_CreatePIN(CKYAPDU *apdu, CKYByte pinNumber, CKYByte maxAttempts, const char *pinValue) { CKYSize len; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_CREATE_PIN); CKYAPDU_SetP1(apdu, pinNumber); CKYAPDU_SetP2(apdu, maxAttempts); len = strlen(pinValue); return CKYAPDU_SetSendData(apdu, (unsigned char *)pinValue, len); } CKYStatus CKYAPDUFactory_VerifyPIN(CKYAPDU *apdu, CKYByte pinNumber, const char *pinValue) { CKYSize len; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_VERIFY_PIN); CKYAPDU_SetP1(apdu, pinNumber); CKYAPDU_SetP2(apdu, 0x00); len = strlen(pinValue); return CKYAPDU_SetSendData(apdu, (unsigned char *)pinValue, len); } CKYStatus CKYAPDUFactory_ChangePIN(CKYAPDU *apdu, CKYByte pinNumber, const char *oldPin, const char *newPin) { CKYSize oldLen, newLen; CKYBuffer buf; CKYStatus ret; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_CHANGE_PIN); CKYAPDU_SetP1(apdu, pinNumber); CKYAPDU_SetP2(apdu, 0x00); CKYBuffer_InitEmpty(&buf); oldLen = strlen(oldPin); newLen = strlen(newPin); /* optimization, do a single malloc for the whole block */ ret = CKYBuffer_Reserve(&buf, oldLen+newLen+4); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendShort(&buf, (unsigned short)oldLen); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendData(&buf, (unsigned char *)oldPin, oldLen); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendShort(&buf, (unsigned short)newLen); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendData(&buf, (unsigned char *)newPin, newLen); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_SetSendDataBuffer(apdu, &buf); fail: CKYBuffer_FreeData(&buf); return ret; } CKYStatus CKYAPDUFactory_ListPINs(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_LIST_PINS); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_LIST_PINS); } CKYStatus CKYAPDUFactory_Logout(CKYAPDU *apdu, CKYByte pinNumber) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_LOGOUT); CKYAPDU_SetP1(apdu, pinNumber); CKYAPDU_SetP2(apdu, 0x00); return CKYSUCCESS; } /* Future add WriteObject */ CKYStatus CKYAPDUFactory_CreateObject(CKYAPDU *apdu, unsigned long objectID, CKYSize size, unsigned short readACL, unsigned short writeACL, unsigned short deleteACL) { CKYBuffer buf; CKYStatus ret; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_CREATE_OBJ); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); CKYBuffer_InitEmpty(&buf); /* optimization, do a single malloc for the whole block */ ret = CKYBuffer_Reserve(&buf,0x0e); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendLong(&buf,objectID); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendLong(&buf,size); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendShort(&buf,readACL); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendShort(&buf,writeACL); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendShort(&buf,deleteACL); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_SetSendDataBuffer(apdu, &buf); fail: CKYBuffer_FreeData(&buf); return ret; } CKYStatus CKYAPDUFactory_DeleteObject(CKYAPDU *apdu, unsigned long objectID, CKYByte zero) { CKYBuffer buf; CKYStatus ret; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_DELETE_OBJ); CKYAPDU_SetP1(apdu, zero); CKYAPDU_SetP2(apdu, 0x00); CKYBuffer_InitEmpty(&buf); ret = CKYBuffer_AppendLong(&buf,objectID); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_SetSendDataBuffer(apdu, &buf); fail: CKYBuffer_FreeData(&buf); return ret; } CKYStatus CKYAPDUFactory_ReadObject(CKYAPDU *apdu, unsigned long objectID, CKYOffset offset, CKYByte size) { CKYBuffer buf; CKYStatus ret; CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_READ_OBJ); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); CKYBuffer_InitEmpty(&buf); /* optimization, do a single malloc for the whole block */ ret = CKYBuffer_Reserve(&buf,0x09); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendLong(&buf,objectID); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendLong(&buf,offset); if (ret != CKYSUCCESS) { goto fail; } ret = CKYBuffer_AppendChar(&buf, size); if (ret != CKYSUCCESS) { goto fail; } ret = CKYAPDU_SetSendDataBuffer(apdu, &buf); fail: CKYBuffer_FreeData(&buf); return ret; } CKYStatus CKYAPDUFactory_ListObjects(CKYAPDU *apdu, CKYByte sequence) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_LIST_OBJECTS); CKYAPDU_SetP1(apdu, sequence); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_LIST_OBJECTS); } CKYStatus CKYAPDUFactory_GetStatus(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_GET_STATUS); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_GET_STATUS); } CKYStatus CKYAPDUFactory_Noop(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_NOP); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYSUCCESS; } CKYStatus CKYAPDUFactory_GetBuildID(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_GET_BUILDID); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_GET_BUILDID); } CKYStatus CKYAPDUFactory_GetLifeCycle(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_GET_LIFECYCLE); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_GET_LIFE_CYCLE); } CKYStatus CKYAPDUFactory_GetLifeCycleV2(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_GET_LIFECYCLE); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_GET_LIFE_CYCLE_V2); } CKYStatus CKYAPDUFactory_GetRandom(CKYAPDU *apdu, CKYByte len) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_GET_RANDOM); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, len); } CKYStatus CKYAPDUFactory_SeedRandom(CKYAPDU *apdu, const CKYBuffer *data) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_SEED_RANDOM); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetSendDataBuffer(apdu, data); } CKYStatus CKYAPDUFactory_GetIssuerInfo(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_GET_ISSUER_INFO); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_GET_ISSUER_INFO); } CKYStatus CKYAPDUFactory_GetBuiltinACL(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_COOLKEY); CKYAPDU_SetINS(apdu, CKY_INS_GET_BUILTIN_ACL); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CKY_SIZE_GET_BUILTIN_ACL); } CKYStatus CACAPDUFactory_SignDecrypt(CKYAPDU *apdu, const CKYBuffer *data) { CKYAPDU_SetCLA(apdu, CKY_CLASS_ISO7816); CKYAPDU_SetINS(apdu, CAC_INS_SIGN_DECRYPT); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetSendDataBuffer(apdu, data); } CKYStatus CACAPDUFactory_GetCertificate(CKYAPDU *apdu, CKYSize size) { CKYAPDU_SetCLA(apdu, CKY_CLASS_ISO7816); CKYAPDU_SetINS(apdu, CAC_INS_GET_CERTIFICATE); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, size); } CKYStatus CACAPDUFactory_GetProperties(CKYAPDU *apdu) { CKYAPDU_SetCLA(apdu, CKY_CLASS_ISO7816); CKYAPDU_SetINS(apdu, CAC_INS_GET_PROPERTIES); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); return CKYAPDU_SetReceiveLen(apdu, CAC_SIZE_GET_PROPERTIES); } CKYStatus CACAPDUFactory_VerifyPIN(CKYAPDU *apdu, const char *pin) { CKYStatus ret; CKYSize size; CKYAPDU_SetCLA(apdu, CKY_CLASS_ISO7816); CKYAPDU_SetINS(apdu, CAC_INS_VERIFY_PIN); CKYAPDU_SetP1(apdu, 0x00); CKYAPDU_SetP2(apdu, 0x00); /* no pin, send an empty buffer */ if (!pin) { return CKYAPDU_SetReceiveLen(apdu, 0); } /* all CAC pins are 8 bytes exactly. If to long, truncate it */ size = strlen(pin); if (size > 8) { size = 8; } ret = CKYAPDU_SetSendData(apdu, (unsigned char *) pin, size); /* if too short, pad it */ if ((ret == CKYSUCCESS) && (size < 8)) { static const unsigned char pad[]= { 0xff , 0xff, 0xff ,0xff, 0xff, 0xff, 0xff, 0xff }; return CKYAPDU_AppendSendData(apdu, pad, 8-size); } return ret; } --- NEW FILE cky_factory.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #ifndef CKY_FACTORY_H #define CKY_FACTORY_H 1 #include "cky_base.h" /* * Various Class bytes */ #define CKY_CLASS_ISO7816 0x00 #define CKY_CLASS_GLOBAL_PLATFORM 0x80 #define CKY_CLASS_SECURE 0x84 #define CKY_CLASS_COOLKEY 0xb0 /* * Applet Instruction Bytes */ /* Card Manager */ #define CKY_INS_SELECT_FILE 0xa4 #define CKY_INS_GET_DATA 0xca /* deprecated */ #define CKY_INS_SETUP 0x2A #define CKY_INS_GEN_KEYPAIR 0x30 #define CKY_INS_EXPORT_KEY 0x34 #define CKY_INS_UNBLOCK_PIN 0x46 #define CKY_INS_GET_CHALLENGE 0x62 #define CKY_INS_CAC_EXT_AUTH 0x38 #define CKY_INS_LOGOUT_ALL 0x60 /* public */ #define CKY_INS_VERIFY_PIN 0x42 #define CKY_INS_LIST_OBJECTS 0x58 #define CKY_INS_LIST_KEYS 0x3A #define CKY_INS_LIST_PINS 0x48 #define CKY_INS_GET_STATUS 0x3C #define CKY_INS_GET_LIFECYCLE 0xF2 #define CKY_INS_GET_ISSUER_INFO 0xF6 #define CKY_INS_GET_BUILTIN_ACL 0xFA #define CKY_INS_GET_BUILDID 0x70 #define CKY_INS_GET_RANDOM 0x72 #define CKY_INS_SEED_RANDOM 0x73 #define CKY_INS_NOP 0x71 /* nonce validated only */ #define CKY_INS_LOGOUT 0x61 /* nonce validated & Secure Channel */ #define CKY_INS_IMPORT_KEY 0x32 #define CKY_INS_COMPUTE_CRYPT 0x36 #define CKY_INS_CREATE_PIN 0x40 #define CKY_INS_CHANGE_PIN 0x44 #define CKY_INS_CREATE_OBJ 0x5A #define CKY_INS_DELETE_OBJ 0x52 #define CKY_INS_READ_OBJ 0x56 #define CKY_INS_WRITE_OBJ 0x54 /* Secure channel only */ #define CKY_INS_INIT_UPDATE 0x50 #define CKY_INS_SEC_EXT_AUTH 0x82 #define CKY_INS_SEC_SET_LIFECYCLE 0xF0 #define CKY_INS_SEC_SET_PIN 0x04 #define CKY_INS_SEC_READ_IOBUF 0x08 #define CKY_INS_SEC_START_ENROLLMENT 0x0C /* CAC */ #define CAC_INS_GET_CERTIFICATE 0x36 #define CAC_INS_SIGN_DECRYPT 0x42 #define CAC_INS_VERIFY_PIN 0x20 #define CAC_INS_GET_PROPERTIES 0x56 #define CAC_SIZE_GET_PROPERTIES 48 /* * Fixed return sized from various commands */ #define CKY_SIZE_GET_CPLCDATA 45 #define CKY_SIZE_LIST_KEYS 11 #define CKY_SIZE_LIST_PINS 2 #define CKY_SIZE_LIST_OBJECTS 14 #define CKY_SIZE_GET_STATUS 16 #define CKY_SIZE_GET_LIFE_CYCLE 1 #define CKY_SIZE_GET_LIFE_CYCLE_V2 4 #define CKY_SIZE_GET_BUILDID 4 #define CKY_SIZE_GET_ISSUER_INFO 0xe0 #define CKY_SIZE_GET_BUILTIN_ACL 7 /* * Crypt functions */ /* functions */ #define CKY_CIPHER_INIT 1 #define CKY_CIPHER_PROCESS 2 #define CKY_CIPHER_FINAL 3 #define CKY_CIPHER_ONE_STEP 4 /* init and final in one APDU */ /* modes */ #define CKY_RSA_NO_PAD 0x00 #define CKY_RSA_PAD_PKCS1 0x01 #define CKY_DSA_SHA 0x10 #define CKY_DES_CBC_NOPAD 0x20 #define CKY_DES_ECB_NOPAD 0x21 /* operations (Cipher Direction) */ #define CKY_DIR_SIGN 0x01 #define CKY_DIR_VERIFY 0x02 #define CKY_DIR_ENCRYPT 0x03 #define CKY_DIR_DECRYPT 0x04 /* Data Location */ #define CKY_DL_APDU 0x01 #define CKY_DL_OBJECT 0x02 /* Key Types */ #define CKY_KEY_RSA_PUBLIC 0x01 #define CKY_KEY_RSA_PRIVATE 0x02 #define CKY_KEY_RSA_PRIVATE_CRT 0x03 #define CKY_KEY_DSA_PUBLIC 0x04 #define CKY_KEY_DSA_PRIVATE 0x05 #define CKY_KEY_DES 0x06 #define CKY_KEY_3DES 0x07 #define CKY_KEY_3DES3 0x08 /* List Operators */ #define CKY_LIST_RESET 0x00 #define CKY_LIST_NEXT 0x01 /* Max Size for a read block */ #define CKY_MAX_READ_CHUNK_SIZE 255 #define CKY_MAX_WRITE_CHUNK_SIZE 240 /* Life Cycle State */ #define CKY_APPLICATION_LOGICALLY_DELETED 0x00 #define CKY_APPLICATION_INSTALLED 0x03 #define CKY_APPLICATION_SELECTABLE 0x07 #define CKY_APPLICATION_PERSONALIZED 0x0f #define CKY_APPLICATION_BLOCKED 0x7f #define CKY_APPLICATION_LOCKED 0xff #define CKY_CARDM_MANAGER_OP_READER 0x01 #define CKY_CARDM_MANAGER_INITIALIZED 0x03 #define CKY_CARDM_MANAGER_SECURED 0x0f #define CKY_CARDM_MANAGER_LOCKED 0x7f #define CKY_CARDM_MANAGER_TERMINATED 0xff /* * The following factories 'Fill in' APDUs for each of the * functions described below. Nonces are not automatically added. * APDU's are for COOLKEY version 1.0 protocol. Callers should pass * in Already inited apdu's . Callers are responsible for freeing. * the APDU data, even in event of failure. */ CKY_BEGIN_PROTOS /* function based factorys */ CKYStatus CKYAPDUFactory_SelectFile(CKYAPDU *apdu, const CKYBuffer *AID); CKYStatus CKYAPDUFactory_SelectCardManager(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_GetCPLCData(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_ListKeys(CKYAPDU *apdu, CKYByte sequence); CKYStatus CKYAPDUFactory_ComputeCryptInit(CKYAPDU *apdu, CKYByte keyNumber, CKYByte mode, CKYByte direction, CKYByte location); CKYStatus CKYAPDUFactory_ComputeCryptProcess(CKYAPDU *apdu, CKYByte keyNumber, CKYByte location, const CKYBuffer *data); CKYStatus CKYAPDUFactory_ComputeCryptFinal(CKYAPDU *apdu, CKYByte keyNumber, CKYByte location, const CKYBuffer *data, const CKYBuffer *sig); CKYStatus CKYAPDUFactory_ComputeCryptOneStep(CKYAPDU *apdu, CKYByte keyNumber, CKYByte mode, CKYByte direction, CKYByte location, const CKYBuffer *data, const CKYBuffer *sig); CKYStatus CKYAPDUFactory_CreatePIN(CKYAPDU *apdu, CKYByte pinNumber, CKYByte maxAttempts, const char *pinValue); CKYStatus CKYAPDUFactory_VerifyPIN(CKYAPDU *apdu, CKYByte pinNumber, const char *pinValue); CKYStatus CKYAPDUFactory_ChangePIN(CKYAPDU *apdu, CKYByte pinNUmber, const char *oldPin, const char *newPin); CKYStatus CKYAPDUFactory_ListPINs(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_Logout(CKYAPDU *apdu, CKYByte pinNumber); /* Future add WriteObject */ CKYStatus CKYAPDUFactory_CreateObject(CKYAPDU *apdu, unsigned long objectID, CKYSize size, unsigned short readACL, unsigned short writeACL, unsigned short deleteACL); CKYStatus CKYAPDUFactory_DeleteObject(CKYAPDU *apdu, unsigned long objectID, CKYByte zero); CKYStatus CKYAPDUFactory_ReadObject(CKYAPDU *apdu, unsigned long objectID, CKYOffset offset, CKYByte size); CKYStatus CKYAPDUFactory_ListObjects(CKYAPDU *apdu, CKYByte sequence); CKYStatus CKYAPDUFactory_GetStatus(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_Noop(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_GetBuildID(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_GetLifeCycle(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_GetLifeCycleV2(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_GetRandom(CKYAPDU *apdu, CKYByte len); CKYStatus CKYAPDUFactory_SeedRandom(CKYAPDU *apdu, const CKYBuffer *data); CKYStatus CKYAPDUFactory_GetIssuerInfo(CKYAPDU *apdu); CKYStatus CKYAPDUFactory_GetBuiltinACL(CKYAPDU *apdu); CKYStatus CACAPDUFactory_SignDecrypt(CKYAPDU *apdu, const CKYBuffer *data); CKYStatus CACAPDUFactory_VerifyPIN(CKYAPDU *apdu, const char *pin); CKYStatus CACAPDUFactory_GetCertificate(CKYAPDU *apdu, CKYSize size); CKYStatus CACAPDUFactory_GetProperties(CKYAPDU *apdu); CKY_END_PROTOS #endif /* CKY_FACTORY_H */ --- NEW FILE cky_list.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #ifndef CKY_LIST_H #define CKY_LIST_H 1 /* * Macro to declare methods and types for CoolKey Lists. */ #define CKYLIST_DECLARE(name, type) \ typedef void *name##List; \ typedef void *name##Iterator; \ \ CKY_BEGIN_PROTOS \ /* get the number of elements in the name##List */ \ unsigned long name##List_GetCount(name##List list); \ \ /* returns the 'index'th element of the list. \ * This provides one way of walking the list... \ * \ * // acquire name##List list \ * int count; \ * int i; \ * \ * count = name##List_GetCount(list); \ * for (i=0; i < count; i++) { \ * const type value = name##List_GetValue(list, i); \ * \ * // Process value \ * } \ */ \ const type name##List_GetValue(name##List list, unsigned long index); \ \ /* * Destroy a list */ \ void name##List_Destroy(name##List list); \ \ /* \ * The following iterators allows someone to easily walk the list using \ * the following sample code. These functions hide the underlying \ * implementation. \ * \ * // acquire name##List list \ * name##Iterator iter; \ * \ * for (iter = name##List_GetIterator(list); !name##Iterator_End(inter); \ * iter = name##Interator_Next(iter) ) { \ * const type value = name##Interator_GetValue(iter); \ * \ * // Process value \ * } \ * \ */ \ name##Iterator name##List_GetIterator(name##List list); \ CKYBool name##Iterator_End(name##Iterator iter); \ name##Iterator name##Iterator_Next(name##Iterator iter); \ const type name##Iterator_GetValue(name##Iterator iter); \ CKY_END_PROTOS \ /* end of Declarations */ #endif /* CKY_LIST_H */ --- NEW FILE cky_list.i --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #ifndef CKY_LIST_I #define CKY_LIST_I 1 #define CKYLIST_IMPLEMENT(name,type) \ \ /* \ * name##List is implemented as a pointer to a NULL terminated array of \ * type##s. A NULL name##List is valid and means a list with '0' elements \ * The actual type is a void * and the follow functions are designed to \ * hide the underlying structure of name##List. \ */ \ \ /* get the number of elements in the reader List */ \ unsigned long \ name##List_GetCount(name##List list) \ { \ type *current; \ int count; \ \ if (list == NULL) { \ return 0; \ } \ \ for (count=0, current = (type *)list; *current; current++, count++) { \ /* EMPTY */ ; \ } \ \ return count; \ } \ \ \ /* returns the 'index'th element of the list. \ * index is not checked for overruns in this implementation. \ * \ * This provides one way of walking the list... \ * \ * // acquire name##List list \ * int count; \ * int i; \ * \ * count = name##List_GetCount(list); \ * for (i=0; i < count; i++) { \ * const type value = name##List_GetValue(list, i); \ * \ * // Process value \ * } \ */ \ const type \ name##List_GetValue(name##List list, unsigned long index) \ { \ type *array = (type *)list; \ \ /* should probably be an assert */ \ if (list == NULL) { \ return NULL; \ } \ return array[index]; \ } \ \ /* Destroy a list */ \ void \ name##List_Destroy(name##List list) \ { \ type *cur; \ if (list == NULL) { \ return ; \ } \ \ for (cur =(type *)list; *cur; cur++) { \ name##_Destroy(*cur); \ } \ free(list); \ } \ \ /* \ * The following iterators allows someone to easily walk the list using \ * the following sample code. These functions hide the underlying \ * implementation. \ * \ * // acquire name##List list \ * name##Iterator iter; \ * \ * for (iter = name##List_GetIterator(list); !name##Iterator_End(inter); \ * iter = name##Iterator_Next(iter) ) { \ * const type value = name##Iterator_GetValue(iter); \ * // process value \ * } \ * \ */ \ name##Iterator \ name##List_GetIterator(name##List list) \ { \ return (name##Iterator) list; \ } \ \ CKYBool \ name##Iterator_End(name##Iterator iter) \ { \ if (iter == NULL) { \ return 1; \ } \ return *(type *)iter == NULL; \ } \ \ name##Iterator \ name##Iterator_Next(name##Iterator iter) \ { \ if (iter == NULL) { \ return NULL; \ } \ return (name##Iterator) (((type *)iter)+1); \ } \ \ const type \ name##Iterator_GetValue(name##Iterator iter) \ { \ /* assert(iter != NULL); */ \ return *(type *)iter; \ } \ \ /* \ * add functions to create lists, & add elements to lists \ */ \ #endif /* CKY_LIST_I */ --- NEW FILE config.mk --- # ***** BEGIN COPYRIGHT BLOCK ***** # Copyright (C) 2005 Red Hat, Inc. # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation version # 2.1 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ***** END COPYRIGHT BLOCK ***** # # Override TARGETS variable so that only static libraries # are specifed as dependencies within rules.mk. # TARGETS = $(LIBRARY) SHARED_LIBRARY = IMPORT_LIBRARY = PROGRAM = ifneq ($(OS_ARCH),WINNT) EXPORTS += msc_winscard.h pcsclite.h wintypes.h endif --- NEW FILE dynlink.c --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #include "../config.h" #ifdef WIN32 #include "dynlink_win.c" #else #ifdef MAC #include "dynlink_mac.c" #else #ifdef HAVE_DLFCN_H #include "dynlink_unix.c" #else #error "Platform not supported... add dynlink_PLAT.c and update dynlink.c" #endif #endif #endif --- NEW FILE dynlink.h --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ /* * the following header file is private to the CoolKey library. * This is because CoolKey library is supposed to operate in the PKCS #11 * module which needs to be independent of runtimes like NSPR. Longer term * there should be a generic version of this which uses the application * runtime, and pkcs #11 supplies it's only copy of these functions. */ #ifndef CKY_SHLIB_H #define CKY_SHLIB_H 1 #undef QUOTE #undef QUOTE_MACRO #define QUOTE(arg) #arg #define QUOTE_MACRO(arg) QUOTE(arg) /* Hmmm maybe this should be hidden in getAddress? */ #ifdef MAC #define DLL_SYM_PREFIX "_" #else #define DLL_SYM_PREFIX #endif #define MAKE_DLL_SYMBOL(name) DLL_SYM_PREFIX QUOTE(name) typedef void *ckyShLibrary; ckyShLibrary ckyShLibrary_open(const char *libname); CKYStatus ckyShLibrary_close(ckyShLibrary libHandle); CKYStatus ckyShLibrary_getAddress(ckyShLibrary libHandle, void **func, const char *funcName); #ifdef MAC void ckyShLibrary_setParent(char *name); #endif #endif --- NEW FILE dynlink_mac.c --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ***** END COPYRIGHT BLOCK *****/ #include #include #include "cky_base.h" #include "dynlink.h" #include "string.h" #include "stdlib.h" #define EXEPATH "@executable_path/" #define SYSPATH "/System/Library/Frameworks/" static char *ckyShLibrary_parent = NULL; /* allow the parent library to set our name */ void ckyShLibrary_setParent(char *p) { ckyShLibrary_parent = p; } #ifdef nodef /* get the parent librarie's path */ char * ckyShLibrary_getParentPath() { char *result; char *image_name; int i, count = _dyld_image_count(); if (ckyShLibrary_parent == NULL) { return NULL; } for (i = 0; i < count; i++) { image_name = _dyld_get_image_name(i); if (strstr(image_name, ckyShLibrary_parent) != NULL) { result = malloc(strlen(image_name)+1); if (result != NULL) { char *truncate; strcpy(result, image_name); truncate = strrchr(result,'/'); if (truncate) { *(truncate+1) = 0; } } return result; } } return NULL; } #endif ckyShLibrary ckyShLibrary_open(const char *libname) { const struct mach_header *library; /*char *parentPath = ckyShLibrary_getParentPath(); */ char *libPath = NULL; int len = sizeof(SYSPATH); #ifdef notdef if (parentPath) { int pLen = strlen(parentPath)+1; if (pLen > len) { len = pLen; } } #endif libPath = malloc(len+strlen(libname)+1); /* if we couldn't get the space, just use the LD_LIBPATH */ if (libPath) { #ifdef notdef /* first try the parent DLL path if known */ if (parentPath) { /* then try the path of the shared library */ strcpy(libPath,parentPath); strcat(libPath,libname); free(parentPath); library = NSAddImage(libPath, NSADDIMAGE_OPTION_RETURN_ON_ERROR | NSADDIMAGE_OPTION_WITH_SEARCHING); if (library) { free(libPath); return (ckyShLibrary)library; } } #endif /* the try the executable's lib path */ strcpy(libPath,SYSPATH); strcat(libPath,libname); library = NSAddImage(libPath, NSADDIMAGE_OPTION_RETURN_ON_ERROR | NSADDIMAGE_OPTION_WITH_SEARCHING); free(libPath); if (library) { return (ckyShLibrary)library; } } /* finally grab it from the system libpath */ library = NSAddImage(libname, NSADDIMAGE_OPTION_RETURN_ON_ERROR | NSADDIMAGE_OPTION_WITH_SEARCHING); return (ckyShLibrary)library; } CKYStatus ckyShLibrary_close(ckyShLibrary _lib) { // Can't unload an image on Mac OS X. return CKYSUCCESS; } CKYStatus ckyShLibrary_getAddress(const ckyShLibrary _lib, void ** func, const char *funcName) { const struct mach_header *library = (const struct mach_header *)_lib; NSSymbol symbol; symbol = NSLookupSymbolInImage(library, funcName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); if( symbol == NULL ) { return CKYLIBFAIL; } *func = NSAddressOfSymbol(symbol); return CKYSUCCESS; } --- NEW FILE dynlink_unix.c --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #include #include #if !defined(MAC) && !defined(HPUX) #include #endif #include #include "cky_base.h" #include "dynlink.h" ckyShLibrary ckyShLibrary_open(const char *libname) { void *library; library = dlopen(libname, RTLD_LAZY); return library; } CKYStatus ckyShLibrary_close(ckyShLibrary library) { int rv; if (library == NULL) { return CKYSUCCESS; } rv = dlclose(library); if( rv != 0 ) { return CKYLIBFAIL; } return CKYSUCCESS; } CKYStatus ckyShLibrary_getAddress(const ckyShLibrary library, void **func, const char *funcName) { assert(library); void* f = dlsym(library, funcName); if( f == NULL ) { return CKYLIBFAIL; } *func = f; return CKYSUCCESS; } --- NEW FILE dynlink_win.c --- /* ***** BEGIN COPYRIGHT BLOCK ***** * Copyright (C) 2005 Red Hat, Inc. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version * 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ #include #include "cky_base.h" #include "dynlink.h" ckyShLibrary ckyShLibrary_open(const char *libname) { HMODULE library; library = LoadLibrary(libname); return (ckyShLibrary) library; } CKYStatus ckyShLibrary_close(ckyShLibrary _lib) { HMODULE library = (HMODULE) _lib; BOOL ret; if( library == NULL ) { return CKYSUCCESS; } ret = FreeLibrary(library); library = NULL; if (!ret) { return CKYLIBFAIL; } return CKYSUCCESS; } CKYStatus ckyShLibrary_getAddress(const ckyShLibrary _lib, void **func, const char *funcName) { const HMODULE library = (const HMODULE) _lib; *func = (void *)GetProcAddress(library, funcName); if (*func == NULL) { return CKYLIBFAIL; } return CKYSUCCESS; } --- NEW FILE manifest.mn --- # ***** BEGIN COPYRIGHT BLOCK ***** # Copyright (C) 2005 Red Hat, Inc. # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation version # 2.1 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ***** END COPYRIGHT BLOCK ***** CORE_DEPTH = .. #USE_NSS=1 #USE_STATIC_RTL=1 MODULE = ckyapplet LIBRARY_NAME = $(MODULE) DEFINES += -DNSPR20 -D_STATIC_CPPLIB EXPORTS = cky_base.h \ cky_card.h \ cky_factory.h \ cky_list.h \ cky_applet.h \ $(NULL) CSRCS = \ cky_base.c \ cky_card.c \ cky_factory.c \ cky_applet.c \ dynlink.c \ $(NULL) From fedora-directory-commits at redhat.com Fri Jun 9 21:56:36 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 14:56:36 -0700 Subject: [Fedora-directory-commits] coolkey Makefile.am, 1.1.1.1, 1.2 Makefile.in, 1.1.1.1, 1.2 config.status, 1.1.1.1, 1.2 configure, 1.1.1.1, 1.2 configure.in, 1.1.1.1, 1.2 coolkey.spec, 1.1.1.1, 1.2 libtool, 1.1.1.1, 1.2 Message-ID: <200606092156.k59Lua53010498@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10446 Modified Files: Makefile.am Makefile.in config.status configure configure.in coolkey.spec libtool Log Message: Build in new tree location. update .spec file from review comments. Index: Makefile.am =================================================================== RCS file: /cvs/dirsec/coolkey/Makefile.am,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Makefile.am 9 Jun 2006 18:31:38 -0000 1.1.1.1 +++ Makefile.am 9 Jun 2006 21:56:34 -0000 1.2 @@ -19,7 +19,7 @@ # Process this file with automake to create Makefile.in. -SUBDIRS = clib pkcs11/smartcard +SUBDIRS = src/libckyapplet src/coolkey ACLOCAL_AMFLAGS = -I m4 Index: Makefile.in =================================================================== RCS file: /cvs/dirsec/coolkey/Makefile.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Makefile.in 9 Jun 2006 18:31:31 -0000 1.1.1.1 +++ Makefile.in 9 Jun 2006 21:56:34 -0000 1.2 @@ -14,6 +14,25 @@ @SET_MAKE@ +# BEGIN COPYRIGHT BLOCK +# Copyright (C) 2005 Red Hat, Inc. +# All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation version +# 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# END COPYRIGHT BLOCK + # Process this file with automake to create Makefile.in. srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -186,7 +205,7 @@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ -SUBDIRS = clib pkcs11/smartcard +SUBDIRS = src/libckyapplet src/coolkey ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = DISTCLEANFILES = Index: config.status =================================================================== RCS file: /cvs/dirsec/coolkey/config.status,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- config.status 9 Jun 2006 18:31:38 -0000 1.1.1.1 +++ config.status 9 Jun 2006 21:56:34 -0000 1.2 @@ -271,7 +271,7 @@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 -config_files=" Makefile clib/Makefile pkcs11/smartcard/Makefile" +config_files=" Makefile src/libckyapplet/Makefile src/coolkey/Makefile" config_headers=" config.h" config_commands=" depfiles" @@ -303,8 +303,8 @@ Report bugs to ." ac_cs_version="\ coolkey config.status "1.1.0" -configured by ./configure, generated by GNU Autoconf 2.59, - with options \"'--disable-dependency-checking'\" +configured by configure, generated by GNU Autoconf 2.59, + with options \"'--disable-dependency-tracking'\" Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation @@ -383,23 +383,23 @@ fi if $ac_cs_recheck; then - echo "running /bin/sh ./configure " '--disable-dependency-checking' $ac_configure_extra_args " --no-create --no-recursion" >&6 - exec /bin/sh ./configure '--disable-dependency-checking' $ac_configure_extra_args --no-create --no-recursion + echo "running /bin/sh configure " '--disable-dependency-tracking' $ac_configure_extra_args " --no-create --no-recursion" >&6 + exec /bin/sh configure '--disable-dependency-tracking' $ac_configure_extra_args --no-create --no-recursion fi # # INIT-COMMANDS section. # -AMDEP_TRUE="" ac_aux_dir="." +AMDEP_TRUE="#" ac_aux_dir="." for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "clib/Makefile" ) CONFIG_FILES="$CONFIG_FILES clib/Makefile" ;; - "pkcs11/smartcard/Makefile" ) CONFIG_FILES="$CONFIG_FILES pkcs11/smartcard/Makefile" ;; + "src/libckyapplet/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/libckyapplet/Makefile" ;; + "src/coolkey/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/coolkey/Makefile" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 @@ -502,12 +502,12 @@ s, at CYGPATH_W@,echo,;t t s, at PACKAGE@,coolkey,;t t s, at VERSION@,1.1.0,;t t -s, at ACLOCAL@,${SHELL} /builds/netkey2/netkey/missing --run aclocal-1.9,;t t -s, at AUTOCONF@,${SHELL} /builds/netkey2/netkey/missing --run autoconf,;t t -s, at AUTOMAKE@,${SHELL} /builds/netkey2/netkey/missing --run automake-1.9,;t t -s, at AUTOHEADER@,${SHELL} /builds/netkey2/netkey/missing --run autoheader,;t t -s, at MAKEINFO@,${SHELL} /builds/netkey2/netkey/missing --run makeinfo,;t t -s, at install_sh@,/builds/netkey2/netkey/install-sh,;t t +s, at ACLOCAL@,${SHELL} /builds/fedora/coolkey/missing --run aclocal-1.9,;t t +s, at AUTOCONF@,${SHELL} /builds/fedora/coolkey/missing --run autoconf,;t t +s, at AUTOMAKE@,${SHELL} /builds/fedora/coolkey/missing --run automake-1.9,;t t +s, at AUTOHEADER@,${SHELL} /builds/fedora/coolkey/missing --run autoheader,;t t +s, at MAKEINFO@,${SHELL} /builds/fedora/coolkey/missing --run makeinfo,;t t +s, at install_sh@,/builds/fedora/coolkey/install-sh,;t t s, at STRIP@,strip,;t t s, at ac_ct_STRIP@,strip,;t t s, at INSTALL_STRIP_PROGRAM@,${SHELL} $(install_sh) -c -s,;t t @@ -515,7 +515,7 @@ s, at AWK@,gawk,;t t s, at SET_MAKE@,,;t t s, at am__leading_dot@,.,;t t -s, at AMTAR@,${SHELL} /builds/netkey2/netkey/missing --run tar,;t t +s, at AMTAR@,${SHELL} /builds/fedora/coolkey/missing --run tar,;t t s, at am__tar@,${AMTAR} chof - "$$tardir",;t t s, at am__untar@,${AMTAR} xf -,;t t s, at MAINTAINER_MODE_TRUE@,#,;t t @@ -531,18 +531,18 @@ s, at DEPDIR@,.deps,;t t s, at am__include@,include,;t t s, at am__quote@,,;t t -s, at AMDEP_TRUE@,,;t t -s, at AMDEP_FALSE@,#,;t t -s, at AMDEPBACKSLASH@,\,;t t -s, at CCDEPMODE@,depmode=gcc3,;t t -s, at am__fastdepCC_TRUE@,,;t t -s, at am__fastdepCC_FALSE@,#,;t t +s, at AMDEP_TRUE@,#,;t t +s, at AMDEP_FALSE@,,;t t +s, at AMDEPBACKSLASH@,,;t t +s, at CCDEPMODE@,depmode=none,;t t +s, at am__fastdepCC_TRUE@,#,;t t +s, at am__fastdepCC_FALSE@,,;t t s, at CXX@,g++,;t t s, at CXXFLAGS@,-g -O2,;t t s, at ac_ct_CXX@,g++,;t t -s, at CXXDEPMODE@,depmode=gcc3,;t t -s, at am__fastdepCXX_TRUE@,,;t t -s, at am__fastdepCXX_FALSE@,#,;t t +s, at CXXDEPMODE@,depmode=none,;t t +s, at am__fastdepCXX_TRUE@,#,;t t +s, at am__fastdepCXX_FALSE@,,;t t s, at EGREP@,grep -E,;t t s, at LN_S@,ln -s,;t t s, at ECHO@,echo,;t t @@ -552,11 +552,11 @@ s, at ac_ct_RANLIB@,ranlib,;t t s, at CPP@,gcc -E,;t t s, at CXXCPP@,g++ -E,;t t -s, at F77@,g77,;t t -s, at FFLAGS@,-g -O2,;t t -s, at ac_ct_F77@,g77,;t t +s, at F77@,,;t t +s, at FFLAGS@,,;t t +s, at ac_ct_F77@,,;t t s, at LIBTOOL@,$(SHELL) $(top_builddir)/libtool,;t t -s, at LIBCKYAPPLET@,${top_builddir}/clib/libckyapplet.la,;t t +s, at LIBCKYAPPLET@,${top_builddir}/src/libckyapplet/libckyapplet.la,;t t s, at PCSC_CFLAGS@,-pthread -I/usr/include/PCSC ,;t t s, at PCSC_LIBS@,-lpcsclite ,;t t s, at SCARD_LIB_NAME@,libpcsclite.so.1,;t t Index: configure =================================================================== RCS file: /cvs/dirsec/coolkey/configure,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- configure 9 Jun 2006 18:31:38 -0000 1.1.1.1 +++ configure 9 Jun 2006 21:56:34 -0000 1.2 @@ -425,7 +425,7 @@ PACKAGE_STRING='coolkey "1.1.0"' PACKAGE_BUGREPORT='' -ac_unique_file="pkcs11/smartcard/coolkey.cpp" +ac_unique_file="src/coolkey/coolkey.cpp" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -18937,7 +18937,7 @@ # add our compiled static libraries -LIBCKYAPPLET="\${top_builddir}/clib/libckyapplet.la" +LIBCKYAPPLET="\${top_builddir}/src/libckyapplet/libckyapplet.la" PCSC_MSG=no pcsc_path=/usr @@ -20996,7 +20996,7 @@ - ac_config_files="$ac_config_files Makefile clib/Makefile pkcs11/smartcard/Makefile" + ac_config_files="$ac_config_files Makefile src/libckyapplet/Makefile src/coolkey/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -21569,8 +21569,8 @@ case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "clib/Makefile" ) CONFIG_FILES="$CONFIG_FILES clib/Makefile" ;; - "pkcs11/smartcard/Makefile" ) CONFIG_FILES="$CONFIG_FILES pkcs11/smartcard/Makefile" ;; + "src/libckyapplet/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/libckyapplet/Makefile" ;; + "src/coolkey/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/coolkey/Makefile" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 Index: configure.in =================================================================== RCS file: /cvs/dirsec/coolkey/configure.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- configure.in 9 Jun 2006 18:31:32 -0000 1.1.1.1 +++ configure.in 9 Jun 2006 21:56:34 -0000 1.2 @@ -24,7 +24,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT(coolkey,"1.1.0") -AC_CONFIG_SRCDIR([pkcs11/smartcard/coolkey.cpp]) +AC_CONFIG_SRCDIR([src/coolkey/coolkey.cpp]) AC_CANONICAL_TARGET([]) AM_INIT_AUTOMAKE(coolkey, "1.1.0") AC_CONFIG_HEADERS([config.h]) @@ -54,7 +54,7 @@ # add our compiled static libraries AC_SUBST(LIBCKYAPPLET) -LIBCKYAPPLET="\${top_builddir}/clib/libckyapplet.la" +LIBCKYAPPLET="\${top_builddir}/src/libckyapplet/libckyapplet.la" PCSC_MSG=no pcsc_path=/usr @@ -190,7 +190,7 @@ AC_CONFIG_FILES([ Makefile -clib/Makefile -pkcs11/smartcard/Makefile +src/libckyapplet/Makefile +src/coolkey/Makefile ]) AC_OUTPUT Index: coolkey.spec =================================================================== RCS file: /cvs/dirsec/coolkey/coolkey.spec,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- coolkey.spec 9 Jun 2006 18:31:34 -0000 1.1.1.1 +++ coolkey.spec 9 Jun 2006 21:56:34 -0000 1.2 @@ -27,10 +27,9 @@ Group: System Environment/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: pcsc-lite-devel -BuildRequires: zlib +BuildRequires: zlib-devel Requires: pcsc-lite Requires: ifd-egate -Requires: zlib Provides: CoolKey Openkey Obsoletes: CoolKey Openkey @@ -40,7 +39,6 @@ %package devel Summary: CoolKey Applet libraries Group: System Environment/Libraries -Provides: coolkey-devel %description devel Linux Driver support to access the CoolKey applet. @@ -50,7 +48,7 @@ %build %configure --disable-dependency-tracking -make %("_smp_mflags) +make %(?_smp_mflags) %install rm -rf $RPM_BUILD_ROOT @@ -71,7 +69,7 @@ %files devel %{_libdir}/libckyapplet.a -%{_includedir} +%{_includedir}/*.h %changelog Index: libtool =================================================================== RCS file: /cvs/dirsec/coolkey/libtool,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- libtool 9 Jun 2006 18:31:32 -0000 1.1.1.1 +++ libtool 9 Jun 2006 21:56:34 -0000 1.2 @@ -40,7 +40,7 @@ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # The names of the tagged configurations supported by this script. -available_tags=" CXX F77" +available_tags=" CXX" # ### BEGIN LIBTOOL CONFIG @@ -6954,311 +6954,3 @@ # ### END LIBTOOL TAG CONFIG: CXX -# ### BEGIN LIBTOOL TAG CONFIG: F77 - -# Libtool was configured on host jordan.sfbay.redhat.com: - -# Shell to use when invoking shell scripts. -SHELL="/bin/sh" - -# Whether or not to build shared libraries. -build_libtool_libs=yes - -# Whether or not to build static libraries. -build_old_libs=yes - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=no - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=no - -# Whether or not to optimize for fast installation. -fast_install=yes - -# The host system. -host_alias= -host=i686-redhat-linux-gnu -host_os=linux-gnu - -# The build system. -build_alias= -build=i686-redhat-linux-gnu -build_os=linux-gnu - -# An echo program that does not interpret backslashes. -echo="echo" - -# The archiver. -AR="ar" -AR_FLAGS="cru" - -# A C compiler. -LTCC="gcc" - -# LTCC compiler flags. -LTCFLAGS="-g -O2" - -# A language-specific compiler. -CC="g77" - -# Is the compiler the GNU C compiler? -with_gcc=yes - -# An ERE matcher. -EGREP="grep -E" - -# The linker used to build libraries. -LD="/usr/bin/ld" - -# Whether we need hard or soft links. -LN_S="ln -s" - -# A BSD-compatible nm program. -NM="/usr/bin/nm -B" - -# A symbol stripping program -STRIP="strip" - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=file - -# Used on cygwin: DLL creation program. -DLLTOOL="dlltool" - -# Used on cygwin: object dumper. -OBJDUMP="objdump" - -# Used on cygwin: assembler. -AS="as" - -# The name of the directory that contains temporary libtool files. -objdir=.libs - -# How to create reloadable object files. -reload_flag=" -r" -reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" - -# How to pass a linker flag through the compiler. -wl="-Wl," - -# Object file suffix (normally "o"). -objext="o" - -# Old archive suffix (normally "a"). -libext="a" - -# Shared library suffix (normally ".so"). -shrext='.so' - -# Executable file suffix (normally ""). -exeext="" - -# Additional compiler flags for building library objects. -pic_flag=" -fPIC" -pic_mode=default - -# What is the maximum length of a command? -max_cmd_len=32768 - -# Does compiler simultaneously support -c and -o options? -compiler_c_o="yes" - -# Must we lock files when doing compilation? -need_locks="no" - -# Do we need the lib prefix for modules? -need_lib_prefix=no - -# Do we need a version for libraries? -need_version=no - -# Whether dlopen is supported. -dlopen_support=unknown - -# Whether dlopen of programs is supported. -dlopen_self=unknown - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=unknown - -# Compiler flag to prevent dynamic linking. -link_static_flag="-static" - -# Compiler flag to turn off builtin functions. -no_builtin_flag="" - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec="\${wl}--export-dynamic" - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive" - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec="" - -# Library versioning type. -version_type=linux - -# Format of library name prefix. -libname_spec="lib\$name" - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}" - -# The coded name of the library, if different from the real name. -soname_spec="\${libname}\${release}\${shared_ext}\$major" - -# Commands used to build and install an old-style archive. -RANLIB="ranlib" -old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs\$old_deplibs~\$RANLIB \$oldlib" -old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$oldlib" -old_postuninstall_cmds="" - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds="" - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds="" - -# Commands used to build and install a shared archive. -archive_cmds="\$CC -shared \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib" -archive_expsym_cmds="\$echo \\\"{ global:\\\" > \$output_objdir/\$libname.ver~ - cat \$export_symbols | sed -e \\\"s/\\\\(.*\\\\)/\\\\1;/\\\" >> \$output_objdir/\$libname.ver~ - \$echo \\\"local: *; };\\\" >> \$output_objdir/\$libname.ver~ - \$CC -shared \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname \${wl}-version-script \${wl}\$output_objdir/\$libname.ver -o \$lib" -postinstall_cmds="" -postuninstall_cmds="" - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds="" -module_expsym_cmds="" - -# Commands to strip libraries. -old_striplib="strip --strip-debug" -striplib="strip --strip-unneeded" - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects="" - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects="" - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps="" - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps="" - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path="" - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method="pass_all" - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd="\$MAGIC_CMD" - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag="" - -# Flag that forces no undefined symbols. -no_undefined_flag="" - -# Commands used to finish a libtool library installation in a directory. -finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval="" - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p'" - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl="sed -n -e 's/^. .* \\(.*\\)\$/extern int \\1;/p'" - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/ {\\\"\\1\\\", (lt_ptr) 0},/p' -e 's/^[BCDEGRST] \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (lt_ptr) \\&\\2},/p'" - -# This is the shared library runtime path variable. -runpath_var=LD_RUN_PATH - -# This is the shared library path variable. -shlibpath_var=LD_LIBRARY_PATH - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=no - -# How to hardcode a shared library path into an executable. -hardcode_action=immediate - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=yes - -# Flag to hardcode $libdir into a binary during linking. -# This must work even if $libdir does not exist. -hardcode_libdir_flag_spec="\${wl}--rpath \${wl}\$libdir" - -# If ld is used when linking, flag to hardcode $libdir into -# a binary during linking. This must work even if $libdir does -# not exist. -hardcode_libdir_flag_spec_ld="" - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator="" - -# Set to yes if using DIR/libNAME during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=no - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=no - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=unsupported - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=no - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=unknown - -# Compile-time system search path for libraries -sys_lib_search_path_spec=" /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/ /usr/lib/gcc/i386-redhat-linux/3.2.3/ /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../../i386-redhat-linux/lib/i386-redhat-linux/3.2.3/ /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../../i386-redhat-linux/lib/ /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../i386-redhat-linux/3.2.3/ /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../ /lib/i386-redhat-linux/3.2.3/ /lib/ /usr/lib/i386-redhat-linux/3.2.3/ /usr/lib/" - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/mysql /usr/lib/mysql /usr/lib/qt-3.3/lib /usr/X11R6/lib /usr/lib/mysql /usr/lib/wine " - -# Fix the shell variable $srcfile for the compiler. -fix_srcfile_path="" - -# Set to yes if exported symbols are required. -always_export_symbols=no - -# The commands to list exported symbols. -export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds="" - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms="_GLOBAL_OFFSET_TABLE_" - -# Symbols that must always be exported. -include_expsyms="" - -# ### END LIBTOOL TAG CONFIG: F77 - From fedora-directory-commits at redhat.com Fri Jun 9 21:56:37 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 14:56:37 -0700 Subject: [Fedora-directory-commits] coolkey/src/coolkey Makefile.am, 1.1, 1.2 Makefile.in, 1.1, 1.2 Message-ID: <200606092156.k59LubCP010508@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/coolkey In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10446/src/coolkey Modified Files: Makefile.am Makefile.in Log Message: Build in new tree location. update .spec file from review comments. Index: Makefile.am =================================================================== RCS file: /cvs/dirsec/coolkey/src/coolkey/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Makefile.am 9 Jun 2006 18:39:11 -0000 1.1 +++ Makefile.am 9 Jun 2006 21:56:34 -0000 1.2 @@ -49,7 +49,7 @@ $(NULL) libcoolkeypk11_la_LDFLAGS = -module -avoid-version -export-symbols coolkeypk11.sym -libcoolkeypk11_la_CPPFLAGS = $(CPPFLAGS) -DNSS_HIDE_NONSTANDARD_OBJECTS=1 -I$(top_srcdir)/clib $(PCSC_CFLAGS) +libcoolkeypk11_la_CPPFLAGS = $(CPPFLAGS) -DNSS_HIDE_NONSTANDARD_OBJECTS=1 -I$(top_srcdir)/src/libckyapplet $(PCSC_CFLAGS) libcoolkeypk11_la_DEPENDENCIES = coolkeypk11.sym libcoolkeypk11_la_LIBADD = @LIBCKYAPPLET@ Index: Makefile.in =================================================================== RCS file: /cvs/dirsec/coolkey/src/coolkey/Makefile.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Makefile.in 9 Jun 2006 18:39:11 -0000 1.1 +++ Makefile.in 9 Jun 2006 21:56:34 -0000 1.2 @@ -58,7 +58,7 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -subdir = pkcs11/smartcard +subdir = src/coolkey DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ @@ -254,7 +254,7 @@ $(NULL) libcoolkeypk11_la_LDFLAGS = -module -avoid-version -export-symbols coolkeypk11.sym -libcoolkeypk11_la_CPPFLAGS = $(CPPFLAGS) -DNSS_HIDE_NONSTANDARD_OBJECTS=1 -I$(top_srcdir)/clib $(PCSC_CFLAGS) +libcoolkeypk11_la_CPPFLAGS = $(CPPFLAGS) -DNSS_HIDE_NONSTANDARD_OBJECTS=1 -I$(top_srcdir)/src/libckyapplet $(PCSC_CFLAGS) libcoolkeypk11_la_DEPENDENCIES = coolkeypk11.sym libcoolkeypk11_la_LIBADD = @LIBCKYAPPLET@ all: all-recursive @@ -270,9 +270,9 @@ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu pkcs11/smartcard/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/coolkey/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu pkcs11/smartcard/Makefile + $(AUTOMAKE) --gnu src/coolkey/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ From fedora-directory-commits at redhat.com Fri Jun 9 21:56:37 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 14:56:37 -0700 Subject: [Fedora-directory-commits] coolkey/src/libckyapplet Makefile.in, 1.1, 1.2 dynlink.c, 1.1, 1.2 Message-ID: <200606092156.k59LubVt010515@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/libckyapplet In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10446/src/libckyapplet Modified Files: Makefile.in dynlink.c Log Message: Build in new tree location. update .spec file from review comments. Index: Makefile.in =================================================================== RCS file: /cvs/dirsec/coolkey/src/libckyapplet/Makefile.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Makefile.in 9 Jun 2006 18:44:17 -0000 1.1 +++ Makefile.in 9 Jun 2006 21:56:35 -0000 1.2 @@ -42,7 +42,7 @@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = .. +top_builddir = ../.. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 @@ -59,7 +59,7 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -subdir = clib +subdir = src/libckyapplet DIST_COMMON = $(nobase_include_HEADERS) $(noinst_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -258,9 +258,9 @@ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu clib/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libckyapplet/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu clib/Makefile + $(AUTOMAKE) --gnu src/libckyapplet/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ Index: dynlink.c =================================================================== RCS file: /cvs/dirsec/coolkey/src/libckyapplet/dynlink.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- dynlink.c 9 Jun 2006 18:44:17 -0000 1.1 +++ dynlink.c 9 Jun 2006 21:56:35 -0000 1.2 @@ -17,7 +17,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ***** END COPYRIGHT BLOCK ***** */ -#include "../config.h" +#ifdef HAVE_CONFIG_H +#include +#endif #ifdef WIN32 #include "dynlink_win.c" From fedora-directory-commits at redhat.com Fri Jun 9 22:01:42 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 15:01:42 -0700 Subject: [Fedora-directory-commits] coolkey/src/coolkey config.mk, 1.1, NONE manifest.mn, 1.1, NONE Message-ID: <200606092201.k59M1gLX012947@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/coolkey In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv12857/src/coolkey Removed Files: config.mk manifest.mn Log Message: Remove coreconf only files (no longer necessary with automake/autoconf) --- config.mk DELETED --- --- manifest.mn DELETED --- From fedora-directory-commits at redhat.com Fri Jun 9 22:01:47 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 15:01:47 -0700 Subject: [Fedora-directory-commits] coolkey/src/libckyapplet config.mk, 1.1, NONE manifest.mn, 1.1, NONE Message-ID: <200606092201.k59M1luP012955@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/libckyapplet In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv12857/src/libckyapplet Removed Files: config.mk manifest.mn Log Message: Remove coreconf only files (no longer necessary with automake/autoconf) --- config.mk DELETED --- --- manifest.mn DELETED --- From fedora-directory-commits at redhat.com Sat Jun 10 00:51:17 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 17:51:17 -0700 Subject: [Fedora-directory-commits] coolkey/src/libckyapplet libckyapplet.pc.in, NONE, 1.1 Makefile.am, 1.1, 1.2 Makefile.in, 1.2, 1.3 Message-ID: <200606100051.k5A0pHVD019117@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey/src/libckyapplet In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19078/src/libckyapplet Modified Files: Makefile.am Makefile.in Added Files: libckyapplet.pc.in Log Message: Package review changes: make libckyapplet a shared library. --- NEW FILE libckyapplet.pc.in --- prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: CoolKey Applet Library Description: Library to talk to the CoolKey applet. Version: 1.0.0 Libs: -L${libdir} -lckyapplet Cflags: Index: Makefile.am =================================================================== RCS file: /cvs/dirsec/coolkey/src/libckyapplet/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Makefile.am 9 Jun 2006 18:44:17 -0000 1.1 +++ Makefile.am 10 Jun 2006 00:51:09 -0000 1.2 @@ -24,7 +24,7 @@ AM_CFLAGS = # bleh what do I add just to get static but pic libraries? -noinst_LTLIBRARIES = libckyapplet.la +lib_LTLIBRARIES = libckyapplet.la libckyapplet_la_SOURCES = \ cky_applet.c \ @@ -35,7 +35,7 @@ quote=\" -libckyapplet_la_LDFLAGS = -avoid-version +libckyapplet_la_LDFLAGS = -version-info 1:0:0 libckyapplet_la_CFLAGS = $(CFLAGS) -DSCARD_LIB_NAME=$(quote)$(SCARD_LIB_NAME)$(quote) $(PCSC_CFLAGS) nobase_include_HEADERS = \ @@ -49,5 +49,5 @@ cky_basei.h \ dynlink.h -#pcdir = $(libdir)/pkgconfig -#pc_DATA = libckyapplet.pc +pcdir = $(libdir)/pkgconfig +pc_DATA = libckyapplet.pc Index: Makefile.in =================================================================== RCS file: /cvs/dirsec/coolkey/src/libckyapplet/Makefile.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.in 9 Jun 2006 21:56:35 -0000 1.2 +++ Makefile.in 10 Jun 2006 00:51:09 -0000 1.3 @@ -36,6 +36,7 @@ # Process this file with automake to create Makefile.in + srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -61,7 +62,8 @@ target_triplet = @target@ subdir = src/libckyapplet DIST_COMMON = $(nobase_include_HEADERS) $(noinst_HEADERS) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/libckyapplet.pc.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.in @@ -69,8 +71,17 @@ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -LTLIBRARIES = $(noinst_LTLIBRARIES) +CONFIG_CLEAN_FILES = libckyapplet.pc +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pcdir)" \ + "$(DESTDIR)$(includedir)" +libLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(lib_LTLIBRARIES) libckyapplet_la_LIBADD = am_libckyapplet_la_OBJECTS = libckyapplet_la-cky_applet.lo \ libckyapplet_la-cky_base.lo libckyapplet_la-cky_card.lo \ @@ -95,13 +106,8 @@ install-recursive installcheck-recursive installdirs-recursive \ pdf-recursive ps-recursive uninstall-info-recursive \ uninstall-recursive -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -am__installdirs = "$(DESTDIR)$(includedir)" +pcDATA_INSTALL = $(INSTALL_DATA) +DATA = $(pc_DATA) nobase_includeHEADERS_INSTALL = $(install_sh_DATA) HEADERS = $(nobase_include_HEADERS) $(noinst_HEADERS) ETAGS = etags @@ -223,7 +229,7 @@ AM_CFLAGS = # bleh what do I add just to get static but pic libraries? -noinst_LTLIBRARIES = libckyapplet.la +lib_LTLIBRARIES = libckyapplet.la libckyapplet_la_SOURCES = \ cky_applet.c \ cky_base.c \ @@ -232,7 +238,7 @@ dynlink.c quote = \" -libckyapplet_la_LDFLAGS = -avoid-version +libckyapplet_la_LDFLAGS = -version-info 1:0:0 libckyapplet_la_CFLAGS = $(CFLAGS) -DSCARD_LIB_NAME=$(quote)$(SCARD_LIB_NAME)$(quote) $(PCSC_CFLAGS) nobase_include_HEADERS = \ cky_base.h \ @@ -245,6 +251,8 @@ cky_basei.h \ dynlink.h +pcdir = $(libdir)/pkgconfig +pc_DATA = libckyapplet.pc all: all-recursive .SUFFIXES: @@ -278,17 +286,37 @@ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +libckyapplet.pc: $(top_builddir)/config.status $(srcdir)/libckyapplet.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libckyapplet.la: $(libckyapplet_la_OBJECTS) $(libckyapplet_la_DEPENDENCIES) - $(LINK) $(libckyapplet_la_LDFLAGS) $(libckyapplet_la_OBJECTS) $(libckyapplet_la_LIBADD) $(LIBS) + $(LINK) -rpath $(libdir) $(libckyapplet_la_LDFLAGS) $(libckyapplet_la_OBJECTS) $(libckyapplet_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -367,6 +395,23 @@ distclean-libtool: -rm -f libtool uninstall-info-am: +install-pcDATA: $(pc_DATA) + @$(NORMAL_INSTALL) + test -z "$(pcdir)" || $(mkdir_p) "$(DESTDIR)$(pcdir)" + @list='$(pc_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(pcDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pcdir)/$$f'"; \ + $(pcDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pcdir)/$$f"; \ + done + +uninstall-pcDATA: + @$(NORMAL_UNINSTALL) + @list='$(pc_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pcdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pcdir)/$$f"; \ + done install-nobase_includeHEADERS: $(nobase_include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)" @@ -563,10 +608,10 @@ done check-am: all-am check: check-recursive -all-am: Makefile $(LTLIBRARIES) $(HEADERS) +all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) installdirs: installdirs-recursive installdirs-am: - for dir in "$(DESTDIR)$(includedir)"; do \ + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pcdir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-recursive @@ -595,7 +640,7 @@ @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-recursive @@ -614,9 +659,9 @@ info-am: -install-data-am: install-nobase_includeHEADERS +install-data-am: install-nobase_includeHEADERS install-pcDATA -install-exec-am: +install-exec-am: install-libLTLIBRARIES install-info: install-info-recursive @@ -642,28 +687,28 @@ ps-am: -uninstall-am: uninstall-info-am uninstall-nobase_includeHEADERS +uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \ + uninstall-nobase_includeHEADERS uninstall-pcDATA uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ - clean clean-generic clean-libtool clean-noinstLTLIBRARIES \ + clean clean-generic clean-libLTLIBRARIES clean-libtool \ clean-recursive ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-recursive distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ - install-info-am install-man install-nobase_includeHEADERS \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ + install-info-am install-libLTLIBRARIES install-man \ + install-nobase_includeHEADERS install-pcDATA install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic \ maintainer-clean-recursive mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ - uninstall-info-am uninstall-nobase_includeHEADERS - + uninstall-info-am uninstall-libLTLIBRARIES \ + uninstall-nobase_includeHEADERS uninstall-pcDATA -#pcdir = $(libdir)/pkgconfig -#pc_DATA = libckyapplet.pc # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: From fedora-directory-commits at redhat.com Sat Jun 10 00:51:11 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Fri, 9 Jun 2006 17:51:11 -0700 Subject: [Fedora-directory-commits] coolkey Makefile.in, 1.2, 1.3 config.status, 1.2, 1.3 configure, 1.2, 1.3 configure.in, 1.2, 1.3 coolkey.spec, 1.2, 1.3 Message-ID: <200606100051.k5A0pfig019124@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19078 Modified Files: Makefile.in config.status configure configure.in coolkey.spec Log Message: Package review changes: make libckyapplet a shared library. Index: Makefile.in =================================================================== RCS file: /cvs/dirsec/coolkey/Makefile.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.in 9 Jun 2006 21:56:34 -0000 1.2 +++ Makefile.in 10 Jun 2006 00:51:08 -0000 1.3 @@ -410,6 +410,7 @@ distdir: $(DISTFILES) $(am__remove_distdir) mkdir $(distdir) + $(mkdir_p) $(distdir)/src/libckyapplet @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ Index: config.status =================================================================== RCS file: /cvs/dirsec/coolkey/config.status,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- config.status 9 Jun 2006 21:56:34 -0000 1.2 +++ config.status 10 Jun 2006 00:51:08 -0000 1.3 @@ -271,7 +271,7 @@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 -config_files=" Makefile src/libckyapplet/Makefile src/coolkey/Makefile" +config_files=" Makefile src/libckyapplet/Makefile src/libckyapplet/libckyapplet.pc src/coolkey/Makefile" config_headers=" config.h" config_commands=" depfiles" @@ -399,6 +399,7 @@ # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/libckyapplet/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/libckyapplet/Makefile" ;; + "src/libckyapplet/libckyapplet.pc" ) CONFIG_FILES="$CONFIG_FILES src/libckyapplet/libckyapplet.pc" ;; "src/coolkey/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/coolkey/Makefile" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; Index: configure =================================================================== RCS file: /cvs/dirsec/coolkey/configure,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- configure 9 Jun 2006 21:56:34 -0000 1.2 +++ configure 10 Jun 2006 00:51:08 -0000 1.3 @@ -20996,7 +20996,7 @@ - ac_config_files="$ac_config_files Makefile src/libckyapplet/Makefile src/coolkey/Makefile" + ac_config_files="$ac_config_files Makefile src/libckyapplet/Makefile src/libckyapplet/libckyapplet.pc src/coolkey/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -21570,6 +21570,7 @@ # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/libckyapplet/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/libckyapplet/Makefile" ;; + "src/libckyapplet/libckyapplet.pc" ) CONFIG_FILES="$CONFIG_FILES src/libckyapplet/libckyapplet.pc" ;; "src/coolkey/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/coolkey/Makefile" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; Index: configure.in =================================================================== RCS file: /cvs/dirsec/coolkey/configure.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- configure.in 9 Jun 2006 21:56:34 -0000 1.2 +++ configure.in 10 Jun 2006 00:51:08 -0000 1.3 @@ -191,6 +191,7 @@ AC_CONFIG_FILES([ Makefile src/libckyapplet/Makefile +src/libckyapplet/libckyapplet.pc src/coolkey/Makefile ]) AC_OUTPUT Index: coolkey.spec =================================================================== RCS file: /cvs/dirsec/coolkey/coolkey.spec,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- coolkey.spec 9 Jun 2006 21:56:34 -0000 1.2 +++ coolkey.spec 10 Jun 2006 00:51:08 -0000 1.3 @@ -48,7 +48,7 @@ %build %configure --disable-dependency-tracking -make %(?_smp_mflags) +make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT @@ -56,7 +56,8 @@ ln -s pkcs11/libcoolkeypk11.so $RPM_BUILD_ROOT/%{_libdir} rm -f $RPM_BUILD_ROOT/%{_libdir}/pkcs11/libcoolkeypk11.la rm -f $RPM_BUILD_ROOT/%{_libdir}/pkcs11/libcoolkeypk11.a -install -m 755 clib/.libs/libckyapplet.a $RPM_BUILD_ROOT/%{_libdir} +rm -f $RPM_BUILD_ROOT/%{_libdir}/libckyapplet.a +rm -f $RPM_BUILD_ROOT/%{_libdir}/libckyapplet.la %clean rm -rf $RPM_BUILD_ROOT @@ -66,9 +67,12 @@ %doc ChangeLog LICENSE %{_libdir}/libcoolkeypk11.so %{_libdir}/pkcs11/libcoolkeypk11.so +%{_libdir}/libckyapplet.so.1 +%{_libdir}/libckyapplet.so.1.0.0 %files devel -%{_libdir}/libckyapplet.a +%{_libdir}/libckyapplet.so +%{_libdir}/pkgconfig/libckyapplet.pc %{_includedir}/*.h From fedora-directory-commits at redhat.com Mon Jun 12 20:51:34 2006 From: fedora-directory-commits at redhat.com (Robert Relyea (rrelyea)) Date: Mon, 12 Jun 2006 13:51:34 -0700 Subject: [Fedora-directory-commits] coolkey coolkey.spec,1.3,1.4 Message-ID: <200606122051.k5CKpYjg029742@cvs-int.fedora.redhat.com> Author: rrelyea Update of /cvs/dirsec/coolkey In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29722 Modified Files: coolkey.spec Log Message: Add URL value. Index: coolkey.spec =================================================================== RCS file: /cvs/dirsec/coolkey/coolkey.spec,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- coolkey.spec 10 Jun 2006 00:51:08 -0000 1.3 +++ coolkey.spec 12 Jun 2006 20:51:32 -0000 1.4 @@ -22,7 +22,7 @@ Release: 1 Summary: CoolKey PKCS #11 module License: LGPL -URL: TBD +URL: http://directory.fedora.redhat.com/wiki/CoolKey Source: coolkey-%{version}.tar.gz Group: System Environment/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -62,6 +62,10 @@ %clean rm -rf $RPM_BUILD_ROOT +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + %files %defattr(-,root,root,-) %doc ChangeLog LICENSE From fedora-directory-commits at redhat.com Mon Jun 12 23:39:57 2006 From: fedora-directory-commits at redhat.com (Jack Magne (jmagne)) Date: Mon, 12 Jun 2006 16:39:57 -0700 Subject: [Fedora-directory-commits] esc - Imported sources Message-ID: <200606122339.k5CNdvBb005269@cvs-int.fedora.redhat.com> Author: jmagne Update of /cvs/dirsec/esc In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv5254 Log Message: Initial drop of ESC code. Status: Vendor Tag: redhat Release Tags: start N esc/Makefile N esc/LICENSE N esc/manifest.mn N esc/coreconf/Linux2.1.mk N esc/coreconf/config.mk N esc/coreconf/import.pl N esc/coreconf/cpdist.pl N esc/coreconf/module.mk N esc/coreconf/version.mk N esc/coreconf/LinuxELF2.0.mk N esc/coreconf/Linux2.5.mk N esc/coreconf/version.pl N esc/coreconf/UNIX.mk N esc/coreconf/Linux2.4.mk N esc/coreconf/headers.mk N esc/coreconf/tree.mk N esc/coreconf/LinuxELF1.2.mk N esc/coreconf/outofdate.pl N esc/coreconf/Makefile N esc/coreconf/suffix.mk N esc/coreconf/location.mk N esc/coreconf/Linux2.6.mk N esc/coreconf/release.pl N esc/coreconf/source.mk N esc/coreconf/coreconf.pl N esc/coreconf/Linux2.2.mk N esc/coreconf/arch.mk N esc/coreconf/jniregen.pl N esc/coreconf/ruleset.mk N esc/coreconf/jdk.mk N esc/coreconf/rules.mk N esc/coreconf/prefix.mk N esc/coreconf/Linux.mk N esc/coreconf/Darwin.mk N esc/coreconf/command.mk N esc/coreconf/makefile.win N esc/coreconf/nsinstall/nfspwd.pl N esc/coreconf/nsinstall/Makefile N esc/coreconf/nsinstall/pathsub.h N esc/coreconf/nsinstall/pathsub.c N esc/coreconf/nsinstall/sunos4.h N esc/coreconf/nsinstall/nsinstall.c N esc/coreconf/nsinstall/nfspwd N esc/src/Makefile N esc/src/manifest.mn N esc/src/lib/NssHttpClient/stdafx.h N esc/src/lib/NssHttpClient/PSCommonLib.h N esc/src/lib/NssHttpClient/config.mk N esc/src/lib/NssHttpClient/NssHttpClient.h N esc/src/lib/NssHttpClient/nscperror.cpp N esc/src/lib/NssHttpClient/response.cpp N esc/src/lib/NssHttpClient/response.h N esc/src/lib/NssHttpClient/NssHttpClient.sln N esc/src/lib/NssHttpClient/NssHttpClient.vcproj N esc/src/lib/NssHttpClient/HttpClientNss.h N esc/src/lib/NssHttpClient/Makefile N esc/src/lib/NssHttpClient/Util.cpp N esc/src/lib/NssHttpClient/http.h N esc/src/lib/NssHttpClient/httpClientNss.cpp N esc/src/lib/NssHttpClient/request.cpp N esc/src/lib/NssHttpClient/http.cpp N esc/src/lib/NssHttpClient/engine.cpp N esc/src/lib/NssHttpClient/stdafx.cpp N esc/src/lib/NssHttpClient/Util.h N esc/src/lib/NssHttpClient/Cache.cpp N esc/src/lib/NssHttpClient/engine.h N esc/src/lib/NssHttpClient/Cache.h N esc/src/lib/NssHttpClient/NssHttpClient.cpp N esc/src/lib/NssHttpClient/manifest.mn N esc/src/lib/NssHttpClient/httpchunked.def N esc/src/lib/NssHttpClient/Defines.h N esc/src/lib/NssHttpClient/request.h N esc/src/lib/NssHttpClient/Iterator.h N esc/src/lib/coolkey/config.mk N esc/src/lib/coolkey/SmartCardMonitoringThread.h N esc/src/lib/coolkey/CoolKey.h N esc/src/lib/coolkey/SAOL_OIDS.h N esc/src/lib/coolkey/Makefile N esc/src/lib/coolkey/CoolKeyID.h N esc/src/lib/coolkey/NSSManager.h N esc/src/lib/coolkey/ckymanager.def N esc/src/lib/coolkey/CoolKeyPref.cpp N esc/src/lib/coolkey/CoolKey.cpp N esc/src/lib/coolkey/CoolKey_Message.cpp N esc/src/lib/coolkey/CoolKey_Message.h N esc/src/lib/coolkey/SlotUtils.h N esc/src/lib/coolkey/NSSManager.cpp N esc/src/lib/coolkey/SmartCardMonitoringThread.cpp N esc/src/lib/coolkey/CoolKeyPref.h N esc/src/lib/coolkey/manifest.mn N esc/src/lib/coolkey/CoolKeyHandler.cpp N esc/src/lib/coolkey/CoolKeyHandler.h N esc/src/lib/coolkey/SlotUtils.cpp N esc/src/app/xpcom/rhICoolKey.idl N esc/src/app/xpcom/rhIKeyNotify.idl N esc/src/app/xpcom/CoolKeyCSP.cpp N esc/src/app/xpcom/Makefile N esc/src/app/xpcom/openkey.h N esc/src/app/xpcom/CoolKeyCSP.h N esc/src/app/xpcom/Makefile.moz N esc/src/app/xpcom/rhCoolKey.h N esc/src/app/xpcom/rhCoolKey.cpp N esc/src/app/xpcom/tray/Makefile.in N esc/src/app/xpcom/tray/rhMacTray.cpp N esc/src/app/xpcom/tray/Makefile N esc/src/app/xpcom/tray/resource.h N esc/src/app/xpcom/tray/Makefile.moz N esc/src/app/xpcom/tray/CoolKeyLogo.gif N esc/src/app/xpcom/tray/rhLinuxTray.cpp N esc/src/app/xpcom/tray/rhITrayWindNotify.idl N esc/src/app/xpcom/tray/cool.rc N esc/src/app/xpcom/tray/esc.bmp N esc/src/app/xpcom/tray/rhTray.cpp N esc/src/app/xpcom/tray/esc.ico N esc/src/app/xpcom/tray/rhTray.h N esc/src/app/xpcom/tray/cool.ico N esc/src/app/xpcom/tray/rhITray.idl N esc/src/app/xul/esc/application.ini N esc/src/app/xul/esc/chrome/chrome.manifest N esc/src/app/xul/esc/chrome/content/esc/TRAY.js N esc/src/app/xul/esc/chrome/content/esc/ESC.js N esc/src/app/xul/esc/chrome/content/esc/esc-image-large.bmp N esc/src/app/xul/esc/chrome/content/esc/esc.css N esc/src/app/xul/esc/chrome/content/esc/esc.xul N esc/src/app/xul/esc/chrome/content/esc/CertInfo.js N esc/src/app/xul/esc/chrome/content/esc/bg.jpg N esc/src/app/xul/esc/chrome/content/esc/logo.gif N esc/src/app/xul/esc/chrome/content/esc/esc_browser.xul N esc/src/app/xul/esc/chrome/content/esc/GenericAuth.js N esc/src/app/xul/esc/chrome/content/esc/settings.xul N esc/src/app/xul/esc/chrome/content/esc/GenericAuth.xul N esc/src/app/xul/esc/chrome/content/esc/config.xul N esc/src/app/xul/esc/chrome/content/esc/certinfo.xul N esc/src/app/xul/esc/chrome/content/esc/contents.rdf N esc/src/app/xul/esc/chrome/locale/en-US/esc.dtd N esc/src/app/xul/esc/chrome/locale/en-US/esc.properties N esc/src/app/xul/esc/defaults/preferences/esc-prefs.js No conflicts created by this import From fedora-directory-commits at redhat.com Thu Jun 15 01:26:05 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Wed, 14 Jun 2006 18:26:05 -0700 Subject: [Fedora-directory-commits] adminutil component_versions.mk,1.4,1.5 Message-ID: <200606150126.k5F1Q5dK015562@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminutil In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15538 Modified Files: component_versions.mk Log Message: [195258] Changes for the internal build NSPR version: v4.6 -> v4.6.2 NSS version: NSS_3_11_RTM -> NSS_3_11_1_RTM Index: component_versions.mk =================================================================== RCS file: /cvs/dirsec/adminutil/component_versions.mk,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- component_versions.mk 1 Mar 2006 23:44:01 -0000 1.4 +++ component_versions.mk 15 Jun 2006 01:26:02 -0000 1.5 @@ -34,12 +34,12 @@ # naming scheme. # NSPR ifndef NSPR_RELDATE - NSPR_RELDATE = v4.6 + NSPR_RELDATE = v4.6.2 endif # SECURITY (NSS) LIBRARY ifndef SECURITY_RELDATE - SECURITY_RELDATE = NSS_3_11_RTM + SECURITY_RELDATE = NSS_3_11_1_RTM endif # LDAP SDK From fedora-directory-commits at redhat.com Thu Jun 15 01:27:37 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Wed, 14 Jun 2006 18:27:37 -0700 Subject: [Fedora-directory-commits] setuputil component_versions.mk,1.3,1.4 Message-ID: <200606150127.k5F1RbmE015611@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/setuputil In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15582 Modified Files: component_versions.mk Log Message: [195258] Changes for the internal build NSPR version: v4.6 -> v4.6.2 NSS version: NSS_3_11_RTM -> NSS_3_11_1_RTM Index: component_versions.mk =================================================================== RCS file: /cvs/dirsec/setuputil/component_versions.mk,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- component_versions.mk 23 Feb 2006 22:50:21 -0000 1.3 +++ component_versions.mk 15 Jun 2006 01:27:34 -0000 1.4 @@ -34,12 +34,12 @@ # naming scheme. # NSPR ifndef NSPR_RELDATE - NSPR_RELDATE = v4.6 + NSPR_RELDATE = v4.6.2 endif # SECURITY (NSS) LIBRARY ifndef SECURITY_RELDATE - SECURITY_RELDATE = NSS_3_11_RTM + SECURITY_RELDATE = NSS_3_11_1_RTM endif # DBM Library From fedora-directory-commits at redhat.com Thu Jun 15 01:29:17 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Wed, 14 Jun 2006 18:29:17 -0700 Subject: [Fedora-directory-commits] adminserver components.mk,1.50,1.51 Message-ID: <200606150129.k5F1THMb015650@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminserver In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15627 Modified Files: components.mk Log Message: [195258] Changes for the internal build NSPR version: v4.6 -> v4.6.2 NSS version: NSS_3_11_RTM -> NSS_3_11_1_RTM Index: components.mk =================================================================== RCS file: /cvs/dirsec/adminserver/components.mk,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- components.mk 23 May 2006 22:13:36 -0000 1.50 +++ components.mk 15 Jun 2006 01:29:14 -0000 1.51 @@ -54,7 +54,7 @@ # NSPR Library ############################################ -NSPR_RELDATE = v4.6 +NSPR_RELDATE = v4.6.2 NSPR_NSOBJDIR=$(NSOBJDIR_NAME) @@ -85,7 +85,7 @@ # SECURITY LIBRARY ################################################ -SECURITY_RELDATE = NSS_3_11_RTM +SECURITY_RELDATE = NSS_3_11_1_RTM ifeq ($(INT_NSS), 1) BASE_NSS = $(INT_DIR)/nss/$(SECURITY_RELDATE) From fedora-directory-commits at redhat.com Thu Jun 15 01:30:54 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Wed, 14 Jun 2006 18:30:54 -0700 Subject: [Fedora-directory-commits] adminserver nsconfig.mk,1.29,1.30 Message-ID: <200606150130.k5F1UsMh015689@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminserver In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15675 Modified Files: nsconfig.mk Log Message: [195258] Changes for the internal build adjusted admservconsole macro. Index: nsconfig.mk =================================================================== RCS file: /cvs/dirsec/adminserver/nsconfig.mk,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- nsconfig.mk 23 May 2006 22:13:36 -0000 1.29 +++ nsconfig.mk 15 Jun 2006 01:30:48 -0000 1.30 @@ -944,8 +944,8 @@ CONSOLE_JAR_DIR = $(CLASS_DEST) endif -ifdef ADMSERVCONSOLE_SOURCE_ROOT - ADMSERVCONSOLE_JAR_DIR = $(ADMSERVCONSOLE_SOURCE_ROOT)/built/package +ifdef ADMSERVCONSOLE_SOURCE_DIR + ADMSERVCONSOLE_JAR_DIR = $(ADMSERVCONSOLE_SOURCE_DIR)/built/package else ADMSERVCONSOLE_JAR_DIR = $(CLASS_DEST) endif From fedora-directory-commits at redhat.com Thu Jun 15 17:00:32 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Thu, 15 Jun 2006 10:00:32 -0700 Subject: [Fedora-directory-commits] mod_admserv mod_admserv.c,1.24,1.25 Message-ID: <200606151700.k5FH0WPP026662@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/mod_admserv In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26620 Modified Files: mod_admserv.c Log Message: [191832] Admin Server password always remembers initial password on (part 2) 1) task_update_registry_server_bindpw updates the password of "uid=admin, ou=Administrators, ou=TopologyManagement, o=NetscapeRoot" 2) in change_sie_password 2-1) increased outbuf size to 64 bytes to store the base64 encoded new password by apr_sha1_base64. 2-2) we don't store the admin password in adm.conf; removed calling update_adm_conf. 2-3) if any of the updates fails (sie password in DS, in admpw, and uid=admin password in DS), recover the old password to keep the passwords in sync. 3) eliminated update_adm_conf. Index: mod_admserv.c =================================================================== RCS file: /cvs/dirsec/mod_admserv/mod_admserv.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- mod_admserv.c 17 May 2006 00:01:55 -0000 1.24 +++ mod_admserv.c 15 Jun 2006 17:00:29 -0000 1.25 @@ -81,6 +81,8 @@ #define RUNTIME_COMMAND_BASE (char*)"commands/" #define AUTH_URI "/admin-serv/authenticate" +#define NETSCAPE_ROOT_BASEDN (char*)"o=NetscapeRoot" + /* Globals...hack. */ static char *serverroot = NULL; static long cacheLifetime = 0; /* Defaults to 0 (entries immediately expire) */ @@ -1135,13 +1137,106 @@ * Miodrag (06-15-98) * The following metthod is called from the runtime command * "change_sie_password" after the sie password is changed + * + * Return value: if successful, 1; otherwise, 0 is returned. */ -static void -task_update_registry_server_bindpw(char *password) +static int +task_update_registry_server_bindpw(char *uid, char *password, char* bindpw) { - if (registryServer.bindPW) - free(registryServer.bindPW); - registryServer.bindPW = password; + LDAP *ld; + int ldapError; + char *filter = NULL; + char *userDN = NULL; + LDAPMessage *result; + LDAPMod mod, *mods[2]; + char *vals[2]; + char *attrs[2]; + int rval = 0; + + /* update password for uid */ + if (!(ld = openLDAPConnection(®istryServer))) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "task_update_registry_server_bindpw(): cannot connect to the Configuration Directory Server"); + return rval; + } + + filter = (char *)malloc(strlen(uid) + 5); /* "uid=" */ + if (NULL == filter) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "task_update_registry_server_bindpw(): cannot allocate %d byte memory", + strlen(uid) + 5); + goto bailout; + } + attrs[0] = "dn"; /* we just need dn ... */ + attrs[1] = NULL; + sprintf(filter, "uid=%s", uid); + ldapError = ldap_search_s(ld, NETSCAPE_ROOT_BASEDN, LDAP_SCOPE_SUBTREE, + filter, attrs, 0, &result); + if (ldapError != LDAP_SUCCESS || ldap_count_entries(ld, result) == 0) { + ldap_msgfree(result); + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "task_update_registry_server_bindpw(): ldap_search %s under %s failed: %s", + filter, NETSCAPE_ROOT_BASEDN, ldap_err2string(ldapError)); + goto bailout; + } else { + LDAPMessage *entry = ldap_first_entry(ld, result); + userDN = ldap_get_dn(ld, entry); + ldap_msgfree(result); + } + if (NULL == userDN || 0 == strlen(userDN)) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "task_update_registry_server_bindpw(): ldap_search %s under %s returned %s", + filter, NETSCAPE_ROOT_BASEDN, userDN?"empty string":"NULL"); + goto bailout; + } + + /* authenticate to LDAP server */ + if (LDAP_SUCCESS != (ldapError = ldap_simple_bind_s(ld, userDN, bindpw))) { + switch (ldapError) { + case LDAP_INAPPROPRIATE_AUTH: + case LDAP_INVALID_CREDENTIALS: + case LDAP_INSUFFICIENT_ACCESS: + /* authenticate failed: Should not continue */ + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "task_update_registry_server_bindpw(): failed to authenticate as %s: %s", + userDN, ldap_err2string(ldapError)); + goto bailout; + case LDAP_NO_SUCH_OBJECT: + case LDAP_ALIAS_PROBLEM: + case LDAP_INVALID_DN_SYNTAX: + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "task_update_registry_server_bindpw(): bad userdn %s: %s", + userDN, ldap_err2string(ldapError)); + goto bailout; + default: + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "task_update_registry_server_bindpw(): ldap error %s", + ldap_err2string(ldapError)); + goto bailout; + } + } + + mod.mod_op = LDAP_MOD_REPLACE; + mod.mod_type = "userPassword"; + vals[0] = password; + vals[1] = NULL; + mod.mod_values = vals; + mods[0] = &mod; + mods[1] = NULL; + if (LDAP_SUCCESS != (ldapError = ldap_modify_s(ld, userDN, mods))) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "task_update_registry_server_bindpw(): ldap_modify for %s failed: %s", + userDN, ldap_err2string(ldapError)); + goto bailout; + } + + registryServer.bindPW = password; + rval = 1; +bailout: + closeLDAPConnection(ld); + if (NULL != filter) + free(filter); + return rval; } /* @@ -1155,8 +1250,11 @@ char *newpw=query; char filename[BIG_LINE]; char inbuf[BIG_LINE]; - char outbuf[32]; + char outbuf[64]; /* needs at least 36 bytes */ char path[PATH_MAX]; + char *origpw = apr_table_get(r->notes, RQ_NOTES_USERPW); + int ds_done = 0; + int admpwd_done = 0; apr_snprintf(path, sizeof(path), "%s%cadmin-serv%cconfig", serverroot, FILE_PATHSEP, FILE_PATHSEP); @@ -1192,19 +1290,36 @@ uid = inbuf; *col=0; pw=col+1; if (!update_ds(path, newpw, r)) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "failed to update siepwd on DS"); return 0; } - if (!update_adm_conf(path, newpw)) { - return 0; - } - + ds_done = 1; apr_sha1_base64(newpw, strlen(newpw), outbuf); if (!update_admpwd(path, uid, outbuf)) { - return 0; + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "failed to update admpw"); + goto recover; } + admpwd_done = 1; - task_update_registry_server_bindpw(strdup(newpw)); + if (!task_update_registry_server_bindpw(uid, strdup(newpw), origpw)) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "failed to update server bindpw"); + goto recover; + } + apr_table_set(r->notes, RQ_NOTES_USERPW, newpw); return 1; + +recover: + if (ds_done) { + update_ds(path, origpw, r); + } + if (admpwd_done) { + apr_sha1_base64(origpw, strlen(origpw), outbuf); + update_admpwd(path, uid, outbuf); + } + return 0; } /* @@ -1243,57 +1358,6 @@ } /* - * Modify adm.conf - */ -static int -update_adm_conf(char *admroot, char *newpw) -{ - FILE *f; - int i, modified=0; - static char filename[BIG_LINE]; - char buf[80]; - int linecnt=0; - char *lines[50]; - static char inbuf[BIG_LINE]; - - apr_snprintf(filename, sizeof(filename), "%s/adm.conf", admroot); - - f = fopen(filename, "r"); - if (f==NULL) { - return 0; - } - - while(fgets(inbuf, sizeof(inbuf), f) != NULL) { - if (strstr(inbuf,"siepid:") == inbuf) { /* Line starts with "Password:" */ - apr_snprintf(buf, sizeof(buf), "siepid: %s\n", newpw); - lines[linecnt++] = strdup(buf); - modified=1; - } else { - lines[linecnt++] = strdup(inbuf); - } - } - fclose(f); - - if (!modified) { - admSetCachedSIEPWD(newpw); - - return 1; - } - - f = fopen(filename, "w"); - if (f==NULL) { - return 0; - } - - for (i=0; i < linecnt; i++) { - fprintf(f, "%s", lines[i]); - } - - fclose(f); - return 1; -} - -/* * Modify userpassword in the DS */ static int @@ -2594,8 +2658,6 @@ /* Cache lookup failed, or cache entry is expired. Try DS. */ /* First try o=NetscapeRoot in the registry server */ -# define NETSCAPE_ROOT_BASEDN (char*)"o=NetscapeRoot" - ret = authenticate_user(®istryServer, NETSCAPE_ROOT_BASEDN, r->user, sent_pw, r); if (ret != DECLINED) { return OK; From fedora-directory-commits at redhat.com Thu Jun 15 17:02:41 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Thu, 15 Jun 2006 10:02:41 -0700 Subject: [Fedora-directory-commits] admservconsole/src/com/netscape/management/admserv/panel CGIAccessSetup.java, 1.1.1.1, 1.2 Message-ID: <200606151702.k5FH2fwP029034@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/admservconsole/src/com/netscape/management/admserv/panel In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29018 Modified Files: CGIAccessSetup.java Log Message: [191832] Admin Server password always remembers initial password on (part 2) Updated the in-memory admin server password when modifying the password in DS returns SUCCESS. Index: CGIAccessSetup.java =================================================================== RCS file: /cvs/dirsec/admservconsole/src/com/netscape/management/admserv/panel/CGIAccessSetup.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- CGIAccessSetup.java 22 May 2006 18:14:45 -0000 1.1.1.1 +++ CGIAccessSetup.java 15 Jun 2006 17:02:33 -0000 1.2 @@ -78,7 +78,11 @@ throw new RemoteRequestException(e); } - task.exec(); + if (0 == task.exec()) { + // Since we've updated the Admin Password, + // let's update the one in _consoleInfo. + _consoleInfo.setAuthenticationPassword(pwd); + } int status = task.getStatus(); Debug.println(adminURL + " "+status); From fedora-directory-commits at redhat.com Thu Jun 15 17:05:01 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Thu, 15 Jun 2006 10:05:01 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/cgi-src40 admpw.c, 1.5, 1.6 Message-ID: <200606151705.k5FH51NU029212@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminserver/admserv/cgi-src40 In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29109 Modified Files: admpw.c Log Message: [191832] Admin Server password always remembers initial password on (part 2) Removed fclose if the preceding fopen failed. Index: admpw.c =================================================================== RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/admpw.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- admpw.c 31 Mar 2006 22:58:20 -0000 1.5 +++ admpw.c 15 Jun 2006 17:04:58 -0000 1.6 @@ -215,7 +215,6 @@ static char inbuf[BIG_LINE]; if (f==NULL) { - fclose(f); rpt_err(SYSTEM_ERROR, i18nMsg(DBT_OPEN_ADMPW, "Can not open admpw file"), NULL, NULL); } if (fgets(inbuf, sizeof(inbuf), f) == NULL) { @@ -259,7 +258,6 @@ logMsg("newuid=%s, newpw=%s\n", newuid ? newuid:"", newpw ? newpw : ""); if ((f=fopen(filename, "r"))==NULL) { - fclose(f); rpt_err(SYSTEM_ERROR, i18nMsg(DBT_OPEN_ADMPW,"Can not open admpw file"), NULL, NULL); } if (fgets(inbuf, sizeof(inbuf), f) == NULL) { @@ -307,7 +305,6 @@ f = fopen(filename, "w"); if (f==NULL) { - fclose(f); rpt_err(SYSTEM_ERROR, i18nMsg(DBT_OPEN_ADMPW_WR, "Can not open admpw file for writing"), NULL, NULL); } @@ -341,7 +338,6 @@ f = fopen(filename, "r"); if (f==NULL) { - fclose(f); rpt_err(SYSTEM_ERROR, i18nMsg(DBT_OPEN_ADMCONF_RD, "Can not open adm.conf for reading"), NULL, NULL); } @@ -363,7 +359,6 @@ f = fopen(filename, "w"); if (f==NULL) { - fclose(f); rpt_err(SYSTEM_ERROR, i18nMsg(DBT_OPEN_ADMCONF_WR, "Can not open adm.conf for writing"), NULL, NULL); } From fedora-directory-commits at redhat.com Fri Jun 16 00:04:05 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Thu, 15 Jun 2006 17:04:05 -0700 Subject: [Fedora-directory-commits] adminserver components.mk,1.51,1.52 Message-ID: <200606160004.k5G04516020967@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminserver In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20910 Modified Files: components.mk Log Message: [195258] Changes for the internal build: .picking up the new components (SetupUtil, AdminUtil, mod_admserv, AdmServConsole) from /s/b/sbsintegration Index: components.mk =================================================================== RCS file: /cvs/dirsec/adminserver/components.mk,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- components.mk 15 Jun 2006 01:29:14 -0000 1.51 +++ components.mk 16 Jun 2006 00:04:03 -0000 1.52 @@ -137,7 +137,7 @@ # SETUPUTIL ############################################################## -SETUPUTIL_RELDATE = 20060405 +SETUPUTIL_RELDATE = 20060615 SETUPUTIL_FILE = setuputil.tar.gz SETUPUTIL_COMPNAME = setuputil/1.0 @@ -171,7 +171,7 @@ ############################################################### ADMINUTIL_SUF = 10 -ADMINUTIL_RELDATE = 20060511 +ADMINUTIL_RELDATE = 20060615 ADMINUTIL_VERSION = $(ADMINUTIL_RELDATE) ADMINUTIL_ROOT = $(NSCP_COMPDIR)/adminutil ADMINUTIL_COMPNAME = adminutil/1.0 @@ -260,7 +260,7 @@ # MOD_ADMSERV ############################################################# -MOD_ADMSERV_RELDATE = 20060511 +MOD_ADMSERV_RELDATE = 20060615 MOD_ADMSERV_SUF = 1.0 MOD_ADMSERV_VERSION = $(MOD_ADMSERV_RELDATE) @@ -404,7 +404,7 @@ ADMSERVCONSOLE_SUF = 1.0.2 ADMSERVCONSOLE_GEN_SUF = 1.0 -ADMSERVCONSOLE_RELDATE = 20060523 +ADMSERVCONSOLE_RELDATE = 20060615 ADMSERVCONSOLE_COMP = admservconsole/$(ADMSERVCONSOLE_GEN_SUF) From fedora-directory-commits at redhat.com Fri Jun 16 16:48:50 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Fri, 16 Jun 2006 09:48:50 -0700 Subject: [Fedora-directory-commits] adminserver/admserv pkgadmin.mk, 1.47, 1.48 Message-ID: <200606161648.k5GGmof1002092@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminserver/admserv In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2073 Modified Files: pkgadmin.mk Log Message: [195258] Changes for the internal build fixed find syntax. Index: pkgadmin.mk =================================================================== RCS file: /cvs/dirsec/adminserver/admserv/pkgadmin.mk,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- pkgadmin.mk 23 May 2006 22:13:36 -0000 1.47 +++ pkgadmin.mk 16 Jun 2006 16:48:47 -0000 1.48 @@ -272,9 +272,9 @@ cp -p admconfig $(ADMIN_DIR)/bin/admin; cd $(JAVA_PACKAGE_DIR) ; \ - find *.html *.gif *.jpg | $(CPIO) $(ADMIN_DIR)/java/html + find . -name "*.html" -o -name "*.gif" -o -name "*.jpg" | $(CPIO) $(ADMIN_DIR)/java/html cd $(JAVA_PACKAGE_DIR)/.. ; \ - find *.html | $(CPIO) $(ADMIN_DIR)/java/html/en + find . -name "*.html" | $(CPIO) $(ADMIN_DIR)/java/html/en endif # NOJAVA cp $(BUILD_ROOT)/lib/ldaputil/certmap.conf $(ADMIN_DIR)/shared/config From fedora-directory-commits at redhat.com Fri Jun 16 16:49:56 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Fri, 16 Jun 2006 09:49:56 -0700 Subject: [Fedora-directory-commits] adminserver/admserv/console Makefile, 1.6, 1.7 Message-ID: <200606161649.k5GGnuS7002124@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminserver/admserv/console In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2103 Modified Files: Makefile Log Message: [195258] Changes for the internal build package/java directory needs to be created explicitly. It used to be generated by the adminconsole build, which was moved out from the admin server. Index: Makefile =================================================================== RCS file: /cvs/dirsec/adminserver/admserv/console/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Makefile 23 May 2006 22:13:37 -0000 1.6 +++ Makefile 16 Jun 2006 16:49:54 -0000 1.7 @@ -41,6 +41,9 @@ cd cmdln; $(MAKE) $(MFLAGS) package: + if [ ! -d $(PACKAGEDIR) ] ; then \ + mkdir -p $(PACKAGEDIR); \ + fi cp smartupdate/goto.gif $(PACKAGEDIR) cp smartupdate/spacer.gif $(PACKAGEDIR) cp smartupdate/start-console.html $(PACKAGEDIR) From fedora-directory-commits at redhat.com Mon Jun 19 16:53:16 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 09:53:16 -0700 Subject: [Fedora-directory-commits] setuputil components.mk,1.2,1.3 Message-ID: <200606191653.k5JGrGw2014668@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/setuputil In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14578 Modified Files: components.mk Log Message: [175900] Setup Util build (RPM); comment#9 Preparation for the RPM build. 1) If these environment variables are set, the paths are used instead of the "local paths" or "internal paths". 2) If the environment variables are set, use shared libraries not the static libraries. Since the dependency on the LDAP C SDK is guaranteed to be solved when we use rpm for the installation, we don't need to link the static libraries (Plus, the static libraries -- libldap50.a, liblber50.a, libldif50.a are not part of mozldap nor mozldap-devel). Index: components.mk =================================================================== RCS file: /cvs/dirsec/setuputil/components.mk,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- components.mk 23 Feb 2006 22:50:21 -0000 1.2 +++ components.mk 19 Jun 2006 16:53:13 -0000 1.3 @@ -208,15 +208,26 @@ # LDAP SDK ################################################### -ifdef LDAPSDK_SOURCE_ROOT - LDAPSDK_LIBPATH = $(LDAPSDK_SOURCE_ROOT)/dist/lib +ifdef LDAPCSDK_INCLUDE_DIR + LDAPSDK_INCDIR = $(LDAPCSDK_INCLUDE_DIR) +else + ifdef LDAPSDK_SOURCE_ROOT LDAPSDK_INCDIR = $(LDAPSDK_SOURCE_ROOT)/dist/public/ldap - LDAPSDK_BINPATH = $(LDAPSDK_SOURCE_ROOT)/dist/bin + else + LDAPSDK_INCDIR = $(LDAP_ROOT)/include + endif +endif + +ifdef LDAPCSDK_LIB_DIR + LDAPSDK_LIBPATH = $(LDAPCSDK_LIB_DIR) else + ifdef LDAPSDK_SOURCE_ROOT + LDAPSDK_LIBPATH = $(LDAPSDK_SOURCE_ROOT)/dist/lib + else LDAPSDK_LIBPATH = $(LDAP_ROOT)/lib - LDAPSDK_INCDIR = $(LDAP_ROOT)/include - LDAPSDK_BINPATH = $(LDAP_ROOT)/bin + endif endif + LDAPSDK_INCLUDE = -I$(LDAPSDK_INCDIR) # package the command line programs @@ -229,22 +240,24 @@ LDAP_LIBPATH = $(LDAPSDK_LIBPATH) LDAP_INCLUDE = $(LDAPSDK_INCDIR) -LDAP_TOOLDIR = $(LDAPSDK_BINPATH) ifeq ($(ARCH), WINNT) - LDAP_LIBNAMES = ldapssl32v$(LDAP_SUF) ldap32v$(LDAP_SUF) ldappr32v$(LDAP_SUF) - LDAPDLL_NAME = $(addprefix ns, $(LDAP_LIBNAMES)) - LDAPOBJNAME = $(addsuffix .lib, $(LDAPDLL_NAME)) + LDAP_LIBNAMES = ldapssl32v$(LDAP_SUF) ldap32v$(LDAP_SUF) ldappr32v$(LDAP_SUF) + LDAPDLL_NAME = $(addprefix ns, $(LDAP_LIBNAMES)) + LDAPOBJNAME = $(addsuffix .lib, $(LDAPDLL_NAME)) + LDAPLINK = $(addprefix $(LDAP_LIBPATH)/, $(LDAPOBJNAME)) else - LDAP_SOLIB_NAMES = ssldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) ldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) prldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) - LDAP_LIBNAMES = ldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) lber$(LDAP_SUF)$(LDAP_DLL_PRESUF) - LDAP_SOLIBS = $(addsuffix .$(LDAP_DLL_SUFFIX), $(addprefix lib, $(LDAP_SOLIB_NAMES))) - LDAPOBJNAME = $(addsuffix .a, $(addprefix lib, $(LDAP_LIBNAMES))) - LDAPLINK = -L$(LDAP_LIBPATH) $(addprefix -l, $(LDAP_SOLIB_NAMES)) + LDAP_SOLIB_NAMES = ssldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) ldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) prldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) + LDAP_LIBNAMES = ldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) lber$(LDAP_SUF)$(LDAP_DLL_PRESUF) + LDAP_SOLIBS = $(addsuffix .$(LDAP_DLL_SUFFIX), $(addprefix lib, $(LDAP_SOLIB_NAMES))) + LDAPOBJNAME = $(addsuffix .a, $(addprefix lib, $(LDAP_LIBNAMES))) + ifdef LDAPCSDK_LIB_DIR # we are using the system LDAPCSDK. + LDAPLINK = -L$(LDAP_LIBPATH) $(addprefix -l, $(LDAP_SOLIB_NAMES)) + else + LDAPLINK = $(addprefix $(LDAP_LIBPATH)/, $(LDAPOBJNAME)) + endif endif -LDAPLINK = $(addprefix $(LDAP_LIBPATH)/, $(LDAPOBJNAME)) - ################################################################# # Infozip (for Windows Packaging) ################################################################# From fedora-directory-commits at redhat.com Mon Jun 19 17:38:38 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 17:38:38 -0000 Subject: [Fedora-directory-commits] ldapserver/ldap/cm Makefile,1.53,1.54 Message-ID: <200604042126.k34LQt4E002937@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/ldapserver/ldap/cm In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2915 Modified Files: Makefile Log Message: setup.inf, setup.res, silent.inf, unzip_wrapper.pl, LICENSE.txt, README.txt were missing from the tar-gz package file. Index: Makefile =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/cm/Makefile,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- Makefile 29 Mar 2006 19:45:15 -0000 1.53 +++ Makefile 4 Apr 2006 21:26:52 -0000 1.54 @@ -194,6 +194,12 @@ ADMIN_SERVER_TARGZ=$(ADMINSERVER_PKG) ADMIN_IMPORTS_TARGZ=$(ADMIN_SERVER_TARGZ) +ifeq ($(USE_SETUPUTIL), 1) + LDAP_PACKAGE_FILES:=setup setup.inf setup.res slient.inf unzip_wrapper.pl dsktune LICENSE.txt README.txt slapd +else + LDAP_PACKAGE_FILES:=setup dsktune slapd +endif + # these are files we need to put in the command line/console only package #LDAPSDK_IMPORTS=ldapsearch ldapdelete ldapmodify @@ -751,8 +757,8 @@ # build the combined packages tar file; use h flag to follow symlinks ifdef BUILD_SHIP ifndef BUILD_PATCH - cd $(INSTDIR); $(TAR) cvfh - setup slapd \ - dsktune $(ADMIN_IMPORTS) | gzip -f > $(BUILD_SHIP)/$(FTPNAMEGZ) + cd $(INSTDIR); $(TAR) cvfh - $(LDAP_PACKAGE_FILES) \ + $(ADMIN_IMPORTS) | gzip -f > $(BUILD_SHIP)/$(FTPNAMEGZ) endif ifeq ($(DEBUG), optimize) # $(REMSH) "/u/svbld/bin/preRtm $(BUILD_SHIP) $(FTPNAMEGZ) svbld" @@ -760,8 +766,8 @@ else echo base/unzipped > $(TMPLIST) echo admin/unzipped >> $(TMPLIST) - cd $(INSTDIR); $(TAR) cvfh - -X $(TMPLIST) setup slapd \ - dsktune $(ADMIN_IMPORTS) | gzip -f > ../all$(NS_BUILD_FLAVOR).tar.gz + cd $(INSTDIR); $(TAR) cvfh - -X $(TMPLIST) $(LDAP_PACKAGE_FILES) \ + $(ADMIN_IMPORTS) | gzip -f > ../all$(NS_BUILD_FLAVOR).tar.gz rm -f $(TMPLIST) endif # BUILD_SHIP #cp $(INSTDIR).tar.gz $(BUILD_SHIP) From fedora-directory-commits at redhat.com Mon Jun 19 17:38:48 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 17:38:48 -0000 Subject: [Fedora-directory-commits] adminserver components.mk,1.47,1.48 Message-ID: <200604052005.k35K5I7T023453@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminserver In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv23436 Modified Files: components.mk Log Message: Updated SETUPUTIL_RELDATE to 20060405. Index: components.mk =================================================================== RCS file: /cvs/dirsec/adminserver/components.mk,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- components.mk 29 Mar 2006 02:19:52 -0000 1.47 +++ components.mk 5 Apr 2006 20:05:15 -0000 1.48 @@ -137,7 +137,7 @@ # SETUPUTIL ############################################################## -SETUPUTIL_RELDATE = 20060327 +SETUPUTIL_RELDATE = 20060405 SETUPUTIL_FILE = setuputil.tar.gz SETUPUTIL_COMPNAME = setuputil/1.0 From fedora-directory-commits at redhat.com Mon Jun 19 17:39:04 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 17:39:04 -0000 Subject: [Fedora-directory-commits] ldapserver/ldap javarules.mk,1.6,1.7 Message-ID: <200604070134.k371Y8jm026718@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/ldapserver/ldap In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26597/ldap Modified Files: javarules.mk Log Message: [186642] Directory Server Makefile updates for Internal build (Comment #6) 1) picked up the latest components including Cyrus SASL, Perldap, SetupUtil, and AdminServer 2) fixed the java paths for the internal build. 3) added an option -AA to HP-UX C++ compiler to adjust to SetupUtil build (use libstd 2) 4) replaced , and with , , respectively in ldap/cm/newinst/ux-dialog.cc 5) package svrcore and perldap, which were dropped in the current ldap/cm/Makefile 6) added a perl script genPerlDAPInf.pl to generate perldap.inf file Index: javarules.mk =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/javarules.mk,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- javarules.mk 3 Oct 2005 19:53:46 -0000 1.6 +++ javarules.mk 7 Apr 2006 01:33:30 -0000 1.7 @@ -68,54 +68,34 @@ PATH_SEP := : ifeq ($(OS), Windows_NT) - GET_JAVA_FROM_PATH := 1 - PATH_SEP := ; - EXE_SUFFIX := .exe + GET_JAVA_FROM_PATH := 1 + PATH_SEP := ; + EXE_SUFFIX := .exe endif -# For NT, assume a locally installed JDK -ifdef GET_JAVA_FROM_PATH +ifeq ($(INTERNAL_BUILD), 1) + # For UNIX, use JDK and JAR files over NFS + ifeq ($(ARCH), Linux) + JDK_VERSION:=1.4.2_SR3 + JDK_VERSDIR:=ibmjdk/$(JDK_VERSION)/$(NSOBJDIR_NAME) + else + ifeq ($(ARCH), HPUX) + JDK_VERSION:=1.4.2_09 + JDK_VERSDIR:=hpjdk/$(JDK_VERSION) + else + JDK_VERSION:=1.4.2_10 # Solaris + JDK_VERSDIR:=jdk/$(JDK_VERSION)/$(NSOBJDIR_NAME) + endif + endif + JDKLIB:=$(COMPONENTS_DIR)/$(JDK_VERSDIR)/lib/tools.jar + JAVABINDIR:=$(COMPONENTS_DIR)/$(JDK_VERSDIR)/bin +else # INTERNAL_BUILD # Figure out where the java lib .jar files are, from where javac is JDKCOMP := $(shell which javac) JDKPRELIB := $(subst bin/javac$(EXE_SUFFIX),lib,$(JDKCOMP)) JDKLIB := $(addprefix $(JDKPRELIB)/,tools.jar) -else - -# For UNIX, use JDK and JAR files over NFS -# Use NT classes.zip; doesn't matter that it was compiled on NT -# -# Version 1.4.0_01 of the JDK does not seem to run well on RHEL 3.0 - ifeq ($(ARCH), Linux) - JDK_VERSION=1.4.2 - else - ifeq ($(ARCH), HPUX) - JDK_VERSION=1.4.1_05 - else - JDK_VERSION=1.4.0_01 - endif - endif +endif - JDK_VERSDIR=jdk$(JDK_VERSION) - JDKLIB=/share/builds/components/jdk/$(JDK_VERSION)/$(PRETTY_ARCH)/lib/tools.jar - ifeq ($(NSOS_ARCH), IRIX) -# Get IRIX compiler from tools directory, currently 1.1.3 - JAVABINDIR=/tools/ns/bin - else - ifeq ($(ARCH), AIX) -# Get AIX compiler from tools directory, currently 1.1.2 - JAVABINDIR=/tools/ns/bin - else - ifeq ($(ARCH), OSF1) - JAVABINDIR=/share/builds/components/jdk/1.1.6beta/OSF1/bin - else -# Solaris, Linux, HP/UX and any others: - JDK_DIR=$(COMPONENTS_DIR)/jdk - JAVABINDIR=$(JDK_DIR)/$(JDK_VERSION)/$(PRETTY_ARCH)/bin - endif - endif - endif -endif - CLASSPATH := $(JAVA_SRC_DIR)$(PATH_SEP)$(LDAPJARFILE) ifndef JAVA From fedora-directory-commits at redhat.com Mon Jun 19 17:39:06 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 17:39:06 -0000 Subject: [Fedora-directory-commits] ldapserver/config HP-UXB.11.23.mk, NONE, 1.1 Message-ID: <200604070133.k371XedD026704@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/ldapserver/config In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26597/config Added Files: HP-UXB.11.23.mk Log Message: [186642] Directory Server Makefile updates for Internal build (Comment #6) 1) picked up the latest components including Cyrus SASL, Perldap, SetupUtil, and AdminServer 2) fixed the java paths for the internal build. 3) added an option -AA to HP-UX C++ compiler to adjust to SetupUtil build (use libstd 2) 4) replaced , and with , , respectively in ldap/cm/newinst/ux-dialog.cc 5) package svrcore and perldap, which were dropped in the current ldap/cm/Makefile 6) added a perl script genPerlDAPInf.pl to generate perldap.inf file --- NEW FILE HP-UXB.11.23.mk --- # # BEGIN COPYRIGHT BLOCK # 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; version 2 of the License. # # 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., 59 Temple # Place, Suite 330, Boston, MA 02111-1307 USA. # # In addition, as a special exception, Red Hat, Inc. gives You the additional # right to link the code of this Program with code not covered under the GNU # General Public License ("Non-GPL Code") and to distribute linked combinations # including the two, subject to the limitations in this paragraph. Non-GPL Code # permitted under this exception must only link to the code of this Program # through those well defined interfaces identified in the file named EXCEPTION # found in the source code files (the "Approved Interfaces"). The files of # Non-GPL Code may instantiate templates or use macros or inline functions from # the Approved Interfaces without causing the resulting work to be covered by # the GNU General Public License. Only Red Hat, Inc. may make changes or # additions to the list of Approved Interfaces. You must obey the GNU General # Public License in all respects for all of the Program code and other code used # in conjunction with the Program except the Non-GPL Code covered by this # exception. 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 # provide this exception without modification, you must delete this exception # statement from your version and license this file solely under the GPL without # exception. # # # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. # Copyright (C) 2006 Red Hat, Inc. # All rights reserved. # END COPYRIGHT BLOCK # # # Config stuff for HP-UX.11.23 # include $(DEPTH)/config/HP-UX.mk From fedora-directory-commits at redhat.com Mon Jun 19 17:39:07 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 17:39:07 -0000 Subject: [Fedora-directory-commits] ldapserver/ldap/servers/slapd Makefile, 1.11, 1.12 Message-ID: <200604070133.k371Xeog026699@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/ldapserver/ldap/servers/slapd In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26597/ldap/servers/slapd Modified Files: Makefile Log Message: [186642] Directory Server Makefile updates for Internal build (Comment #6) 1) picked up the latest components including Cyrus SASL, Perldap, SetupUtil, and AdminServer 2) fixed the java paths for the internal build. 3) added an option -AA to HP-UX C++ compiler to adjust to SetupUtil build (use libstd 2) 4) replaced , and with , , respectively in ldap/cm/newinst/ux-dialog.cc 5) package svrcore and perldap, which were dropped in the current ldap/cm/Makefile 6) added a perl script genPerlDAPInf.pl to generate perldap.inf file Index: Makefile =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/Makefile,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Makefile 29 Mar 2006 19:46:21 -0000 1.11 +++ Makefile 7 Apr 2006 01:33:37 -0000 1.12 @@ -91,12 +91,12 @@ endif ifeq ($(ARCH), HPUX) -ifeq ($(OS_TEST),ia64) -LDAP_DONT_USE_SMARTHEAP=1 -ifeq ($(DEBUG), optimize) -CFLAGS+=+O3 -endif -endif + ifeq ($(NSOS_TEST1),ia64) + LDAP_DONT_USE_SMARTHEAP=1 + ifeq ($(DEBUG), optimize) + CFLAGS+=+O3 + endif + endif endif # Don't use smartheap for debug builds @@ -200,12 +200,12 @@ ifeq ($(DEBUG), full) ifeq ($(USE_64), 1) EXTRA_LIBS_TEMP:=$(EXTRA_LIBS) - ifneq ($(OS_TEST), ia64) + ifneq ($(NSOS_TEST1), ia64) EXTRA_LIBS += /opt/langtools/lib/pa20_64/end.o endif else EXTRA_LIBS_TEMP:=$(EXTRA_LIBS) - ifneq ($(OS_TEST), ia64) + ifneq ($(NSOS_TEST1), ia64) EXTRA_LIBS += /opt/langtools/lib/end.o endif endif #USE_64 From fedora-directory-commits at redhat.com Mon Jun 19 17:39:07 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 17:39:07 -0000 Subject: [Fedora-directory-commits] ldapserver/ldap/cm/newinst ux-dialog.cc, 1.8, 1.9 Message-ID: <200604070133.k371XdLo026695@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/ldapserver/ldap/cm/newinst In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26597/ldap/cm/newinst Modified Files: ux-dialog.cc Log Message: [186642] Directory Server Makefile updates for Internal build (Comment #6) 1) picked up the latest components including Cyrus SASL, Perldap, SetupUtil, and AdminServer 2) fixed the java paths for the internal build. 3) added an option -AA to HP-UX C++ compiler to adjust to SetupUtil build (use libstd 2) 4) replaced , and with , , respectively in ldap/cm/newinst/ux-dialog.cc 5) package svrcore and perldap, which were dropped in the current ldap/cm/Makefile 6) added a perl script genPerlDAPInf.pl to generate perldap.inf file Index: ux-dialog.cc =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/cm/newinst/ux-dialog.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ux-dialog.cc 19 Apr 2005 22:07:21 -0000 1.8 +++ ux-dialog.cc 7 Apr 2006 01:33:37 -0000 1.9 @@ -49,17 +49,20 @@ ** *********************************************************************/ -#include -#include -#include -/* Newer g++ wants the new std header forms */ -#if defined( Linux ) +#if !defined(HPUX) || defined(_HP_NAMESPACE_STD) +#include #include +#include +using namespace std; using std::ostrstream; -/* But some platforms won't accept those (specifically HP-UX aCC */ #else +/* older HP-UX compiler, using libstd 1 (no -AA) */ +#include /* use old name on older systems */ #include +#include #endif + +#include #include #include #include From fedora-directory-commits at redhat.com Mon Jun 19 17:39:09 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 17:39:09 -0000 Subject: [Fedora-directory-commits] ldapserver/ldap/cm genPerlDAPInf.pl, NONE, 1.1 Makefile, 1.54, 1.55 Message-ID: <200604070133.k371XdE2026689@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/ldapserver/ldap/cm In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26597/ldap/cm Modified Files: Makefile Added Files: genPerlDAPInf.pl Log Message: [186642] Directory Server Makefile updates for Internal build (Comment #6) 1) picked up the latest components including Cyrus SASL, Perldap, SetupUtil, and AdminServer 2) fixed the java paths for the internal build. 3) added an option -AA to HP-UX C++ compiler to adjust to SetupUtil build (use libstd 2) 4) replaced , and with , , respectively in ldap/cm/newinst/ux-dialog.cc 5) package svrcore and perldap, which were dropped in the current ldap/cm/Makefile 6) added a perl script genPerlDAPInf.pl to generate perldap.inf file --- NEW FILE genPerlDAPInf.pl --- # # BEGIN COPYRIGHT BLOCK # 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; version 2 of the License. # # 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., 59 Temple # Place, Suite 330, Boston, MA 02111-1307 USA. # # In addition, as a special exception, Red Hat, Inc. gives You the additional # right to link the code of this Program with code not covered under the GNU # General Public License ("Non-GPL Code") and to distribute linked combinations # including the two, subject to the limitations in this paragraph. Non-GPL Code # permitted under this exception must only link to the code of this Program # through those well defined interfaces identified in the file named EXCEPTION # found in the source code files (the "Approved Interfaces"). The files of # Non-GPL Code may instantiate templates or use macros or inline functions from # the Approved Interfaces without causing the resulting work to be covered by # the GNU General Public License. Only Red Hat, Inc. may make changes or # additions to the list of Approved Interfaces. You must obey the GNU General # Public License in all respects for all of the Program code and other code used # in conjunction with the Program except the Non-GPL Code covered by this # exception. 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 # provide this exception without modification, you must delete this exception # statement from your version and license this file solely under the GPL without # exception. # # # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. # Copyright (C) 2006 Red Hat, Inc. # All rights reserved. # END COPYRIGHT BLOCK # # Usage: genPerlDAPInf.pl $vendor = "Red Hat, Inc."; if ($#ARGV < 1) { print "Usage: genPerlDAPInf.pl []\n"; exit 1; } $outfile = $ARGV[0]; $version = $ARGV[1]; if ($#ARGV >= 2) { $vendor = $ARGV[2]; } print "outfile: $outfile, version: $version, vendor: $vendor\n"; ($nodot_version = $version) =~ tr/\.//d; $component = "perldap" . $nodot_version; open(OUT, ">$outfile") or die "Error: could not write file $outfile: $!"; print OUT "[General]\n"; print OUT "Name=PerLDAP\n"; print OUT "Description=This is mozilla.org PerLDAP.\n"; print OUT "Components=$component\n\n"; print OUT "[$component]\n"; print OUT "Description=The mozilla.org PerLDAP $version\n"; print OUT "NickName=$component\n"; print OUT "Name=PerLDAP $version\n"; print OUT "SourcePath=perldap\n"; print OUT "Vendor=$vendor\n"; print OUT "Security=none\n"; print OUT "Version=$version\n"; print OUT "Compatible=$version\n"; print OUT "Archive=perldap-$version.zip\n"; print OUT "Visible=FALSE\n"; print OUT "Checked=TRUE\n"; close OUT; exit 0; Index: Makefile =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/cm/Makefile,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- Makefile 4 Apr 2006 21:26:52 -0000 1.54 +++ Makefile 7 Apr 2006 01:33:36 -0000 1.55 @@ -195,7 +195,7 @@ ADMIN_IMPORTS_TARGZ=$(ADMIN_SERVER_TARGZ) ifeq ($(USE_SETUPUTIL), 1) - LDAP_PACKAGE_FILES:=setup setup.inf setup.res slient.inf unzip_wrapper.pl dsktune LICENSE.txt README.txt slapd + LDAP_PACKAGE_FILES:=setup setup.inf setup.res silent.inf unzip_wrapper.pl svrcore dsktune LICENSE.txt README.txt slapd else LDAP_PACKAGE_FILES:=setup dsktune slapd endif @@ -626,12 +626,24 @@ # this gets setup, setup.inf, silent.inf, the zip wrapper, and svrcore, among others ifeq ($(USE_SETUPUTIL), 1) cp -R $(SETUPUTIL_BINPATH)/* $(INSTDIR) + @echo "removing unzipped dir" + @dirs=`ls $(INSTDIR)`; for adir in $$dirs ; do \ + if [ -d $(INSTDIR)/$$adir/unzipped ] ; then \ + rm -rf $(INSTDIR)/$$adir/unzipped; \ + fi; \ + done ifeq ($(DS_BRAND), redhat) - cd $(INSTDIR); \ - $(RELTOOLSPATH)/brandver.pl -i $(ABS_ROOT)/branding/rhds/setup.dat; \ + @(cd $(INSTDIR); \ + $(PERL) $(RELTOOLSPATH)/brandver.pl -i $(ABS_ROOT)/branding/rhds/setup.dat; \ cat setup.inf | sed -e "s/^#Resource/Resource/" > setup.inf.tmp; \ - mv setup.inf.tmp setup.inf + mv setup.inf.tmp setup.inf) +endif endif + +ifeq ($(USE_PERLDAP), 1) + mkdir $(INSTDIR)/perldap + cp -R $(PERLDAP_BUILT_DIR)/* $(INSTDIR)/perldap + $(PERL) genPerlDAPInf.pl $(INSTDIR)/perldap/perldap.inf 1.5 "Fedora Project" endif # copy in our product .inf files From fedora-directory-commits at redhat.com Mon Jun 19 17:39:09 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 17:39:09 -0000 Subject: [Fedora-directory-commits] ldapserver Makefile, 1.31, 1.32 component_versions.mk, 1.43, 1.44 components.mk, 1.44, 1.45 internal_buildpaths.mk, 1.8, 1.9 internal_comp_deps.mk, 1.38, 1.39 nsconfig.mk, 1.19, 1.20 nsperl.mk, 1.5, 1.6 Message-ID: <200604070134.k371Y2sv026712@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/ldapserver In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26597 Modified Files: Makefile component_versions.mk components.mk internal_buildpaths.mk internal_comp_deps.mk nsconfig.mk nsperl.mk Log Message: [186642] Directory Server Makefile updates for Internal build (Comment #6) 1) picked up the latest components including Cyrus SASL, Perldap, SetupUtil, and AdminServer 2) fixed the java paths for the internal build. 3) added an option -AA to HP-UX C++ compiler to adjust to SetupUtil build (use libstd 2) 4) replaced , and with , , respectively in ldap/cm/newinst/ux-dialog.cc 5) package svrcore and perldap, which were dropped in the current ldap/cm/Makefile 6) added a perl script genPerlDAPInf.pl to generate perldap.inf file Index: Makefile =================================================================== RCS file: /cvs/dirsec/ldapserver/Makefile,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- Makefile 29 Mar 2006 19:42:39 -0000 1.31 +++ Makefile 7 Apr 2006 01:33:30 -0000 1.32 @@ -199,17 +199,17 @@ brandDirectory: $(RELTOOLSPATH)/brandver.pl @echo ==== Branding LDAP Server ========== - $(RELTOOLSPATH)/brandver.pl -i branding/rhds/brandver.dat -s redhat-ds.spec + $(PERL) $(RELTOOLSPATH)/brandver.pl -i branding/rhds/brandver.dat -s redhat-ds.spec @echo ==== Finished Branding LDAP Server ========== versionDirectory: $(RELTOOLSPATH)/brandver.pl @echo ==== Debranding LDAP Server ========== - $(RELTOOLSPATH)/brandver.pl -i branding/fedora/brandver.dat -s fedora-ds.spec + $(PERL) $(RELTOOLSPATH)/brandver.pl -i branding/fedora/brandver.dat -s fedora-ds.spec @echo ==== Finished Debranding LDAP Server ========== normalizeDirectory: $(RELTOOLSPATH)/brandver.pl @echo ==== Normalizing LDAP Server ========== - $(RELTOOLSPATH)/brandver.pl -i branding/fedora/normalize.dat -s redhat-ds.spec + $(PERL) $(RELTOOLSPATH)/brandver.pl -i branding/fedora/normalize.dat -s redhat-ds.spec @echo ==== Normalizing Branding LDAP Server ========== buildAndPkgDirectory: buildDirectory pkgDirectory Index: component_versions.mk =================================================================== RCS file: /cvs/dirsec/ldapserver/component_versions.mk,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- component_versions.mk 29 Mar 2006 19:42:39 -0000 1.43 +++ component_versions.mk 7 Apr 2006 01:33:30 -0000 1.44 @@ -63,10 +63,10 @@ # LIBDB DBDEFS:= ifndef DB_MAJOR_MINOR -DB_MAJOR_MINOR:=db42 +DB_MAJOR_MINOR:=db-4.2 endif ifndef DB_VERSION - DB_VERSION:=20040813 + DB_VERSION:=20060308 endif # SMARTHEAP @@ -109,7 +109,7 @@ # admin server ifndef ADM_RELDATE - ADM_RELDATE = 20060328 + ADM_RELDATE = 20060405 endif ifndef ADM_VERSDIR ADM_VERSDIR = adminserver/1.0 @@ -122,7 +122,7 @@ # setuputil ifndef SETUPUTIL_RELDATE - SETUPUTIL_RELDATE = 20060327 + SETUPUTIL_RELDATE = 20060405 endif ifndef SETUPUTIL_VER SETUPUTIL_VER = 10 @@ -166,7 +166,7 @@ endif ifndef PERLDAP_VERSION - PERLDAP_VERSION=1.5/20051028 + PERLDAP_VERSION=1.5/20060331 endif ifndef JSS_COMP @@ -185,7 +185,7 @@ SASL_VERSDIR=cyrus endif ifndef SASL_RELDATE - SASL_RELDATE=v2.1.20 + SASL_RELDATE=v2.1.20.1 endif # jakarta/axis for DSMLGW Index: components.mk =================================================================== RCS file: /cvs/dirsec/ldapserver/components.mk,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- components.mk 29 Mar 2006 19:42:39 -0000 1.44 +++ components.mk 7 Apr 2006 01:33:30 -0000 1.45 @@ -194,7 +194,8 @@ SECURITY_INCLUDE = -I$(SECURITY_INCDIR) # add crlutil and ocspclnt when we support CRL and OCSP cert checking in DS SECURITY_BINNAMES = certutil derdump pp pk12util ssltap modutil shlibsign -SECURITY_LIBNAMES = ssl3 nss3 softokn3 +# as of NSS 3.11, no longer need to link with softokn3 +SECURITY_LIBNAMES = ssl3 nss3 # these libs have a corresponding .chk file SECURITY_NEED_CHK = softokn3 @@ -359,7 +360,7 @@ SASL_INCDIR = $(SASL_SOURCE_ROOT)/include/sasl else SASL_LIBPATH = $(SASL_BUILD_DIR)/lib - SASL_INCDIR = $(SASL_BUILD_DIR)/include + SASL_INCDIR = $(SASL_BUILD_DIR)/include/sasl endif endif SASL_INCLUDE = $(SASL_INCDIR) Index: internal_buildpaths.mk =================================================================== RCS file: /cvs/dirsec/ldapserver/internal_buildpaths.mk,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- internal_buildpaths.mk 29 Oct 2005 02:21:40 -0000 1.8 +++ internal_buildpaths.mk 7 Apr 2006 01:33:30 -0000 1.9 @@ -118,11 +118,10 @@ #DB_SOURCE_ROOT = $(BUILD_ROOT)/../db-4.2.52.NC # DB_MAJOR_MINOR is the root name for the db shared library -# source builds use db-4.2 - uncomment this if using source -#DB_MAJOR_MINOR := db-4.2 +DB_MAJOR_MINOR := db-4.2 ifndef DB_SOURCE_ROOT -DB_MAJOR_MINOR := db42 -db_component_name=$(DB_MAJOR_MINOR) +# db_component_name is the dir name in /s/b/c +db_component_name=db42 db_path_config :=$(NSCP_DISTDIR)/$(db_component_name) endif # DB_SOURCE_ROOT Index: internal_comp_deps.mk =================================================================== RCS file: /cvs/dirsec/ldapserver/internal_comp_deps.mk,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- internal_comp_deps.mk 29 Mar 2006 19:42:39 -0000 1.38 +++ internal_comp_deps.mk 7 Apr 2006 01:33:30 -0000 1.39 @@ -176,7 +176,7 @@ ifndef SASL_SOURCE_ROOT ifneq ($(ARCH), Linux) -SASL_RELEASE = $(COMPONENTS_DIR)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME) +SASL_RELEASE = $(COMPONENTS_DIR_DEV)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME) SASL_DEP = $(SASL_INCLUDE)/sasl.h ifndef SASL_PULL_METHOD SASL_PULL_METHOD = $(COMPONENT_PULL_METHOD) @@ -216,10 +216,11 @@ ifndef DB_SOURCE_ROOT #if no version specified, we'll use the latest one ifndef DB_VERSION - DB_VERSION=20040130 + DB_VERSION=20060308 endif # define the paths to the component parts -db_components_share=$(COMPONENTS_DIR)/$(db_component_name) +#db_components_share=$(COMPONENTS_DIR)/$(db_component_name) +db_components_share=$(COMPONENTS_DIR_DEV)/$(db_component_name) MY_NSOBJDIR_TAG=$(NSOBJDIR_TAG).OBJ db_release_config =$(db_components_share)/$(DB_VERSION)/$(NSCONFIG_NOTAG)$(MY_NSOBJDIR_TAG) # add ",bin" to DB_FILES if you want the programs like db_verify, db_recover, etc. @@ -508,7 +509,18 @@ #PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR_DEV)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32) ifeq ($(BUILD_MODE), int) -PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR_DEV)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32) + PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR_DEV)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32) + ifeq ($(BUILD_ARCH), RHEL4) + # use 64-bit perl on 64-bit RHEL4; 32-bit on 32-bit RHEL4 + PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR_DEV)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME) + endif + ifeq ($(BUILD_ARCH), HPUX) + HPUX_ARCH := $(shell uname -m) + ifeq ($(HPUX_ARCH), ia64) + # use 64-bit perl on 64-bit IPF HP-UX + PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR_DEV)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME) + endif + endif else PERLDAP_COMPONENT_DIR = $(FED_COMPONENTS_DIR)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32) endif Index: nsconfig.mk =================================================================== RCS file: /cvs/dirsec/ldapserver/nsconfig.mk,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- nsconfig.mk 28 Feb 2006 21:51:21 -0000 1.19 +++ nsconfig.mk 7 Apr 2006 01:33:30 -0000 1.20 @@ -67,6 +67,7 @@ USE_DSGW:=1 USE_JAVATOOLS:=1 USE_SETUPUTIL:=1 + USE_PERLDAP:=1 else USE_ADMINSERVER:=1 USE_CONSOLE:=1 @@ -75,6 +76,7 @@ USE_DSGW:=1 USE_JAVATOOLS:=1 USE_SETUPUTIL:=1 + USE_PERLDAP:=1 GET_JAVA_FROM_PATH := 1 GET_ANT_FROM_PATH := 1 USE_PERL_FROM_PATH := 1 @@ -532,13 +534,15 @@ CC=cc -Ae -D_POSIX_C_SOURCE=199506L ifeq ($(BUILD_MODULE), HTTP_ADMIN) ifeq ($(NSOS_RELEASE),B.11.23) -CXX=aCC -AP -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L -ext +# -AA -- new-lib libstd 2 +CXX=aCC -AA -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L -ext else CXX=aCC -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L -ext endif else ifeq ($(NSOS_RELEASE),B.11.23) -CXX=aCC -AP -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L -ext +# -AA -- new-lib libstd 2 +CXX=aCC -AA -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L -ext else CXX=aCC -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L -ext endif Index: nsperl.mk =================================================================== RCS file: /cvs/dirsec/ldapserver/nsperl.mk,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- nsperl.mk 21 Oct 2005 19:21:04 -0000 1.5 +++ nsperl.mk 7 Apr 2006 01:33:30 -0000 1.6 @@ -41,7 +41,7 @@ NSPERL_RELDATE := 20020626 # default; will be redefined below for specific platform #PERL=$(NSPERL_COMPONENT_DIR)/lib/$(NSPERL_VERSION)/nsperl -PERL=/share/builds/sbstools/nsPerl/$(NSPERL_RELDATE)/$(NSOBJDIR_NAME_32)/nsperl +PERL=perl ifeq ($(BUILD_ARCH), WINNT) PERL=nsperl endif From fedora-directory-commits at redhat.com Mon Jun 19 18:59:46 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Mon, 19 Jun 2006 11:59:46 -0700 Subject: [Fedora-directory-commits] adminserver/admserv pkgadmin.mk, 1.48, 1.49 Message-ID: <200606191859.k5JIxkES020994@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/adminserver/admserv In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20945 Modified Files: pkgadmin.mk Log Message: [195258] Changes for the internal build; comment#14 fixed typo introduced in 1.47. Index: pkgadmin.mk =================================================================== RCS file: /cvs/dirsec/adminserver/admserv/pkgadmin.mk,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- pkgadmin.mk 16 Jun 2006 16:48:47 -0000 1.48 +++ pkgadmin.mk 19 Jun 2006 18:59:44 -0000 1.49 @@ -273,7 +273,7 @@ cd $(JAVA_PACKAGE_DIR) ; \ find . -name "*.html" -o -name "*.gif" -o -name "*.jpg" | $(CPIO) $(ADMIN_DIR)/java/html - cd $(JAVA_PACKAGE_DIR)/.. ; \ + cd $(JAVA_PACKAGE_DIR) ; \ find . -name "*.html" | $(CPIO) $(ADMIN_DIR)/java/html/en endif # NOJAVA From fedora-directory-commits at redhat.com Tue Jun 20 20:25:23 2006 From: fedora-directory-commits at redhat.com (Robert Crittenden (rcritten)) Date: Tue, 20 Jun 2006 13:25:23 -0700 Subject: [Fedora-directory-commits] mod_nss mod_nss.c, 1.11, 1.12 mod_nss.h, 1.11, 1.12 nss_engine_config.c, 1.10, 1.11 nss_engine_init.c, 1.18, 1.19 nss_engine_pphrase.c, 1.5, 1.6 Message-ID: <200606202025.k5KKPNLk010196@cvs-int.fedora.redhat.com> Author: rcritten Update of /cvs/dirsec/mod_nss In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10135 Modified Files: mod_nss.c mod_nss.h nss_engine_config.c nss_engine_init.c nss_engine_pphrase.c Log Message: 196070 Fix compilation warnings Index: mod_nss.c =================================================================== RCS file: /cvs/dirsec/mod_nss/mod_nss.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- mod_nss.c 2 Mar 2006 19:21:54 -0000 1.11 +++ mod_nss.c 20 Jun 2006 20:25:20 -0000 1.12 @@ -224,7 +224,7 @@ if (rv != SECSuccess) { char *remote = CERT_GetCommonName(&peerCert->subject); ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, - "SSL Proxy: Possible man-in-the-middle attack. The remove server is %s, we expected %s", remote, c->remote_host, rv); + "SSL Proxy: Possible man-in-the-middle attack. The remove server is %s, we expected %s", remote, c->remote_host); PORT_Free(remote); } } else { @@ -234,7 +234,7 @@ break; default: ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, - "Bad remote server certificate.", err); + "Bad remote server certificate: %d", err); nss_log_nss_error(APLOG_MARK, APLOG_ERR, NULL); break; } Index: mod_nss.h =================================================================== RCS file: /cvs/dirsec/mod_nss/mod_nss.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- mod_nss.h 7 Apr 2006 20:17:12 -0000 1.11 +++ mod_nss.h 20 Jun 2006 20:25:20 -0000 1.12 @@ -439,6 +439,7 @@ void nss_util_ppclose(server_rec *, apr_pool_t *, apr_file_t *); char *nss_util_readfilter(server_rec *, apr_pool_t *, const char *, const char * const *); +int nss_rand_seed(server_rec *s, apr_pool_t *p, ssl_rsctx_t nCtx, char *prefix); /* Pass Phrase Handling */ SECStatus nss_Init_Tokens(server_rec *s); Index: nss_engine_config.c =================================================================== RCS file: /cvs/dirsec/mod_nss/nss_engine_config.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- nss_engine_config.c 2 Mar 2006 19:21:54 -0000 1.10 +++ nss_engine_config.c 20 Jun 2006 20:25:20 -0000 1.11 @@ -383,7 +383,7 @@ { SSLDirConfigRec *dc = (SSLDirConfigRec *)dcfg; SSLSrvConfigRec *sc = mySrvConfig(cmd->server); - nss_verify_t mode; + nss_verify_t mode = SSL_CVERIFY_UNSET; const char *err; if ((err = nss_cmd_verify_parse(cmd, arg, &mode))) { @@ -451,6 +451,8 @@ SSLSrvConfigRec *sc = mySrvConfig(cmd->server); sc->proxy->auth.protocols = arg; + + return NULL; } const char *nss_cmd_NSSProxyCipherSuite(cmd_parms *cmd, Index: nss_engine_init.c =================================================================== RCS file: /cvs/dirsec/mod_nss/nss_engine_init.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- nss_engine_init.c 7 Apr 2006 20:17:12 -0000 1.18 +++ nss_engine_init.c 20 Jun 2006 20:25:20 -0000 1.19 @@ -19,6 +19,8 @@ #include "secmod.h" #include "sslerr.h" #include "pk11func.h" +#include "ocsp.h" +#include "keyhi.h" static SECStatus ownBadCertHandler(void *arg, PRFileDesc * socket); static SECStatus ownHandshakeCallback(PRFileDesc * socket, void *arg); @@ -902,11 +904,8 @@ apr_pool_t *ptemp, modnss_ctx_t *mctx) { - SECCertTimeValidity certtimestatus; SECStatus secstatus; - PK11SlotInfo* slot = NULL; - /* * Get own certificate and private key. */ @@ -1066,7 +1065,7 @@ switch (err) { default: ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, - "Bad remote server certificate.", err); + "Bad remote server certificate: %d", err); nss_log_nss_error(APLOG_MARK, APLOG_ERR, NULL); return SECFailure; break; Index: nss_engine_pphrase.c =================================================================== RCS file: /cvs/dirsec/mod_nss/nss_engine_pphrase.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- nss_engine_pphrase.c 7 Apr 2006 20:17:12 -0000 1.5 +++ nss_engine_pphrase.c 20 Jun 2006 20:25:20 -0000 1.6 @@ -24,7 +24,7 @@ static char * nss_password_prompt(PK11SlotInfo *slot, PRBool retry, void *arg); static char * nss_no_password(PK11SlotInfo *slot, PRBool retry, void *arg); -static unsigned char * nss_get_password(FILE *input, FILE *output, PK11SlotInfo *slot, PRBool (*ok)(unsigned char *), pphrase_arg_t * parg); +static char * nss_get_password(FILE *input, FILE *output, PK11SlotInfo *slot, PRBool (*ok)(unsigned char *), pphrase_arg_t * parg); static PRBool nss_check_password(unsigned char *cp); static void echoOff(int fd); static void echoOn(int fd); @@ -139,8 +139,8 @@ memset(buf, 0, sizeof(buf)); rv = apr_file_read(parg->mc->proc.out, buf, &nBytes); - if (rv = APR_SUCCESS) - res = atoi(buf); + if (rv == APR_SUCCESS) + res = atoi(buf); if (rv != APR_SUCCESS || (res != PIN_SUCCESS && res != PIN_INCORRECTPW)) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, @@ -192,7 +192,7 @@ * twiddling with the tty. Alternatively, if the file password.conf * exists then it may be used to store the token password(s). */ -static unsigned char *nss_get_password(FILE *input, FILE *output, +static char *nss_get_password(FILE *input, FILE *output, PK11SlotInfo *slot, PRBool (*ok)(unsigned char *), pphrase_arg_t *parg) @@ -298,7 +298,7 @@ fprintf(output, "non-alphabetic characters\n"); continue; } - return (unsigned char*) PORT_Strdup((char*)phrase); + return (char*) PORT_Strdup((char*)phrase); } } From fedora-directory-commits at redhat.com Tue Jun 20 20:42:23 2006 From: fedora-directory-commits at redhat.com (Robert Crittenden (rcritten)) Date: Tue, 20 Jun 2006 13:42:23 -0700 Subject: [Fedora-directory-commits] mod_nss gencert.in,1.1,1.2 Message-ID: <200606202042.k5KKgNSF010554@cvs-int.fedora.redhat.com> Author: rcritten Update of /cvs/dirsec/mod_nss In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10532 Modified Files: gencert.in Log Message: Drop dependency on ksh and use bash instead. Improve hostname detection on Solaris by using the script /usr/lib/mail/sh/check-hostname if it exists. Index: gencert.in =================================================================== RCS file: /cvs/dirsec/mod_nss/gencert.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- gencert.in 25 May 2005 21:01:13 -0000 1.1 +++ gencert.in 20 Jun 2006 20:42:21 -0000 1.2 @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash # Copyright 2001-2004 The Apache Software Foundation # @@ -35,6 +35,14 @@ getFQDN() { max=0 maxhost= + OS=`uname -s` + if [ $OS == "SunOS" ]; then + if [ -x /usr/lib/mail/sh/check-hostname ]; then + maxhost=`/usr/lib/mail/sh/check-hostname | awk 'BEGIN { FS=" " } { if ($3 == "OK:") { print $7 } }'` + fi + echo $maxhost + return + fi defhost=`hostname` hosthost=`host $defhost | grep -v "not found" | awk '{print $1}'` for host in $defhost $hosthost `hostname -f` `hostname -a` ; do @@ -97,7 +105,7 @@ # 5 9 n -> Cert signing key # y 10 y -> basic constraints: CA cert # 5 6 7 9 n -> SSL, S/MIME, Object signing CA -echo "5\n9\nn\ny\n10\ny\n5\n6\n7\n9\nn\n" | \ +echo -e "5\n9\nn\ny\n10\ny\n5\n6\n7\n9\nn\n" | \ $CERTUTIL -S -d $DEST -n cacert \ -s "$CA_CERTDN" \ -x \ @@ -119,7 +127,7 @@ let CERTSERIAL=CERTSERIAL+1 # 0 2 9 n -> Key usage: Key Encipherment, Digital Signature # 0 9 n -> SSL Client -echo "0\n2\n9\nn\n0\n9\nn\n" | \ +echo -e "0\n2\n9\nn\n0\n9\nn\n" | \ $CERTUTIL -S -d $DEST -n alpha \ -s "$ALPHA_CERTDN" \ -c cacert \ @@ -149,7 +157,7 @@ echo "Generating server certificate" echo "#####################################################################" let CERTSERIAL=CERTSERIAL+1 -echo "2\n9\nn\n1\n9\nn\n" | \ +echo -e "2\n9\nn\n1\n9\nn\n" | \ $CERTUTIL -C -d $DEST \ -c cacert \ -i $DEST/tmpcertreq \ From fedora-directory-commits at redhat.com Tue Jun 20 20:48:05 2006 From: fedora-directory-commits at redhat.com (Robert Crittenden (rcritten)) Date: Tue, 20 Jun 2006 13:48:05 -0700 Subject: [Fedora-directory-commits] mod_nss gencert.in,1.2,1.3 Message-ID: <200606202048.k5KKm5OY010604@cvs-int.fedora.redhat.com> Author: rcritten Update of /cvs/dirsec/mod_nss In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10587 Modified Files: gencert.in Log Message: Remove some invalid comments No need to set LD_LIBRARY_PATH Fix location of certutil Index: gencert.in =================================================================== RCS file: /cvs/dirsec/mod_nss/gencert.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- gencert.in 20 Jun 2006 20:42:21 -0000 1.2 +++ gencert.in 20 Jun 2006 20:48:02 -0000 1.3 @@ -19,13 +19,8 @@ # # gencert - generate new CA, server and user certificates for NSS testing. # -# Note that this script requires the Korn shell. -NSSDIR=@nss_dir@ -NSPRDIR=@nspr_dir@ - -export LD_LIBRARY_PATH=$NSPRDIR/lib:$NSSDIR/lib -CERTUTIL=$NSSDIR/bin/certutil +CERTUTIL=/usr/bin/certutil # Note: In order for the client tests that ship with this module to work # properly with this test certificate you need to ensure that the domain of @@ -64,7 +59,7 @@ SERVER_CERTDN="CN=${FQDN}, O=example.com, C=US" ALPHA_CERTDN="E=alpha@${FQDN}, CN=Frank Alpha, UID=alpha, OU=People, O=example.com, C=US" -# size of the keys - this needs to be 512 for export servers +# size of the keys KEYSIZE=1024 # validity of the certs in months From fedora-directory-commits at redhat.com Wed Jun 21 14:25:53 2006 From: fedora-directory-commits at redhat.com (Robert Crittenden (rcritten)) Date: Wed, 21 Jun 2006 07:25:53 -0700 Subject: [Fedora-directory-commits] mod_nss nss_engine_init.c,1.19,1.20 Message-ID: <200606211425.k5LEPs2u017652@cvs-int.fedora.redhat.com> Author: rcritten Update of /cvs/dirsec/mod_nss In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17633 Modified Files: nss_engine_init.c Log Message: 196070 Fix some warnings related to not checking the return value of getcwd and chdir. Index: nss_engine_init.c =================================================================== RCS file: /cvs/dirsec/mod_nss/nss_engine_init.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- nss_engine_init.c 20 Jun 2006 20:25:20 -0000 1.19 +++ nss_engine_init.c 21 Jun 2006 14:25:51 -0000 1.20 @@ -208,11 +208,23 @@ /* We need to be in the same directory as libnssckbi.so to load the * root certificates properly. */ - getcwd(cwd, PATH_MAX); - chdir(mc->pCertificateDatabase); + if (getcwd(cwd, PATH_MAX) == NULL) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, + "Unable to determine current working directory"); + nss_die(); + } + if (chdir(mc->pCertificateDatabase) != 0) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, + "Unable to change directory to %s", mc->pCertificateDatabase); + nss_die(); + } /* Initialize NSS and open the certificate database read-only. */ rv = NSS_Initialize(mc->pCertificateDatabase, mc->pDBPrefix, mc->pDBPrefix, "secmod.db", NSS_INIT_READONLY); - chdir(cwd); + if (chdir(cwd) != 0) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, + "Unable to change directory to %s", cwd); + nss_die(); + } /* Assuming everything is ok so far, check the cert database password(s). */ if (sslenabled && (rv != SECSuccess)) { From fedora-directory-commits at redhat.com Wed Jun 21 14:30:21 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Wed, 21 Jun 2006 07:30:21 -0700 Subject: [Fedora-directory-commits] dsbuild/ds/admservconsole - New directory Message-ID: <200606211430.k5LEULuj017723@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/dsbuild/ds/admservconsole In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17708/admservconsole Log Message: Directory /cvs/dirsec/dsbuild/ds/admservconsole added to the repository From fedora-directory-commits at redhat.com Wed Jun 21 14:42:09 2006 From: fedora-directory-commits at redhat.com (Robert Crittenden (rcritten)) Date: Wed, 21 Jun 2006 07:42:09 -0700 Subject: [Fedora-directory-commits] mod_nss TODO,1.2,1.3 Message-ID: <200606211442.k5LEg91a017853@cvs-int.fedora.redhat.com> Author: rcritten Update of /cvs/dirsec/mod_nss In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17830 Modified Files: TODO Log Message: mod_proxy support has been around for a while. We want SNI support as soon as NSS allows it. Index: TODO =================================================================== RCS file: /cvs/dirsec/mod_nss/TODO,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TODO 31 May 2005 14:32:42 -0000 1.2 +++ TODO 21 Jun 2006 14:42:06 -0000 1.3 @@ -1,3 +1,5 @@ -- Support for mod_proxy - Offer to automatically generate a self-signed cert using gencert during install? +- Should gencert create a database with an empty password or continue + to create a protected on? +- Once NSS fully supports the SNI TLS extension, add that. From fedora-directory-commits at redhat.com Wed Jun 21 15:18:36 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Wed, 21 Jun 2006 08:18:36 -0700 Subject: [Fedora-directory-commits] dsbuild/ds/adminserver Makefile,1.4,1.5 Message-ID: <200606211518.k5LFIavT020741@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/dsbuild/ds/adminserver In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20699/ds/adminserver Modified Files: Makefile Log Message: added admservconsole Index: Makefile =================================================================== RCS file: /cvs/dirsec/dsbuild/ds/adminserver/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Makefile 8 Apr 2006 19:26:50 -0000 1.4 +++ Makefile 21 Jun 2006 15:18:33 -0000 1.5 @@ -32,7 +32,8 @@ MOD_NSS_BINPATH=$(ABS_GARDIR)/$(CATEGORIES)/mod_nss/work/mod_nss-1.0.2 ifndef NOJAVA -BUILD_ARGS += CONSOLE_SOURCE_DIR=$(ABS_GARDIR)/$(CATEGORIES)/console/work +BUILD_ARGS += CONSOLE_SOURCE_DIR=$(ABS_GARDIR)/$(CATEGORIES)/console/work \ + ADMSERVCONSOLE_SOURCE_DIR=$(ABS_GARDIR)/$(CATEGORIES)/admservconsole/work endif # NOJAVA ifneq ($(DEBUG), full) From fedora-directory-commits at redhat.com Wed Jun 21 15:18:36 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Wed, 21 Jun 2006 08:18:36 -0700 Subject: [Fedora-directory-commits] dsbuild/ds/admservconsole Makefile, NONE, 1.1 checksums, NONE, 1.1 Message-ID: <200606211518.k5LFIaGF020746@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/dsbuild/ds/admservconsole In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20699/ds/admservconsole Added Files: Makefile checksums Log Message: added admservconsole --- NEW FILE Makefile --- include ../../objdirname.mk GARNAME = fedora-admservconsole GARVERSION = 1.1 CATEGORIES = ds PATCHFILES = ifdef USE_CVS CVSMODULES=admservconsole else DISTFILES = $(GARNAME)-$(GARVERSION).tar.gz endif LIBDEPS = DESCRIPTION = admservconsole #CONFIGURE_SCRIPTS = $(WORKSRC)/configure BUILD_SCRIPTS = custom #INSTALL_SCRIPTS = $(WORKSRC)/Makefile INSTALL_SCRIPTS = custom IMPORTS=-Dconsole.location=$(ABS_GARDIR)/$(CATEGORIES)/console/work/built/release/package ifdef USE_CVS post-extract: extract-cvs endif configure-custom: $(MAKECOOKIE) build-custom: cd $(WORKSRC) && ant $(IMPORTS) $(MAKECOOKIE) install-custom: $(MAKECOOKIE) include ../../gar.conf.mk include ../category.mk --- NEW FILE checksums --- 7ac4d67dc915a533aed476395cc086bd download/fedora-admservconsole-1.1.tar.gz From fedora-directory-commits at redhat.com Wed Jun 21 15:18:37 2006 From: fedora-directory-commits at redhat.com (Richard Allen Megginson (rmeggins)) Date: Wed, 21 Jun 2006 08:18:37 -0700 Subject: [Fedora-directory-commits] dsbuild/meta/ds Makefile,1.5,1.6 Message-ID: <200606211518.k5LFIblc020750@cvs-int.fedora.redhat.com> Author: rmeggins Update of /cvs/dirsec/dsbuild/meta/ds In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20699/meta/ds Modified Files: Makefile Log Message: added admservconsole Index: Makefile =================================================================== RCS file: /cvs/dirsec/dsbuild/meta/ds/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Makefile 24 Feb 2006 17:37:59 -0000 1.5 +++ Makefile 21 Jun 2006 15:18:34 -0000 1.6 @@ -15,7 +15,7 @@ LIBDEPS = ds/mozilla ds/icu ds/adminutil ds/setuputil ds/mod_nss ds/mod_admserv ds/mod_restartd ifndef NOJAVA -LIBDEPS += ds/console +LIBDEPS += ds/console ds/admservconsole endif LIBDEPS += ds/onlinehelp ds/adminserver From fedora-directory-commits at redhat.com Wed Jun 21 18:44:34 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Wed, 21 Jun 2006 11:44:34 -0700 Subject: [Fedora-directory-commits] setuputil/installer/unix Makefile, 1.2, 1.3 Message-ID: <200606211844.k5LIiYV2030249@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/setuputil/installer/unix In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30205/installer/unix Modified Files: Makefile Log Message: [175900] Setup Util build (RPM); Comment#12 Preparation for the RPM build. Since rpm/pkg build needs to use shared version of LDAP C SDK libraries, NSPR and NSS libraries need to be dynamically linked to setup and uninstall. Index: Makefile =================================================================== RCS file: /cvs/dirsec/setuputil/installer/unix/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile 28 Jan 2006 02:33:20 -0000 1.2 +++ Makefile 21 Jun 2006 18:44:27 -0000 1.3 @@ -156,13 +156,15 @@ @echo $(CXX) $(NONSHARED) $(MODULE_CFLAGS) \ -o $(BINDEST)/setup \ - $(INSTOBJS) $(OBJS) $(LIBINSTALL) $(EXTRA_LIBS) $(CURSES) $(LDAPLINK) + $(INSTOBJS) $(OBJS) $(LIBINSTALL) $(EXTRA_LIBS) $(CURSES) \ + $(LDAPLINK) $(SECURITYLINK) $(NSPRLINK) $(BINDEST)/uninstall: $(OBJS) $(UNINSTOBJS) $(LIBINSTALL) @echo $(CXX) $(NONSHARED) $(MODULE_CFLAGS) \ -o $(BINDEST)/uninstall \ - $(UNINSTOBJS) $(OBJS) $(LIBINSTALL) $(LDAPLINK) $(EXTRA_LIBS) $(CURSES) + $(UNINSTOBJS) $(OBJS) $(LIBINSTALL) $(LDAPLINK) $(EXTRA_LIBS) \ + $(CURSES) $(SECURITYLINK) $(NSPRLINK) #$(BINDEST)/download.bin: $(OBJS) $(DNLDOBJS) $(LIBINSTALL) $(LIBNET) # @echo From fedora-directory-commits at redhat.com Wed Jun 21 18:44:29 2006 From: fedora-directory-commits at redhat.com (Noriko Hosoi (nhosoi)) Date: Wed, 21 Jun 2006 11:44:29 -0700 Subject: [Fedora-directory-commits] setuputil components.mk,1.3,1.4 Message-ID: <200606211844.k5LIixAj030255@cvs-int.fedora.redhat.com> Author: nhosoi Update of /cvs/dirsec/setuputil In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30205 Modified Files: components.mk Log Message: [175900] Setup Util build (RPM); Comment#12 Preparation for the RPM build. Since rpm/pkg build needs to use shared version of LDAP C SDK libraries, NSPR and NSS libraries need to be dynamically linked to setup and uninstall. Index: components.mk =================================================================== RCS file: /cvs/dirsec/setuputil/components.mk,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- components.mk 19 Jun 2006 16:53:13 -0000 1.3 +++ components.mk 21 Jun 2006 18:44:26 -0000 1.4 @@ -59,12 +59,23 @@ endif endif NSPR_LIBNAMES += nspr4 -ifdef NSPR_SOURCE_ROOT - NSPR_LIBPATH = $(NSPR_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/lib +ifdef NSPR_INCLUDE_DIR + NSPR_INCDIR = $(NSPR_INCLUDE_DIR) +else + ifdef NSPR_SOURCE_ROOT NSPR_INCDIR = $(NSPR_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/include + else + NSPR_INCDIR = $(NSPR_BUILD_DIR)/include + endif +endif +ifdef NSPR_LIB_DIR + NSPR_LIBPATH = $(NSPR_LIB_DIR) else + ifdef NSPR_SOURCE_ROOT + NSPR_LIBPATH = $(NSPR_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/lib + else NSPR_LIBPATH = $(NSPR_BUILD_DIR)/lib - NSPR_INCDIR = $(NSPR_BUILD_DIR)/include + endif endif NSPR_INCLUDE = -I$(NSPR_INCDIR) NSPR_LIBS_TO_PKG = $(addsuffix .$(DLL_SUFFIX),$(addprefix $(NSPR_LIBPATH)/lib,$(NSPR_LIBNAMES))) @@ -88,7 +99,11 @@ NSPR_SOLIBS = $(addsuffix .$(DLL_SUFFIX), $(addprefix $(LIB_PREFIX), $(NSPR_LIBNAMES))) NSPROBJNAME = $(addsuffix .a, $(addprefix $(LIB_PREFIX), $(NSPR_LIBNAMES)) LIBNSPR = $(addprefix $(NSPR_LIBPATH)/, $(NSPR_SOLIBS)) - NSPRLINK = -L$(NSPR_LIBPATH) $(addprefix -l, $(NSPR_LIBNAMES)) + ifdef NSPR_LIB_DIR # we are using the system NSPR (shared lib) + NSPRLINK = -L$(NSPR_LIBPATH) $(addprefix -l, $(NSPR_LIBNAMES)) + else + NSPRLINK = + endif endif ### DBM ############################# @@ -117,18 +132,27 @@ ### DBM END ############################# ### SECURITY ############################# -ifdef SECURITY_SOURCE_ROOT - SECURITY_LIBPATH = $(SECURITY_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/lib - SECURITY_BINPATH = $(SECURITY_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/bin +ifdef NSS_INCLUDE_DIR + SECURITY_INCDIR = $(NSS_INCLUDE_DIR) +else + ifdef SECURITY_SOURCE_ROOT SECURITY_INCDIR = $(SECURITY_SOURCE_ROOT)/dist/public/nss + else + SECURITY_INCDIR = $(SECURITY_BUILD_DIR)/include + endif +endif + +ifdef NSS_LIB_DIR + SECURITY_LIBPATH = $(NSS_LIB_DIR) else + ifdef SECURITY_SOURCE_ROOT + SECURITY_LIBPATH = $(SECURITY_SOURCE_ROOT)/dist/$(MOZ_OBJDIR_NAME)/lib + else SECURITY_LIBPATH = $(SECURITY_BUILD_DIR)/lib - SECURITY_BINPATH = $(SECURITY_BUILD_DIR)/bin - SECURITY_INCDIR = $(SECURITY_BUILD_DIR)/include + endif endif SECURITY_INCLUDE = -I$(SECURITY_INCDIR) # add crlutil and ocspclnt when we support CRL and OCSP cert checking in DS -SECURITY_BINNAMES = certutil derdump pp pk12util ssltap modutil shlibsign SECURITY_LIBNAMES = ssl3 nss3 softokn3 # these libs have a corresponding .chk file SECURITY_NEED_CHK = softokn3 @@ -149,9 +173,6 @@ endif endif # USE_64 -SECURITY_TOOLS = $(addsuffix $(EXE_SUFFIX),$(SECURITY_BINNAMES)) -SECURITY_TOOLS_FULLPATH = $(addprefix $(SECURITY_BINPATH)/, $(SECURITY_TOOLS)) - SECURITY_LIBS_TO_PKG = $(addsuffix .$(DLL_SUFFIX),$(addprefix $(SECURITY_LIBPATH)/$(LIB_PREFIX),$(SECURITY_LIBNAMES.pkg))) SECURITY_LIBS_TO_PKG += $(addsuffix .chk,$(addprefix $(SECURITY_LIBPATH)/$(LIB_PREFIX),$(SECURITY_NEED_CHK))) LIBS_TO_PKG += $(SECURITY_LIBS_TO_PKG) @@ -170,15 +191,16 @@ else SECURITYOBJNAME = $(addsuffix .$(DLL_SUFFIX), $(addprefix $(LIB_PREFIX), $(SECURITY_LIBNAMES))) LIBSECURITY = $(addprefix $(SECURITY_LIBPATH)/, $(SECURITYOBJNAME)) - SECURITYLINK = -L$(SECURITY_LIBPATH) $(addprefix -l, $(SECURITY_LIBNAMES)) + ifdef NSPR_LIB_DIR # we are using the system NSPR (shared lib) + SECURITYLINK = -L$(SECURITY_LIBPATH) $(addprefix -l, $(SECURITY_LIBNAMES)) + else + SECURITYLINK = + endif endif # we need to package the root cert file in the alias directory PACKAGE_SRC_DEST += $(SECURITY_LIBPATH)/$(LIB_PREFIX)nssckbi.$(DLL_SUFFIX) alias -# need to package the sec tools in shared/bin -BINS_TO_PKG_SHARED += $(SECURITY_TOOLS_FULLPATH) - ### SECURITY END ############################# ### SVRCORE #############################