Jeffrey Walton | 1 Oct 2006 02:19
Picon

Re: error C2027: use of undefined type 'CryptoPP::OID'

Hi Yosi,

Are you including asn.h in you project?

> I am  getting this error when trying to comile
> the library anyone help?
I've never had a compile problem when compiling the library (except on
earliier versions on Win 9x). Are you sure it is a library compilation
problem (and not a problem with your project)?

Jeff

On 9/29/06, Yossi <yossi1981 <at> gmail.com> wrote:
>
> Hi all.
>
> I am  getting this error when trying to comile the library
> anyone help?
>
> thanks
> --
> Yossi Mozgerashvily

Wei Dai | 1 Oct 2006 04:02

Fw: Visual Studio, SP1-Beta Issue

Colin Carter reported the following issue with VS2005 SP1 beta. In case 
others run into the same problem, it can be fixed by changing 
AllocatorBase<T>::pointer to AlignedAllocator<T>::pointer in integer.cpp.

----- Original Message ----- 
From: "Colin Carter" <cc <at> ChionaTech.com>
To: <webmaster <at> weidai.com>
Sent: Thursday, September 28, 2006 7:02 AM
Subject: Visual Studio, SP1-Beta Issue

> Hi Wei Dai
>
> We've been using your Crypto++ library for some time to do some simple
> encryption stuff in an in-house app. It's been working fine in Visual 
> Studio
> 2005 for quite some time.
>
> I just downloaded and installed the Service Pack 1 Beta for VS 2005
> (http://connect.microsoft.com/site/sitehome.aspx?SiteID=210 - you need to
> apply for the beta, then download it a bit later when you get a reply).
>
> Everything was working fine before, but now there is a compile error, and
> I'm not familiar with templates enough to fix it.
>
> The function on line 57 in the integer.cpp file:
>
> template <class T>
> CPP_TYPENAME AllocatorBase<T>::pointer
> AlignedAllocator<T>::allocate(size_type n, const void *)
>
(Continue reading)

Wei Dai | 1 Oct 2006 04:04

Re: Conformance to RFC 2440

Crypto++ does not support OpenPGP, nor am I aware of any open source projects to build OpenPGP support on top of Crypto++.
----- Original Message -----
Sent: Thursday, September 28, 2006 5:40 AM
Subject: Conformance to RFC 2440

Hi,
  
   I wish to know, if the crypto++ library conforms to RFC 2440. This
is the RFC which is Open PGP and colloquially called PGP.
  
   And if crypto++ conforms to that, then we do not need to look at gpg
project.
  
   Appreciate your time in advance.
  
  Sanjay Alavandi

Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.
Yossi | 1 Oct 2006 10:36
Picon

Re: error C2027: use of undefined type 'CryptoPP::OID'

100% sure ,
I even read documantation about this problem
which help me to dix it.
 


 
2006/10/1, Jeffrey Walton <noloader <at> gmail.com>:
Hi Yosi,

Are you including asn.h in you project?

> I am  getting this error when trying to comile
> the library anyone help?
I've never had a compile problem when compiling the library (except on
earliier versions on Win 9x). Are you sure it is a library compilation
problem (and not a problem with your project)?

Jeff

On 9/29/06, Yossi <yossi1981 <at> gmail.com> wrote:
>
> Hi all.
>
> I am  getting this error when trying to comile the library
> anyone help?
>
> thanks
> --
> Yossi Mozgerashvily




--
Yossi Mozgerashvily
Frank Martinez | 5 Oct 2006 03:47
Picon

Python Port?

Does a Python port of Crypto++ exist to anyones knowledge?

Frank Martinez
They flew on a sweet, sweet mushroom bridge to the...baseball...game. -- Strong Bad, Homestarrunner.com


Lars Magnusson | 17 Oct 2006 11:48
Picon
Favicon

Extract "raw" encrypted data from ECIES/ECP encryption?

Hi,

 

