Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.DSI.Pkcs11ExtKey

Feature notes: PKIX / CMS implementation notes

Classes, interfaces and records

classePkcs11KeyError

inherits from Exception

(no public members)

classtPkcs11IFPrivateKey

inherits from tExternalIFPrivateKey

constructor Create; override; procedure Bind(aToken: tPkcs11Token; aKeyHandle: CK_OBJECT_HANDLE);
Binds this adapter to an already-located private key object on aToken. The token is referenced, not owned: one token backs many keys.
function ImportKey(const aPKIdentifier; aPKILen: Integer): Boolean; override;
Locates the CKO_PRIVATE_KEY whose CKA_ID matches and binds it. The identifier blob is the raw CKA_ID; that is this subclass's definition of the opaque identifier the base class documents.
function GetIdentifier: string; override; function GetKeySize: Integer; override;
Modulus size in BITS -- the unit the library uses it in (lFBitSize := GetKeySize - 1).
function IFPrivateKeyOperation(aI: iDSInteger; var aJ: iDSInteger): Boolean; override; function SignMsg(const aMsg : tBytes; aOffset, aCount : Integer; aHashAlgorithm : tHashAlgorithm; aMGFHashAlgorithm: tHashAlgorithm; aSaltLen : Cardinal; aEncoding : tSignEncoding; var aSign : tBytes; var aSignCount : Integer): Boolean; override; function SignDigest(const aDigest : tBytes; aOffset, aCount : Integer; aHashAlgorithm : tHashAlgorithm; aMGFHashAlgorithm: tHashAlgorithm; aSaltLen : Cardinal; aEncoding : tSignEncoding; aNullMsg : Boolean; var aSign : tBytes; var aSignCount : Integer): Boolean; override; function IFESDecryption(const aEMsg : tBytes; aEOffset, aECount : Integer; const aP : tBytes; aPOffset, aPCount : Integer; aHashAlgorithm : tHashAlgorithm; aMGFHashAlgorithm: tHashAlgorithm; aEncryptEncoding : tEncryptEncoding; var aMsg : tBytes; var aSuccess : Boolean): Boolean; override; function Validate(aPubl: iIFPublicKey): Boolean; override; property Token: tPkcs11Token read fToken; property KeyHandle: CK_OBJECT_HANDLE read fKeyHandle; property KeyLabel: string read fKeyLabel; property KeyID: tBytes read fKeyID;

classtPkcs11DLPrivateKey

inherits from tExternalDLPrivateKey

The EC counterpart. Only the signature primitive is delegated: the token is handed the raw digest and returns r||s, and the library encodes that pair as DER or P1363 exactly as it does for a software key.

ECDSA needs no equivalent of the RSA padding negotiation -- CKM_ECDSA is the one mechanism, it takes a bare digest, and the device truncates to the group order itself. That is why this class is so much smaller than the RSA one.

constructor Create; override; procedure Bind(aToken: tPkcs11Token; aKeyHandle: CK_OBJECT_HANDLE);
Binds to an already-located CKO_PRIVATE_KEY of type CKK_EC.
function ImportKey(const aPKIdentifier; aPKILen: Integer): Boolean; override; function GetIdentifier: string; override; function GetOrderSize: Integer; override;
Returns the current value of the fOrderBits field.
function SignDigest(const aDigest : tBytes; aOffset, aCount : Integer; aHashAlgorithm: tHashAlgorithm; out aSigR : iDSInteger; out aSigS : iDSInteger): Boolean; override; function Validate(const aPubl: iDLPublicKey): Boolean; override;
Checks that the key on the device really is the private half of aPubl, by comparing the token's public point with aPubl's. Both halves are read from the DEVICE (CKA_EC_POINT lives on the public key object, found by the CKA_ID that pairs it with this one), so this catches a certificate paired to the wrong key -- the EC equivalent of the RSA modulus check.
function GetPublicKey: iGroupElement; override;
The point NewPkcs11DLPrivateKey was given, from the paired certificate; Validate is what checks it against the device. nil after ImportKey.
property Token: tPkcs11Token read fToken; property KeyHandle: CK_OBJECT_HANDLE read fKeyHandle; property KeyLabel: string read fKeyLabel; property KeyID: tBytes read fKeyID;

Routines