<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us">
  <title type="text">LockBox 3 Forums</title>
  <subtitle type="text">Feed from all the TPLB3 Forums</subtitle>
  <logo>http://lockbox.seanbdurkin.id.au/img/tiki/tikilogo.png</logo>
  <updated>2012-05-20T22:53:22-06:00</updated>
  <generator uri="http://framework.zend.com" version="1.11.11">Zend_Feed_Writer</generator>
  <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/"/>
  <link rel="self" type="application/atom+xml" href="http://lockbox.seanbdurkin.id.au/tiki-forums_rss.php?ver=5"/>
  <id>http://lockbox.seanbdurkin.id.au/</id>
  <entry>
    <title type="html"><![CDATA[RSA and SHA-1 first enciptation]]></title>
    <summary type="html"><![CDATA[I need to generate RSA encripttion SHA-1 encriptation, based on a Public/private Key
I sow the examples in the forums:


   function  TfrmMain.mEntryRSA_String(str:string):AnsiString;
   var
	Signatory1: TSignatory;
	codecRSA: TCodec;
	CryptographicLibrary1: TCryptographicLibrary;
	ms:TMemoryStream;
	base64Ciphertext: ansistring;
   begin
	Result :='';
	//=================ini====================
	codecRSA:=TCodec.Create(nil);
	CryptographicLibrary1:=TCryptographicLibrary.Create(nil);
	Signatory1:=TSignatory.Create(nil);
	//=============TCodec===================
	codecRSA.CryptoLibrary  := CryptographicLibrary1;
	codecRSA.StreamCipherId := 'native.RSA';
	codecRSA.ChainModeId:= 'native.CBC';
	codecRSA.AsymetricKeySizeInBits := 1024;

	//====Signatory1=====================
	Signatory1.Codec :=codecRSA;
	//===Load public key=============
	ms:=TMemoryStream.Create;
	ms.LoadFromFile('c:\RSAKeys_Public.dat');
	Signatory1.LoadKeysFromStream(ms,[partPublic]);
	codecRSA.EncryptString( str, base64Ciphertext);
	Result := base64Ciphertext;
	//==free===========
	ms.Free;
	codecRSA.Free;
	CryptographicLibrary1.Free;
	Signatory1.Free;
   end;



It works, but where is the “SHA-1” part where and how do I use the Thash ?

The specs that I have to follow are:
   Format = x.509 
   Charset = UTF-8
   Encoding = Base-64 
   Endianess = Little Endian 
   OAEP Padding = PKCS1 v1.5 padding 
   Key size = 1024 bits 
   Hash format = SHA-1 

Also the result must have 172 chars in size, so no line breaks must be in (“-A” in OpenSSL).

Can I also generate a binary file with the resulting SHA-1 hash?
to send to the customer.

I need the File containing the public to be a TXT file in PEM mode, likes this:
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDWDX9wVqj6ZqNZU1ojwBpyKKku
zHTCmfK39xx/T9vWkqpcV7h3sx++ZOv2KhhNkIe/1I4OCWDPCXRE4g0uIQr0NS29
vMlP3aHHayy76+lbBCNVcHFxM0ggjre1acnD0qUpZ6Vza7F+PpCyuypD2V/pkL1n
X9Z6z5uYyqc0XaSFdwIDAQAB
-----END PUBLIC KEY-----
How can I do this ?
How do I loaded.

I am messing around with security and encriptation for the first time and I am lost.
I am doing this with LockBox 3 that I just download and installed.
In DELPHI 2007
This is for a SATF-(PT) certification, in an open source billing app that I am upgrading.
Appreciate the Help, 
Thanks]]></summary>
    <published>2012-05-19T09:45:11-06:00</published>
    <updated>2012-05-19T09:45:11-06:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=3&amp;comments_parentId=298"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=3&amp;comments_parentId=298</id>
    <author>
      <name>jlouro</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[Compatible hashes]]></title>
    <summary type="html"><![CDATA[How do I use the THash to encrypt a string to give the same result as a PHP equivalent?

We have a web application being developed and I want to be able to add users in the database from a Delphi app, with the same hashed result as the PHP one does.

If I encrypt "The quick brown fox jumps over the lazy dog" on (say) [http://www.xorbin.com/tools/sha256-hash-calculator] then it gives the hashed string as d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592 but if I use THash set to SHA-256 I get B3FBA8D79480D707BC9ACA694F2E08B0E451568D76DB3C6DBFD0022D92E5C937

Thanks
Jeremy]]></summary>
    <published>2012-04-24T05:21:14-06:00</published>
    <updated>2012-04-24T05:21:14-06:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=288"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=288</id>
    <author>
      <name>homecaredirect</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[RSA Encrypt error - Wrong Mode]]></title>
    <summary type="html"><![CDATA[Hi. I created a certificate as follows:
openssl genrsa -out provider.ppk 1024

openssl req -new -key provider.ppk -out provider.req

openssl x509 -req -days 730 -in provider.req -signkey provider.ppk -out provider.cer

Then I try encrypt string:

var
  Signatory1: TSignatory;
  codecRSA: TCodec;
  CryptographicLibrary1: TCryptographicLibrary;
  ms: TStream;
  base64Ciphertext: ansistring;
begin
  Memo2.Text := '';

  codecRSA := TCodec.Create(nil);
  CryptographicLibrary1 := TCryptographicLibrary.Create(nil);
  Signatory1 := TSignatory.Create(nil);
  ms := TFileStream.Create(KEY_F_NAME, fmOpenRead);

  try
    CryptographicLibrary1.CustomCipher.ProgId := RSA_ProgId;
    codecRSA.CryptoLibrary := CryptographicLibrary1;
    codecRSA.StreamCipherId := RSA_ProgId;
    codecRSA.ChainModeId := RSA_ProgId;
    codecRSA.AsymetricKeySizeInBits := 1024;
    Signatory1.Codec := codecRSA;
    ms.Position := 0;
    Signatory1.LoadKeysFromStream(ms, [partPrivate]);
    codecRSA.EncryptString('AaaaaaA', base64Ciphertext);
    Memo1.Lines.Add(String(base64Ciphertext));
  finally
    ms.Free;
    codecRSA.Free;
    CryptographicLibrary1.Free;
    Signatory1.Free;
  end;

end;

And I take error - TSimpleCodec.Begin_EncryptMemory - Wrong mode.

What am I doing wrong?]]></summary>
    <published>2012-04-23T04:07:57-06:00</published>
    <updated>2012-04-23T04:07:57-06:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=285"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=285</id>
    <author>
      <name>mike</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[Incorrect Base64 Conversion]]></title>
    <summary type="html"><![CDATA[I believe that I found a bug in uTPLb_StreamUtils.  The Base64Chars constant appears to have the "O" and the "N" reversed.  I called Stream_to_Base64 to convert the bytes:

     $1D $F3 $71 $2D $EC $BE $03 $77 $87 $1C
     $80 $B8 $5B $FD $FE $8A $C7 $75 $D3 $B1

into Base64, and it produced:

     HfNxLey+A3eHHIC4W/3+isd107E=

rather than:

     HfOxLey+A3eHHIC4W/3+isd107E=

-- Mark]]></summary>
    <published>2012-04-05T14:15:13-06:00</published>
    <updated>2012-04-05T14:15:13-06:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=269"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=269</id>
    <author>
      <name>odie34</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[Slow RSA Decryption]]></title>
    <summary type="html"><![CDATA[I have been experimenting with LockBox 3, and am running into a performance issue with RSA decryption.

I used the Demo program to generate a set of 1024 bit keys.  This took a minute or so, but that didn't seem unreasonable given that this isn't something that's done realtime.

I then encrypted a small file (336 bytes), which seemed reasonably fast.  (The program indicated 3 KB/sec.)

I then decrypted the file that I had just created, but the task took 3 or 4 seconds.  (The Ciphertext size was 476 bytes, and the program reported -1 KB/sec.)  Unfortunately, we probably won't be able to use LockBox 3 and/or RSA if it takes 3 or 4 seconds to decrypt a small string.

I traced through the program and determined that the delay appears to be in the THugeCardinal.PowerMod method, which is called when loading the symetric key.  It appears to do a number of time-consuming calculations for each bit in the exponent (if the exponent is > 64 bits), and the exponent is 1020 bits long when decrypting.  This doesn't affect encryption, as the exponent is only 17 bits during that operation.

I understand that RSA is slower than a symetric algorithm, but 3 seconds just doesn't seem right.  Is it possible that this could be sped up?  (I don't completely understand these algorithms, so even though I could identify where the performance issue is coming from, I have no idea what to do about it.)  I'm using D7 running under XP on a 3.2 GHz P4.  This certainly isn't a power setup, but I assume that it should be adequate for this type of operation.

Thanks for any insight.
-- Mark]]></summary>
    <published>2012-04-05T09:26:58-06:00</published>
    <updated>2012-04-05T09:26:58-06:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=268"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=268</id>
    <author>
      <name>odie34</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[Some very minor comments]]></title>
    <summary type="html"><![CDATA[First off, thanks for developing LockBox3, I'm currently evaluating it.  It would be helpful if any unit that causes range or overflow warnings include

{$R-,Q-}  // turn off range and overflow checking for this unit.

at the top (I'm currently only testing twofish, so I've added this to the 
DCPtwofish_LB3Modified unit.)

This change would allow the code to work regardless of the user's compiler settings.

Also, I often turn off RTTI generation in my programs by using the following code in the .dpr file.

{$IF CompilerVersion >= 21.0}
  {$WEAKLINKRTTI ON}
  {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$IFEND}

However this causes the RTTI checking in uTPLb_Codec to give an access violation.  I actually don't know much about rtti generation in general, but I was wondering if you could explicitly turn on rtti generation in the units that need it or alternately document that users shouldn't turn off rtti in projects that include LockBox3.

Thanks again, obviously these are very minor points!

-Mark]]></summary>
    <published>2012-03-24T07:19:27-06:00</published>
    <updated>2012-03-24T07:19:27-06:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=264"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=264</id>
    <author>
      <name>markace</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[Could you make  3DES and MD5  tutorial]]></title>
    <summary type="html"><![CDATA[thanks!]]></summary>
    <published>2012-02-26T11:36:41-07:00</published>
    <updated>2012-02-26T11:36:41-07:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=257"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=257</id>
    <author>
      <name>westwood</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[Installation Problem with Delphi XE]]></title>
    <summary type="html"><![CDATA[I can not compile. The Installation program fails with this error:

......................
Will now attempt to execute 10 jobs.
Cmd: De-installing the design-time package dclTP_LockBox3.dpk with compiler Delphi XE
Diag: Job completed ok.
Cmd: Configuring TP_LockBox3.dpk in preparation for compilation.
TP_LockBox3.dpk:
  Compiler = Delphi XE
  Type = Package (BPL output)
  RunTime = True
  DesignTime = False
  Description = 'TurboPower LockBox 3 run-time package'
  Project directory = "D:\DelphiTools\LockBox3\packages\DXE"
  BPL suffix = _dXE
  BPL output dir = "D:\Users\Alfonso\Documents\Borland Studio-Projekte\Bpl"
  Include directories = D:\Users\Alfonso\Documents\Borland Studio-Projekte\Inc
  DCP output dir = "D:\DelphiTools\LockBox3\Compiled"
  DCU output dir = "D:\DelphiTools\LockBox3\Compiled"
Diag: Job completed ok.
Cmd: Compiling package TP_LockBox3.dpk with compiler Delphi XE.
Embarcadero Delphi für Win32 Compiler-Version 22.0
Copyright (c) 1983,2010 Embarcadero Technologies, Inc.

TP_LockBox3.dpk(82) Warnung: W1007 Unit 'uTPLb_OpenSSL' ist experimentell
25067 Zeilen, 0.14 Sekunden, 213828 Byte-Code, 16072 Byte-Daten.
Diag: Job completed ok.
Cmd: Configuring dclTP_LockBox3.dpk in preparation for compilation.
dclTP_LockBox3.dpk:
  Compiler = Delphi XE
  Type = Package (BPL output)
  RunTime = False
  DesignTime = True
  Description = 'TurboPower LockBox 3 design-time package'
  Project directory = "D:\DelphiTools\LockBox3\packages\DXE"
  BPL suffix = _dXE
  BPL output dir = "D:\Users\Alfonso\Documents\Borland Studio-Projekte\Bpl"
  Include directories = D:\Users\Alfonso\Documents\Borland Studio-Projekte\Inc
  DCP output dir = "D:\DelphiTools\LockBox3\Compiled"
  DCU output dir = "D:\DelphiTools\LockBox3\Compiled"
Diag: Job completed ok.
Cmd: Compiling package dclTP_LockBox3.dpk with compiler Delphi XE.
Embarcadero Delphi für Win32 Compiler-Version 22.0
Copyright (c) 1983,2010 Embarcadero Technologies, Inc.

dclTP_LockBox3.dpk(32) Schwerwiegend: E2202 Package 'TP_LockBox3_DXE' wird benötigt, konnte aber nicht gefunden werden
Diag: Job "Compiling package dclTP_LockBox3.dpk with compiler Delphi XE." failed!
Cmd: Erasing temporary configuration files.
Diag: Job completed ok.
At least one job failed. Processing of remaining jobs aborted.]]></summary>
    <published>2012-02-19T10:57:33-07:00</published>
    <updated>2012-02-19T10:57:33-07:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=249"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=249</id>
    <author>
      <name>alfonso</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[ 3.4.1 memory leak]]></title>
    <summary type="html"><![CDATA[Hi there, thank you for your great work on lockbox 3. I am also a long time LB2 user.

I am shifting my code to adapt LB3. However I've come across two memory leaks under XE/XE2 :

The OpenSSL Signatory leaks 3 unknown memory blocks when:

  OpenSSL_Signatory1.isLoaded := true;
  OpenSSL_Signatory1.GenerateKeys;

Also there will be an access violation if when GenerateKeys() is called at second time without unloading the library first.

Another leak is from TCodec's RSA decryption routine. I can decrypt using the private key without any problem, but 2x TPooledMemoryStream will be leaked each time after decryptstring/stream is called. The leak happens in both Win32 and Win64. This only affects RSA though afaik, I've tried AES and it's ok. Thanks.

-Alan]]></summary>
    <published>2012-02-19T08:17:04-07:00</published>
    <updated>2012-02-19T08:17:04-07:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=248"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=2&amp;comments_parentId=248</id>
    <author>
      <name>akirabbq</name>
    </author>
  </entry>
  <entry>
    <title type="html"><![CDATA[Blowfish from Lockbox2 Delphi and Java]]></title>
    <summary type="html"><![CDATA[Hi

I am using Lockbox2 blowfish encryption / decryption for years now and need to get a Java implementation that produces the same results.

Unfortunately I am failing to do this. Can you help me?

Thanks a lot & best regards

Daniel]]></summary>
    <published>2012-02-15T00:18:35-07:00</published>
    <updated>2012-02-15T00:18:35-07:00</updated>
    <link rel="alternate" type="text/html" href="http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=4&amp;comments_parentId=242"/>
    <id>http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?forumId=4&amp;comments_parentId=242</id>
    <author>
      <name>waeberd</name>
    </author>
  </entry>
</feed>

