Abort from the CryptoPP Libraray, need help !

55 views
Skip to first unread message

MrWebLover

unread,
Jul 13, 2004, 6:49:24 AM7/13/04
to crypto...@eskimo.com
Hi @ all,

at the first, sorry for my bad english.
I have wrote some functions in windows (Visual Studio 6) to handle
my parts with the library. All worked fine.

Now i compiled the cryptopp library on linux (gcc 3.3.1).
The compile was successful.

Now i test a little Program like this :

RandomPool randPool;
randPool.Put((byte *)"->My-Security-Seed<-", 20);

RSAES_OAEP_SHA_Decryptor priv(randPool, 1024);

The Program 'abort' at the last line 'RSAES_OAEP_SHA_Decryptor
priv(randPool, 1024)'

Can someone give me a tip, what the problem ?

Very thanks for help !

Best regards,
Torsten
Alias MrWebLover

MrWebLover

unread,
Jul 13, 2004, 8:18:26 AM7/13/04
to crypto...@eskimo.com

Hi @ all again,

i have tested my testprogram on an other Linux machine with gcc 3.2
The same problem occurs.

Please help me fast ! I need a solution to work with the cryptopp
library on linux.

Here is my full testprogram :

#include "cryptlib.h"
#include "randpool.h"
#include "sha.h"
#include "rsa.h"
#include "hex.h"
#include "files.h"
#include "pubkey.h"
#include "validate.h"
#include "randpool.h"
#include "pkcspad.h"
#include "oaep.h"
#include "integer.h"
#include "asn.h"

#include <stdio.h>

using namespace std;
using namespace CryptoPP;
int main()
{
/* Nun erstellen der Key's */
RandomPool randPool;
printf("1\n");


randPool.Put((byte *)"->My-Security-Seed<-", 20);

printf("2\n");
RSAES_OAEP_SHA_Decryptor priv(randPool, 4096);

printf("3\n");
RSAES_OAEP_SHA_Encryptor shorterPriv(priv);
printf("Ende\n");

James Vanns

unread,
Jul 13, 2004, 10:39:50 AM7/13/04
to crypto...@eskimo.com
Well the following (albeit slightly amended - note the headers) compiles
and runs OK on my Fedora Core 2 box. Of course, your code doesn't do
much! Also, note I changed the 4096 down to a realistic 1024.

#include <sha.h>
#include <rsa.h>
#include <osrng.h>

#include <stdio.h>

using namespace std;
using namespace CryptoPP;

int main (int argc, char *argv[]) {
RandomPool randPool;

printf ("1\n");
randPool.Put ((byte *)"->My-Security-Seed<-", 20);

printf("2\n");
RSAES_OAEP_SHA_Decryptor priv(randPool, 1024);

printf("3\n");
RSAES_OAEP_SHA_Encryptor shorterPriv(priv);

printf("End\n");
}

Jim

--
James Vanns BSc (Hons) MCP
Senior Software Engineer (Linux / C & C++)
Canterbury Christ Church University College
Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x24045370


MrWebLover

unread,
Jul 13, 2004, 11:50:22 AM7/13/04
to crypto...@eskimo.com
Thank you Jim,

for your help !
It's right, my testprogram doesn't do much. The rest i have cutted,
because the error
occurs in this snippet.
I have tested your example, and i have the same error. The program
abort's at the line :

RSAES_OAEP_SHA_Decryptor priv(randPool, 1024);

At windows all works fine ...
The compile of the library on linux work's too.
I can not resolv the error. I hope someone can help me.

Is there a trick to compile ? I have compiled with the GNUMakefile (gmake).

Thanks for your answer's.

Best regards
Torsten

James Vanns

unread,
Jul 13, 2004, 12:26:38 PM7/13/04
to crypto...@eskimo.com
Hmm, so the app linked fine (against the cryptopp library)? You could
try and look at the symbols (using 'nm' and grep) to see if the cryptopp
functions do appear (it being c++ they're probably a little mangled).

Compile it with debugging info and run it from gdb. Then do a stack
trace (bt) and post the output. This may not help much but it's a start.

What version of gcc and ld are you using? Oh BTW the obvious thing is of
course to add exception handling in your program so you can catch the
exception and at least print out what it says rather than just letting
it abort.

Jim

> .
>
>
> James Vanns schrieb:

MrWebLover

unread,
Jul 13, 2004, 12:56:14 PM7/13/04
to crypto...@eskimo.com
Hi Jim,

also i have tested the cryptest.exe program
with the option g, also
cryptest.exe g
the program runs the same code, as my testprogram.
In the cryptest.exe program, compiled with the GNUMakefile, it works.
If i copy the relevant code in a separate file and compile it with :
g++ -o mytest -g -msse2 -pipe mytest.cpp -lcryptopp

The compile is succesful but the program aborts.
I have included the exception handling, and this is the output :

CryptoPP::Exception caught: NameValuePairs: type mismatch for
'RandomNumberType', stored 'i', trying to retrieve
'N8CryptoPP7Integer16RandomNumberTypeE'

Help this ?

Torsten

James Vanns schrieb:

Walton, Jeffrey

unread,
Jul 13, 2004, 1:56:38 PM7/13/04
to crypto...@eskimo.com
Hi Torsten,

Your English is better than me speaking in your native tongue :)

Did you run Wei's validation suite?

Jeff

> >Jim
> >

MrWebLover

unread,
Jul 13, 2004, 1:57:32 PM7/13/04
to crypto...@eskimo.com
Ok, Jim,

i have found my problem.
I have modified the library in some cases and one of the cases make the error.
In windows all my modified sources works ok, but under linux one of them crashes.

I added support for PK encrypt with the private key und decrypt with the public key.
This works fine ...

And i added the follow's in rsa.cpp at
InvertibleRSAFunction::GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg):

    if (m_e == 17)
        m_e.RandomizeMy (rng ,Integer(3), Integer::Power2 (256));
    m_e += m_e.IsEven();

