Skip to content
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

Change counter to uint64_t #3

Merged
merged 1 commit into from
Apr 20, 2020
Merged

Conversation

real-or-random
Copy link
Contributor

I hope this fixes #2. I haven't tested this.

I hope this fixes cloudtools#2. I haven't tested this.
@markpeek
Copy link
Member

markpeek commented Apr 2, 2020

@samrushing can you review, test, and approve?

@samrushing
Copy link
Contributor

Sorry for the delay! The bitcount is obviously being packed as a 64-bit quantity. Although I found some C implementations using 'int' or 'uint32_t', uint64_t is obviously correct. That's also what's used in NaCl/libsodium.

@samrushing
Copy link
Contributor

Heh, I added an 8GB test and it took 2200s to fail. You sure you want a test? 8^)

@markpeek
Copy link
Member

Technically I did get you to test it. ;-) Are you going to hit "Approve" through "Review Changes"?

@samrushing
Copy link
Contributor

diff --git a/tests/test_sha256.py b/tests/test_sha256.py
index 6290ea3..968f993 100644
--- a/tests/test_sha256.py
+++ b/tests/test_sha256.py
@@ -50,6 +50,14 @@ class TestSHA256(unittest.TestCase):
                     s = new
             self.assertEquals(s.hexdigest(), hash)
 
+    def test_counter(self):
+        s = 'X' * 1048576
+        h0 = sha()
+        h1 = hsha()
+        for i in range (512):
+            h0.update (s)
+            h1.update (s)
+        self.assertEquals (h0.hexdigest(), h1.hexdigest())
 
 if __name__ == '__main__':
     unittest.main()

That takes about 150s to run, add it if you dare!

@markpeek markpeek merged commit e0645d1 into cloudtools:master Apr 20, 2020
@markpeek
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect digest after 2^32 bits = 512 MB
3 participants