crypto++

Crypto++ pbkdf2 output is different than Rfc2898DeriveBytes (C#) and crypto.pbkdf2 (JavaScript)

天大地大妈咪最大 提交于 2019-12-01 05:28:52
So I'm trying to use PBKDF2 to derive a key given a base64 string of 256bits. I am able to use C#'s Rfc2898DeriveBytes and node-crypto's pbkdf2 to derive the same key, however, I can't say the same for C++. I'm not sure if I'm doing wrong conversions or using the functions improperly, but I'll let you guys look at it. C++ /* 256bit key */ string key = "Y1Mjycd0+O+AendY5pB58JMlmS0EmBWgjdj2r2KW6qQ="; string decodedKey; StringSource(key, true, new Base64Decoder(new StringSink(decodedKey))); const byte* keyByte = (const byte*) decodedKey.data(); /* Generate IV */ /* AutoSeededRandomPool prng; byte

Use previously generated private key in ECIES

醉酒当歌 提交于 2019-12-01 04:51:43
问题 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) ) ); //decrypt the message string dm0; // decrypted message

Crypto++ pbkdf2 output is different than Rfc2898DeriveBytes (C#) and crypto.pbkdf2 (JavaScript)

≯℡__Kan透↙ 提交于 2019-12-01 02:23:49
问题 So I'm trying to use PBKDF2 to derive a key given a base64 string of 256bits. I am able to use C#'s Rfc2898DeriveBytes and node-crypto's pbkdf2 to derive the same key, however, I can't say the same for C++. I'm not sure if I'm doing wrong conversions or using the functions improperly, but I'll let you guys look at it. C++ /* 256bit key */ string key = "Y1Mjycd0+O+AendY5pB58JMlmS0EmBWgjdj2r2KW6qQ="; string decodedKey; StringSource(key, true, new Base64Decoder(new StringSink(decodedKey)));

Crypto++ encrypt and decrypt in two different c++ programs

别等时光非礼了梦想. 提交于 2019-12-01 01:25:54
I am writing a code to encrypt and decrypt with crypto++ library .I found a code to encrypt and decrypt which is shown below.The code works OK as one program.but when I divide into two c++ programs (One for encryption and another for decryption) the decryption pargram gives me error terminate called after throwing an instance of 'CryptoPP::InvalidCiphertext' what(): StreamTransformationFilter: ciphertext length is not a multiple of block size The ciphertext I get after encryption is ���z=(f�����P%���2��W3�p�H�����^��@C��#������bp���nx�� which I transfer into the decryption code. What am I

Using cryptographic streams in C++

不羁的心 提交于 2019-12-01 00:16:34
I'd like to use some cryptographic operations (mainly integrty check hashsums). However I have problems with finding documentations of doing operations of such form: bool read(std::istream &in) { hasher hv(in); // Do some operations on hv as if it was std::istream hash_type h = hv.finish (); hash_type h2 = read_hash(in); return h == h2; } PS. It may be different library provided it a) is GPL-3-compatible b) works on GNU/Linux PPS. I don't insist on crypto++ however I would like to have IOStream-like behaviour for interoperability with other C++ libraries. Implement your own istream using

Crypto++ encrypt and decrypt in two different c++ programs

你离开我真会死。 提交于 2019-11-30 20:27:59
问题 I am writing a code to encrypt and decrypt with crypto++ library .I found a code to encrypt and decrypt which is shown below.The code works OK as one program.but when I divide into two c++ programs (One for encryption and another for decryption) the decryption pargram gives me error terminate called after throwing an instance of 'CryptoPP::InvalidCiphertext' what(): StreamTransformationFilter: ciphertext length is not a multiple of block size The ciphertext I get after encryption is ���z=(f��

AES with padding pkcs7 c++ code

妖精的绣舞 提交于 2019-11-30 19:37:00
问题 I need an example of string encryption (in C++ -> I'm working on linux-Ubuntu) with aes-cbc256 and a padding: PKCS7 Please help. For the following code how can I set the IV to 0 and set the key value to a string value? I would also like to add the pkcs7 padding. I'm using the crypto++ lib (in Linux) // Driver.cpp // #include "stdafx.h" #include "cryptopp/dll.h" #include "cryptopp/default.h" #include "crypto++/osrng.h" using CryptoPP::AutoSeededRandomPool; #include <iostream> using std::cout;

Encrypt/Decrypt byte array Crypto++

梦想的初衷 提交于 2019-11-30 19:34:09
问题 I am trying to encrypt a byte array using AES. I have been able to encrypt strings and files no problem, however byte arrays seem to not be working for me. I pass in a byte array to be encrypted, for ease of testing I just pass in a generated AES key by crypto++ (bArrayToEncrypt). The encryption appears to be working but then the decryption does work at all. I also found it strange that the encryption has a large amount of duplicate characters. What I am doing wrong here?? I saw a similar

Using cryptographic streams in C++

你。 提交于 2019-11-30 18:47:24
问题 I'd like to use some cryptographic operations (mainly integrty check hashsums). However I have problems with finding documentations of doing operations of such form: bool read(std::istream &in) { hasher hv(in); // Do some operations on hv as if it was std::istream hash_type h = hv.finish (); hash_type h2 = read_hash(in); return h == h2; } PS. It may be different library provided it a) is GPL-3-compatible b) works on GNU/Linux PPS. I don't insist on crypto++ however I would like to have

AES 256 encryption - Qt equivalent for Java

断了今生、忘了曾经 提交于 2019-11-30 15:37:06
I have my AES 256 encryption method implemented and working fine in Java as follows! private static final byte[] IV = { 0, 2, 4, 8, 16, 32, 64, 127, 127, 64, 32, 16, 8, 4, 2, 0 }; //actual encryption over here private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception { SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = null; if(isIVUsedForCrypto) { cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(IV)); } else { cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); }