[PYTHON-CRYPTO] Draft hashing PEP

Andrew Kuchling akuchlin at mems-exchange.org
Sat Mar 24 17:43:07 CET 2001


On Fri, Mar 23, 2001 at 10:36:41PM -0500, Andrew Archibald wrote:
>Currently, sha objects have a digestsize attribute.  This is convenient;
>should it be required by the PEP?

Good point; it can be added.  (Ditto for Rich Salz's suggestion of changing
clear() to reset().)

>How common are variable-size hashes?  (For example, the SHA-160, SHA-256,
>SHA-384, SHA-512 family)  Is it worth allowing a module to support multiple
>digest sizes?  I would suggest allowing this by having such a module (say
>SHA_variable) export a digestsize of 0.  Then new() can accept a digestsize
>argument, and each object will have its own digestsize attribute.

That seems reasonable.  An alternate way would be to have sha, sha256,
sha512 modules, but that would be a bit annoying.  (Though it's not clear to
me that there would be much sharing of code between SHA-{160,256,384,512}
implementations.

>Some hashes have additional parameters (HAVAL has a rounds parameter, I
>believe); perhaps new should accept arbitrary additional keyword arguments?

Yes; additional random keyword arguments would be allowed (they'd count as
extensions).  The PEP wouldn't specify them -- except maybe for 'rounds' --
but if there was a variable blocksize hash it could choose its own keyword.

>What should unkeyed hashes do when presented with a key?  Presumably, raise
>an exception.

Yes.  Hmm.. should there be a requires_key variable or function, and a
key_size value?

--amk





More information about the python-crypto mailing list