this changes the PublicExponent to a randomly generated one.
This is only for the security.
The Memberfunction RandomizeMy, i have added to the Integer class, is the crash - function  ....
Why, i don't know at this time, but i find it ... *smile*
First, i used the member m_e.Randomize (rng,Integer(3), Integer::Power2 (256), Integer::RandomNumberType::ANY) ,
but my Visual Studio Compiler have a problem with the last argument Integer::RandomNumberType::ANY
and i don't know why (The compiler not found the RandomNumberType::ANY Typ) ...
So i have added my RandomizeMy Function with fixed Integer::RandomNumberType::ANY argument or better his
Value of '0', here is the snippet :

bool Integer::RandomizeMy(RandomNumberGenerator &rng, const Integer &min, const Integer &max)
{
    return GenerateRandomNoThrow(rng, MakeParameters("Min", min)("Max", max)("RandomNumberType", 0)("EquivalentTo", Zero())("Mod", One()));
}                                                                                                                                                          |

In windows this works, but in linux it crash's ...

If i remove this mod's, so it works .....
( I not tested my encrypt mod's on linux, but the problem of my testprogram is resolved)

Very thanks for your help at this time !

@ Wai Dai ,  at the first, your Library is a very very great and fantastic work !!!
I know that you think, it is not necessarily to use an private key encode .... but ...
I need the Public Key Decrypt and Private Key encrypt, why signing for my case is NOT the right way. 
If i signing someone, so i check this sign with an 'if'. This check end's in assembler only in an 'Conditional jump' Variant.
This is, by disassemble a binary file, simple to find, and so to hack. (NOP's and direct 'jump')
When i encrypt needed data (runtime data)  for a program with a private key, and the program decrypt this at runtime to his memory,
with the included public key, so it can not hacked (or better, it is very very difficulty). The encrypted file can not be changed with the
public key. (The public key can be rebuild with the private key, but not reverse, right ?)
So the binary file is much saver
This only as information ....


Torsten



James Vanns schrieb:
Reply all
Reply to author
Forward
0 new messages