summaryrefslogtreecommitdiff
path: root/src/RIPEMD160.c
diff options
context:
space:
mode:
authorDwayne Litzenberger <dlitz@dlitz.net>2013-02-17 11:21:38 -0800
committerDwayne Litzenberger <dlitz@dlitz.net>2013-02-17 20:07:02 -0800
commitfd398a28e3a227a539b264a9f1e11287b904c7da (patch)
tree9f1628ef88c17604f55ec0ad652b0e1fb3959f38 /src/RIPEMD160.c
parent0d8ea5ff1607a3d7ae544667bff99229954484ff (diff)
downloadpycrypto-fd398a28e3a227a539b264a9f1e11287b904c7da.tar.gz
Hash: Speed up initialization by removing pure-Python wrappershash-speedup-wip
The pure Python wrappers around Crypto.Hash.* were convenient, but they slowed down hash initialization by 4-7x. There is a speed trade-off here: The MD5 and SHA1 objects are just wrapped hashlib objects (or old-style md5/sha objects). To maintain API compatibility with the rest of PyCrypto, we still have to wrap them, so they're slower to initialize than the rest of the hash functions. If hashlib ever adds a .new() method, we will automatically use hashlib directly and gain the initialization speed-up.
Diffstat (limited to 'src/RIPEMD160.c')
-rw-r--r--src/RIPEMD160.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/RIPEMD160.c b/src/RIPEMD160.c
index 37d4c73..9593fc8 100644
--- a/src/RIPEMD160.c
+++ b/src/RIPEMD160.c
@@ -61,6 +61,26 @@
#define RIPEMD160_DIGEST_SIZE 20
#define BLOCK_SIZE 64
+static char MODULE__doc__[] =
+ "RIPEMD-160 cryptographic hash algorithm.\n"
+ "\n"
+ "RIPEMD-160_ produces the 160 bit digest of a message.\n"
+ "\n"
+ " >>> from Crypto.Hash import RIPEMD160\n"
+ " >>>\n"
+ " >>> h = RIPEMD160.new()\n"
+ " >>> h.update(b'Hello')\n"
+ " >>> print h.hexdigest()\n"
+ "\n"
+ "RIPEMD-160 stands for RACE Integrity Primitives Evaluation Message Digest\n"
+ "with a 160 bit digest. It was invented by Dobbertin, Bosselaers, and Preneel.\n"
+ "\n"
+ "This algorithm is considered secure, although it has not been scrutinized as\n"
+ "extensively as SHA-1. Moreover, it provides an informal security level of just\n"
+ "80bits.\n"
+ "\n"
+ ".. _RIPEMD-160: http://homes.esat.kuleuven.be/~bosselae/ripemd160.html\n";
+
#define RIPEMD160_MAGIC 0x9f19dd68u
typedef struct {
uint32_t magic;
@@ -401,8 +421,7 @@ static int ripemd160_digest(const ripemd160_state *self, unsigned char *out)
}
/* Template definitions */
-#define MODULE_NAME _RIPEMD160
-#define ALGORITHM_NAME "RIPEMD160"
+#define MODULE_NAME RIPEMD160
#define DIGEST_SIZE RIPEMD160_DIGEST_SIZE
#define hash_state ripemd160_state
#define hash_init ripemd160_init