aboutsummaryrefslogtreecommitdiff
path: root/decrepit/ripemd
AgeCommit message (Collapse)AuthorFilesLines
2023-07-11Use std::make_unique when possibleDavid Benjamin1-1/+1
We've required C++14 for a while now. As we're mostly C with a little C++, this is less helpful, but may as well avoid bare new where possible. Change-Id: Icf3386e3f3b6f2092bb0089ed874cc50985f1a40 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61429 Reviewed-by: Bob Beck <bbe@google.com> Commit-Queue: David Benjamin <davidben@google.com>
2022-12-09Finish porting dh_test.cc and ripemd_test.cc to GTest.David Benjamin1-20/+5
They're the only two half-finished ports left, so we may as well finish that up and trim them down a little. Change-Id: Ic058124a44086161ab5d2d6fa24448492c3ba219 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/55506 Auto-Submit: David Benjamin <davidben@google.com> Commit-Queue: Bob Beck <bbe@google.com> Reviewed-by: Bob Beck <bbe@google.com>
2021-10-05Extract common rotl/rotr functions.David Benjamin1-15/+13
We have a ton of per-file rotation functions, often with generic names that do not tell you whether they are uint32_t vs uint64_t, or rotl vs rotr. Additionally, (x >> r) | (x << (32 - r)) is UB at r = 0. (x >> r) | (x << ((-r) & 31)) works for 0 <= r < 32, which is what cast.c does. GCC and Clang recognize this pattern as a rotate, but MSVC doesn't. MSVC does, however, provide functions for this. We usually rotate by a non-zero constant, which makes this moot, but rotation comes up often enough that it's worth extracting out. Some particular changes to call out: - I've switched sha256.c from rotl to rotr. There was a comment explaining why it differed from the specification. Now that we have both functions, it's simpler to just match the specification. - I've dropped all the inline assembly from sha512.c. Compilers should be able to recognize rotations in 2021. Change-Id: Ia1030e8bfe94dad92514ed1c28777447c48b82f9 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/49765 Reviewed-by: Adam Langley <agl@google.com>
2021-06-01Make md32_common.h single-included and use an unsized helper for SHA-256.David Benjamin1-24/+18
Similar to https://boringssl-review.googlesource.com/c/boringssl/+/46405, SHA256_Final and SHA224_Final hit array size warnings in the new GCC. The array sizes are, strictly speaking, purely decoration, but this is a good warning so we should be clean with it on. That same change is difficult to apply to md32_common.h because md32_common.h generates the functions for us. md32_common.h is already strange in that it is multiply-included and changes behavior based on macros defined by the caller. Instead, replace it with inline functions, which are a bit more conventional and typesafe. This allows each hash function to define the function prototype. Use this to add an unsized helper for SHA-256. Bug: 402 Change-Id: I61bc30fb58c54dd40a55c9b1ebf3fb9adde5e038 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/47807 Reviewed-by: Adam Langley <agl@google.com> Reviewed-by: Peter Foley <pefoley@google.com> Commit-Queue: David Benjamin <davidben@google.com>
2021-06-01Pull HASH_TRANSFORM out of md32_common.h.David Benjamin1-1/+5
The macro isn't doing any work here. Change-Id: Id97dfa4b027407c5e4b3e7eb1586c3c2a2d977d8 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/47806 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
2021-04-02Fold ripemd/internal.h into ripemd.c.David Benjamin2-497/+423
It's only used from that file and, given the names defined by it, probably isn't usable by other files anyway. Change-Id: Ice205408962ade00c1dcb51406da3ef2fd7f0393 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/46426 Reviewed-by: Adam Langley <agl@google.com>
2021-04-02Move load/store helpers to crypto/internal.h.David Benjamin2-46/+48
We have loads of variations of these. Align them in one set. This avoids the HOST_* macros defined by md32_common.h, so it'll be a little easier to make it a more conventional header. Change-Id: Id47fe7b51a8f961bd87839f8146d8a5aa8027aa6 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/46425 Reviewed-by: Adam Langley <agl@google.com>
2019-04-08Rename 'md' output parameter to 'out' and add bounds.David Benjamin2-4/+6
We usually name output parameters 'out'. (Someone made a C++ templating change in Chromium which messed up const-ness, saw the compile error, and thought it was in MD5_Final.) Also tag the parameters with the sizes. Sadly, there's a bit of goofiness around SHA224_Final/SHA256_Final and SHA384_Final/SHA512_Final, but they're just documentation anyway. (Though it does touch on the mess that is sha->md_len which would be nice to clear through somehow.) Change-Id: I1918b7eecfe13f13b217d01d4414ac2358802354 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35484 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
2018-09-05Flatten the decrepit target.David Benjamin1-9/+0
https://boringssl-review.googlesource.com/c/boringssl/+/31364 wants to add a dependency to each target, which is much easier with fewer of them. Start with decrepit. Change-Id: Ib3777063d545dfebe3e2b8448eb7e5bbb5c3aaac Reviewed-on: https://boringssl-review.googlesource.com/31584 Reviewed-by: Adam Langley <agl@google.com>
2018-03-15fix compilation error for non-english windows (like cjk)sphawk1-1/+1
add /utf-8 switch for msvc build. source code has several utf-8 characters fix C2001 error. escape non-printable ascii code generated by embed_test_data.go fix C4819 warning. add u8 keyword on utf-8 string literal (ripemd_test.cc) Change-Id: I8c04dc7f0359e6ee27efada066863826d263d5cd Reviewed-on: https://boringssl-review.googlesource.com/26484 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-18Run the comment conversion script on decrepit/David Benjamin2-4/+4
No one has CLs open there. Change-Id: I387c1f04cc9ee7bf794bdc390d498e3f80b21091 Reviewed-on: https://boringssl-review.googlesource.com/19484 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-04-07First part of the FIPS module.Adam Langley1-1/+1
Change-Id: Ic3a91ccd2c8cdc364740f256fdb8a7ff66177947 Reviewed-on: https://boringssl-review.googlesource.com/14506 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com>
2017-01-21Do a cursory conversion of a few tests to GTest.David Benjamin2-19/+5
For now, this is the laziest conversion possible. The intent is to just get the build setup ready so that we can get everything working in our consumers. The intended end state is: - The standalone build produces three test targets, one per library: {crypto,ssl,decrepit}_tests. - Each FOO_test is made up of: FOO/**/*_test.cc crypto/test/gtest_main.cc test_support - generate_build_files.py emits variables crypto_test_sources and ssl_test_sources. These variables are populated with FindCFiles, looking for *_test.cc. - The consuming file assembles those variables into the two test targets (plus decrepit) from there. This avoids having generate_build_files.py emit actual build rules. - Our standalone builders, Chromium, and Android just run the top-level test targets using whatever GTest-based reporting story they have. In transition, we start by converting one of two tests in each library to populate the three test targets. Those are added to all_tests.json and all_tests.go hacked to handle them transparently. This keeps our standalone builder working. generate_build_files.py, to start with, populates the new source lists manually and subtracts them out of the old machinery. We emit both for the time being. When this change rolls in, we'll write all the build glue needed to build the GTest-based tests and add it to consumers' continuous builders. Next, we'll subsume a file-based test and get the consumers working with that. (I.e. make sure the GTest targets can depend on a data file.) Once that's all done, we'll be sure all this will work. At that point, we start subsuming the remaining tests into the GTest targets and, asynchronously, rewriting tests to use GTest properly rather than cursory conversion here. When all non-GTest tests are gone, the old generate_build_files.py hooks will be removed, consumers updated to not depend on them, and standalone builders converted to not rely on all_tests.go, which can then be removed. (Unless bits end up being needed as a malloc test driver. I'm thinking we'll want to do something with --gtest_filter.) As part of this CL, I've bumped the CMake requirements (for target_include_directories) and added a few suppressions for warnings that GTest doesn't pass. BUG=129 Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a Reviewed-on: https://boringssl-review.googlesource.com/13232 Reviewed-by: Adam Langley <agl@google.com>
2016-12-21Work around language and compiler bug in memcpy, etc.David Benjamin2-4/+5
Most C standard library functions are undefined if passed NULL, even when the corresponding length is zero. This gives them (and, in turn, all functions which call them) surprising behavior on empty arrays. Some compilers will miscompile code due to this rule. See also https://www.imperialviolet.org/2016/06/26/nonnull.html Add OPENSSL_memcpy, etc., wrappers which avoid this problem. BUG=23 Change-Id: I95f42b23e92945af0e681264fffaf578e7f8465e Reviewed-on: https://boringssl-review.googlesource.com/12928 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
2016-10-18Fix up macros.David Benjamin2-21/+21
Macros need a healthy dose of parentheses to avoid expression-level misparses. Most of this comes from the clang-tidy CL here: https://android-review.googlesource.com/c/235696/ Also switch most of the macros to use do { ... } while (0) to avoid all the excessive comma operators and statement-level misparses. Change-Id: I4c2ee51e347d2aa8c74a2d82de63838b03bbb0f9 Reviewed-on: https://boringssl-review.googlesource.com/11660 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
2016-04-27Revert md_len removal from SHA256_CTX and SHA512_CTX.David Benjamin2-19/+15
This reverts commits: - 91586371422dae70481c39752e55f01f50e9a93a - a90aa643024459c1698dbec84f4c79a3238b3db8 - c0d8b83b4462a0eb1889f32dbd7f46e83f4dbc81 It turns out code outside of BoringSSL also mismatches Init and Update/Final functions. Since this is largely cosmetic, it's probably not worth the cost to do this. Change-Id: I14e7b299172939f69ced2114be45ccba1dbbb704 Reviewed-on: https://boringssl-review.googlesource.com/7793 Reviewed-by: Adam Langley <agl@google.com>
2016-04-27Pull HASH_MAKE_STRING out of md32_common.h.David Benjamin2-15/+19
This is in preparation for taking md_len out of SHA256_CTX by allowing us to do something similar to SHA512_CTX. md32_common.h now emits a static "finish" function which Final composes with the extraction step. Change-Id: I314fb31e2482af642fd280500cc0e4716aef1ac6 Reviewed-on: https://boringssl-review.googlesource.com/7721 Reviewed-by: Adam Langley <agl@google.com>
2016-03-09Add RIPEMD160 support in decrepit.Adam Langley4-0/+957
This version is taken from OpenSSL 1.0.2 with tweaks to support the changes that we have made to md32_common.h. None of the assembly implementations have been imported. This makes supporting nmap easier. Change-Id: Iae9241abdbc9021cc6bc35a65b40c3d739011ccc Reviewed-on: https://boringssl-review.googlesource.com/7402 Reviewed-by: David Benjamin <davidben@google.com>