bozhu / aes-gcm-python Goto Github PK
View Code? Open in Web Editor NEWA Python implementation of the authenticated encryption mode Galois/Counter Mode (GCM).
A Python implementation of the authenticated encryption mode Galois/Counter Mode (GCM).
What would be necessary to add support for AES-256?
Am I correctly assuming, that it's mostly about creating an equivalent function for "gf_2_128_mul"?
I don't really understand the maths behind it well enough to touch it...
I noticed that changing the implementation of AES_GCM.__pre_table
to the code below fills the cache much faster than assigning all values in a nested loop directly.
For example I see user time of my script going from 0.430ms to 0.056ms. Using CPython 2.7.10 here.
class GCMulCacheProxy:
__fields__ = ('gcmc', 'i')
def __init__(self, gcmc, i):
self.gcmc = gcmc
self.i = i
def __getitem__(self, j): # i=0..15, j=0..255
val = self.gcmc.cache[self.i][j]
if val is None:
val = gf_2_128_mul(self.gcmc.auth_key, j << (8 * self.i))
self.gcmc.cache[self.i][j] = val
return val
class GCMulCache:
__fields__ = ('auth_key', 'cache')
def __init__(self, auth_key, time_invariant=True):
self.auth_key = auth_key
self.cache = [[None]*256]*16
if time_invariant:
for i in range(16):
for j in range(256):
self[i][j]
def __getitem__(self, i):
return GCMulCacheProxy(self, i)
and
class AES_GCM:
[...]
def change_key(self, master_key):
[...]
self.__pre_table = GCMulCache(self.__auth_key)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.