Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-12-07 06:09:33 +0300
committerAdam Langley <agl@google.com>2015-12-16 22:57:31 +0300
commit5a19d7dfa8abe611da91d3b90f3313611bc9b3c4 (patch)
tree82bc1b7a7411c3d4013cfce11669569df6ae25d6 /crypto/sha
parent78fefbf3bbb3ac6ddf537fc927b15b4c41db7f6c (diff)
Use the straight-forward ROTATE macro.
I would hope any sensible compiler would recognize the rotation. (If not, we should at least pull this into crypto/internal.h.) Confirmed that clang at least produces the exact same instructions for sha256_block_data_order for release + NO_ASM. This is also mostly moot as SHA-1 and SHA-256 both have assembly versions on x86 that sidestep most of this. For the digests, take it out of md32_common.h since it doesn't use the macro. md32_common.h isn't sure whether it's a multiply-included header or not. It should be, but it has an #include guard (doesn't quite do what you'd want) and will get HOST_c2l, etc., confused if one tries to include it twice. Change-Id: I1632801de6473ffd2c6557f3412521ec5d6b305c Reviewed-on: https://boringssl-review.googlesource.com/6650 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/sha')
-rw-r--r--crypto/sha/sha1.c1
-rw-r--r--crypto/sha/sha256.c2
2 files changed, 3 insertions, 0 deletions
diff --git a/crypto/sha/sha1.c b/crypto/sha/sha1.c
index 568706ba..0396b95a 100644
--- a/crypto/sha/sha1.c
+++ b/crypto/sha/sha1.c
@@ -117,6 +117,7 @@ uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out) {
#define HASH_TRANSFORM SHA1_Transform
#define HASH_FINAL SHA1_Final
#define HASH_BLOCK_DATA_ORDER sha1_block_data_order
+#define ROTATE(a, n) (((a) << (n)) | ((a) >> (32 - (n))))
#define Xupdate(a, ix, ia, ib, ic, id) \
((a) = (ia ^ ib ^ ic ^ id), ix = (a) = ROTATE((a), 1))
diff --git a/crypto/sha/sha256.c b/crypto/sha/sha256.c
index 36813080..85bbad56 100644
--- a/crypto/sha/sha256.c
+++ b/crypto/sha/sha256.c
@@ -204,6 +204,8 @@ static const uint32_t K256[64] = {
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL};
+#define ROTATE(a, n) (((a) << (n)) | ((a) >> (32 - (n))))
+
/* FIPS specification refers to right rotations, while our ROTATE macro
* is left one. This is why you might notice that rotation coefficients
* differ from those observed in FIPS document by 32-N... */