Delphi asymmetric encryption
Asked Answered
O

6

9

I'm looking for a Delphi implementation of an asymmetric encryption algorithm without any dependencies on external DLLs. Is there any available?

My goal is to encrypt/decrypt a string (or array of bytes) using a public/private key pair.

Oballa answered 8/6, 2010 at 15:40 Comment(0)
R
7

SecureBlackBox from Eldos offers a native, comprehensive solution - including certificate management and access to external crypto devices (i.e. USB tokens)

Rugged answered 8/6, 2010 at 18:40 Comment(3)
By reading through it's documentation it doesn't seem to allow to encrypt a string using an asymmetric algorithm, just symmetric ones.Oballa
Look at ElRSAPublicKeyCrypto class. You may need to go through a Stream (use the TStringStream class, in needed), because you must threat cyphered data as binary stream to avoid character set conversions.Rugged
Yep, this seems to cover my needs. Thanks!Oballa
K
5

LockBox is now improved. It allows long keys for RSA, AES cipher and is in active development. It is free, Open Source and 100% native code with no DLLs.

Kirwin answered 26/10, 2010 at 0:27 Comment(0)
Q
3

You can try Lockbox - http://sourceforge.net/projects/tplockbox/. It's free and includes RSA among others (Blowfish, MD5, SHA-1, DES, triple-DES, Rijndael, & digital signing of messages).

It comes complete with a good RSA example that demonstrates how to generate your public/private keys and how to actually encrypt and decrypt data using the keys.

I'm currently using it with Delphi 2010.

Quipster answered 9/6, 2010 at 20:26 Comment(2)
Until improved, LockBox implements only short keys and weak block ciphers. Last release in now seven years old, and in cryptography relying on old, not updated code may be dangerous.Rugged
The above comment only applies to Lockbox 2. Lockbox 3 is a great improvement over Lockbox 2 - Asymetric keys of arbitary length and strong ciphers.Kirwin
S
3

I realize that the original question stated "no external DLLs" but in the absence of an acceptable answer maybe you should take a look at the OpenSSL DLLs along with this Delphi link which contains an import unit for the library and some good examples on how to use it, including RSA encryption.
I have tinkered with this and got it working pretty well. There are some changes required to make it work with unicode Delphi - but these are mostly to do with changing PChar to PAnsiChar or PBytes.
Simple Delphi wrappers now allow me to sign/verify/encrypt sym or asym and use SSL. And let's be honest - the distribution of the OpenSSL DLLs is a lot more straightforward than some of the Microsoft offerings. Plus it's free and well maintained.

Schmeltzer answered 10/6, 2010 at 9:55 Comment(0)
R
2

Take a look at the FGInt package on this site: http://submanifold.be/

If you can stomach using Windows services, there is the Crypto API: http://msdn.microsoft.com/en-us/library/aa380255(v=VS.85).aspx

If you are targeting Vista and up, there is the new Cryptography API: Next Generation. This also supports Elliptic Curve crypto: http://msdn.microsoft.com/en-us/library/aa376210(VS.85).aspx

Ribbonfish answered 9/6, 2010 at 2:30 Comment(6)
Took a look into the FGIntRSA (and FGInt) package but due to the lack of any documentation wasn't able to figure out how to handle the public/private keys.Oballa
Have no stomach or time for Windows Crypto API at this time, I'm looking for a quick drop-in implementation.Oballa
@carlosb - you want a "drop-and-forget" approach for a security solution? Are you sure? The result will be the same as no using encryption at all :DHaletky
I agree with Alexander on this one... May I ask what it is being used for?Ribbonfish
I guess the OP meant a Delphi library to implement security without having to wrestle with Windows CryptoAPI or implementing algotithms from scratch. DIY in security could be very dangerous too.Rugged
Alexander and Nat, the goal is simple, need to encrypt an activation string with a private key on a server, that string will be handled by users which unless encrypted could be tampered, that activation string will then be decrypted on the application using the public key. This should be something quick and efficient to implement provided an appropriate Delphi framework exists, something like DCPCrypt but with asymmetric algorithm support.Oballa
D
1

Another very good fairly complete package is the Delphi Encryption Compendium (DEC) 5.2. You can download (Free with source) from http://www.torry.net/pages.php?id=519#939342.

Darnel answered 9/6, 2010 at 6:26 Comment(2)
There's no asymmetric algorithm implementation in that package.Oballa
Right, had forgotten about that. It's been awhile since I used it myself .. but otherwise it's an excellent package.Darnel

© 2022 - 2024 — McMap. All rights reserved.