So, in pyDes, a cryptographic library of DES, there is an API, which goes like this pyDes.des(key, [mode], [IV], [pad], [padmode])
. An usage of it goes like this k = des("DESCRYPT", CBC, "\0\0\0\0\0\0\0\0", pad=None, padmode=PAD_PKCS5)
- where I can either use CBC or ECB mode of encryption.However, as an assignment from my professor, I am told to encrypt using pyDes library, but using CBC and Counter Mode manually.
I managed to do CBC mode fine, unfortunately I am stuck with the counter mode.
Using the given api of des(key, CBC, IV ...)
I can only use IV when I use CBC or ECB mode of operation. I can not use it something like des("hello", mode = None, "foo",....)
where "foo" is my IV.( I am supposed to implement Counter mode of operation and the iv is random in every single iteration)
So, my question is did anyone faced this issue, and tried to overcome it.