I'm using ECIES/ECP for encryption/decryption. As I understand it, a message with size n encrypted with 224 bit ECIES should be n bytes long + two 224 bit numbers, which is n+56 bytes. When I encrypt a 16 byte message, the result is 93 bytes rather than 72. What are the other bytes and how can I extract the "raw" encrypted message from the data I get from crypto++?

 

 

Source code:

----------

 

#include <string>

#include <stdio.h>

 

// Lot's of warnings from the lib without these on MSVC 2003 #pragma warning(disable:4267) #pragma warning(disable:4661)

 

#include <oids.h>

#include <osrng.h>

#include <eccrypto.h>

 

using namespace CryptoPP;

 

 

void test() {

           // Generate keys and initialize encryptor

           AutoSeededRandomPool rng;

 

           typedef ECIES<ECP>::PrivateKey ECPrivateKey;

           ECPrivateKey privkey;

           Integer integer("11111111111111111111111111111111111111111111111111111111h");

           privkey.Initialize(ASN1::secp224r1(), integer);

 

           typedef ECIES<ECP>::PublicKey ECPublicKey;

           ECPublicKey pubkey;

              privkey.MakePublicKey(pubkey);

 

           typedef ECIES<ECP>::Encryptor ECEncryptor;

           ECEncryptor encryptor(pubkey);

 

 

           // Encrypt

           string sContents("0123456789012345"); // 16 bytes

           SecByteBlock sbbCipherText(encryptor.CiphertextLength(sContents.size()));

 

           encryptor.Encrypt(

                      rng,

                      (byte const*) sContents.data(),

                      sContents.size(),

                      sbbCipherText.begin());

 

           // This prints 93, expected 72 (72 is 2*224/8+16)

           printf("Size: %d\n", sbbCipherText.size());

}

 

int main() {

           test();

           return 0;

}

 

---------

 

 

//Lars

 

Ian Thomas | 30 Oct 2006 13:52
Picon
Picon
Favicon

Encrypt with JCE (AES/CBC/PKCS5Padding), decrypt with crypto++ v521 - doesn't work!

Hello,

I'm new to cryptography and I'm working on my first project. I have 
written a Java applet to encrypt files with 128bit AES in CBC mode using 
PKCS5 padding. The 16 byte random IV is written to the file first, then 
the encrypted data. The Java app can decrypt it's own output with no 
problems. However, I need my C++ app to be able to decrypt it using 
crypto++ and it currently doesn't work.

I get a cyrpto++ exception thrown when 'messageEnd()' is called:

StreamTransformationFilter: invalid PKCS #7 block padding found.

I think this is because the two apps are not using the same block 
padding mode but I don't know how to change crypto++ to use the same 
mode. It's possible that I've just made a newbie mistake - any help 
would be fantastic!

Here's the relevant Java source code:

------------------------------------------------
       SecretKeySpec skeySpec = new SecretKeySpec(secret_key, "AES");

       // Instantiate the cipher
       Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
       cipher.init(Cipher.ENCRYPT_MODE, skeySpec);

       byte[] encrypted = cipher.doFinal( 
input_text_area_.getText().getBytes() );
             FileOutputStream output_stream = new 
FileOutputStream(output_file);
       output_stream.write( cipher.getIV() ); // write IV first
       output_stream.write(encrypted);
       output_stream.close();
---------------------------------------------------

Here's the C++:

---------------------------------------------------
   std::ifstream licence_file_stream( licence_file_, std::ios::in | 
std::ios::binary );

   // Key and IV setup
   const std::vector<byte> encryption_key = 
Base64::Decode(encryption_password);

   // read the first 16 byte block of data from the file - this is the 
IV...
   std::vector<byte> initialisation_vector(16);
   licence_file_stream.read( (char*) &initialisation_vector[0], 
initialisation_vector.size() );

   // read the remaining binary file content - this is the cipher text...
   std::vector<byte> cipher_text( file_size - 16 );
   licence_file_stream.read( (char*) &cipher_text[0], cipher_text.size() );
     licence_file_stream.close();

   // Decrypt
   CryptoPP::AES::Decryption aesDecryption( &encryption_key[0], 
encryption_key.size() );
   CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( 
aesDecryption, &initialisation_vector[0] );

   // init string sink...
   std::string decrypted_text;

   CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new 
