unit pkcs11;
//-------------------------------------------------------
//Coypright (c) 2009,Feitian Technologies Co., Ltd.
//All rights reserved
//Description: Cryptoki function prototypes and variables definition
//Created Time:20090625
//Author:Allen of ITD
//-------------------------------------------------------
//------------------------------------------------------------------------
interface

type

  CK_BYTE = byte;
  CK_UTF8CHAR=byte;
  CK_CHAR=byte;
  CK_FLAGS=longint;
  CK_BBOOL=byte;
  CK_ULONG=longword;
  CK_RV=longword;
  CK_SLOT_ID=longword;
  CK_SLOT_ID_PTR=^CK_SLOT_ID;
  CK_ULONG_PTR=^CK_ULONG;
  CK_OBJECT_HANDLE=longword;
  CK_OBJECT_CLASS=longword;
  CK_OBJECT_HANDLE_PTR=^CK_OBJECT_HANDLE;
  CK_SESSION_HANDLE=longword;
  CK_UTF8CHAR_PTR=^CK_UTF8CHAR;
  CK_BYTE_PTR=^CK_BYTE;

  CK_ATTRIBUTE =record
    attrtype:longword;
    pValue:pointer;
    ulValueLen:longword;
  end;

  CK_ATTRIBUTE_PTR=^CK_ATTRIBUTE;

  CK_VERSION = record
    major:CK_BYTE;
    minor:CK_BYTE;
  end;
  CK_SLOT_INFO = record
    slotDescription: array[0..63]of byte;
    manufacturerID: array[0..31] of byte;
    flags:longword;
    hardwareVersion:CK_VERSION;
    firmwareVersion:CK_VERSION;
  end;

  CK_SLOT_INFO_PTR=^CK_SLOT_INFO;
    
  CK_TOKEN_INFO=record
    token_label:array[0..31] of CK_UTF8CHAR;
    manufacturerID:array[0..31] of CK_UTF8CHAR;
    model:array[0..15] of CK_UTF8CHAR;
    serialNumber:array[0..15] of CK_CHAR;
    flags:CK_FLAGS;
    ulMaxSessionCount:CK_ULONG;
    ulSessionCount:CK_ULONG;
    ulMaxRwSessionCount:CK_ULONG;
    ulRwSessionCount:CK_ULONG;
    ulMaxPinLen:CK_ULONG;
    ulMinPinLen:   CK_ULONG;
    ulTotalPublicMemory: CK_ULONG;
    ulFreePublicMemory:CK_ULONG;
    ulTotalPrivateMemory:CK_ULONG ;
    ulFreePrivateMemory:CK_ULONG;
    hardwareVersion:CK_VERSION;
    firmwareVersion:CK_VERSION;
    utcTime:array[0..15] of CK_CHAR;
  end;

  CK_TOKEN_INFO_PTR=^CK_TOKEN_INFO;

    
  CK_INFO=record
    cryptokiVersion:CK_VERSION;                     //Cryptoki interface ver *
    manufacturerID:array[0..31] of CK_UTF8CHAR;     //blank padded
    flags:array[0..3] of char;                                 //must be zero
    libraryDescription:array[0..31] of CK_UTF8CHAR; //blank padded
    libraryVersion:CK_VERSION;                      //version of library
  end;
  CK_INFO_PTR=^CK_INFO;

const
  CKR_OK = 0;
  CKR_DEVICE_ERROR = 48;
  CKR_TOKEN_NOT_PRESENT =342;
  CKR_FUNCTION_FAILED=6;
var

  //initializes the Cryptoki library .
  C_Initialize:function(pInitArgs: longword):longword; cdecl;

  //C_Finalize indicates that an application is done with the Cryptoki library.
  C_Finalize:function(pReserved: longword):longword; cdecl;
  
  //returns general information about Cryptoki.
  C_GetInfo:function(pInfo:CK_INFO_PTR):longword;cdecl;
  
  //C_GetSlotList obtains a list of slots in the system .
  C_GetSlotList:function(tokenPresent: byte; pSlotList :pointer;VAR pulCount:longword):longword;cdecl;

  //C_GetSlotInfo obtains information about a particular slot in the system.
  C_GetSlotInfo:function(slotID: longword;pInfo :CK_SLOT_INFO_PTR):CK_RV; cdecl;

  //obtains information about a particular token in the system.
  C_GetTokenInfo:function(slotID:CK_SLOT_ID; pInfo:CK_TOKEN_INFO_PTR):CK_RV; cdecl;


//-----------------------------------------------------------------------


implementation

end.
