Discussion:
Cross-platform problems
Allan
2016-05-10 21:16:40 UTC
Permalink
I'm experiencing the exact same issue as:
http://comments.gmane.org/gmane.comp.encryption.cryptopp/2518

In this case, because I'm using DefaultEncryptorWithMAC with AES-256, I
get the exception "cannot decrypt message with this passphrase".
Generally,

----
std::string pdata;
std::ifstream ifs(sFilePlainText.c_str(), std::ifstream::binary);
std::ofstream ofs(sFileCipherText.c_str(), std::ofstream::binary);

m_enc = new Base64Encoder(NULL, true, 72);
AlgorithmParameters params = MakeParameters(Name::Separator(),
ConstByteArrayParameter("\n#"))
(Name::InsertLineBreaks(), true);
m_enc->IsolatedInitialize(params);
m_enc->Attach(new FileSink(ofs));
m_dem = new DefaultEncryptorWithMAC((byte*)password.data(),
password.size(), new Redirector(*m_enc));

// ... ifs >> pdata ...

m_dem->Put2((byte const*)pdata.data(), pdata.size(), 0, true);
m_dem->MessageEnd();

----

Encrypts/decrypts fine within each OS. The encrypted output for each OS
is different - Ubuntu's is smaller in size. I've gone at this all day.
Any help is appreciated.
--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-***@googlegroups.com.
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 cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeffrey Walton
2016-05-15 15:10:34 UTC
Permalink
Post by Allan
http://comments.gmane.org/gmane.comp.encryption.cryptopp/2518
In this case, because I'm using DefaultEncryptorWithMAC with AES-256, I
get the exception "cannot decrypt message with this passphrase".
Generally,
----
std::string pdata;
std::ifstream ifs(sFilePlainText.c_str(), std::ifstream::binary);
std::ofstream ofs(sFileCipherText.c_str(), std::ofstream::binary);
m_enc = new Base64Encoder(NULL, true, 72);
AlgorithmParameters params = MakeParameters(Name::Separator(),
ConstByteArrayParameter("\n#"))
(Name::InsertLineBreaks(), true);
m_enc->IsolatedInitialize(params);
m_enc->Attach(new FileSink(ofs));
m_dem = new DefaultEncryptorWithMAC((byte*)password.data(),
password.size(), new Redirector(*m_enc));
// ... ifs >> pdata ...
m_dem->Put2((byte const*)pdata.data(), pdata.size(), 0, true);
m_dem->MessageEnd();
----
Encrypts/decrypts fine within each OS. The encrypted output for each OS
is different - Ubuntu's is smaller in size. I've gone at this all day.
Any help is appreciated.
C++ fstreams can be problematic, even in binary mode. I seem to recall
there was some unwanted conversions going on, and I had to disable the
processing of whitespace for a time. Microsoft fstreams can be problematic,
especially when they are wide streams.

First, ensure the fstreams are behaving as expected. Second, verify the
password is expected. There's a difference between encodings, code pages
and UTF-8. For password presentation to a lower lay like crypto, always use
UTF-8 because its portable across all platforms.

