summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakuchling <akuchling@rivest.dlitz.net>2003-12-19 15:24:25 -0700
committerakuchling <akuchling@rivest.dlitz.net>2003-12-19 15:24:25 -0700
commitc44bccd5616c491931bea1e1c4631b1efc3bc285 (patch)
treef08292c89c1db298d31b5b0e24f3b20ff8f83993
parent3d2bf697089e808f77d87e823284b97212a256f3 (diff)
downloadpycrypto-c44bccd5616c491931bea1e1c4631b1efc3bc285.tar.gz
[project @ akuchling-20031219222425-b2ffbae528141f6e]
[project @ 2003-12-19 14:24:25 by akuchling] Add Crypto.Hash.SHA256 module
-rw-r--r--ChangeLog10
-rw-r--r--Hash/__init__.py4
-rw-r--r--setup.py5
-rw-r--r--test/test_hashes.py9
-rw-r--r--test/testdata.py22
5 files changed, 45 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 11f26a6..ef43afb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,14 @@
+1.9alpha7
+=========
+
+ * Added SHA256 module contributed by Jeethu Rao, with test data
+ from Taylor Boon.
+
+ * Fixed AES.c compilation problems with Borland C.
+ (Contributed by Jeethu Rao.)
+
+
1.9alpha6
=========
diff --git a/Hash/__init__.py b/Hash/__init__.py
index 9f5f201..18fe4bc 100644
--- a/Hash/__init__.py
+++ b/Hash/__init__.py
@@ -19,6 +19,6 @@ Crypto.Hash.RIPEMD
Crypto.Hash.SHA
"""
-__all__ = ['HMAC', 'MD2', 'MD4', 'MD5', 'RIPEMD', 'SHA']
-__revision__ = "$Id: __init__.py,v 1.5 2002-07-11 14:31:19 akuchling Exp $"
+__all__ = ['HMAC', 'MD2', 'MD4', 'MD5', 'RIPEMD', 'SHA', 'SHA256']
+__revision__ = "$Id: __init__.py,v 1.6 2003-12-19 14:24:25 akuchling Exp $"
diff --git a/setup.py b/setup.py
index f0ce98d..25fbb1b 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
#! /usr/bin/env python
-__revision__ = "$Id: setup.py,v 1.26 2003-04-07 16:09:41 akuchling Exp $"
+__revision__ = "$Id: setup.py,v 1.27 2003-12-19 14:24:25 akuchling Exp $"
from distutils import core
from distutils.core import Extension
@@ -71,6 +71,9 @@ class PCTBuildExt (build_ext):
include_dirs=['src/'],
sources=["src/RIPEMD.c"],
libraries=HTONS_LIBS),
+ Extension("Crypto.Hash.SHA256",
+ include_dirs=['src/'],
+ sources=["src/SHA256.c"]),
# Block encryption algorithms
Extension("Crypto.Cipher.AES",
diff --git a/test/test_hashes.py b/test/test_hashes.py
index 7cbacf2..4be435b 100644
--- a/test/test_hashes.py
+++ b/test/test_hashes.py
@@ -2,7 +2,7 @@
# Test script for Crypto.Util.randpool.
#
-__revision__ = "$Id: test_hashes.py,v 1.2 2003-02-28 15:23:59 akuchling Exp $"
+__revision__ = "$Id: test_hashes.py,v 1.3 2003-12-19 14:24:25 akuchling Exp $"
import time, string, binascii
from sancho.unittest import TestScenario, parse_args, run_scenarios
@@ -11,7 +11,7 @@ from Crypto.Hash import *
import testdata
tested_modules = [ "Crypto.Hash.MD2", "Crypto.Hash.MD4", "Crypto.Hash.MD5",
- "Crypto.Hash.RIPEMD", "Crypto.Hash.SHA"]
+ "Crypto.Hash.RIPEMD", "Crypto.Hash.SHA", "Crypto.Hash.SHA256"]
class HashTest (TestScenario):
@@ -76,6 +76,11 @@ class HashTest (TestScenario):
self.run_test_suite(SHA, testdata.sha)
self.benchmark(SHA)
+ def check_sha256 (self):
+ "SHA256 module"
+ self.run_test_suite(SHA256,testdata.sha256)
+ self.benchmark(SHA256)
+
# class HashTest
diff --git a/test/testdata.py b/test/testdata.py
index d4a6df7..a91168b 100644
--- a/test/testdata.py
+++ b/test/testdata.py
@@ -65,6 +65,28 @@ sha = [
(1000000 * 'a', '34aa973cd4c4daa4f61eeb2bdbad27316534016f'),
]
+sha256 = [
+ ('abc', "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"),
+ ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"),
+ ("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+ "cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1"),
+ ("Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate--we can not consecrate--we can not hallow--this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us--that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion--that we here highly resolve that these dead shall not have died in vain--that this nation, under God, shall have a new birth of freedom--and that government of the people, by the people, for the people, shall not perish from the earth. -- President Abraham Lincoln, November 19, 1863",
+ "4d25fccf8752ce470a58cd21d90939b7eb25f3fa418dd2da4c38288ea561e600"),
+ ("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"),
+ ("This is exactly 64 bytes long, not counting the terminating byte", "ab64eff7e88e2e46165e29f2bce41826bd4c7b3552f6b382a9e7d3af47c245f8"),
+ ("For this sample, this 63-byte string will be used as input data", "f08a78cbbaee082b052ae0708f32fa1e50c5c421aa772ba5dbb406a2ea6be342"),
+ ("And this textual data, astonishing as it may appear, is exactly 128 bytes in length, as are both SHA-384 and SHA-512 block sizes",
+ "0ab803344830f92089494fb635ad00d76164ad6e57012b237722df0d7ad26896"),
+ ("By hashing data that is one byte less than a multiple of a hash block length (like this 127-byte string), bugs may be revealed.",
+ "e4326d0459653d7d3514674d713e74dc3df11ed4d30b4013fd327fdb9e394c26"),
+ ("qwerty" * 65536,
+ "5e3dfe0cc98fd1c2de2a9d2fd893446da43d290f2512200c515416313cdf3192"),
+ ("Rijndael is AES" * 1024,
+ "80fced5a97176a5009207cd119551b42c5b51ceb445230d02ecc2663bbfb483a"),
+ (1000000 * 'a', 'cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0'),
+ ]
+
ripemd = [ ("", "9c1185a5c5e9fc54612808977ee8f548b2258d31"),
("a", "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe"),
("abc", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"),