EldoS | Feel safer!

Software components for data protection, secure storage and transfer

RSA encryption / decryption

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#24658
Posted: 04/23/2013 10:00:08
by Pierre Nuttin (Basic support level)
Joined: 04/23/2013
Posts: 4

Hi,

I'm trying to use SB to encrypt / decrypt message.

Language : Delphi

I dont have pem files, I only have numbers ( e public exponant, d private exponant, n modulus )

Encryption is ok

RSA := TElRSAPublicKeyCrypto.create (SB_OID_RSAENCRYPTION) ;
KeyMaterial := TElRSAKeyMaterial.Create ;
KeyMaterial.LoadPublic(@sModulus[1], length(sModulus) , @sExp[1] , length(sExp) );
RSA.KeyMaterial := KeyMaterial ;
...
RSA.Encrypt(AStream , AstreamOut );

But How can I load the priavet exponant to decrypt ?

I tried

RSA := TElRSAPublicKeyCrypto.create (SB_OID_RSAENCRYPTION) ;
KeyMaterial := TElRSAKeyMaterial.Create ;
KeyMaterial.LoadPublic(@sModulus[1], length(sModulus) , @sExp[1] , length(sExp) );

KeyMaterial.Passphrase := '' ;
KeyMaterial.LoadSecret(@sPvKey[1], 0 );

( or KeyMaterial.LoadSecret(@sPvKey[1], length(sPvKey) );

==> I'm receiving error because invalid secret key ( no in ASN1 format ? )

RSA.KeyMaterial := KeyMaterial ;
RSA.Decrypt(AStream , AstreamOut );

Thanks

Example :

Message = 'test'

n = 'a526...98d3' ;

e = '010001'

encrypted =: 5541...df5f

d = '8e99...a161' ;

I'm converting these hex values in binary before using them. (except for the message 'test' )
#24659
Posted: 04/23/2013 10:35:42
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi. Thank you for contacting us.

ElRSAKeyMaterial expects secret/public key in specific ASN.1 encoded structure.
You can use method .EncodePrivate key to build that structure and save to buffer, and later call .LoadSecret on this buffer.
#24660
Posted: 04/23/2013 10:50:52
by Pierre Nuttin (Basic support level)
Joined: 04/23/2013
Posts: 4

Thanks , I will try in the next days !
#24677
Posted: 04/25/2013 04:43:07
by Pierre Nuttin (Basic support level)
Joined: 04/23/2013
Posts: 4

I tried

KeyMaterial.EncodePrivateKey(@sModulus[1],0,@sExp[1],0, @sPvKey[1],0,@sPvKey[1],0,@Q[1],0,....

But I dont have DP , DQ

Not possible to only use N, D , E ?

or only N, D,E , P, Q ?

Thanks
#24678
Posted: 04/25/2013 04:50:31
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

RSA key material has overload with N, E, D parameters, you should use it:

Code
function EncodePrivateKey(PublicModulus : pointer; PublicModulusSize : integer;
PublicExponent : pointer; PublicExponentSize : integer; PrivateExponent : pointer; PrivateExponentSize : integer; OutBuffer : pointer; var OutSize : integer) : boolean; overload;
#24679
Posted: 04/25/2013 05:25:36
by Pierre Nuttin (Basic support level)
Joined: 04/23/2013
Posts: 4

Is it present in SB version 6 (for Delphi 6) ?

I dont see it.

thanks
#24680
Posted: 04/25/2013 05:33:35
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

SBB 6 is quite old. Please download the latest SecureBlackbox 10 from our site. It also supports Delphi 6.
#24681
Posted: 04/25/2013 08:23:09
by Eugene Mayevski (EldoS Corp.)

Can you please elaborate why you are using version 6? If you have a license for it, please link the license ticket to your user account before we continue. The ticket itself and the procedure of its use are specified in the registration e-mail that was sent to you upon license purchase. If you don't have the license ticket, please contact the person from which you have obtained the license key (the one in your source code) for a license ticket.

NOTE: please don't post license keys and license tickets to the forum. If you need to clarify something about your license, please use HelpDesk ( http://www.eldos.com/helpdesk/ ).


Sincerely yours
Eugene Mayevski
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

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