1 from blockcipher
import *
3 import Crypto
.Cipher
.IDEA
5 print "Crypto.Cipher.IDEA isn't available. You're probably using the Debian pycrypto version. Install the original pycrypto for IDEA."
8 def new(key
,mode
=MODE_ECB
,IV
=None,counter
=None):
9 """Create a new cipher object
11 IDEA using pycrypto for algo and pycryptoplus for ciphermode
13 new(key,mode=MODE_ECB,IV=None,counter=None):
14 key = raw string containing the keys
15 mode = python_AES.MODE_ECB/CBC/CFB/OFB/CTR/CMAC, default is ECB
16 IV = IV as a raw string
17 -> only needed for CBC mode
18 counter = counter object (CryptoPlus.Util.util.Counter)
19 -> only needed for CTR mode
21 https://www.cosic.esat.kuleuven.be/nessie/testvectors/
22 -----------------------------------------
23 >>> from CryptoPlus.Cipher import IDEA
24 >>> key = "2BD6459F82C5B300952C49104881FF48".decode('hex')
25 >>> plaintext = "F129A6601EF62A47".decode('hex')
26 >>> cipher = IDEA.new(key,IDEA.MODE_ECB,)
27 >>> cipher.encrypt(plaintext).encode('hex').upper()
30 return IDEA(key
,mode
,IV
,counter
)
32 class IDEA(BlockCipher
):
33 def __init__(self
,key
,mode
,IV
,counter
):
34 self
.cipher
= Crypto
.Cipher
.IDEA
.new(key
)
35 self
.blocksize
= Crypto
.Cipher
.IDEA
.block_size
36 BlockCipher
.__init
__(self
,key
,mode
,IV
,counter
)
42 if __name__
== "__main__":