CryptoPP::StringSink( decrypted_text ) );
   stfDecryptor.Put( &cipher_text[0], cipher_text.size() );
   stfDecryptor.MessageEnd();
----------------------------------------------------

Thanks a lot for your help,

Ian

Haytham Mohammed | 30 Oct 2006 14:56
Picon
Favicon

Re: Encrypt with JCE (AES/CBC/PKCS5Padding), decrypt with crypto++ v521 - doesn't work!

Hi Thomas
 
Instantiate the cipher with
   Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
 
instead of 
   Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
 
Regards
Haytham Mohammed
----- Original Message ----
From: Ian Thomas <thomas <at> ccdc.cam.ac.uk>
To: cryptopp-list <at> eskimo.com
Sent: Monday, October 30, 2006 2:52:48 PM
Subject: Encrypt with JCE (AES/CBC/PKCS5Padding), decrypt with crypto++ v521 - doesn't work!

Hello,

I'm new to cryptography and I'm working on my first project. I have
written a Java applet to encrypt files with 128bit AES in CBC mode using
PKCS5 padding. The 16 byte random IV is written to the file first, then
the encrypted data. The Java app can decrypt it's own output with no
problems. However, I need my C++ app to be able to decrypt it using
crypto++ and it currently doesn't work.

I get a cyrpto++ exception thrown when 'messageEnd()' is called:

StreamTransformationFilter: invalid PKCS #7 block padding found.

I think this is because the two apps are not using the same block
padding mode but I don't know how to change crypto++ to use the same
mode. It's possible that I've just made a newbie mistake - any help
would be fantastic!

Here's the relevant Java source code:

------------------------------------------------
       SecretKeySpec skeySpec = new SecretKeySpec(secret_key, "AES");

       // Instantiate the cipher
       Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
       cipher.init(Cipher.ENCRYPT_MODE, skeySpec);

       byte[] encrypted = cipher.doFinal(
input_text_area_.getText().getBytes() );
             FileOutputStream output_stream = new
FileOutputStream(output_file);
       output_stream.write( cipher.getIV() ); // write IV first
       output_stream.write(encrypted);
       output_stream.close();
---------------------------------------------------

Here's the C++:

---------------------------------------------------
   std::ifstream licence_file_stream( licence_file_, std::ios::in |
std::ios::binary );

   // Key and IV setup
   const std::vector<byte> encryption_key =
Base64::Decode(encryption_password);

   // read the first 16 byte block of data from the file - this is the
IV...
   std::vector<byte> initialisation_vector(16);
   licence_file_stream.read( (char*) &initialisation_vector[0],
initialisation_vector.size() );

   // read the remaining binary file content - this is the cipher text...
   std::vector<byte> cipher_text( file_size - 16 );
   licence_file_stream.read( (char*) &cipher_text[0], cipher_text.size() );
     licence_file_stream.close();

   // Decrypt
   CryptoPP::AES::Decryption aesDecryption( &encryption_key[0],
encryption_key.size() );
   CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(
aesDecryption, &initialisation_vector[0] );

   // init string sink...
   std::string decrypted_text;

   CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new
CryptoPP::StringSink( decrypted_text ) );
   stfDecryptor.Put( &cipher_text[0], cipher_text.size() );
   stfDecryptor.MessageEnd();
----------------------------------------------------

Thanks a lot for your help,

Ian


Ian Thomas | 30 Oct 2006 16:47
Picon
Picon
Favicon

Re: Encrypt with JCE (AES/CBC/PKCS5Padding), decrypt with crypto++ v521 - doesn't work!

Hi Haytham,

Thanks for your advice. I just made your recommended change but I now 
get an exception from my Java app:

"Cannot find any provider supporting AES/CBC/PKCS7Padding"

Does this mean that I won't be able to encrypt in Java and decrypt using 
Crypto++ because they can't use a mutually compatible padding system, or 
is there another one I can use that is supported by both systems? Is it 
not possible to configure Crypto++ to use "PKCS5Padding"?

