crypto++

Crypto++ explicit destruction during encryption/decryption?

橙三吉。 提交于 2019-11-28 09:47:19
问题 I wrote some wrapper functions to encrypt/decrypt files using crypto++. I tried looking in the wiki but could find my answer. I am wondering if I need to explicitly destroy my objects that are created? I found in the wiki that some objects when passed into functions are destroyed for you, but no examples of my exact use were there so I just wanted to be sure. CryptoPP::AutoSeededRandomPool prng; //Key generation byte key[AES::DEFAULT_KEYLENGTH]; prng.GenerateBlock(key, sizeof(key)); //IV

How can I work around warning C4505 in third party libraries?

こ雲淡風輕ζ 提交于 2019-11-28 07:12:19
问题 I've got a project that uses Crypto++ for a few hashing functions. Recently, I decided to clean things up a bit and use warning level 4 on MSVC++. Here's what my source looks like: #pragma warning(push) #pragma warning(disable: 4100) //Unreferenced formal parameter #pragma warning(disable: 4244) //Conversion, possible loss of data #pragma warning(disable: 4512) //Assignment operator could not be generated #pragma warning(disable: 4127) //Conditional expression is constant #pragma warning

How to convert SecByteBlock to string?

一曲冷凌霜 提交于 2019-11-28 01:34:03
I'm having a problem trying to convert SecByteBlock to string. Here's my case: I want to encrypt user access data using AES with static key and dynamic iv. My code is something like this: AesKeyIvFactory aesKeyIvFactory; SecByteBlock key = aesKeyIvFactory.loadKey(); SecByteBlock iv = aesKeyIvFactory.createIv(); encryptionService->encode(&userAccess, key, iv); std::string token = std::string(iv.begin(), iv.end()) + userAccess; The code above is supposed to: Load key from file; Create iv; Encrypt (AES) user access data; Concatenate the iv with the user data access encrypted to create a "token";

Having trouble decrypting a well-formed cipher text using Crypto++

末鹿安然 提交于 2019-11-27 08:22:10
问题 Background I've been struggling with decrypting an apparently well-formed cipher text for about a day. Assume we've got the following hex-encoded cipher text which contains exactly 160 characters thereby having 80 bytes. QString c = "1BFAC407AF0D440A2D6176C0B5D125AA96088490299AC18C74623C0EF1BB1372E554FC4150A8066220E943697BE2491D8AE13AA036B298425AC510A8A917D59EBB69708B9040AB3A84C63043EAD4AB07"; QString k = CryptoUtils::hexEncode("abc"); QString p = CryptoUtils::decrypt(c, k); qDebug() << p;

ECDSA sign with BouncyCastle and verify with Crypto++

▼魔方 西西 提交于 2019-11-27 08:15:09
问题 Here is the Java code: public static String sign(String data) throws Exception { KeyPair keyPair = loadKeyPair(System.getProperty("user.dir"), "ECDSA"); Signature signature = Signature.getInstance("SHA256withECDSA", "BC"); signature.initSign(keyPair.getPrivate(), new SecureRandom()); byte[] message = data.getBytes(); signature.update(message); byte[] sigBytes = signature.sign(); String signatureStr = new BigInteger(1, sigBytes).toString(16); return signatureStr; } Then the C++ Code to verify

Example of AES using Crypto++ [closed]

谁说胖子不能爱 提交于 2019-11-27 02:50:37
I have been searching the Internet for good c++ AES code sample/tutorial that teaches the basics of the encryption technology and the use of the Library but so far I have had no luck getting decent material. good: Easy to understand (Just the basics for on the go study). berkay Official document of Crypto++ AES is a good start. And from my archive, a basic implementation of AES is as follows: Please refer here with more explanation, I recommend you first understand the algorithm and then try to understand each line step by step. #include <iostream> #include <iomanip> #include "modes.h"

std::string to SecByteBlock conversion

非 Y 不嫁゛ 提交于 2019-11-26 23:44:23
问题 I'm currently writing blowfish encryption/decryprion program in C++ (using crypto++). I really didn't find a satisfied answer at google. I'm trying to send a key of a SecByteBlock as a string and then received in the other part as string then need to be regained to SecByteBlock. Is it possible to convert string <--> SecByteBlock Can I do something better to send key from one function to another? Thank you for help in advance. The code I use is the following: int main(int argc, char* argv[]) {

ECDSA sign with OpenSSL, verify with Crypto++

て烟熏妆下的殇ゞ 提交于 2019-11-26 21:59:02
问题 I create an ECDSA keypair (secp128r1) in my application with Wei Dai's Crypto++. Signing and verifying works as expected. I do not add the message itself to the signature to minimize the signature length (which is exactly 32 Bytes). However, when I create the signature with openssl: $ cat test.txt | openssl dgst -ecdsa-with-SHA1 -sign sample.key -keyform DER > act.bin OpenSSL obviously puts the message itself to the signature resulting in a larger signature (e.g. 39 Bytes). I can verify the

Example of AES using Crypto++ [closed]

僤鯓⒐⒋嵵緔 提交于 2019-11-26 10:19:07
问题 I have been searching the Internet for good c++ AES code sample/tutorial that teaches the basics of the encryption technology and the use of the Library but so far I have had no luck getting decent material. good: Easy to understand (Just the basics for on the go study). 回答1: Official document of Crypto++ AES is a good start. And from my archive, a basic implementation of AES is as follows: Please refer here with more explanation, I recommend you first understand the algorithm and then try to

Mismatch Detected for &#39;RuntimeLibrary&#39;

不问归期 提交于 2019-11-26 07:56:56
问题 I downloaded and extracted Crypto++ in C:\\cryptopp. I used Visual Studio Express 2012 to build all the projects inside (as instructed in readme), and everything was built successfully. Then I made a test project in some other folder and added cryptolib as a dependency. After that, I added the include path so I can easily include all the headers. When I tried to compile, I got an error about unresolved symbols. To remedy that, I added C:\\cryptopp\\Win32\\Output\\Debug\\cryptlib.lib to link