EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Signature text using the algorithms RSA and SHA1

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#32921
Posted: 04/02/2015 13:23:41
by Eugene Mayevski (EldoS Corp.)

Here's a small sample. Please note -- if you use Unicode Delphi, then TStringStream can not be used. Instead you will need to use TMemoryStream and read/write your string data to/from those streams.


Code
Crypto := TElRSAPublicKeyCrypto.Create();
    try
        Crypto.KeyMaterial := ACert.KeyMaterial; // here you will need to specify an instance of TElRSAPublicKey
        Crypto.InputEncoding := pkeBinary;
        Crypto.InputIsHash := false;
        Crypto.HashAlgorithm := SB_ALGORITHM_DGST_SHA1;

        Crypto.OutputEncoding := pkeBase64;

        StringStream := TStringStream.Create( 'your login challenge here' );
        SignStringStream := TStringStream.Create( '' );

        Crypto.SignDetached( StringStream , SignStringStream );

        MessageDlg( SignStringStream.DataString , mtWarning, [mbOK], 0);
    finally
        FreeAndNil(Crypto);
    end;


Sincerely yours
Eugene Mayevski
#32922
Posted: 04/02/2015 13:32:36
by Lucas Fávero (Standard support level)
Joined: 05/27/2013
Posts: 9

This is the chalenge example of the webservice manual

<DesafioAssinado>JZZ5m8xln6E0/Tr9ySyum0Co2SahD+c1rG31POaL+oGdDz8S0JauK1S3DfhoQBPYir/sZWokSsJFj/7ObEH0T
ZdOGiT11O6nVJnjBKU7xGES+cnq1SJ9CgHIrUYctuuNvZFD/3HsmdXyWQZyrC/+IaesKbfkKJwGG4PZnvX+Ckk=</DesafioAssinado>
#32923
Posted: 04/02/2015 13:37:56
by Lucas Fávero (Standard support level)
Joined: 05/27/2013
Posts: 9

I was unable to implement this example
#32924
Posted: 04/02/2015 13:43:46
by Lucas Fávero (Standard support level)
Joined: 05/27/2013
Posts: 9

the command was not recognized

Crypto.HashAlgorithm := SB_ALGORITHM_DGST_SHA1;
#32926
Posted: 04/03/2015 01:08:58
by Eugene Mayevski (EldoS Corp.)

Can you please specify what exactly error you got on that line? If there's a constant not found, then you need to add SBConstants to the Uses clause.

In general we have samples in <SecureBlackbox>\Samples\Delphi\PKIBlackbox\Primitives directory, including the ones for PKCS#1 signing.


Sincerely yours
Eugene Mayevski
#32988
Posted: 04/07/2015 09:24:48
by Lucas Fávero (Standard support level)
Joined: 05/27/2013
Posts: 9

I managed to solve the problem. Perfectly signed the challenge and I managed to connect the webservice I needed.

I used the example PKIBlackbox - Primitives - SignDetached.

But I had to add the commands
Crypto.InputIsHash: = false;
Crypto.HashAlgorithm: = SB_ALGORITHM_DGST_SHA1;

just after
Crypto: TElRSAPublicKeyCrypto.Create = ();

Without these two lines was not working. More now worked.
Thanks for your help.
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.

Reply

Statistics

Topic viewed 2266 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!