Thanks again,

Ian

Haytham Mohammed wrote:
> Hi Thomas
>  
> Instantiate the cipher with
>    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
>  
> instead of 
>    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
>  
> Regards
> Haytham Mohammed
> ----- Original Message ----
> From: Ian Thomas <thomas <at> ccdc.cam.ac.uk>
> To: cryptopp-list <at> eskimo.com
> Sent: Monday, October 30, 2006 2:52:48 PM
> Subject: Encrypt with JCE (AES/CBC/PKCS5Padding), decrypt with 
> crypto++ v521 - doesn't work!
>
> Hello,
>
> I'm new to cryptography and I'm working on my first project. I have
> written a Java applet to encrypt files with 128bit AES in CBC mode using
> PKCS5 padding. The 16 byte random IV is written to the file first, then
> the encrypted data. The Java app can decrypt it's own output with no
> problems. However, I need my C++ app to be able to decrypt it using
> crypto++ and it currently doesn't work.
>
> I get a cyrpto++ exception thrown when 'messageEnd()' is called:
>
> StreamTransformationFilter: invalid PKCS #7 block padding found.
>
> I think this is because the two apps are not using the same block
> padding mode but I don't know how to change crypto++ to use the same
> mode. It's possible that I've just made a newbie mistake - any help
> would be fantastic!
>
> Here's the relevant Java source code:
>
> ------------------------------------------------
>        SecretKeySpec skeySpec = new SecretKeySpec(secret_key, "AES");
>
>        // Instantiate the cipher
>        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
>        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
>
>        byte[] encrypted = cipher.doFinal(
> input_text_area_.getText().getBytes() );
>              FileOutputStream output_stream = new
> FileOutputStream(output_file);
>        output_stream.write( cipher.getIV() ); // write IV first
>        output_stream.write(encrypted);
>        output_stream.close();
> ---------------------------------------------------
>
> Here's the C++:
>
> ---------------------------------------------------
>    std::ifstream licence_file_stream( licence_file_, std::ios::in |
> std::ios::binary );
>
>    // Key and IV setup
>    const std::vector<byte> encryption_key =
> Base64::Decode(encryption_password);
>
>    // read the first 16 byte block of data from the file - this is the
> IV...
>    std::vector<byte> initialisation_vector(16);
>    licence_file_stream.read( (char*) &initialisation_vector[0],
> initialisation_vector.size() );
>
>    // read the remaining binary file content - this is the cipher text...
>    std::vector<byte> cipher_text( file_size - 16 );
>    licence_file_stream.read( (char*) &cipher_text[0], 
> cipher_text.size() );
>      licence_file_stream.close();
>
>    // Decrypt
>    CryptoPP::AES::Decryption aesDecryption( &encryption_key[0],
> encryption_key.size() );
>    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(
> aesDecryption, &initialisation_vector[0] );
>
>    // init string sink...
>    std::string decrypted_text;
>
>    CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new
> CryptoPP::StringSink( decrypted_text ) );
>    stfDecryptor.Put( &cipher_text[0], cipher_text.size() );
>    stfDecryptor.MessageEnd();
> ----------------------------------------------------
>
> Thanks a lot for your help,
>
> Ian
>
>

Wei Dai | 30 Oct 2006 19:40

Re: Encrypt with JCE (AES/CBC/PKCS5Padding), decrypt with crypto++ v521 - doesn't work!

PKCS #5 padding and PKCS #7 padding are essentially the same thing. See 
http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#pad_PKCSPadding.

There is probably something else going wrong. For example not using the same 
key or IV on both sides would also produce this error, since the decrypted 
padding would be random. I suggest using the debugger and step through the 
code to see what is going on.

----- Original Message ----- 
From: "Ian Thomas" <thomas <at> ccdc.cam.ac.uk>
To: <cryptopp-list <at> eskimo.com>
Sent: Monday, October 30, 2006 11:47 PM
Subject: Re: Encrypt with JCE (AES/CBC/PKCS5Padding), decrypt with crypto++ 
v521 - doesn't work!

