crypto++

How to use Shamir Secret Sharing Class in Crypto++

ε祈祈猫儿з 提交于 2019-12-23 11:11:47
问题 I tried to use the SecretSharing Class in Crypto++, but I couldn't make it work. Here is my code: using namespace CryptoPP; void secretSharing(){ AutoSeededRandomPool rng; SecretSharing shamir(rng, 4, 6); byte test[] = {'a', 'b', 'c', 'd'}; shamir.Put(test, 4); //shamir.MessageEnd(); //cout << shamir.TotalBytesRetrievable() <<endl; } After compile and run, I will get: ./main terminate called after throwing an instance of 'CryptoPP::BufferedTransformation::NoChannelSupport' what(): unknown:

Crypto++ and Compressed EC keys

六月ゝ 毕业季﹏ 提交于 2019-12-22 14:51:11
问题 How can I generate compressed ECDSA keys in Crypto++? AutoSeededRandomPool prng; ECDSA<ECP, SHA1>::PrivateKey privateKey; ECDSA<ECP, SHA1>::PublicKey publicKey; privateKey.Initialize( prng, CryptoPP::ASN1::secp256r1()); const Integer& x1 = privateKey.GetPrivateExponent(); cout << "priv: " << std::hex << x1 << endl; privateKey.MakePublicKey( publicKey ); const ECP::Point& q = publicKey.GetPublicElement(); const Integer& qx = q.x; const Integer& qy = q.y; cout << "pub x: " << std::hex << qx <<

crypto++ RSA public key encryption with long plaintext

我们两清 提交于 2019-12-22 11:15:10
问题 i am trying to encrypt/decrypt some long text with RSA public/private key encryption using cryptopp. I found many examples including the official on http://www.cryptopp.com/wiki/RSA but all of the examples have one problem: They only allow me to encrypt data that is a bit shorter then the key size. So the question is: Do i really have to split the data and encrypt block for block myself, or does crypto++ already provide some functions to handle this (like GCM or CFB modes on AES encryption)?

How to build a project using Crypto++ library in kdevelop

本秂侑毒 提交于 2019-12-21 21:07:15
问题 I wrote a small program that uses the crypto++ library using kdevelop in Ubuntu . I get the output correctly when I compile it from the terminal using -lcryptopp . I would like to build and execute the program using the cmake from kdevelop itself. How can I include the CRYPTOPP_DIR in the cmake configuration for doing this. Any help will be appreciated. Thankyou. 回答1: Adding the following piece of code to cmake file helped me: FIND_LIBRARY(CRYPTOPP crypto++ /usr/lib) ## location of

Generating a SHA256 hash with Crypto++, using a string as input and output?

江枫思渺然 提交于 2019-12-20 09:36:48
问题 I need an example of how to use Crypto++ to generate a SHA256 hash from a std::string and output a std::string. I can't seem to figure it out. Everything I've tried gives me invalid output. Here's the new code after interjay's answer: string SHA256(string data) { byte const* pbData = (byte*) data.data(); unsigned int nDataLen = data.size(); byte abDigest[CryptoPP::SHA256::DIGESTSIZE]; CryptoPP::SHA256().CalculateDigest(abDigest, pbData, nDataLen); return string((char*)abDigest); } The output

Installing Crypto++ 5.6.2 on Mac OS X

点点圈 提交于 2019-12-20 04:27:18
问题 I'm trying to installing Crypto++ 5.6.2 on my Mac. When I run make -j4 libcryptopp.a" I get the following error: libtool: unrecognized option `-static' libtool: Try `libtool --help' for more information. make: *** [libcryptopp.a] Error 1 Can someone please help me with this? 回答1: Can someone please help me with this? There's a couple of things you can do to make this easier. First, open GNUmake and add fPIC on line 1: CXXFLAGS = -DNDEBUG -g -O2 -fPIC Second, open GNUmake and drop "version"

How to read an image to a string for encrypting Crypto++

狂风中的少年 提交于 2019-12-20 04:14:06
问题 I need to read a file as binary data, then be able encrypt and decrypt it. I am testing speeds of different algorithms in Crypto++. Up until now, I have been using getline to read text files. int main( int argc, char* argv[] ) { string plaintext, ciphertext, encoded, recovered, sample_files_path, data_file, line_contents, file_size; ifstream initial_file_contents ( "1MB.txt"); if (initial_file_contents.is_open()) { plaintext = ""; while ( getline( initial_file_contents, line_contents ) ) {

256-bit Rijndael blocksize?

会有一股神秘感。 提交于 2019-12-20 01:44:13
问题 I am trying to port a decryption routine from C# program to C++ using cryptopp, but I have a problem. In the C# program, the key and IV are both 256 bits. So I tried to do something like this: char *hash1 = "......"; std::string hash2; CryptoPP::StringSource(hash1, true,new CryptoPP::Base64Decoder(new CryptoPP::StringSink(hash2))); CryptoPP::Rijndael::Decryption decryptor(key, 32); CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( decryptor, iv); CryptoPP:

TripleDES in CFB mode, C# and Crypto++ differs

拜拜、爱过 提交于 2019-12-20 01:43:59
问题 Here is my problem: I've got a legacy code in C++ (using crypto++ v5.6.1) and I develop a new one in C# (.NET 3.5 using System.Security.Cryptography). I can't change the C++ code, but I need to be able to decrypt data previously encrypted and previous applications has to be able to decrypt the data I will crypt with my new C# code. The algorithm used is TripleDES with CFB cipher mode in both cases, but in the end, the encrypted data are not the same, the number of bytes are identical as well

Convert Hex string to bytes in Crypto++

两盒软妹~` 提交于 2019-12-19 09:54:32
问题 I have string of hexadecimals which I need to convert to const byte* . I am using Crypto++ to do hashing and it needs the key to be in const byte* Is there any way i can convert the string of hexadecimal into const byte* using any of the Crypto++ libs or must i need to come up with my own? 回答1: There is a HexDecoder class in Crypto++. You need to feed this characters. It seems that Crypto++ does not directly distinguish between characters and bytes. So the following line of code supplied by