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 iv from the file back I use following: // read key string file = m_file_name + ".key";SecByteBlock key(AES::DEFAULT_KEYLENGTH);ArraySink* arr_key_in = new ArraySink(key, key.size());Base64Decoder* base64_key_dec = new Base64Decoder(arr_key_in);FileSource source(file.c_str(), false, base64_key_dec); source.PumpMessages(1); // read only the key // read ivSecByteBlock iv(AES::BLOCKSIZE);ArraySink* arr_iv_in = new ArraySink(iv, iv.size()); base64_key_dec->Detach(arr_iv_in); source.PumpAll(); // read the rest (the iv) Problem is that after reading a file the key is correct but iv is not, so i wornder what could be wrong with my sintax? the contents of a key file are base64 hex encoded and it looks like so: *2Gnh3TbAJeQPmza9FKdqNg== FowuKut3pBl7g0Or+4FJUg==* the *==* means end of the message/key... First on is the key, while the other one is the iv, the above code does not read the iv from the file properly. What is wrong with my code? -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
