[PYTHON-CRYPTO] A pythonic way of calling crypto algorithms
Treutwein Guido
Guido.Treutwein at NBG.SIEMENS.DE
Thu Feb 22 09:25:35 CET 2001
Hi all,
I'm not sure how settled the design is in respect to calling the algorithm,
once it is found via the mechanisms discussed here, but we found the
following approach quite useful:
# alg() is assumed to be a cryptographic algorithm
cipher = alg(plain="something", key=aKey)
#encrypt or signature generation or MAC computation
plain = alg(cipher="$#qq!", key=aKey)
#decrypt
alg(plain="something", cipher="$#qq!", key=aKey) #MAC
or signature verification
In the last case its a matter of taste, whether an exception results in the
mismatch case, or something true is returned in the match case (e.g.
timestamp) or both.
The advantages are
- everything can be handled within the algorithm itself (so a hashing
function would reject the decrpytion by raising an exception)
- all types of algorithms can be called uniformly
- no magic constants are needed for encryption/decryption
Guido Treutwein
guido.treutwein at nbg.siemens.de
More information about the python-crypto
mailing list