-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have you ever tried to cross-compile it? #44
Comments
Hi. I have never tried to cross compile OpenPGP for ARM. I suggest running the code with gdb to find out where the error is coming from. You might just be out of memory. |
@GeorgeKalovyrnas Have you gotten a diagnosis of what's going on? |
No, not yet. For sure there will be an issue with larger files. Is it difficult to substitute some parts of the code, with calls from OpenSSL stack (already cross-compiled)? |
I do not know how difficult it would be to use the OpenSSL stack, as I have never used it. It might be an interesting project to add an abstraction layer to allow for switching between the stuff I wrote and OpenSSL. Can you tell me what packages you are using/steps you are taking to cross compile OpenPGP? I tried cross compiling for armhf a few days ago, but my lack of experience with cross compiling stopped me pretty early on. |
As it seems the out of memory issue is happening in function S2K3::run(). |
Yes. That looks correct according to RFC 4880 sec 3.7.1.3
The issue might be that the 32505856 octets are required:
meaning that I have to do something like this:
which generates lots of temporary data (especially without |
Give f797d7d a try. I reduced the amount of duplicate data being generated by a bit. Maybe that might help? |
Obviously, since hashing requires 32505856 byes (32Mb) it's impossible for my device to cope with this size. So, I assume that "out-of-memory" issue is a normal consequence! |
Darn. I suppose it is possible to regenerate the data for each round |
Repeatedly regenerating the context is faster than combining it all together. 25bf52e |
Amazingly good job! |
How big is your key? |
…g the context early Fixes high memory usage in S2K3 for low-memory devices (#44)
How should I measure it? |
If you dump your public key, it will tell you:
Now that I think about it, I'm not entirely sure what I can do to speed things up, since the calculations are done by GMP, not my me for the most part. Maybe change RNGs? |
I have some good news for you and for me too of course. :-) |
Huh. I didn't realize I was doing so much string copying in the hashing code. |
In function SHA1::calc it has, one string allocation inside the "for" loop and a couple of substring operations. When you have millions of iterations, these operations are really expensive. |
Using OpenSSL's SHA1 functions I've managed to bring down the total time from 10 seconds to 3 seconds. |
Wow... Would you care to add analogous changes to the other hash/encryption functions? I would be happy to add using OpenSSL as a configurable option to OpenPGP. I could do it, but I would like to have an example piece of code to work off of. |
I created a new branch to start integrating OpenSSL into OpenPGP. https://github.com/calccrypto/OpenPGP/tree/openssl |
Sure, I will try to help you, although I don't have experience using OpenSSL. This was my first attempt to do so. |
Here's the first pass with adding hashes. The files will probably be reorganized at some point, but it works for now. You should be able to enable OpenSSL by adding |
I don't think I will be adding in the OpenSSL encryption algorithms. They have all sorts of weird quirks that were making it impossible to properly integrate:
|
OK Of course there are other cryptographic libraries that include all the functions that you need. For example crypto++. And I am sure that you find one that matches your needs and project's license. I will try to give you my version of improvement, which doesn't include OpenSSL functionality. |
I've merged the OpenSSL stuff into master with 9187f64. You can use OpenSSL hashing and rng with |
@GeorgeKalovyrnas Can I close this issue? |
Yes sure. |
Hi,
I have tried to cross-compile it for ARM (very restricted) architecture.
The cross compilation was successful. But when trying to run the application I get always std::bad_alloc exception.
The very same code works just fine on my laptop.
Can you suggest a way to find the error?
Thanks and regards
The text was updated successfully, but these errors were encountered: