-
-
Notifications
You must be signed in to change notification settings - Fork 991
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
Changes to prepare for ubuntu 22.04 CI #6635
Changes from 4 commits
751be1e
dcb6672
fb243d4
3af06dd
d8b5379
88fcf5f
2a038d5
3c00169
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,18 +29,13 @@ extern "C" { | |
|
||
#ifndef __APPLE__ | ||
|
||
#include <openssl/sha.h> | ||
#include <openssl/md5.h> | ||
|
||
static_assert(utils::md5::DIGEST_SIZE == MD5_DIGEST_LENGTH, "Constants mismatch"); | ||
static_assert(utils::sha1::DIGEST_SIZE == SHA_DIGEST_LENGTH, "Constants mismatch"); | ||
#include <openssl/evp.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove the MD5 static_assert here but not in the Apple section? You should probably remove either both or neither. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the new evp header doesn't have the constant to compare against anymore, and the evp header isn't used on Apple systems. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well… how does it even know what the size is? Is it just hard-coded and will break if we ever change hash type? Although, I guess if we change hash type we'd at least make a separate hashing class, so maybe that doesn't matter… There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't follow? Are there multiple types of MD5 hashes? |
||
|
||
#else | ||
|
||
#include <CommonCrypto/CommonDigest.h> | ||
|
||
static_assert(utils::md5::DIGEST_SIZE == CC_MD5_DIGEST_LENGTH, "Constants mismatch"); | ||
static_assert(utils::sha1::DIGEST_SIZE == CC_SHA1_DIGEST_LENGTH, "Constants mismatch"); | ||
|
||
#endif | ||
|
||
|
@@ -71,10 +66,19 @@ namespace utils { | |
md5::md5(const std::string& input) { | ||
|
||
#ifndef __APPLE__ | ||
MD5_CTX md5_worker; | ||
MD5_Init(&md5_worker); | ||
MD5_Update(&md5_worker, input.data(), input.size()); | ||
MD5_Final(hash.data(), &md5_worker); | ||
EVP_MD_CTX *mdctx = EVP_MD_CTX_new(); | ||
unsigned int md5_digest_len = EVP_MD_size(EVP_md5()); | ||
assert(utils::md5::DIGEST_SIZE == md5_digest_len); | ||
|
||
// MD5_Init | ||
EVP_DigestInit_ex(mdctx, EVP_md5(), NULL); | ||
|
||
// MD5_Update | ||
EVP_DigestUpdate(mdctx, input.c_str(), input.size()); | ||
|
||
// MD5_Final | ||
EVP_DigestFinal_ex(mdctx, hash.data(), &md5_digest_len); | ||
EVP_MD_CTX_free(mdctx); | ||
#else | ||
CC_MD5(input.data(), static_cast<CC_LONG>(input.size()), hash.data()); | ||
#endif | ||
|
@@ -124,28 +128,6 @@ std::string md5::base64_digest() const | |
return encode_hash<DIGEST_SIZE>(hash); | ||
} | ||
|
||
sha1::sha1(const std::string& str) | ||
{ | ||
#ifndef __APPLE__ | ||
SHA_CTX hasher; | ||
SHA1_Init(&hasher); | ||
SHA1_Update(&hasher, str.data(), str.size()); | ||
SHA1_Final(hash.data(), &hasher); | ||
#else | ||
CC_MD5(str.data(), static_cast<CC_LONG>(str.size()), hash.data()); | ||
#endif | ||
} | ||
|
||
std::string sha1::hex_digest() const | ||
{ | ||
return hexencode_hash<DIGEST_SIZE>(hash); | ||
} | ||
|
||
std::string sha1::base64_digest() const | ||
{ | ||
return encode_hash<DIGEST_SIZE>(hash); | ||
} | ||
|
||
bcrypt::bcrypt(const std::string& input) | ||
{ | ||
assert(is_valid_prefix(input)); | ||
|
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.
This is a negative change, as it loses the error message…
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.
It was either this or remove it entirely, since Clang was rejecting the version that allowed an error message.
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.
Sounds like a clang bug. You're supposed to be able to use a message. Or did it have a problem with
dependent_false_v
?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.
See https://github.com/wesnoth/wesnoth/runs/6146018736?check_suite_focus=true#step:3:215
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.
That looks like it could have been solved with
decltype(cat)
.