Feature notes: PKIX / CMS implementation notes
A signing capability this token actually has. Hash = haUndefined means the mechanism is hash-agnostic (it takes whatever we prepare).
Mech : CK_MECHANISM_TYPE;
Hash : tHashAlgorithm;
Encoding : tSignEncoding;
Kind : tPkcs11SignKind;
MinKeyBits: CK_ULONG;
MaxKeyBits: CK_ULONG;
inherits from Exception
(no public members)
constructor Create(aLib: tPkcs11Library);
destructor Destroy; override;
function Open(const aToken: string): Boolean;
procedure Close;
function Login(const aPassphrase: string; aCheckLength: Boolean = True): CK_RV;
procedure Logout;
function GenerateRSAKeyPair(aBits : CK_ULONG; const aKeyLabel : string; const aID : tBytes; out aPublicKey : CK_OBJECT_HANDLE; out aPrivateKey: CK_OBJECT_HANDLE): CK_RV;
function GenerateECKeyPair(const aCurveParams: tBytes; const aKeyLabel : string; const aID : tBytes; out aPublicKey : CK_OBJECT_HANDLE; out aPrivateKey : CK_OBJECT_HANDLE): CK_RV;
function CreateCertificate(const aDER : tBytes; const aCertLabel: string; const aID : tBytes; const aSubject : tBytes; const aIssuer : tBytes; const aSerial : tBytes; out aObject : CK_OBJECT_HANDLE): CK_RV;
function CreateDataObject(const aValue : tBytes; const aDataLabel: string; aPrivate : Boolean; out aObject : CK_OBJECT_HANDLE): CK_RV;
function FindDataObjects(const aDataLabel: string): tCK_ObjectHandleArray;
function DestroyObject(aObject: CK_OBJECT_HANDLE): CK_RV;
function ReopenReadWrite: CK_RV;
function GenerateRandom(aByteLen: Integer): tBytes;
function FindObjects(const aTemplate: array of CK_ATTRIBUTE): tCK_ObjectHandleArray;
function GetAttribute(aObject: CK_OBJECT_HANDLE; aType : CK_ATTRIBUTE_TYPE; out aValue : tBytes): Boolean;
function GetAttributeULong(aObject: CK_OBJECT_HANDLE; aType : CK_ATTRIBUTE_TYPE; out aValue : CK_ULONG): Boolean;
function HasMechanism(aMech: CK_MECHANISM_TYPE; aFlags: CK_FLAGS): Boolean;
function MechanismInfo(aMech: CK_MECHANISM_TYPE; out aMinKeyBits, aMaxKeyBits: CK_ULONG): Boolean;
function ResolveSign(aHash : tHashAlgorithm; aEncoding: tSignEncoding; aAllowed : tPkcs11SignKinds; out aMech : tPkcs11SignMech): Boolean;
function CanSign(aHash: tHashAlgorithm; aEncoding: tSignEncoding): Boolean;
function ConformantKinds(aEncoding: tSignEncoding): tPkcs11SignKinds;
function SignHashAlgorithms(aEncoding: tSignEncoding): tHashAlgorithms;
function SignEncodings: tSignEncodings;
function CapabilityReport: string;
property Lib: tPkcs11Library read fLib;
property Slot: CK_SLOT_ID read fSlot;
property Session: CK_SESSION_HANDLE read fSession;
property IsOpen: Boolean read fOpen;
property LoggedIn: Boolean read fLoggedIn;
property TokenLabel: string read fTokenLabel;
property Serial: string read fSerial;
property Model: string read fModel;
property LoginNeeded: Boolean read fLoginNeeded;
property HasRNG: Boolean read fHasRNG;
property MinPinLen: CK_ULONG read fMinPinLen;
property MaxPinLen: CK_ULONG read fMaxPinLen;
property PinFinalTry: Boolean read fPinFinalTry;
property PinLocked: Boolean read fPinLocked;
How a mechanism wants its input, which decides what the adapter has to hand C_Sign:
pskMessage - the message itself; the token hashes and pads
pskDigestInfo - PKCS#1 v1.5 over a DigestInfo blob we build
pskDigest - the bare digest plus mechanism parameters (PSS)
pskRaw - raw modexp; the library did the padding
pskDigestPlain is PKCS#1 v1.5 over the supplied bytes VERBATIM, with no DigestInfo: what a TLS 1.0/1.1 signature needs (a bare MD5+SHA-1 concatenation), and what seEMSA3 with aNullMsg means. It must never be substituted for pskDigestInfo -- signing a bare digest as though it carried a DigestInfo yields a non-conforming signature.