Git Product home page Git Product logo

sbox's Introduction

Overview

A substitution box or S-box is one of the basic components of symmetric key cryptography. In general, an S-box takes n input bits and transforms them into m output bits. This is called an n x m S-box and is often implemented as a lookup table.

Another representation is by vectorial Boolean function, which is defined by a Polynomial Ring in x over Finite Field in a of size 2n with primitive element g.

Note that by default bits are interpreted in little endian notation, e.g.

610 = 1102

1010 = 10102 = A16

Authors

  • Oleksandr Kazymyrov
  • Maksim Storetvedt
  • Anna Maria Eilertsen

How to use

  1. In Sage. Go to the ''Sage'' directory and type load("./Sbox.sage").
  2. Use externaly (see examples in ''Main.sage'' ).

Examples

  • Create an example of a 3 x 3 substitution

      sage: S = Sbox(n=3,m=3,sbox=[1,2,3,0,7,6,5,4])
      sage: S.get_sbox()
      [1, 2, 3, 0, 7, 6, 5, 4]
      
      sage: F=S.interpolation_polynomial()
      sage: F
      'g^2*x^6 + g^3*x^5 + g^4*x^4 + g^5*x^3 + g^6*x^2 + 1'
      
      sage: S.generate_sbox(method='polynomial',G=F)
      sage: S.get_sbox() == [1, 2, 3, 0, 7, 6, 5, 4]
      True
    
  • Generate APN permutation for n = 6 [1]

      sage: S=Sbox(n=6,m=6)
      sage: S.generate_sbox(method='APN6')
      sage: S.is_APN()
      True
      sage: S.MDT()
      2
      sage: S.is_bijection()
      True
    
  • Apply CCZ and EA equivalence

      sage: S=Sbox(n=3,m=3)
      sage: S.generate_sbox(method='polynomial',G='x^3')
      sage: S
      [0, 1, 3, 4, 5, 6, 7, 2]
      
      sage: S.generate_sbox(method='polynomial',G='x^3',T='CCZ')
      sage: S # random
      [0, 6, 2, 3, 6, 3, 6, 4]
      sage: S.is_APN()
      True
      
      sage: S.generate_sbox(method='polynomial',G='x^3',T='EA')
      sage: S # random
      [7, 0, 7, 5, 0, 6, 6, 5]
    
      sage: S.is_APN()
      True
    

References

  1. J. F. Dillon, APN Polynomials: An Update. Fq9, International Conference on Finite Fields and their Applications, University College Dublin. July 2009.
  2. Sage

sbox's People

Contributors

okazymyrov avatar

Watchers

James Cloos avatar  avatar

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.