Jeff
--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-***@googlegroups.com.
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 cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Allan
2016-05-16 15:53:58 UTC
Permalink
Post by Jeffrey Walton
C++ fstreams can be problematic, even in binary mode. I seem to recall
there was some unwanted conversions going on, and I had to disable the
processing of whitespace for a time. Microsoft fstreams can be
problematic, especially when they are wide streams.First, ensure the
fstreams are behaving as expected. Second, verify the password is
expected. There's a difference between encodings, code pages and UTF-8.
For password presentation to a lower lay like crypto, always use UTF-8
because its portable across all platforms.Jeff
Thanks for the help. I posted a modified crypto example at
http://stackoverflow.com/q/37163270/5099723. It looks like fstream is ok.
Could you offer a simple cross platform example? Cheers.
--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-***@googlegroups.com.
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 cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
aeh
2018-09-07 18:59:57 UTC
Permalink
Just wondering if there was any headway with cross-platform, or any
successful examples I can reproduce?
Post by Jeffrey Walton
Post by Jeffrey Walton
C++ fstreams can be problematic, even in binary mode. I seem to recall
there was some unwanted conversions going on, and I had to disable the
processing of whitespace for a time. Microsoft fstreams can be
problematic, especially when they are wide streams.First, ensure the
fstreams are behaving as expected. Second, verify the password is
expected. There's a difference between encodings, code pages and UTF-8.
For password presentation to a lower lay like crypto, always use UTF-8
because its portable across all platforms.Jeff
Thanks for the help. I posted a modified crypto example at
http://stackoverflow.com/q/37163270/5099723. It looks like fstream is ok.
Could you offer a simple cross platform example? Cheers.
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
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 cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeffrey Walton
2018-09-07 19:09:08 UTC
Permalink
Post by aeh
Just wondering if there was any headway with cross-platform, or any
successful examples I can reproduce?
There are lots of examples of using the library in the library's test
files. The test files are listed at
https://github.com/weidai11/cryptopp/blob/master/GNUmakefile#L812 .

You can verify the build of the library with 'cryptest.exe v'. The wiki
also has lots of examples.

Otherwise provide an example of your problem on GitHub and we can take a
look at it.

Jeff
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
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 cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeffrey Walton
2018-09-08 16:12:09 UTC
Permalink
Post by aeh
Just wondering if there was any headway with cross-platform, or any
successful examples I can reproduce?
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
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 cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
aeh
2018-09-07 19:22:16 UTC
Permalink
I was referring to the below, or more specifically this
<https://stackoverflow.com/q/37163270/5099723>.
Post by Jeffrey Walton
Post by Allan
http://comments.gmane.org/gmane.comp.encryption.cryptopp/2518
In this case, because I'm using DefaultEncryptorWithMAC with AES-256, I
get the exception "cannot decrypt message with this passphrase".
Generally,
----
std::string pdata;
std::ifstream ifs(sFilePlainText.c_str(), std::ifstream::binary);
std::ofstream ofs(sFileCipherText.c_str(), std::ofstream::binary);
m_enc = new Base64Encoder(NULL, true, 72);
AlgorithmParameters params = MakeParameters(Name::Separator(),
ConstByteArrayParameter("\n#"))
(Name::InsertLineBreaks(), true);
m_enc->IsolatedInitialize(params);
m_enc->Attach(new FileSink(ofs));
m_dem = new DefaultEncryptorWithMAC((byte*)password.data(),
password.size(), new Redirector(*m_enc));
// ... ifs >> pdata ...
m_dem->Put2((byte const*)pdata.data(), pdata.size(), 0, true);
m_dem->MessageEnd();
----
Encrypts/decrypts fine within each OS. The encrypted output for each OS
is different - Ubuntu's is smaller in size. I've gone at this all day.
Any help is appreciated.
C++ fstreams can be problematic, even in binary mode. I seem to recall
there was some unwanted conversions going on, and I had to disable the
processing of whitespace for a time. Microsoft fstreams can be problematic,
especially when they are wide streams.
First, ensure the fstreams are behaving as expected. Second, verify the
password is expected. There's a difference between encodings, code pages
and UTF-8. For password presentation to a lower lay like crypto, always use
UTF-8 because its portable across all platforms.
Jeff
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
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 cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeffrey Walton
2018-09-08 17:10:55 UTC
Permalink
Post by Allan
http://comments.gmane.org/gmane.comp.encryption.cryptopp/2518
In this case, because I'm using DefaultEncryptorWithMAC with AES-256, I
get the exception "cannot decrypt message with this passphrase".
We added a binary decryption test at
https://github.com/weidai11/cryptopp/commit/4ff34ee32938 . It tested OK on
Windows 8.1, Solaris 11 and Fedora 28.

Please post a reproducer on GitHub.

Jeff
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
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 cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...