skolnick | 1 Jan 2009 19:17
Picon

Compile success on Solaris x86 - GCC 3.4.3


Hi!

Just as this link suggests: 
http://www.cryptopp.com/fom-serve/cache/99.html I am reporting I had 
success compiling cryptopp 5.5.2 on Solaris 10 U4 (x86) using the 
included GCC 3.4.3. I just had to tweak the GNUMakefile a bit:

on line 16:
- PREFIX = /usr
+ PREFIX = /usr/local

line ~40:
remove the "if GAS210_OR_LATER" and the corresponding "endif". For some 
reason, even tought Solaris GCC uses gas 2.15, it wasn't entering in the 
if and then when building it was failing because of assembler errors.

line ~45:
- CXXFLAGS += -Wa,--divide    # allow use of "/" operator
+ CXXFLAGS += -Wa # allow use of "/" operator

Sorry for not providing a patch, but I am no expert creating them. 
Notice that the build process throws a lot of warning regarding template 
usage, and other things, but in the end the cryptest.exe file passed all 
tests.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
(Continue reading)

Geoff Beier | 2 Jan 2009 06:24
Picon

Re: How to load a DSA key from binary file


On Wed, Dec 31, 2008 at 17:55, Ventura <jorge.araujo.ventura <at> gmail.com> wrote:
>
> How do I setup a DSA::PublicKey object with the data from a binary
> file generated
> using "gpg --export" ???
>

That file doesn't contain a DER-encoded subjectPublicKeyInfo
structure. If you want to parse it, look at RFC 4880 for documentation
of the packet format. Here's an example that gets openpgp keys into
OpenSSL:

http://cypherspace.org/openpgp/pgpdsa/

