Giter VIP home page Giter VIP logo

xtea's Issues

Bug in the decrypt() of version 0.7.1 but not in 0.4.1

Hi,

The follow is my test code when using Xtea 0.7.1 with python3:

import xtea, struct

from binascii import hexlify


msg = b"This is a text. "
key = b' '*16
ivv = b"12345678"
tea = xtea.new(key, mode=xtea.MODE_OFB, IV=ivv)


enc = tea.encrypt(msg)
clr = tea.decrypt(enc)

print (msg == clr)
print (f' IV: {hexlify(ivv).decode()} LEN:{len(ivv)}')
print (f' KEY: {hexlify(key).decode()} LEN:{len(key)}')
print (f' MSG: {hexlify(msg).decode()} LEN:{len(msg)}')
print (f' ENC: {hexlify(enc).decode()} LEN:{len(enc)}')
print (f' CLR: {hexlify(clr).decode()} LEN:{len(clr)}')

Output when I ran it against version 0.7.1

 IV: 3132333435363738 LEN:8
 KEY: 20202020202020202020202020202020 LEN:16
 MSG: 54686973206973206120746578742e20 LEN:16
 ENC: fa66ec11b82e38bc77c14be093bb8aa0 LEN:16
 CLR: 79f08adb7eab4acbb4cc1aca058c0a29 LEN:16

Test code when ran with 0.4.1 and Python2.7

import xtea, struct

from binascii import hexlify


msg = b"This is a text. "
key = b' '*16
ivv = b"12345678"
tea = xtea.new(key, mode=xtea.MODE_OFB, IV=ivv)


enc = tea.encrypt(msg)
clr = tea.decrypt(enc)


print msg == clr
print "IV: {} LEN:{}".format(hexlify(ivv).decode(),len(ivv))
print "KEY: {} LEN:{}".format(hexlify(key).decode(),len(key))
print "MSG: {} LEN:{}".format(hexlify(msg).decode(),len(msg))
print "ENC: {} LEN:{}".format(hexlify(enc).decode(),len(enc))
print "CLR: {} LEN:{}".format(hexlify(clr).decode(),len(clr))

Output:

IV: 3132333435363738 LEN:8
KEY: 20202020202020202020202020202020 LEN:16
MSG: 54686973206973206120746578742e20 LEN:16
ENC: fa66ec11b82e38bc77c14be093bb8aa0 LEN:16
CLR: 54686973206973206120746578742e20 LEN:16

CBCMAC implementation

CBCMAC implementation is insecure because of following, fix will come soon. Try to not use it before next patch.

MAC(Message1)+MAC(Message2) = MAC(Message1+Message2)

Why is rounds divided by 2?

All other implementations that I've seen define the default # of rounds to be 64, and they do 64 iterations in the encrypt. This implementation defines a round as 2 cycles, so 64 rounds = 32 iterations. This makes it not act the same as most of the other implementations of XTEA unless you set rounds=128.

CCM-Mode

Add CCM-Mode to the modes, beeing compitable for PyCrypto

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.