|
I use Visual c++, it seems ok. first of all, you need compile pch.cpp, which is in the source files of cryptlib files.
|
|
|
|
|
Hello, I'm tring to use crypto++ 5.2.1 and I notice that the maximum message length that I can encrypt is KeyLength/8-42 (ex for a 1024bits key : 1024/8-42 = 86 characters max)
So I can't use 128 or 256 bits key
Someone know where does the -42 comes from ?
thanks for all
|
|
|
|
|
Hi all,
Just wondering how I might be able to convert the HEX encrypted text output to normal, 8-bit characters?
Thanks.
|
|
|
|
|
256, 512, 1024 bit keys all could be generated correctly. But when the program generate 2048-bit key, errors will occur.
I want confirmation that the lib is ok to generate 2048-bit keys.
Thanks a lot!
|
|
|
|
|
Hello, sir. After testing, I found that the MFC Style Crypto++ v4.2 Library GUI could not be used with v5.1. Since I want to demo Crypto++ v5.1, I have been trying to make a GUI for v5.1 in a similar way. First I only test RSA. But there always is such an error:
\crypto51\secblock.h(191) : fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit
Error executing cl.exe.
After using /Zm to specify a higher limit, there will be lots of linking errors.
Could you please help me with the GUI demo for Crypto++ v5.1? Thank you very much. The above problem has already harrassed me for several days.
Yanhua
Yanhua
|
|
|
|
|
I have written a dll library from Crypto++ v5.1. and GUI in VC6 to test it.
Everything works correctly except encrypting and decrypting
string. When I start GUI the library encrypts and decrypts
string only for a first time. When I try to call this function
second time application generates error and displaying window:
"Debug Assertion Failed"
file: dbgheap.c
line:1044
----------------------------------------------
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
-----------------------------------------------
My dll is a MFC dll.
Please let me know if you've seen something like this.
|
|
|
|
|
Do you have some example code to show us where the problem is?
Regards,
Dan
|
|
|
|
|
Here is the encrypt method defined in dll file:
------------------------------------------------------
CString CMFCCryptDLLApp::RSAEncryptString(const char *pubFilename, const char *message)
{
FileSource pubFile(pubFilename, true, new HexDecoder);
RSAES_OAEP_SHA_Encryptor pub(pubFile);
AutoSeededRandomPool rng;
char outStr[1024];
std::string result;
StringSource(message, true, new PK_EncryptorFilter(rng, pub, new HexEncoder(new StringSink(result))));
sprintf(outStr,"%s", result.c_str());
CString Cresult(outStr);
return Cresult;
}
--------------------------------------------------------
When I calling this method from dll in dialog file:
--------------------------------------------------------
void CGUICrypto51Dlg::OnExecute()
{
CMFCCryptDLLApp* cipher = (CMFCCryptDLLApp*) AfxGetApp();
.
.
.
case 4:
m_sEncrypted = cipher->RSAEncryptStringSeed(m_sPubFileName, m_sMessage);
GetDlgItem(IDC_ENCRYPTED)->SetWindowText(m_sEncrypted);
GetDlgItem(RAD_DECRYPT)->EnableWindow(TRUE);
break;
.
.
.
}
--------------------------------------------------------
I need dll because I have to create GUI in VB. For now a test it in VC6.0.
I don't know where is the problem - in dll? or GUI?
As I said it works correctly if I click button (Encrypt String) first time.
Next test returns that error. Maybe it needs to free memory ...
If you need more soure code - let me know.
Thans for last fast replay.
Regards,
Lukasz Kuznicki
|
|
|
|
|
Your function is called "RSAEncryptString(...)", but you are calling "cipher->RSAEncryptStringSeed"?? Is there more code somewhere or is this a type-o ??
Regards,
Dan
|
|
|
|
|
Here is how I do it in one of my newer apps:
CString RSAEncryptString(const char *pubFilename, const char *seed, const char *message)
{
CString csErr;
try
{
FileSource pubFile(pubFilename, true, new HexDecoder);
RSAES_OAEP_SHA_Encryptor pub(pubFile);
RandomPool randPool;
randPool.Put((byte *)seed, strlen(seed));
string result;
StringSource(message, true, new PK_EncryptorFilter(randPool, pub, new HexEncoder(new StringSink(result))));
CString csRet;
csRet.Format("%s", result.c_str());
return csRet;
}
catch(CryptoPP::Exception &e)
{
csErr.Format("CryptoPP: %s",e.what());
WriteLogFile(csErr, "RSAEncryptString()", 1);
}
catch(std::exception &e)
{
csErr.Format("std: %s",e.what());
WriteLogFile(csErr, "RSAEncryptString()", 1);
}
return csErr;
}
CString RSADecryptString(const char *privFilename, const char *ciphertext)
{
CString csErr;
try
{
FileSource privFile(privFilename, true, new HexDecoder);
RSAES_OAEP_SHA_Decryptor priv(privFile);
string result;
StringSource(ciphertext, true, new HexDecoder(new PK_DecryptorFilter(GlobalRNG(), priv, new StringSink(result))));
CString csRet;
csRet.Format("%s", result.c_str());
return csRet;
}
catch(CryptoPP::Exception &e)
{
csErr.Format("CryptoPP: %s",e.what());
WriteLogFile(csErr, "RSADecryptString()", 1);
}
catch(std::exception &e)
{
csErr.Format("std: %s",e.what());
WriteLogFile(csErr, "RSADecryptString()", 1);
}
return csErr;
}
Regards,
Dan
|
|
|
|
|
Sorry Dan, it should be "cipher->RSAEncryptString()" - my mistake.
I defined in dll two kinds of RSAEncryptString functions:
1. CString RSAEncryptStringSeed(const char *pubFilename, const char *seed, const char *message);
2. CString RSAEncryptString(const char *pubFilename, const char *message);
In second function I use autoseed, so there isn't variable seed.
As I described in advance both of them work correctly, but application
which uses the dll returns "Debug Assertion Failed" after second calling one of them. I applayed Your method, but the same error apperars. I notice that there is a problem only with functions which returns CString.
Thankyou for your interest and patience.
Regards,
Lukasz
|
|
|
|
|
Have you tried making the functions return "const char *" instead of a CString ??
Regards,
Dan
|
|
|
|
|
I have just tried to use your suggestion. I think it works much better now - GIU doesn't return errors.
But there is another problem. My function looks like below:
const char* RSAEncryptStringSeed(const char *pubFilename, const char *seed, const char *message)
{
...
string result;
StringSource(message, true, new PK_EncryptorFilter(randPool, pub, new HexEncoder(new StringSink(result))));
const char* csRet;
csRet = result.c_str();
return csRet;
}
DLL always returns: {"ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"
Now I trying to use different string formating ...
Thanks a lot Dan.
Lukasz
|
|
|
|
|
Hi all,
It's really a great work. thanks you all.
Currentlt, i want to make use of the Cryptlib4.2 for my project.
But it's doesn't work once i want the lib GZIP a string. below is the details.
code1 :
string sInput = "Just for test";
string sOutput
StringSource(sInput, true, new Gzip(new StringSink(sOutput), deflate_level));
code2:
std::string outstr;
Gzip ziper( new StringSink(outstr), deflate_level );
ziper.Put((byte *)in, strlen(in));
ziper.MessageEnd();
After executed, both they all ouput "?", i don't know why.
It's highly appreciated for your great help.
Kemp Ge
Hi, everyone.
|
|
|
|
|
int GzipString(const char *in, char *out, int deflate_level)
{
int nResult = RETURN_EXIST;
std::string outstr;
Gzip ziper( new StringSink(outstr), deflate_level );
ziper.Put((byte *)in, strlen(in));
ziper.MessageEnd();
sprintf(out,"%s", outstr.c_str());
}
why can it not work successfully?
How to do?
|
|
|
|
|
I was wondering should anyone be writing the demo of this long time ago. The demo provided by Wei Dai is troublesome to be used and could not demonstrate all of the algorithms provided by him effectively. And finally, here you are. Thanks man.
[modified]oops, it seems that it has been here for some time[/modified]
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
I am building an editor sort of thing in vc++ and i want to get the filename of the open file & for that i want to know How to override the OnOpenDocument() function and also how to edit the text in the title bar of the SDI application's window.
|
|
|
|
|
<br />
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
if( !CFrameWnd::PreCreateWindow(cs) )<br />
return FALSE;<br />
<br />
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE<br />
| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;<br />
<br />
cs.style &= ~(LONG) FWS_ADDTOTITLE;<br />
cs.lpszName = "APP - Add some Text";<br />
<br />
return TRUE;<br />
}<br />
<br />
<br />
Regards,
Dan
|
|
|
|
|
Hi,
I have read many places and found that Crypto++ functions are very much compatible to php mcrypt library. I never knew how to use this in VC++ application. You have dobe such a wonderful work and its so easy to understand that i can compile and run your code easily. But i am having a small problem and hope that you can solve it out. I have to use the mcrypt library of php to encrypt a file at server and i have to decrypt the same file on client side using VC++. I am using Rijndael algorithm for encryption at server side through PHP. as the documentation says...
mcrypt's MCRYPT_RIJNDAEL_128 is compatible with cryptopp-php's CRYPTOPP_CIPHER_AES/ CRYPTOPP_CIPHER_RIJNDAEL, which are just aliases for each other.
and
MCRYPT_MODE_CBC in mcrypt and CRYPTOPP_MODE_CBC in cryptopp-php.
MCRYPT_MODE_ECB in mcrypt and CRYPTOPP_MODE_ECB in cryptopp-php.
Can you tell me how to use crypto++ to do the same. or show me some piece of code to make it easy to understand..I need it urgently..Please help in doing the same. Any help or pointers are highly appreciated.
Thanks a lot in advance..
Regards,
Himanshu
|
|
|
|
|
Program :
Ftp server & Crypto++ makes...
Usage.
-- Files encrypt / decrypt use.
Error :
When user connecting, program runtime error
-- Unhandled exception in FTPServer.exe:pxC0000005: Access Violation.
Error Code section: (I think ...)
ASSERT(CAsyncSocket::LookupHandle(hSocket, bDead) == NULL);
if (pState->m_pmapSocketHandle->IsEmpty())
-------------------------------------------
Others program (I think ...)
When I tested other programs with folowing codes, I found same errors.
- Mutithread program
- CTypedPtrList<CObList, ConnectThread*> m_ThreadList; <-- I think
- Socket
Have a nice day! bye.
yang hyuk
|
|
|
|
|
o~~
plz look here
For the validation portion to work, you need to copy the .dat files from the Crypto++ location to the build directory
thx
|
|
|
|
|
Hi,
Platform: Win 2K, VC++ 6.0 SP5, Crypto++ 4.2 (tried 5.1 but that has other errors).
I am receiving the following compilation errors when I try to compile the Cryptest app. :
Compiling...
bench.cpp
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(444) : error C2079: 'priv' uses undefined class 'BlumGoldwasserPrivateKey'
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(585) : see reference to function template instantiation 'void __cdecl BenchMarkCrypto(const char *,const char *,double,class CryptoPP::BlumGoldwasserPrivateKey *,class CryptoPP::BlumGol
dwasserPublicKey *)' being compiled
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(444) : error C2440: 'initializing' : cannot convert from 'class CryptoPP::FileSource' to 'int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(585) : see reference to function template instantiation 'void __cdecl BenchMarkCrypto(const char *,const char *,double,class CryptoPP::BlumGoldwasserPrivateKey *,class CryptoPP::BlumGol
dwasserPublicKey *)' being compiled
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(445) : error C2079: 'pub' uses undefined class 'BlumGoldwasserPublicKey'
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(585) : see reference to function template instantiation 'void __cdecl BenchMarkCrypto(const char *,const char *,double,class CryptoPP::BlumGoldwasserPrivateKey *,class CryptoPP::BlumGol
dwasserPublicKey *)' being compiled
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(446) : error C2665: 'BenchMarkEncryption' : none of the 3 overloads can convert parameter 2 from type 'int'
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(585) : see reference to function template instantiation 'void __cdecl BenchMarkCrypto(const char *,const char *,double,class CryptoPP::BlumGoldwasserPrivateKey *,class CryptoPP::BlumGol
dwasserPublicKey *)' being compiled
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(447) : error C2664: 'BenchMarkDecryption' : cannot convert parameter 2 from 'int' to 'class CryptoPP::PK_Decryptor &'
A reference that is not to 'const' cannot be bound to a non-lvalue
C:\Docs\Projects\Crypto\CryptestDemo\Cryptest\bench.cpp(585) : see reference to function template instantiation 'void __cdecl BenchMarkCrypto(const char *,const char *,double,class CryptoPP::BlumGoldwasserPrivateKey *,class CryptoPP::BlumGol
dwasserPublicKey *)' being compiled
If anyone knows how to overcome these errors please let me know. As far as I can tell ( ) everything else appears to be set correctly.
Any assistance would be much appreciated.
Regards
|
|
|
|
|
It's ok - ignore the previous message. Was an error on my part.
Compilation of 4.2 works fine.
Will now try 5.1...
|
|
|
|
|
Hi,
I've got a lot of error when i try to compil under vs.net I try to use /MD but it not worlk to...
Here is some error that i got : a lot of LNK4098 and LNK2005
Thanks you for your help
PS : i'm using the 4.2 version, and try with the 51 but it is the same problem
|
|
|
|
|
Hi !
Your program is a really great !
I have a question about RSA keys that you produce :
As i read it in RSA documentation, 'P' and 'Q' primes are generated in order to compute a public key (who is a combinaison of 'N' and 'E' numbers) and a private key (who is a combinaison of 'N' and 'D' numbers).
My question is : how can I extract 'N' and 'E' from the file containing the public key and 'N' and 'D' from the file containing the private key ?
Thank you !!
|
|
|
|
|