FAQ Database Discussion Community


AES/GCM with GunZip, cannot decompress correctly

c++,qt,encryption,crypto++,aes-gcm
EDIT I have rephrased the question yet again and provided a MINIMAL working example which can reproduce the bug. I am trying to use GCM for file encryption. My underlining framework is Qt. Idea is this: load sourceFile e.g. a.jpg encrypt the file in GCM mode as PDATA into ADATA...

Different results when encrypting with Common Crypto and Crypto++ with AES

c++,objective-c,encryption,crypto++,commoncrypto
I get different results when encrypting the same file (binary data) with the same key with Apple's Common Crypto and Crypto++. The algorithm I'm using is AES. Here's the code in Objective C using Common Crypto: void FileUtil::writeToFileEncrypt(string fileName, const void *data, int size, string key, int *sizeOut) { int...

Load RSA public key created in JSBN, then encrypt a message

javascript,c++,encryption,rsa,crypto++
I am trying to create a RSA key pair in JavaScript using JSBN and transfer the public key to Crypto++. Then, I am trying to encrypt a message in Crypto++ and send it back to JavaScript and decrypt it. But I am relatively new at this, so I think I...

How to regenerate values in AutoSeededX917RNG

c++,random,crypto++
I need to regenerate the pseuorandom values when I need them. My code is: static const unsigned int BLOCKSIZE = 5; byte scratch[ BLOCKSIZE ]; CryptoPP::AutoSeededX917RNG<CryptoPP::AES> rng; rng.GenerateBlock(scratch,BLOCKSIZE); std::cout << "The generated random block is:" << std::endl; for( unsigned int i = 0; i < BLOCKSIZE; i++ ) { std::cout...

salt vs. iv for PKCS5_PBKDF2_HMAC

c++,cryptography,crypto++
Understanding that PKCS5_PBKDF2_HMAC() requires a salt and gives back a derivedKey And that GCM<AES>::Encryption.SetKeyWithIV() requires an iv (along with the derivedKey) Is it safe to use the same value for salt (in PKCS5_PBKDF2_HMAC()) and iv (in GCM<AES>::Encryption.SetKeyWithIV()) - or should they be different?...

Passing a key in a SecByteBlock to an algorithm?

c++,blowfish,crypto++
I am currently working on a Cryptopp encryption project and would need to pass a key to a Blowfish encryption algorithm. If I understand correctly I would need to edit these 2 lines: SecByteBlock key(Blowfish::DEFAULT_KEYLENGTH); prng.GenerateBlock( key, key.size() ); My idea would be to pass a string variable (like ekey)...

Setting up crypto++

c++,c++11,gcc,crypto++
I downloaded crypto++ 5.6.2 (the zip file) and built it using just make (I have gcc 4.8.1). It seemed to work and gave me a libcryptopp.a file. Now, to test the setup, I tried to compile the test.cpp file that was provided with the download (link here: http://www.cryptopp.com/docs/ref/test_8cpp_source.html). First, I...

Cannot kill Qt thread with CryptoPP FileSink running in the thread run method

c++,multithreading,qt,encryption,crypto++
I have a UI app in C++ and QT5.4, Im using CryptoPP 5.6.2 to encrypt files. I ran into the following problem: When the Encrypt button is hit, a new thread is started based on this tutorial. // new thread CryptoWorkerThread = new QThread; this->worker = new CryptoWorker(fileName.c_str(), newFileName.c_str(), key,...

MT / MD mismatch when compiling cryptopp despite no library dependencies

c++,visual-c++,visual-studio-2013,linker-error,crypto++
I'm currently trying to compile a static 64 bit version of cryptopp (more precisely, the cryptlib VS project) using MS Visual Studio 2013 on a Windows 8.1 machine. Since it is a static release build, I've set the Runtime Library to Multithreaded (/MT). However the linker throws several of the...

Error while sending encrypted data with Boost::asio::async_send_to

c++,encryption,aes,boost-asio,crypto++
I am developing an encrypted version of a realtime communication application. The issue I have is, that the encrypted data pakets sent to the receiver are faulty. An example from the error log: (hex encoded data, the original data is pure byte code). sent: 262C1688215232656B5235B691826A21C51D37A99413050BAEADB81D8892493FC0DB519250199F5BE73E18F2703946593C4F6CEA396A168B3313FA689DE84F380606ED3C322F2ADFC561B9F1571E29DF5870B59D2FCF497E01D9CD5DFCED743559C3EE5B00678966C8D73EA3A5CD810BB848309CDF0F955F949FDBA618C401DA70A10C36063261C5DBAB0FC0F1...

AES, 128 and 256 Invalid Key Length

c++,encryption,aes,crypto++,aes-gcm
I am trying to encrypt a text using Crypto++. It worked well last time when using AES CTR, but now when using CBC or GCM the max key length I can use is 32 bits?? The code that handles the encryption: string xAESPlain, xAESCipher; AutoSeededRandomPool xRng; byte xAESKey[128]; // Doesnt...

How would I load a Private / Public Key from a string / byte array or any other container

c++,cryptography,rsa,public-key-encryption,crypto++
Is it possible to store a RSA Private/Public Key in the source for example in a byte[] or string or any other container and use this key for encryption / decryption? A decode function from file would look like: void Decode(const string& filename, BufferedTransformation& bt) { // http://www.cryptopp.com/docs/ref/class_file_source.html FileSource file(filename.c_str(),...

Can I specify the nonce and counter in AES encryption counter mode?

encryption,aes,crypto++
I'm trying to use the library Crypto++ to make AES Counter mode based encryption/decryption I want to split the IV value into nonce and counter. Is there any API that directly takes the nonce and counter to construct the IV ? I did the following to achieve it byte counter[AES::BLOCKSIZE/2]...

PumpMessages in crypto++, reading a key file?

c++,file-io,aes,crypto++
I'm writing an AES key and iv to the file with crypto++ by using following code: // write the key: SecByteBlock key(AES::DEFAULT_KEYLENGTH); SecByteBlock iv(AES::BLOCKSIZE); string file = m_file_name + ".key"; FileSink* key_out = new FileSink(file.c_str()); Base64Encoder base64_key_enc(key_out); base64_key_enc.Put(key.BytePtr(), key.size()); base64_key_enc.MessageEnd(); base64_key_enc.Put(iv.BytePtr(), iv.size()); base64_key_enc.MessageEnd(); and to read a the key and...

Steps to decrypt encrypted data in Crypto++ in libgcrypt

c++,crypto++,libgcrypt
I need to decrypt the encrypted data by Crypto++ in libgcrypt due to C language restriction on target platform. So I've decided to use libgcrypt since it supporting the AES128 and GCM mode. In Crypto++, the data is encrypted this way: std::string encrypt_data(const std::string &data, const std::vector<unsigned char> &iv, const...

Undefined symbols in cryptopp at IOS 64-bit project

c++,ios,xcode,cocos2d-x,crypto++
I tried to build with github's prebuilt cryptopp but it doesn't work, too. it occur errors like below: Undefined symbols for architecture arm64: "CryptoPP::BufferedTransformation::ChannelFlush(std::string const&, bool, int, bool)", referenced from: vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o "CryptoPP::Filter::CopyRangeTo2(CryptoPP::BufferedTransformation&, unsigned long long&, unsigned long long, std::string const&, bool)...

Use previously generated private key in ECIES

c++,public-key-encryption,crypto++,elliptic-curve
I wan to encrypt /decrypt data using ECIES , I am using cryptopp for this. AutoSeededRandomPool prng; //get private key generated ECIES<ECP>::Decryptor d0(prng, ASN1::secp256r1()); PrintPrivateKey(d0.GetKey()); //get public key ECIES<ECP>::Encryptor e0(d0); PrintPublicKey(e0.GetKey()); //encrypt the message string em0; // encrypted message StringSource ss1 (message, true, new PK_EncryptorFilter(prng, e0, new StringSink(em0) ) );...

Generate nonce c++

c++,openssl,cryptography,crypto++,nonce
I am wondering if there is a way to generate a Cryptographic Nonce using OpenSSL or Crypto++ libraries. Is there anything more to it than just generating a set of random bytes using autoseeded pools?

Integer to string conversion issues

c++,crypto++
I am experiencing a few problems with Crypto++'s Integer class. I am using the latest release, 5.6.2. I'm attempting to convert Integer to string with the following code: CryptoPP::Integer i("12345678900987654321"); std::ostrstream oss; oss << i; std::string s(oss.str()); LOGDEBUG(oss.str()); // Pumps log to console and log file The output appears to...

Encryption and export license for an App Store or Google Play app

android,ios,appstore-approval,crypto++
My iOS app uses crypto++ as a static library for confidentiality. Since this library is open-sourced, and thus visible to any would-be wrong-doers as it is, common sense implies that there should be no hassle. However, based on Category 5, Part 2 of the U.S. Export Administration Regulations, my app...

Instructions for using Rabin Information Dispersal Algorithm (IDA)

cryptography,crypto++,instructions
I want to work on Rabin Information Dispersal Algorithm (IDA) using Crypto++ in Linux. A simple instruction can help me....