Obviously, that won't map perfectly to crypto++, but it should get you
a jump start on the file format. To make something that's general and
robust (that example clearly isn't), I think I'd consider using GNUTLS
OpenPGP support to produce a utility that converts the exported public
key to a subjectPublicKeyInfo structure, then using that with
crypto++.

HTH,

Geoff

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
(Continue reading)

Jorge Ventura | 2 Jan 2009 17:09
Picon

Re: How to load a DSA key from binary file

You are right. I was trying to use a key generated by  GnuPG and this one
it's not in the DER format.

I did a test using one generated by openssl in the DER format and it works.

What I am trying to do is that my code just check the signature in a text file.

Unfortunately when I use crypto++ I have to have the text and signature
in  separated files (if I am understanding crypto++). When you sign a file
with GnuPG, the signature stay in the bottom of the file, with openssl you
have two files, one with the text and another one with the signature.

One solution (I guess) is use the library gpgme, the library from GnuPG
but I have been using crypto++ for all of my code and I wouldn't like to
have second library in the program.

Do you have a better suggestion so that I can remain using Crypto++ ???

Thanks in advance,
Jorge Ventura



Geoff Beier wrote:
On Wed, Dec 31, 2008 at 17:55, Ventura <jorge.araujo.ventura <at> gmail.com> wrote:
How do I setup a DSA::PublicKey object with the data from a binary file generated using "gpg --export" ???
That file doesn't contain a DER-encoded subjectPublicKeyInfo structure. If you want to parse it, look at RFC 4880 for documentation of the packet format. Here's an example that gets openpgp keys into OpenSSL: http://cypherspace.org/openpgp/pgpdsa/ Obviously, that won't map perfectly to crypto++, but it should get you a jump start on the file format. To make something that's general and robust (that example clearly isn't), I think I'd consider using GNUTLS OpenPGP support to produce a utility that converts the exported public key to a subjectPublicKeyInfo structure, then using that with crypto++. HTH, Geoff

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

y0ug | 4 Jan 2009 12:12
Picon

Crypt file with RSA alternative


Hi,

Problem:
At first I wanted to use a system based on public key
RSA for encrypted files. But i've searched solution for encrypt data
that is larger than FixedMaxPlaintextLength().

I've find to solution on this :
- http://www.mail-archive.com/cryptopp-list <at> eskimo.com/msg03084.html

To sum up:
Generate and use a temporary AES key to encrypt the
actual file and use RSA to encrypt the AES key in the firsts octet of
file.

I wrote a class that allows you to do that, I will know what you
think.

PS: I use cryptopp552 in static lib and i compile on VC2005 SP1.

Thanks

------------------------------------------------------------------------------------------------------------------------------
// exemple.cpp
// CARON Hugo
// y0ug <at> segmentationfault33.net
// http://segmentationfault33.net
// 04/01/2009

#include "RSAClass.h"

void main(void)
{
	const char privFilename[]= "key.priv";
	const char pubFilename[] = "key.pub";

	const char File[] = "test.mp3";
	const char FileCrypt[] = "test.mp3.crypt";
	const char FileUncrypt[] = "test-new.mp3";

	RSAClass RSACrypt;

	//RSACrypt.GenerateRSAKey(2048);
	//RSACrypt.SaveKey(pubFilename,privFilename);
	RSACrypt.LoadKey(pubFilename,privFilename);

	RSACrypt.AES_CTR_Encrypt(File,FileCrypt);
	RSACrypt.AES_CTR_Decrypt(FileCrypt,FileUncrypt);
}

-----------------------------------------------------------------------------------------------------------
// RSAClass.h
// CARON Hugo
// y0ug <at> segmentationfault33.net
// http://segmentationfault33.net
// 04/01/2009

#pragma once

#include <iostream>
#include <windows.h>
#include <fstream>

#include "cryptopp552/rsa.h"
#include "cryptopp552/modes.h"
#include "cryptopp552/hex.h"
#include "cryptopp552/osrng.h"
#include "cryptopp552/des.h"
#include "cryptopp552/files.h"

#ifdef _DEBUG
#  pragma comment ( lib, "cryptlib552d" )
#else
#  pragma comment ( lib, "cryptlib552" )
#endif

using namespace std;

class RSAClass
{
public:
	RSAClass(void);
	~RSAClass(void);

	void GenerateRSAKey(unsigned int keyLength);

	void LoadKey(const char *pubFilename,const char *privFilename);
	void SaveKey(const char *pubFilename,const char *privFilename);

	string RSAEncryptString(const char *message);
	string RSADecryptString(const char *ciphertext);

	void AES_CTR_Encrypt(const char *infile, const char *outfile);
	void AES_CTR_Decrypt(const char *infile, const char *outfile);

private:
	string privString;
	string pubString;
};

-------------------------------------------------------------------------------------------------------------------
// RSAClass.cpp
// CARON Hugo
// http://segmentationfault33.net
// 04/01/2009

#include "RSAClass.h"

RSAClass::RSAClass(void)
{
}

RSAClass::~RSAClass(void)
{
}

void RSAClass::GenerateRSAKey(unsigned int keyLength)
{
	//Random seed
	CryptoPP::AutoSeededX917RNG <CryptoPP::DES_EDE3> rng;

	//Create private key RSA size keyLength and save in string privKey
	CryptoPP::RSAES_OAEP_SHA_Decryptor priv(rng, keyLength);
	CryptoPP::HexEncoder privKey(new CryptoPP::StringSink(privString));
	priv.DEREncode(privKey);
	privKey.MessageEnd();

	//Create public key RSA and save in string pubKey
	CryptoPP::RSAES_OAEP_SHA_Encryptor pub(priv);
	CryptoPP::HexEncoder pubKey(new CryptoPP::StringSink(pubString));
	pub.DEREncode(pubKey);
	pubKey.MessageEnd();
}

string RSAClass::RSAEncryptString(const char *message)
{
	//Load pubString and load encryptor for RSA
	CryptoPP::StringSource pubStr(pubString, true, new
CryptoPP::HexDecoder);
	CryptoPP::RSAES_OAEP_SHA_Encryptor pub(pubStr);
	CryptoPP::AutoSeededX917RNG <CryptoPP::DES_EDE3> rng;

	//Crypt the message and return a crypt string
	string result;
	CryptoPP::StringSource(message, true,
		new CryptoPP::PK_EncryptorFilter(rng, pub,
		new CryptoPP::HexEncoder(new CryptoPP::StringSink(result))));

	return result;
}

string RSAClass::RSADecryptString(const char *ciphertext)
{
	CryptoPP::StringSource privStr(privString, true, new
CryptoPP::HexDecoder);
	CryptoPP::RSAES_OAEP_SHA_Decryptor priv(privStr);
	CryptoPP::AutoSeededX917RNG<CryptoPP::DES_EDE3> rng;
	string result;
	CryptoPP::StringSource(ciphertext, true,
		new CryptoPP::HexDecoder(
		new CryptoPP::PK_DecryptorFilter(rng, priv,
		new CryptoPP::StringSink(result))));

	return result;
}

//Save the pubkey and private key in file
void RSAClass::SaveKey(const char *pubFilename,const char
*privFilename)
{
	CryptoPP::StringSource (pubString, true, new CryptoPP::FileSink
(pubFilename));
	CryptoPP::StringSource (privString, true, new CryptoPP::FileSink
(privFilename));
}

//Load the pubkey and private key in string
void RSAClass::LoadKey(const char *pubFilename,const char
*privFilename)
{
	CryptoPP::FileSource (pubFilename, true, new CryptoPP::StringSink
(pubString));
	CryptoPP::FileSource (privFilename, true, new CryptoPP::StringSink
(privString));
}

void RSAClass::AES_CTR_Encrypt(const char *infile, const char
*outfile)
{
	try
	{
		//Open outfile in binary and output
		ofstream file( outfile, ios::binary );

		BYTE keyAES[ CryptoPP::AES::MAX_KEYLENGTH ];
		BYTE  ivAES[ CryptoPP::AES::BLOCKSIZE ];

		//Generate AES key and iv
		CryptoPP::OS_GenerateRandomBlock(false, keyAES,
CryptoPP::AES::MAX_KEYLENGTH);
		CryptoPP::OS_GenerateRandomBlock(false, ivAES,
CryptoPP::AES::BLOCKSIZE);

		//Pass key to string
		string AesKey((char*)keyAES, CryptoPP::AES::MAX_KEYLENGTH);
		AesKey.append((char*)ivAES, CryptoPP::AES::BLOCKSIZE);

		//Crypt string AesKey with RSA and save to file stream in HexFormat
		CryptoPP::StringSource pubStr(pubString, true, new
CryptoPP::HexDecoder);
		CryptoPP::RSAES_OAEP_SHA_Encryptor pub(pubStr);
		CryptoPP::AutoSeededX917RNG <CryptoPP::DES_EDE3> rng;

		CryptoPP::StringSource(AesKey, true,
			new CryptoPP::PK_EncryptorFilter(rng, pub,
			new CryptoPP::HexEncoder(new CryptoPP::FileSink(file))));

		//Crypt file with AES-CBC and save to file stream
		CryptoPP::AES::Encryption aesEncryption( keyAES,
CryptoPP::AES::MAX_KEYLENGTH);
		CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption
( aesEncryption,ivAES );

		CryptoPP::FileSource(infile, true,
			new CryptoPP::StreamTransformationFilter(cbcEncryption,
			new CryptoPP::FileSink(file)));

		//Close the stream
		file.close();
	}
	catch(CryptoPP::Exception &e)
	{
		cout << "CryptoPP::Exception caught: " << e.what() << endl;
	}
}

void RSAClass::AES_CTR_Decrypt(const char *infile, const char
*outfile)
{
	try
	{
		//Open infile in binary and read
		ifstream file( infile , ios::binary );

		BYTE keyAES[ CryptoPP::AES::MAX_KEYLENGTH ];
		BYTE  ivAES[ CryptoPP::AES::BLOCKSIZE ];

		//Read the key in file (size of key crypted by RSA 2048 is 512)
		char Key[512];
		file.read(Key,512);

		//Decrypt Key with RSA private key
		CryptoPP::StringSource privStr(privString, true, new
CryptoPP::HexDecoder);
		CryptoPP::RSAES_OAEP_SHA_Decryptor priv(privStr);
		CryptoPP::AutoSeededX917RNG<CryptoPP::DES_EDE3> rng;
		string AesKeyUnCrypt;

		CryptoPP::StringSource(Key, true,
			new CryptoPP::HexDecoder(
			new CryptoPP::PK_DecryptorFilter(rng, priv,
			new CryptoPP::StringSink(AesKeyUnCrypt))));

		//Copy decrypted key to keyAES and ivAES
		memcpy(keyAES,AesKeyUnCrypt.data(),CryptoPP::AES::MAX_KEYLENGTH);
		memcpy(ivAES,AesKeyUnCrypt.data()+ CryptoPP::AES::MAX_KEYLENGTH,
CryptoPP::AES::BLOCKSIZE);

		//Decrypt file with AES-CBC and save to outfile
		CryptoPP::AES::Decryption aesDecryption( keyAES,
CryptoPP::AES::MAX_KEYLENGTH);
		CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption
( aesDecryption, ivAES );

		CryptoPP::FileSource(file, true,
			new CryptoPP::StreamTransformationFilter(cbcDecryption,
			new CryptoPP::FileSink(outfile)));
	}
	catch(CryptoPP::Exception &e)
	{
		cout << "CryptoPP::Exception caught: " << e.what() << endl;
	}
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Jeffrey Walton | 5 Jan 2009 17:04
Picon

Re: DSA signature check


Hi Venturea,

The following might help.
http://www.codeproject.com/KB/security/CryptoInteropSign.aspx

Jeff

On Tue, Dec 30, 2008 at 8:47 PM, Ventura <jorge.araujo.ventura <at> gmail.com> wrote:
>
> I am trying to check a file signature using an DSA key exported in
> binary. The idea is not have to install the public key in the key
> server ring but keep inside the code to check a file signed by the
> private key. My test code is:
>
> //
> // Private key exported by gpg --export <email> > pubkey.dat
> // and converted to C vector using khexdit
> //
> unsigned char pub_rem_key[937]=
> {  0x99,0x01,0xa2,0x04,0x49,0x5a,........};
>
>
> int
> main (int argc, char **argv)
> {
>  // Signature verification
>  FileSink test("test.txt", false);
>  ArraySink bufArr(pub_rem_key, sizeof(pub_rem_key));
>
>  DSA::PublicKey dsaPublicKey;
>  dsaPublicKey.Load(bufArr);
>
>  DSA::Verifier verifier(dsaPublicKey);
>
> ....
> // more code
> ....
>
>  exit(0);
> }
>
> Unfortunately the code is throwing an exception when I try to load the
> bufArr in the dsaPublicKey.
>
> terminate called after throwing an instance of
> 'CryptoPP::BERDecodeErr'
>  what():  BER decode error
> Aborted
>
> I think I have to do something with bufArr before load the key.
>
> Any suggestion is welcome. Thanks in advance,
> Jorge Ventura
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Jorge Ventura | 5 Jan 2009 19:16
Picon

Re: DSA signature check


It's perfect!

Thank you.
Ventura

Jeffrey Walton wrote:
> Hi Venturea,
>
> The following might help.
> http://www.codeproject.com/KB/security/CryptoInteropSign.aspx
>
> Jeff
>
> On Tue, Dec 30, 2008 at 8:47 PM, Ventura <jorge.araujo.ventura <at> gmail.com> wrote:
>   
>> I am trying to check a file signature using an DSA key exported in
>> binary. The idea is not have to install the public key in the key
>> server ring but keep inside the code to check a file signed by the
>> private key. My test code is:
>>
>> //
>> // Private key exported by gpg --export <email> > pubkey.dat
>> // and converted to C vector using khexdit
>> //
>> unsigned char pub_rem_key[937]=
>> {  0x99,0x01,0xa2,0x04,0x49,0x5a,........};
>>
>>
>> int
>> main (int argc, char **argv)
>> {
>>  // Signature verification
>>  FileSink test("test.txt", false);
>>  ArraySink bufArr(pub_rem_key, sizeof(pub_rem_key));
>>
>>  DSA::PublicKey dsaPublicKey;
>>  dsaPublicKey.Load(bufArr);
>>
>>  DSA::Verifier verifier(dsaPublicKey);
>>
>> ....
>> // more code
>> ....
>>
>>  exit(0);
>> }
>>
>> Unfortunately the code is throwing an exception when I try to load the
>> bufArr in the dsaPublicKey.
>>
>> terminate called after throwing an instance of
>> 'CryptoPP::BERDecodeErr'
>>  what():  BER decode error
>> Aborted
>>
>> I think I have to do something with bufArr before load the key.
>>
>> Any suggestion is welcome. Thanks in advance,
>> Jorge Ventura
>> >>
>>
>>     

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

DirtyMagic | 8 Jan 2009 01:55
Picon

Crypto++ Distribution / License Restrictions


I would like to use Crypto++ in commercial software, but there are two
parts of the license that are not clear to me. I do not have access to
a lawyer, so if anyone could clarify the restrictions for use in
commercial software it would be greatly appreciated.

1. Can I take the whole source provided in crypto552.zip, integrate
into our build system to produce a static lib, and link it in to our
application for distribution?  The parts of the license agreement
(http://www.cryptopp.com/wiki/License) that put this into question is
the patent related documentation in mars.cpp, and also the part
indicating you can place code segments into your own project "up to
the limit set by fair use".

2. If I cannot include the whole source in our application, does
anyone know what the limit of "fair use" is or which files cannot be
used as part of the application?

Thanks in advance!  Best Regards.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Geoff Beier | 8 Jan 2009 02:30
Picon

Re: Crypto++ Distribution / License Restrictions


On Wed, Jan 7, 2009 at 19:55, DirtyMagic <ctempro <at> gmail.com> wrote:
> I would like to use Crypto++ in commercial software, but there are two
> parts of the license that are not clear to me. I do not have access to
> a lawyer, so if anyone could clarify the restrictions for use in
> commercial software it would be greatly appreciated.

I'm not a lawyer, and this isn't legal advice; if you're incorporating
other people's code into software that forms the basis for your
business, and you don't understand the license requirements, it is a
very good idea to gain access to a lawyer and run the licenses for
that by them. That said, I don't think you're looking at the actual
license, but a summary. The real license is here:

http://www.cryptopp.com/License.txt

If you look at that, your situation seems to be addressed directly and
the restrictions are very clearly enumerated.

HTH,

Geoff

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

darknumen | 8 Jan 2009 07:32
Picon
Favicon

re: including cryptolib.lib in an existing lib project


Hello everyone!

I am currently trying to include the cryptlib.lib to an my lib
project. What I am trying to do is use the ECC functionality of crypto
and use it on my current lib project. I included it in the setting of
the library (project settings) but I get a lot of errors. My lib
project doesnt use MFC (btw in using Visual Studio 6.0). Could you
please point me in the right direction? If you were me, how do you go
about integrating a lib to another lib?

thanks!

Ryan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Wei Dai | 8 Jan 2009 20:10

Re: Crypto++ Distribution / License Restrictions


> 1. Can I take the whole source provided in crypto552.zip, integrate
> into our build system to produce a static lib, and link it in to our
> application for distribution?  The parts of the license agreement
> (http://www.cryptopp.com/wiki/License) that put this into question is
> the patent related documentation in mars.cpp, and also the part
> indicating you can place code segments into your own project "up to
> the limit set by fair use".

You don't have to worry about the MARS license. First, MARS is now available 
worldwide under a royalty-free license. See 
http://domino.research.ibm.com/comm/research_projects.nsf/pages/security.mars.html. 
Second, the linker will discard any algorithms you don't use, so you don't 
have to worry about patents of things you don't plan to use.

The "up to the limit set by fair use" means that because the individual 
files are public domain, you can take code segments or a few files from the 
library and not have to follow the license. If you want to add the entire 
library to your application, then just follow the license, which allows you 
to do so with a few conditions that aren't very burdensome.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe <at> googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Gmane