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
SHA-3 CalculateDigest results in Segmentation fault #130
Comments
More detailed output from gdb: Program received signal SIGSEGV, Segmentation fault. |
This happens on Ubuntu/g++: geo@geo-Lenovo-G580: |
You need to provide a buffer. This is not correct:
Try:
This is kind of odd:
In C++, you usually just:
Finally, I don't believe a bit-count with the SHA3 constructor is correct. I seem to recall it should be a byte-count. Also see sha3.h. |
If you have questions, then you should discuss things at the User Group. |
Here's the result of your suggestion: sha3.cpp:28:18: error: ‘DIGESTSIZE’ is not a member of ‘CryptoPP::SHA3’ It is Generally good idea to return some error code from any function instead of void! |
Your second idea: $ ./sha3 |
Works for me. Here's the program:
Here's the result:
OK, thanks. Crypto++ usually throws an exception rather than returning codes. |
We also update the documentation for member functions like CalculateDigest. They now include the precondition on the buffer sizes used for the digest. Also see Commit 389b6fc5da221680 and Commit 9430de2e46f5321e |
Glad to see that you are Responsive to library client developers! I think it might be a Good Idea to update projects Wiki with simple and working examples like above. Also linking with LOCAL ./libcryptopp.a makes LOTS of difference. Without it one would get: "error: ld returned 1 exit status". Which is not a good sign imho :-) Thanks for helping us out with SHA-3 stuff! |
Yes, its not a problem. The reason I have not been providing answers here is I want to see where you go with things. I try to use it as a case study to identify gaps, like the missing wiki documentation on hashes. If I tell you to do X or don't do Y, then I influence the outcome of the experiment. And I also experience the gaps when using other's warez. For example, this does not make sense to me: GCC missing libasan and libubsan after installing gcc and gcc-c++. I would have used it as authority to act in some way. I would not have closed the bug and forgotten about it.
Yes, you are right. We have good coverage on block ciphers and other areas, but it pretty much sucks for hashes. I'll put it on the TODO list.
This one is tough because I know the gap exists, but I don't know how to disseminate the information. When you found your compile and link command, where did you find it? Or did you just do what you kind of know? |
Respectfully, anyone who does:
... is not the target audience for Crypto++. A person who does something like this should not trusted with a C++ compiler to begin with. Crypto++ has its problems - the design is somewhat overly arcane, it's attempting to be both a crypto library and an infrastructural framework. However, I'm not sure that the design of the library and its supporting materials should be aimed at C++ novices. |
Hi, simple program that attempts to calculate SHA-3 hash compiles and links without any warnings but then crashes. Here's the code:
Gdg shows the following:
As it designed now method CalculateDigest returns void which makes it difficult to understand the problem. Using try catch does NOT help. It might be a good idea to use return error codes instead of void. This is already second submission of this but. First one was simply removed by someone without answering the question.
The text was updated successfully, but these errors were encountered: