views:

375

answers:

6

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.

+2  A: 

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

ldsandon
By reading through it's documentation it doesn't seem to allow to encrypt a string using an asymmetric algorithm, just symmetric ones.
carlosb
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.
ldsandon
Yep, this seems to cover my needs. Thanks!
carlosb
+1  A: 

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

Nat
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.
carlosb
Have no stomach or time for Windows Crypto API at this time, I'm looking for a quick drop-in implementation.
carlosb
@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 :D
Alexander
I agree with Alexander on this one... May I ask what it is being used for?
Nat
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.
ldsandon
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.
carlosb
A: 

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.

K.Sandell
There's no asymmetric algorithm implementation in that package.
carlosb
Right, had forgotten about that. It's been awhile since I used it myself .. but otherwise it's an excellent package.
K.Sandell
+1  A: 

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.

norgepaul
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.
ldsandon
A: 

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.

shunty
+1  A: 

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.

Sean B. Durkin