uploaded version 2018_11_15 for python3

This commit is contained in:
Matteo ℱan 2018-11-14 23:13:51 +01:00 committed by GitHub
parent 7130486efc
commit e98858c9d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1204 additions and 853 deletions

View file

@ -3,7 +3,8 @@
# aes.py: implements AES - Advanced Encryption Standard
# from the SlowAES project, http://code.google.com/p/slowaes/
#
# Copyright (c) 2008 Josh Davis ( http://www.josh-davis.org ), Alex Martelli ( http://www.aleax.it )
# Copyright (c) 2008 Josh Davis ( http://www.josh-davis.org )
# Alex Martelli ( http://www.aleax.it )
#
# Ported from C code written by Laurent Haan ( http://www.progressive-coding.com )
@ -12,8 +13,8 @@
#
"""
Modified for py-kms;
Ported to Python3 with minimal changements.
© Copyright 2018 Matteo an <SystemRage@protonmail.com>
"""
import os
@ -160,7 +161,7 @@ class AES( object ):
def expandKey(self, key, size, expandedKeySize):
""" Method performing Rijndael's key expansion.
Expands an 128, 192, 256 key into an 176, 208, 240 bit key.
Expands an 128, 192, 256 key into an 176, 208, 240 bytes key.
"""
# Current expanded keySize, in bytes.
currentSize = 0
@ -238,14 +239,12 @@ class AES( object ):
state[i] = getter(state[i])
return state
def shiftRows(self, state, isInv):
""" Method to iterate over the 4 rows and call shiftRow(...) with that row. """
for i in range(4):
state = self.shiftRow(state, i * 4, i, isInv)
return state
def shiftRow(self, state, statePointer, nbr, isInv):
""" Method to shift the row to the left. """
for i in range(nbr):
@ -426,7 +425,7 @@ class AES( object ):
nbrRounds = 12
elif size == self.KeySize["SIZE_256"]:
nbrRounds = 14
#*py-kms* The KMS v4 parameters.
#*py-kms* The KMS v4 parameters.
elif size == 20:
nbrRounds = 11
else: