-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
config: Port openssl sha224 to use EVP functions #244
Conversation
As suggested by SHA224(3ssl), use the EVP_DigestInit functions. Calling the hash functions directly is deprecated for applications. Further, actually check the return values from the OpenSSL functions and throw appropriate runtime errors.
LGTM. Thanks! |
throw runtime_error("could not output hash"); | ||
} | ||
|
||
for (unsigned int i = 0; i < digest_len; ++i) { | ||
sprintf(mdString + (i << 1), "%02x", (unsigned int)digest[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use snprintf
instead: https://stackoverflow.com/questions/3662899/understanding-the-dangers-of-sprintf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can see from the diff, I didn’t change this line. But I’d be curious in seeing how you intend to exploit this with a single byte ...
Why not sha256? |
On Wed, Feb 10, 2021 at 8:39 AM GFHuang ***@***.***> wrote:
Why not sha256?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#244 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG2Z7DQBV6QEB3P4JBPLIIDS6KZD3ANCNFSM4KSF6XAQ>
.
SHA224 is specified in the Trojan Protocol.
https://github.com/trojan-gfw/trojan/blob/master/docs/protocol.md
|
I means why choose sha224 to define the protocol rather than the popular sha256? I have no experience in cryptography, but I'm just curious. |
@GF-Huang It's shorter |
If it's for shorter, why not just use the 28 bytes output from SHA224, rather than convert to hex string that make it 56 bytes? |
@GF-Huang That was one of my design failures :) |
As suggested by SHA224(3ssl), use the EVP_DigestInit functions. Calling
the hash functions directly is deprecated for applications. Further,
actually check the return values from the OpenSSL functions and throw
appropriate runtime errors.