Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » External resources » Cripto with Botan
Cripto with Botan [message #22303] Thu, 02 July 2009 12:10 Go to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member
Hi All

Can anyone help me compile the Botan Cryptographic library using ultimate++ with gcc because it has some nice algorithms missing in the Crypto package.

Here's were I'm now, I created a new Package, and used the Import Directory Source function in the Package Organizer, but with no success, it generates the file list but they all point to the first level of the folder structure. Is this expected? Confused
I manually added some files later to the upp file. Rolling Eyes

Compile fails because it cannot find the include file Crying or Very Sad <botan\whatever.h>

I could change the lines to "whatever.h" because all the <botan\...> include files are in utils sub directory, but I don't want to make changes to the code.

Can someone shed some light?

Thanks
Re: Cripto with Botan [message #22309 is a reply to message #22303] Thu, 02 July 2009 23:50 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3023
Registered: August 2008
Ultimate Member
Hello Ruimg

Thank you for your post.

I was looking without success for some easy to use library to code files or data in a database (Cryptography is enough complex by itself) to be used from Upp. With your post you have given me the key Razz

It seems Botan is the best option, over Crypto++.

So I will help you to compile Botan in Upp. Your compiling problems sound familiar to me.

One problem I have is that I will stay on holidays for one week.

If you have not done it before, we will have a Hello World ready pretty soon.

Best regards
Koldo


Best regards
Iñaki
Re: Cripto with Botan [message #22327 is a reply to message #22309] Fri, 03 July 2009 18:59 Go to previous messageGo to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member
Hi koldo

Glad to be of use, and thanks for the help.

Managed to compile Botan from command line with cl (VS 2009) compiler, although with the gcc (MinGW)(3.4.5) gives me the following message

.../3.4.5/cwchar:161: error: `::swprintf' has not been declared

I googled this error and it seams that this is an MinGW bug, I'm trying to work around it... maybe tomorrow I'll try again

Command Line used to compile :

perl configure.pl --msvc
nmake

here is some output so you can help me put the any necessary compiler parameter onto theIde
...
cl.exe /Ibuild\include /O2 /EHsc /GR /D_CONSOLE /nologo /c src\asn1\asn1_att.cpp /Fobuild\lib\asn1_att.obj
...

My question is this, how can I add the src files to theIde and perform the compilation from there?

Many thanks, have nice vacations

Re: Cripto with Botan [message #22329 is a reply to message #22327] Fri, 03 July 2009 21:33 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3023
Registered: August 2008
Ultimate Member
Hello Rui

Just my last post before vacation.

It has happen the same to me: Good compiling with Msc9 but problems with MinGW (gcc 4.4.0).

We have a problem: Botan compiling infrastructure make some ad hoc .h files and choose the right .cpp set of files depending on for example OS and compiler Sad. I do not know how to do that in Upp.

I have tried to compile in Upp the Msc version, taking the right set of .cpp files (after checking the configure output...) and using the command line options as you have indicated in your post. But I have found compiling problems in some files.

I am trying a solution:
- For the .cpp ... use the libbotan.lib compiled with the command line configure
- For the .h, I have checked that both msc and mingw have many common .h files but only 3 different, so I have created 3 dummy .h files with this:

build.h
#if defined(__MINGW32__)
#include <mingw/build.h>
#elif defined(_MSC_VER)
#include <msc/build.h>
#endif


This way it is very simple to update the library. The drawback is that you cannot debug inside.

Best regards
Koldo


Best regards
Iñaki
Re: Cripto with Botan [message #22385 is a reply to message #22303] Thu, 09 July 2009 17:38 Go to previous messageGo to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member
Hello

I found out that for you to compile most of the complex libs you have to disable BLITZ because of duplicated declarations. I was unable to workaround this.

I just created a upp file with the required files and compiler options. Botan does compile (with some dll warnings) with the MSVC compiler.

Please put the Botan.upp file in the root of your Botan project
My project root directory is called Botan
This file also includes some necessary compiler options.

This should compile only in windows and with the MSVC compiler.

Some problems have arise

The Assist++ has gone mad, it does not auto complete some parts of Botan.

To compile my project with Botan theIDE had to have the include paths option by project. Without this I had to include the /I option in my projects compiler like this "/I..\botan\build\include"

I did not link yet, so I don't know if it works.

Shocked
Since Botan is too architecture dependent I decided to compile Crypto++ with success, if you want I can pack it and send it to you.

Best regards
  • Attachment: Botan.upp
    (Size: 12.94KB, Downloaded 458 times)
Re: Cripto with Botan [message #22386 is a reply to message #22385] Thu, 09 July 2009 17:44 Go to previous messageGo to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member
Ok ok here's the Crypto++ lib Smile Laughing

I should make some changes and make a wapper for the lib, in the mean time here's some simple functions


#include "CryptoPP/hex.h"
#include "CryptoPP/dll.h"
#include "CryptoPP/default.h"
#include "CryptoPP/md5.h"
#include "CryptoPP/hex.h"

.....

	String EncryptString(String &instr, String &passPhrase)
	{
		std::string outstr;
	
		CryptoPP::DefaultEncryptorWithMAC encryptor(passPhrase, new CryptoPP::HexEncoder(new CryptoPP::StringSink(outstr)));
		encryptor.Put((byte *)instr.Begin(), instr.GetLength());
		encryptor.MessageEnd();
	
		return outstr;
	}
	
	String DecryptString(String &instr, String &passPhrase)
	{
		std::string outstr;
	
		CryptoPP::HexDecoder decryptor(new CryptoPP::DefaultDecryptorWithMAC(passPhrase, new CryptoPP::StringSink(outstr)));
		decryptor.Put((byte *)instr.Begin(), instr.GetLength());
		decryptor.MessageEnd();
	
		return outstr;
	}
  • Attachment: CryptoPP.7z
    (Size: 702.29KB, Downloaded 460 times)
Re: Cripto with Botan [message #22405 is a reply to message #22386] Fri, 10 July 2009 15:37 Go to previous messageGo to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member

Botan VS Crypto++[ 3 votes ]
1. Botan of course 1 / 33%
2. Crypto++ Rules 2 / 67%

New post for new botan upp project. Shocked

Now Compiles with VC9 and MingW.

Before changing compiler you must run the configure.pl script, I tried to automate this or make some adjustments to the project with no success.

So, for Microsoft Visual Studio compiler run

perl configure.pl -cc msvc

For Mingw GCC (in my case I have to disable TR1 so)

perl configure.pl -cc gcc --with-tr1=none

Either MSVC and Mingw compilation gives me a lot of warnings

I'm using Ultimate++ build 1393 Cool witch adds some interesting options like internal includes.
So I changed my project file, no more /I compiler options.

Some test code

#include <botan/botan.h>
#include <botan/pbkdf2.h>
#include <botan/hmac.h>
#include <botan/sha160.h>

...

	void DoBotan()
	{   
		using namespace Botan;
		try{
			LibraryInitializer init;
			
	        AutoSeeded_RNG rng;

	        std::auto_ptr<S2K> s2k(get_s2k("PBKDF2(SHA-1)"));
	        s2k->set_iterations(8192);
	        s2k->new_random_salt(rng, 8);
	
	        SymmetricKey key = s2k->derive_key(16, "TEST");
	
			std::string alg = "AES/CBC/PKCS7";
			Pipe enc(get_cipher(alg, key, ENCRYPTION), new Hex_Encoder);
			Pipe dec(new Hex_Decoder, get_cipher(alg, key, DECRYPTION));
			String secret = ToUtf8(txtIn.GetText());
			enc.process_msg(secret);
			String cipher = enc.read_all_as_string();
			dec.process_msg(cipher);
			String bubu = dec.read_all_as_string();
			
			PromptOK(bubu);
		}
		catch (std::exception se)
		{
			String err;
			err << "Error \n" << se.what();
			PromptOK(err);
		}
	}


Assist++ is still a bit broken try to list the enc variable methods for example, many are missing.

Created a poll to spice discussion.

Next is to create a simple Botan Wrapper
  • Attachment: Botan.upp
    (Size: 13.08KB, Downloaded 454 times)

[Updated on: Fri, 10 July 2009 15:38]

Report message to a moderator

Re: Cripto with Botan [message #22420 is a reply to message #22405] Mon, 13 July 2009 15:55 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3023
Registered: August 2008
Ultimate Member
Hello Ruimg

After some effort I have compiled a console sample with Botan Smile

About the poll, could you advise me?

I just want a library to encrypt:
- Database fields (strings)
- Files

so that with the right password you can decrypt it.

Coding system?. I just want one so that nobody in the world (without running millions of computers to brute force attack it Smile) can read the string or file without the password.

If you have that fitted into Upp, I will vote yes.

For your info I have found a library comparison here:
http://cookingandcoding.wordpress.com/2008/09/20/c-crypto-li braries/

Best regards
Koldo


Best regards
Iñaki
Re: Cripto with Botan [message #22421 is a reply to message #22420] Mon, 13 July 2009 16:52 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1400
Registered: September 2007
Senior Contributor
IMO the poll is a little bit premature. Both libraries have a horrible interface from both what I think is the U++ way and a personal point of view. But with some nice wrappers, using both should be equally easy and then I think we should decide based on technical merit. Just my 2 cents, I don't want to discourage this effort, because I think it is well worth while.

But if I had to choose now, I would say Crypto++.
Re: Cripto with Botan [message #22422 is a reply to message #22421] Mon, 13 July 2009 19:41 Go to previous messageGo to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member
Hello koldo

I must agree with cbpporter. Both of the libs have woeful interfaces. I will try to create a simple wapper for Cripto++ the U++ way. Razz

Botan is much harder to compile because it needs some scripts to enable the right files to be compiled. (Had a bad time with this one Confused )
On the other hand Cripto++ compiled smoothly on both compilers.

This being said, for simple encryption with multi-platform ease Cripto++ is the way to go.
Re: Cripto with Botan [message #22425 is a reply to message #22303] Tue, 14 July 2009 00:21 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3023
Registered: August 2008
Ultimate Member
Hello all

I think the same. Both seem to work but Botan is more difficult to match with Upp.

So for me it is better a wrapper to Crypto++ following your comments and if possible my suggestions.

Best regards
Koldo

Addition. Two links
- Integration with Msc in http://www.codeproject.com/KB/tips/CryptoPPIntegration.aspx
- Libraries comparison in http://idlebox.net/2008/0714-cryptography-speedtest-comparis on/

Other thing Rui. If you would not have time we are here to help Smile


Best regards
Iñaki

[Updated on: Tue, 14 July 2009 00:25]

Report message to a moderator

Re: Cripto with Botan [message #22601 is a reply to message #22425] Thu, 30 July 2009 08:42 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3023
Registered: August 2008
Ultimate Member
Hello Rui

Could you post a project with a demo using Crypto ?. I cannot wait any more for the wrapper Smile

Best regards
Koldo


Best regards
Iñaki
Re: Cripto with Crypto++ [message #23123 is a reply to message #22601] Thu, 17 September 2009 20:41 Go to previous messageGo to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member
Hello all

Sorry for the delay... Rolling Eyes
Been very busy and have no time for my own projects.

But here is the current state of my small Crypto++ wrapper.

Features :
- MD5 and SHA Hash
- Symmetric String Encryption
- Asymmetric RSA String Encryption (this is cool)

See Test function for how to use it.

Please send comments, bugs and contributes. It is fairly easy to add code so do it!

Am trying to keeping it simple.

NOTES : It does not compile with MingW because the AES needs to be patched. Maybe on my second release.
  • Attachment: CryptoPP.zip
    (Size: 1.00MB, Downloaded 437 times)
Re: Cripto with Crypto++ [message #23170 is a reply to message #23123] Mon, 21 September 2009 18:15 Go to previous messageGo to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member
Hi again

New version released Very Happy

Changes include
MingW compiler support
Added allot more Hash Algorithms (CRC, SHA2, Tiger, Whirlpool, RIPEMD, ...)
Rijndael(AES) alloca bug solved.

  • Attachment: CryptoPP.7z
    (Size: 705.31KB, Downloaded 459 times)
Re: Cripto with CryptoPP [message #23217 is a reply to message #22303] Tue, 29 September 2009 16:40 Go to previous messageGo to next message
Ruimg is currently offline  Ruimg
Messages: 10
Registered: July 2009
Promising Member
Hi again.

New release BUT with memory leak! Shocked

Added a password based template class that can use with any desired hash and encryption algorithm.

This is quite nice but suffers from a memory leak that I cant find.
passcrypt.h is not made by me so credits go to ???

Leak happens with MSVC compiler near PutMaybeModifiable in filters.h while executing Test method.

Can anyone please help?
  • Attachment: CryptoPP.7z
    (Size: 706.45KB, Downloaded 475 times)
Re: Cripto with CryptoPP [message #35455 is a reply to message #23217] Sat, 18 February 2012 21:06 Go to previous message
koldo is currently offline  koldo
Messages: 3023
Registered: August 2008
Ultimate Member
Hello Rui

Please check this version. It seems to work perfect for MinGW and MSC. It is now a pure console app (CryptoPP_demo).

It uses latest CryptoPP.

Best regards
Koldo

PD: Included a couple of fixes and now works perfectly with gcc 4.6 in Ubuntu 11.10.


Best regards
Iñaki

[Updated on: Mon, 20 February 2012 10:03]

Report message to a moderator

Previous Topic: Old version in getdeb
Next Topic: an efficient embedded database library
Goto Forum:
  


Current Time: Tue Nov 12 22:02:51 CET 2019

Total time taken to generate the page: 0.01953 seconds