Hi folks, seems to be the day of new components... I just committed a gb.crypt.openssl component to wrap the cryptographic functions in OpenSSL's libcrypto. The idea came actually from Sebastian in conjunction with his gambas-online project. But maybe it's useful to someone else.
I've been working on it since yesterday. Even if I wrote almost straight since then, this seemed kind of quick to me - which is usually not a good sign regarding code quality :-) Additionally, I'm not even a cryptography novice, so I encourage anyone with knowledge of this matter to look at the code and report any (security) problem (but not too much, please). At least, the test cases (see attachment) work correctly and without crash or memory leak (on non-Linux platforms, I can't promise anything, though; there may trigger some assert()s!) and the design seems future-proof. You basically have two classes which work somewhat alike: Digest and Cipher. One gets access to an algorithm by giving its name to the array accessors: Digest["md5"].Hash("some string") et voila. The conversion between the string "md5" and the actual hashing function is done by libcrypto itself. The names are *not* provided by my component. You can get a full list of all supported algorithm names in the Digest.List: Dim sName As String For Each sName In Digest.List.Sort() Print sName ' May contain duplicates. Don't know why... Next It's similar for the Cipher class. It has just Encrypt() and Decrypt() (and EncryptSalted() and DecryptSalted()) methods instead of Hash(). There's also the HMac class for an HMAC authentication code because this algorithm has (apparently) no such name to make it findable by the above two classes. Regards, Tobi
test_crypt_openssl-0.0.1.tar.gz
Description: Binary data
------------------------------------------------------------------------------ AlienVault Unified Security Management (USM) platform delivers complete security visibility with the essential security capabilities. Easily and efficiently configure, manage, and operate all of your security controls from a single console and one unified framework. Download a free trial. http://p.sf.net/sfu/alienvault_d2d
_______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user