Giter Site home page Giter Site logo

aes-gcm-python's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aes-gcm-python's Issues

Add AES-256 support

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...

Faster AES_GCM.__pre_table

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)

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.