EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PKCS#11 Over Vista

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#2317
Posted: 02/15/2007 06:23:29
by Eugene Mayevski (EldoS Corp.)

Try this code:

Code
procedure TElPKCS11SlotInfo.Refresh;
var
  RSlotInfo: TPKCS11SlotInfo;
  RTokenInfo: TPKCS11TokenInfo;
  CKRes: CK_RV;
begin
  // check state and parameters

  // read slot info
  {$ifndef DELPHI_NET}
  CKRes := TPKCS11GetSlotInfoFunc(FModule.FuncArray[PKCS11_GetSlotInfo])(FSlotID, RSlotInfo);
  {$else}
  CKRes := C_GetSlotInfo(FModule.HLib, FSlotID, RSlotInfo);
  {$endif}

  if CKRes = CKR_OK then
  begin
    SetSlotData(FSlotID, RSlotInfo);

    // read token info, if token is present
    CKRes :=
      {$ifndef DELPHI_NET}
      TPKCS11GetTokenInfoFunc(FModule.FuncArray[PKCS11_GetTokenInfo])(FSlotID, RTokenInfo);
      {$else}
      C_GetTokenInfo(FModule.HLib, FSlotID, RTokenInfo);
      {$endif}
  end;

  if CKRes = CKR_OK then
  begin
    FTokenPresent := true;
    SetTokenData(RTokenInfo);
  end
  else
  if (CKRes = CKR_SLOT_ID_INVALID) or (CKRes = CKR_DEVICE_ERROR) or (CKRes = CKR_TOKEN_NOT_RECOGNIZED) then // alien token/reader
  begin
    FTokenPresent := false;
  end
  else
  if (CKRes = CKR_TOKEN_NOT_PRESENT) or (CKRes = CKR_DEVICE_REMOVED) or (CKRes = CKR_FUNCTION_FAILED) then
  begin
    FTokenPresent := false;
  end
  else
    PKCS11CheckError(CKRes);
end;


Sincerely yours
Eugene Mayevski
#2318
Posted: 02/15/2007 06:57:26
by Santiago CastaƱo (Standard support level)
Joined: 04/16/2006
Posts: 155

Yes!, It works perfectly. And by the way, I've seen that FireFox also shows 17 slots 15 of them "Unnamed slot" (If I had seen it before i shouldn't have worried that it happens in my program, I always compare PKCS#11 in my program with Mozilla).

So I'll use this code, and leave all the rest as it was. Many thanks (once again). By the way, is this going to be in the next build? or should I have to take a look in the next build to see if this code is updated?
#2319
Posted: 02/15/2007 07:11:44
by Eugene Mayevski (EldoS Corp.)

Quote
Santiago Castaño wrote:
By the way, is this going to be in the next build? or should I have to take a look in the next build to see if this code is updated?


This has been added to the main code.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 7883 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!