This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cowlicks
Recipients Ramchandra Apte, abarnert, christian.heimes, cowlicks, georg.brandl, gregory.p.smith, gvanrossum, josh.r, martin.panter, pitrou, rhettinger, serhiy.storchaka, socketpair, terry.reedy, vstinner
Date 2016-04-26.18:35:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461695704.5.0.395120188604.issue19251@psf.upfronthosting.co.za>
In-reply-to
Content
@gvanrossum in this previous comment https://bugs.python.org/issue19251?@ok_message=msg%20264184%20created%0Aissue%2019251%20message_count%2C%20messages%20edited%20ok&@template=item#msg257964

I pointed out code from the wild which would be more readable, and posted preliminary benchmarks. But there is a typo, I should have written:

def __mix_single_column(self, a):
    t = len(a) * bytes([reduce(xor, a)])
    a ^= t ^ xtime(a ^ (a[1:] + a[0:1]))


As @gregory.p.smith points out, my claim about security isn't very clear. This would be "more secure" for two reasons. Code would be easier to read and therefore verify, but this is the same as readability. The other reason, doing some binary bitwise op on two bytes objects enforces that the objects be the same length, so unexpected bugs in these code samples would be avoided.

bytes(x ^ y for x, y in zip(a, b))

(int.from_bytes(a, 'big') ^ int.from_bytes(b, 'big')).to_bytes(len(a), 'big')

# XOR each byte of the roundKey with the state table
def addRoundKey(state, roundKey):
    for i in range(len(state)):
        state[i] = state[i] ^ roundKey[i]
History
Date User Action Args
2016-04-26 18:35:04cowlickssetrecipients: + cowlicks, gvanrossum, georg.brandl, rhettinger, terry.reedy, gregory.p.smith, pitrou, vstinner, christian.heimes, socketpair, Ramchandra Apte, martin.panter, serhiy.storchaka, abarnert, josh.r
2016-04-26 18:35:04cowlickssetmessageid: <1461695704.5.0.395120188604.issue19251@psf.upfronthosting.co.za>
2016-04-26 18:35:04cowlickslinkissue19251 messages
2016-04-26 18:35:04cowlickscreate