Page 1 of 1

Digital Signature - SHA256 RSA

Posted: Tue 03 Aug 2021 02:06
by james883
Hi, We are Delphi developer and new to Digital Signature.
We would like to know if this can be done using SecureBridge component ?

Customer requested Digital Signature on a text file which generated from our application.

Here are the details :
Signature algorithm : SHA256 RSA (where RSA is using 2048 Bits)
Signature hash algorithm : SHA256
Signature key (Signer’s private key) provided
Verification key (Signer’s public key) provided

Private Key/Public Key : RSA (2048 Bits)

Basically what we need is > Text > Hash (with provided key) > generate text file and signature file.

May I know how to go about it using Secure Bridge component ?

Thank you

Re: Digital Signature - SHA256 RSA

Posted: Fri 06 Aug 2021 15:17
by YanishevskiyVI
Hi James,

You may use TScKey object directly as showed in an example:

Code: Select all

uses ...ScBridge, ScUtils
...
var
  Source, Signed :TBytes;
  aComment: string;
  Key: TScKey;
...  
  Key := TScKey.Create();
  Key.ImportFrom('MyKeyFile.pem',Password,aComment);
...  
  Signed := Key.Sign(Source, haSHA2_256);
...
  if Key.VerifySign(Source, Signed, haSHA2_256) = True then
    //Sign is verified
...  
  Key.Free;
...
Please note: TScKey cannot sign files directly but only a TBytes buffers. Thus, you must fill Source before call TScKey.Sign.

See also:
Class TScKey;
Method TScKey.ImportKey;
Method TScKey.Sign;
Method TScKey.VerifySign;
Type TScHashAlgorithm.