crypto++

Incorrect key size when porting Crypto++ AES encryption to PHP's mcrypt

血红的双手。 提交于 2019-12-11 01:14:15
问题 Earlier I managed to port some C++ CryptoPP Rijndael_128 CBC code to MCrypt PHP, but now I'm having problems with CFB mode. The C++ and PHP results do not match (well the first byte matches but this could be coincidence, everything else doesn't). With some diagnostics, it looks like PHP's mcrypt is not setting the key length correctly? Here's the C++ (diagnostics and sundries removed for simplicity): CFB_Mode<AES>::Encryption encryptor(g_encrypt_key, AES::DEFAULT_KEYLENGTH, g_encrypt_iv);

Not getting same session key after decoding payload under RSA

ぃ、小莉子 提交于 2019-12-10 23:32:12
问题 I am not getting same session key after encoding and decoding it using below functions which uses crypto++ library: CryptoPP::RSA::PrivateKey RSA_master_privKey; CryptoPP::RSA::PublicKey RSA_master_pubKey; std::string generate_Master_Keys() { std::string rsaParams; try { CryptoPP::InvertibleRSAFunction parameters; RSA_master_privKey = CryptoPP::RSA::PrivateKey(parameters); RSA_master_pubKey = CryptoPP::RSA::PublicKey(parameters); } catch (const CryptoPP::Exception& e) { std::cerr << e.what()

How to decode non-key ASN1 data?

放肆的年华 提交于 2019-12-10 22:46:02
问题 Is it possible to use crypto++ library to decode arbitrary ASN1 data (which has couple of sequences and integers) which I have in a byte array. ash.h contains methods which all take BufferedTransformation as input, but that class is interface for different ciphers and hashes, which really seems to be not related to my simple case at all. I also found ASN1Object in cryptlib.h but it's another interface and I haven't managed to find any implementing classes. Have I thought it way too complex

Crypto++ output data length

ε祈祈猫儿з 提交于 2019-12-10 18:48:53
问题 I am trying to use AES encryption from Crypto++ libary: CBC_Mode<AES>::Encryption e; I have a binary data block that I need to encrypt. The class seems to provide a method called ProcessData for this purpose: virtual void ProcessData(byte *outString, const byte *inString, size_t length); Looks like the last parameter is the size of the input data. What is not clear is why the method does not return me the size of the encrypted data. Is it assumed that the size of output data block is exactly

HexDecoder output empty

99封情书 提交于 2019-12-10 18:33:37
问题 I'm having a bit of an issue with cryptopp562 (on Debian for what it matters) I have a hex string and am trying to convert it to a decimal int. I'm using the HexDecoder in cryptopp (since I'm already using cryptopp for other things in the project). Since I don't know of a way to go straight from a hex string to a decimal int in one step, I have an intermediate step of decimal string. So it goes Hex string > Decimal string > Decimal int However my pipeline appears to be incorrect, but I can't

How to check if openssl or cryptopp is installed and use the library that actually exists in the system (is installed)?

半城伤御伤魂 提交于 2019-12-10 17:50:29
问题 I wrote function that encrypts/decrypts a buffer (2 versions of the same function - first, with cryptopp, second - with openssl). I would like to make something like this: #if defined OPENSSL run_aes_openssl(...); #elif defined CRYPTOPP run_aes_crytopp(...); #else error(...); #end Is it possible? 回答1: It's not quite that simple. In order to find that a macro is defined, you have to include the header that defines that macro. And C doesn't have anything like "include foo.h iff it exists"; it

Safe way to sending a public key over a socket

你离开我真会死。 提交于 2019-12-10 17:33:53
问题 What is a safe way to send a RSA::PublicKey to another user over a socket? I was thinking to export the key into a ByteQueue and send the byte array to the user where he can construct the public key again. Or does this leak information that can be misuse? //Generate keys AutoSeededRandomPool rng; InvertibleRSAFunction params; params.GenerateRandomWithKeySize(rng, 3072); //Create RSA::PublicKey publicKey(params); //Save ByteQueue queue; publicKey.Save(queue); byte publicKeyBuffer[1000]; size_t

'mutex' is not a member of 'std' in MinGW 5.3.0

萝らか妹 提交于 2019-12-10 14:52:00
问题 I am using MinGW 5.3.0 and Crypto++ 5.6.5: C:\MinGW>g++ -std=c++11 -s -D_WIN32_WINNT=0x0501 LOG.cpp -U__STRICT_ANSI__ Decclass.cpp \ -IC:\\MinGW\\ -IC:\\MinGW\\boost -LC:\\MinGW -lssl -lcrypto -lcryptopp -lgdi32 -lPCRYPT \ -lz -ltiny -lwsock32 -lws2_32 -lShlwapi Compiling results in the error below. c:\mingw\cryptopp565\include\cryptopp\misc.h:287:14: error: 'mutex' in namespace 'std' does not name a typestatic std::mutex s_mutex; c:\mingw\cryptopp565\include\cryptopp\misc.h:296:18: error:

Creation of ECDSA private key given curve and private exponent?

心不动则不痛 提交于 2019-12-10 10:52:03
问题 I am new to cryptopp and have been struggling for a while with the creation of private keys for ECDSA signing. I have a hex encoded private exponent E4A6CFB431471CFCAE491FD566D19C87082CF9FA7722D7FA24B2B3F5669DBEFB . This is stored as a string. I want to use this to sign a text block using ECDSA. My code looks a bit like this string Sig::genSignature(const string& privKeyIn, const string& messageIn) { AutoSeededRandomPool prng; ECDSA<ECP, SHA256>::PrivateKey privateKey; privateKey

How to encrypt a byte array with Crypto++

被刻印的时光 ゝ 提交于 2019-12-10 10:38:24
问题 How can I encrypt a byte array with Crypto++'s RSA implementation? I already found an example for strings. But I can't find a good example how to do the same for a byte array. This is my first attempt: //dataSize: Size of data that is going to be send //dataToSend Bytes to send to the user //seedPool is an AutoSeededRandomPool CryptoPP::RSAES_OAEP_SHA_Encryptor encryptor(publicKey); int size = 64000; byte * cipher = new byte(size); CryptoPP::ArraySink* test = new CryptoPP::ArraySink(cipher,