Esempio n. 1
0
CK_RV api_driver(void)
{
	CK_RV rc;

	rc = do_GetInfo();
        if (rc && !no_stop)
		return rc;

	rc = do_GetSlotList();
	if(rc && !no_stop)
		return rc;

	rc = do_GetSlotInfo();
	if(rc && !no_stop)
		return rc;

	rc = do_GetTokenInfo();
        if(rc && !no_stop)
                return rc;

	rc = do_GetMechanismList();
        if(rc && !no_stop)
                return rc;

	rc = do_GetMechanismInfo();
        if(rc && !no_stop)
                return rc;

	rc = do_InitToken();
        if(rc && !no_stop)
                return rc;

	rc = do_InitPIN();
        if(rc && !no_stop)
                return rc;

	rc = do_SetPIN();
        if(rc && !no_stop)
                return rc;

	return rc;
}
Esempio n. 2
0
int main( int argc, char **argv )
{
   CK_BYTE            line[20];
   CK_ULONG           val, i;
   int rc;

   SLOT_ID = 0;

   for (i=1; i < argc; i++) {
      if (strcmp(argv[i], "-slot") == 0) {
         SLOT_ID = atoi(argv[i+1]);
         i++;
      }

      if (strcmp(argv[i], "-h") == 0) {
         printf("usage:  %s [-slot <num>] [-h]\n\n", argv[0] );
         printf("By default, Slot #1 is used\n\n");
         return -1;
      }
   }

   printf("Using slot #%lu...\n\n", SLOT_ID );

   rc = do_GetFunctionList();
   if (!rc)
      return rc;

   funcs->C_Initialize( NULL );


   while (1) {
      printf("\n1.  Create a token object\n");
      printf("2.  Count token objects\n");
      printf("3.  Verify contents of the first token object\n");
      printf("4.  Destroy all token objects\n");
      printf("5.  Initialize Token\n");
      printf("6.  Set USER PIN\n");
      printf("7.  Get Token Info\n");
      printf("9.  Exit\n");
      printf("Selection:   ");  fflush(stdout);

      fgets(line, 10, stdin);

      val = atoi(line);

      switch (val) {
         case 1:  do_create_token_object();
                  break;

         case 2:  do_count_token_objects();
                  break;

         case 3:  do_verify_token_object();
                  break;

         case 4:  do_destroy_all_token_objects();
                  break;

         case 5:  do_inittoken();
                  break;

         case 6:  do_setUserPIN();
                  break;

         case 7:  do_GetTokenInfo();
                  break;

         case 9:  goto done;
                  break;
      }
   }

done:

   rc = funcs->C_Finalize( NULL );

   return rc;
}
Esempio n. 3
0
int main( int argc, char **argv )
{
   CK_BYTE            line[20];
   CK_ULONG           val;
   int i, rc;

   SLOT_ID = 0;

   for (i=1; i < argc; i++) {
      if (strcmp(argv[i], "-slot") == 0) {
         SLOT_ID = atoi(argv[i+1]);
         i++;
      }

      if (strcmp(argv[i], "-h") == 0) {
         printf("usage:  %s [-slot <num>] [-h]\n\n", argv[0] );
         printf("By default, Slot #1 is used\n\n");
         return -1;
      }
   }

   printf("Using slot #%lu...\n\n", SLOT_ID );

   rc = do_GetFunctionList();
   if (!rc)
      return rc;

   funcs->C_Initialize( NULL );


   menu();
   
   while (fgets((char *)line, 10, stdin)) {
      val = atoi((char *)line);

      switch (val) {
         case 1:  do_create_token_object();
                  break;

         case 2:  do_count_token_objects();
                  break;

         case 3:  do_verify_token_object();
                  break;

         case 4:  do_destroy_all_token_objects();
                  break;

         case 5:  do_inittoken();
                  break;

         case 6:  do_setUserPIN();
                  break;

         case 7:  do_GetTokenInfo();
                  break;

         case 9:  goto done;
                  break;
      }

      menu();
   }

done:

   rc = funcs->C_Finalize( NULL );
   return rc;
}