> Hi Haytham,
>
> Thanks for your advice. I just made your recommended change but I now get 
> an exception from my Java app:
>
> "Cannot find any provider supporting AES/CBC/PKCS7Padding"
>
> Does this mean that I won't be able to encrypt in Java and decrypt using 
> Crypto++ because they can't use a mutually compatible padding system, or 
> is there another one I can use that is supported by both systems? Is it 
> not possible to configure Crypto++ to use "PKCS5Padding"?
>
> Thanks again,
>
> Ian
>
>
> Haytham Mohammed wrote:
>> Hi Thomas
>>  Instantiate the cipher with
>>    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
>>  instead of Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
>>  Regards
>> Haytham Mohammed
>> ----- Original Message ----
>> From: Ian Thomas <thomas <at> ccdc.cam.ac.uk>
>> To: cryptopp-list <at> eskimo.com
>> Sent: Monday, October 30, 2006 2:52:48 PM
>> Subject: Encrypt with JCE (AES/CBC/PKCS5Padding), decrypt with crypto++ 
>> v521 - doesn't work!
>>
>> Hello,
>>
>> I'm new to cryptography and I'm working on my first project. I have
>> written a Java applet to encrypt files with 128bit AES in CBC mode using
>> PKCS5 padding. The 16 byte random IV is written to the file first, then
>> the encrypted data. The Java app can decrypt it's own output with no
>> problems. However, I need my C++ app to be able to decrypt it using
>> crypto++ and it currently doesn't work.
>>
>> I get a cyrpto++ exception thrown when 'messageEnd()' is called:
>>
>> StreamTransformationFilter: invalid PKCS #7 block padding found.
>>
>> I think this is because the two apps are not using the same block
>> padding mode but I don't know how to change crypto++ to use the same
>> mode. It's possible that I've just made a newbie mistake - any help
>> would be fantastic!
>>
>> Here's the relevant Java source code:
>>
>> ------------------------------------------------
>>        SecretKeySpec skeySpec = new SecretKeySpec(secret_key, "AES");
>>
>>        // Instantiate the cipher
>>        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
>>        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
>>
>>        byte[] encrypted = cipher.doFinal(
>> input_text_area_.getText().getBytes() );
>>              FileOutputStream output_stream = new
>> FileOutputStream(output_file);
>>        output_stream.write( cipher.getIV() ); // write IV first
>>        output_stream.write(encrypted);
>>        output_stream.close();
>> ---------------------------------------------------
>>
>> Here's the C++:
>>
>> ---------------------------------------------------
>>    std::ifstream licence_file_stream( licence_file_, std::ios::in |
>> std::ios::binary );
>>
>>    // Key and IV setup
>>    const std::vector<byte> encryption_key =
>> Base64::Decode(encryption_password);
>>
>>    // read the first 16 byte block of data from the file - this is the
>> IV...
>>    std::vector<byte> initialisation_vector(16);
>>    licence_file_stream.read( (char*) &initialisation_vector[0],
>> initialisation_vector.size() );
>>
>>    // read the remaining binary file content - this is the cipher text...
>>    std::vector<byte> cipher_text( file_size - 16 );
>>    licence_file_stream.read( (char*) &cipher_text[0], 
>> cipher_text.size() );
>>      licence_file_stream.close();
>>
>>    // Decrypt
>>    CryptoPP::AES::Decryption aesDecryption( &encryption_key[0],
>> encryption_key.size() );
>>    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(
>> aesDecryption, &initialisation_vector[0] );
>>
>>    // init string sink...
>>    std::string decrypted_text;
>>
>>    CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new
>> CryptoPP::StringSink( decrypted_text ) );
>>    stfDecryptor.Put( &cipher_text[0], cipher_text.size() );
>>    stfDecryptor.MessageEnd();
>> ----------------------------------------------------
>>
>> Thanks a lot for your help,
>>
>> Ian
>>
>>
> 


Gmane