diff options
author | Dwayne Litzenberger <dlitz@dlitz.net> | 2013-02-17 11:21:28 -0800 |
---|---|---|
committer | Dwayne Litzenberger <dlitz@dlitz.net> | 2013-02-17 19:00:50 -0800 |
commit | 59018ff99c97261f9bbaee33f919938871e05118 (patch) | |
tree | a07cdc2d6404d983314e1b5cbae78757e5a7a9be /src/hash_template.c | |
parent | 4e4cc0beefbb316db2a8750e747e697df0b754d7 (diff) | |
download | pycrypto-59018ff99c97261f9bbaee33f919938871e05118.tar.gz |
Hash: Remove "oid" attributes; add "name" attribute
In PyCrypto v2.5, the "oid" attribute was added to hash objects. In
retrospect, this was not a good idea, since the OID is not really a
property of the hash algorithm, it's a protocol-specific identifer for
the hash functions. PKCS#1 v1.5 uses it, but other protocols (e.g.
OpenPGP, DNSSEC, SSH, etc.) use different identifiers, and it doesn't make
sense to add these to Crypto.Hash.* every time a new algorithm is added.
This also has the benefit of being compatible with the Python standard
library's "hashlib" objects, which also have a name attribute.
Diffstat (limited to 'src/hash_template.c')
-rw-r--r-- | src/hash_template.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/hash_template.c b/src/hash_template.c index 10b1b1c..afffbfb 100644 --- a/src/hash_template.c +++ b/src/hash_template.c @@ -209,9 +209,13 @@ ALG_getattr(PyObject *self, char *name) if (PyUnicode_CompareWithASCIIString(attr, "digest_size")==0) return PyLong_FromLong(DIGEST_SIZE); + if (PyUnicode_CompareWithASCIIString(attr, "name")==0) + return PyUnicode_FromString(ALGORITHM_NAME); #else if (strcmp(name, "digest_size")==0) return PyInt_FromLong(DIGEST_SIZE); + if (strcmp(name, "name")==0) + return PyString_FromString(ALGORITHM_NAME); #endif #ifdef IS_PY3K |