Package: libpkcs11-helper1-dev
Version: 1.09-1
Severity: important

Dear Maintainer,

When compiling a program calling pkcs11h_token logout:
gcc -o provacardlogin provacardlogin.c -lpkcs11-helper
-DENABLE_PKCS11H_ENGINE_OPENSSL -DENABLE_PKCS11H_CERTIFICATE -Wall

the compiler return eror like:
rovacardlogin.c:(.text+0x371): undefined reference to `pkcs11h_token_logout'

pkcs11_toke_logout is documented in
http://www.opensc-
project.org/files/pkcs11-helper/doc/api/group__pkcs11h__token.html#g1e1c4fef0571b30f7351561afea7ad2f





-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.4-trunk-rt-amd64 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=ca_ES.UTF-8, LC_CTYPE=ca_ES.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libpkcs11-helper1-dev depends on:
ii  libpkcs11-helper1  1.09-1
ii  libssl-dev         1.0.1c-4

libpkcs11-helper1-dev recommends no packages.

libpkcs11-helper1-dev suggests no packages.

-- no debconf information
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <pkcs11-helper-1.0/pkcs11h-certificate.h>
#include <pkcs11-helper-1.0/pkcs11h-token.h>
#include <unistd.h>

#define TEST_PROVIDER "/usr/lib/x86_64-linux-gnu/opensc-pkcs11.so"
#define TEST_LOG_LEVEL PKCS11H_LOG_ERROR

static void fatal (const char * const m, CK_RV rv) {
 fprintf (stderr, "%s - %lu - %s\n", m, rv, pkcs11h_getMessage (rv));
 exit (1);
}
static
PKCS11H_BOOL _pkcs11h_hooks_pin_prompt (void * const global_data,void * const user_data,
					const pkcs11h_token_id_t token,const unsigned retry,
					char * const pin, const size_t pin_max) {
  char prompt[1024];
  char *p = NULL;

  snprintf (prompt, sizeof (prompt), "Please enter '%s' PIN or 'cancel': ", token->display);
  p = getpass (prompt);
  strncpy (pin, p, pin_max);
  pin[pin_max-1] = '\0';
  return strcmp (pin, "cancel") != 0;
}

int main(int argv ,char ** argc){
  pkcs11h_certificate_id_list_t issuers, certs, temp;
  pkcs11h_token_id_list_t tokens,tmptok;
  CK_RV rv;
  
  if ((rv = pkcs11h_initialize ()) != CKR_OK) {
    fatal ("pkcs11h_initialize failed", rv);
  }
  if ((rv = pkcs11h_setPINPromptHook (_pkcs11h_hooks_pin_prompt, NULL)) != CKR_OK) {
    fatal ("pkcs11h_setPINPromptHook failed", rv);
  }
  if ((rv = pkcs11h_addProvider ( TEST_PROVIDER, TEST_PROVIDER, FALSE,
                        PKCS11H_PRIVATEMODE_MASK_AUTO,PKCS11H_SLOTEVENT_METHOD_AUTO,
                        0, false )) != CKR_OK) {
    fatal ("pkcs11h_terminate failed", rv);
  }
  if ( (rv = pkcs11h_token_enumTokenIds(PKCS11H_ENUM_METHOD_RELOAD, &tokens)) != CKR_OK){
    fatal("pkcs11h_token_enumTokenIds failes",rv); 
  }
  for(tmptok = tokens; tmptok!= NULL; tmptok = tmptok->next){
    printf("Token Display: %s, ManufacturerId: %s, model: %s, serialNumber:%s , Label: %s.\n",
	    tmptok->token_id->display , tmptok->token_id->manufacturerID , tmptok->token_id->model , tmptok->token_id->serialNumber , tmptok->token_id->label);
  }
  tmptok = tokens;
  pkcs11h_token_login(tmptok->token_id ,false , "*******");	
  if ((rv = pkcs11h_certificate_enumCertificateIds (PKCS11H_ENUM_METHOD_CACHE,NULL,
                        PKCS11H_PROMPT_MASK_ALLOW_PIN_PROMPT,&issuers,&certs)) != CKR_OK) {
    fatal ("pkcs11h_certificate_enumCertificateIds failed", rv);
  }
  for (temp = issuers;temp != NULL;temp = temp->next) {
	  printf ("Issuer: %s\n", temp->certificate_id->displayName);
  }
  for (temp = certs;temp != NULL;temp = temp->next) {
	  printf ("Certificate: %s\n", temp->certificate_id->displayName);
  }

  if (certs == NULL) {
	  fatal ("No certificates found", rv);
  }

  pkcs11h_certificate_freeCertificateIdList (issuers);
  pkcs11h_certificate_freeCertificateIdList (certs);
  /*!Call pkcs11_token_logout*/
  pkcs11h_token_logout(tmptok->token_id); 
  return 0;

}

Reply via email to