Discussion:
[Cryptlib] Problems creating RC5 context
Александр Комратов
2015-11-15 14:36:02 UTC
Permalink
Hi, everybody!

I'm testing Cryptlib 3.4.3 under Windows in project using x64 platform
and MS Visual Studio 2013

I've got a strange malfunction.

I'm trying to use encryption using RC5 algorythm as a source of
pseudo-random data for further usage.


CRYPT_CONTEXT rc4;

this->cl_err = cryptCreateContext( &rc4, CRYPT_UNUSED, CRYPT_ALGO_RC5);
if (this->cl_err) { free(tmp); CL_IRET("nllCryptlibCenter::GetRandom()",
"ERROR(%u) cryptCreateContext() failed with emsg = \"%s\"", 4,
this->last_err, NSB_LOG_LEVEL_NORMAL); };

this->cl_err = cryptSetAttribute(rc4,CRYPT_CTXINFO_KEYSIZE,104);
if (this->cl_err) { free(tmp); CL_IRET("nllCryptlibCenter::GetRandom()",
"ERROR(%u) cryptSetAttribute() failed with emsg = \"%s\"", 5,
this->last_err, NSB_LOG_LEVEL_NORMAL); };

this->cl_err = cryptGenerateKey(rc4);
if (this->cl_err) { free(tmp); CL_IRET("nllCryptlibCenter::GetRandom()",
"ERROR(%u) cryptGenerateKey() failed with emsg = \"%s\"", 6,
this->last_err, NSB_LOG_LEVEL_NORMAL); };

this->cl_err = cryptEncrypt(rc4,tmp,(int) size);
if (this->cl_err) { free(tmp); CL_IRET("nllCryptlibCenter::GetRandom()",
"ERROR(%u) cryptEncrypt() failed with emsg = \"%s\"", 7, this->last_err,
NSB_LOG_LEVEL_NORMAL); };

this->cl_err = cryptDestroyContext(rc4);
if (this->cl_err) { free(tmp); CL_IRET("nllCryptlibCenter::GetRandom()",
"ERROR(%u) cryptDestroyContext() failed with emsg = \"%s\"", 8,
this->last_err, NSB_LOG_LEVEL_NORMAL); };

The quoted code is working good only once.
And even though I'm every time destroing context, the next time I get an
error in cryptCreateContext() -11 "Data has not been initialised"

What's wrong?

Thanks for any help.

_______________________________________________
Cryptlib mailing list
***@mbsks.franken.deAdministration via Mail: cryptlib-***@mbsks.franken.de
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam,
Peter Gutmann
2015-11-16 02:50:58 UTC
Permalink
The quoted code is working good only once. And even though I'm every time
destroing context, the next time I get an error in cryptCreateContext() -11
"Data has not been initialised"
Can you send me the exact code needed to reproduce the problem? When I run
the code you posted it works as expected...

Peter.

_______________________________________________
Cryptlib mailing list
***@mbsks.franken.deAdministration via Mail: cryptlib-***@mbsks.franken.de
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to

Loading...