[PYTHON-CRYPTO] PEP-272 Deficiencies - Comments
Janusz A. Urbanowicz
alex at BOFH.TORUN.PL
Sun Dec 16 22:12:32 CET 2001
Paul wrote/napisał[a]/schrieb:
> At 3:54 PM -0700 12/15/01, Jason R. Mastaler wrote:
> >phr-pycrypt at nightsong.com writes:
> >
> >> Is a draft copy of PEP 272 actually available somewhere?
> >
> >http://python.sourceforge.net/peps/pep-0272.html
>
> This api has several problems:
>
> 1) I agree with Janusz A. Urbanowicz's earlier note that symmetric
> encryption should be a class. The initialization can give it the
> key. Note that it may later need to be reinitialized, so a
> set_key(key) method should also be available and the initialization
> should be optional (but raise an exception on use when no
> key is available)
I don't like it very much. This breaks the OO design view - any instance of
CIpher is a cipher with a particular key. If you want to change the key,
yopu create a new instacne of the class.
If there is absolutely a must of some set_key method, it should return a new
instance of the class, not reset the live object.
> 2) The modes of operation should not be parameters. The modes create
> new algorithms types. It's easy to spin out new mode algorithms with
> a mode "wrapper" class.
Agreed. I thought of it that way: there are three base classes: Cipher for
symmetric key, Encryptor for pubkey and Hash for hashes. Any given cipher
algorithm is a subclass of Cipher etc. A variation of algorithm is a subclass
of base cipher. So it would be that 3DES-CBC is a subclass of 3DES, which is a
subclass of DES which is a subclass of Cipher.
Alex
--
C _-=-_ H| Janusz A. Urbanowicz | ALEX3-RIPE | SF-F Framling | | *
; (_O : +-------------------------------------------------------------+ --+~|
! &~) ? | Płynąć chcę na Wschód, za Suez, gdzie jest dobrem każde zło | l_|/
A ~-=-~ O| Gdzie przykazań brak dziesięciu, a pić można aż po dno; | |
More information about the python-crypto
mailing list