Near Final PEP 247 - API for Cryptographic Hash Functions

Boyd Roberts boyd at insultant.net
Sat Sep 22 21:27:32 EDT 2001


MD5 deals with bits, not bytes.  i think there's a problem with:

    digest_size

        An integer value; the size of the digest produced by the
        hashing objects created by this module, measured in bytes.
        You could also obtain this value by creating a sample object
        and accessing its 'digest_size' attribute, but it can be
        convenient to have this value available from the module.
        Hashes with a variable output size will set this variable to 0.

normally we're dealing with bytes, but, for the sake of argument, the digest
size should be measured in bits.

to quote _network security_:

    http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0130614661&vm=

    The message digest is a 128-bit quantity.

it just so happens that this is divisible by 8.

i am also unconvinced of the semantics of:

    update(arg)

        Update this hashing object with the string 'arg'.

it's unclear whether update() appends or replaces.

now if update() appends then it's ok, but if it replaces you'll
only ever be able to checksum stuff that fits in memory.

due to the padding of the last block, it only really make sense
to call digest() right at the end.

bundling it all into one crypto module is probably a bad idea.
future hash functions may not fit the current model.

        >>> m.hexdigest()
        '900150983cd24fb0d6963f7d28e17f72'

i think the digest should be returned as an ascii hex string (as
above).  it only makes sense to do equality comparisons;  LongType
seems to me to be overkill.






More information about the Python-list mailing list