Coder Social home page Coder Social logo

maxt86 / cryptomoo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

A simple Python library implementing cryptographic modes of operation

License: BSD 2-Clause "Simplified" License

Python 100.00%
crypto cryptography cryptography-api cryptography-library

cryptomoo's Introduction

CryptoMOO

CryptoMOO is a simple Python library which implements cryptographic modes of operation.

API

The API is very simple and contains all the methods needed as follows:

  • get_key() -> bytes - get a key in a safe manner
  • set_key(key: bytes) -> None - set a key for encryption/decryption
  • get_iv() -> bytes - get an IV in a safe manner
  • get_ctr() -> bytes - get a counter in a safe manner
  • inc_ctr(ctr: bytes) -> bytes - returns the given counter incremented
  • set_mode(mode: Mode) -> None - mode of operation setup
  • block_cipher_encrypt(data: bytes) -> bytes - encrypt a block
  • block_cipher_decrypt(data: bytes) -> bytes - decrypt a block
  • pad(data: bytes, pkcs7: bool) -> bytes - pad a block (including an empty block)
  • unpad(data: bytes, pkcs7: bool) -> bytes - unpad a block (including an empty block)
  • proccess_block_encrypt(data: bytes, is_final_block: bool, padding: str) -> bytes - add one block for encryption
    • This method is responsible for the main logic, mode branching happens here.
  • process_block_decrypt(data: bytes, is_final_block: bool, padding: str) -> bytes - the same method, but for decryption
  • encrypt(data: bytes, iv: bytes = None) -> bytes - encrypt data of arbitrary length
  • decrypt(data: bytes, iv: bytes) -> bytes - decrypt data of arbitrary length

The methods that are most likely to be looked for in the first place are set_key, set_mode, encrypt and decrypt.

Sample decryption

The tests prove correctness of the primitives from the theoretical point of view.

To demonstrate how things work from the practical perspective, however, there is a separate program which decrypts the sample strings using the modes and the keys, all given in samples.txt

You can see the decrypted strings by running sample_dec.py or by looking directly at the results in samples_dec.txt

cryptomoo's People

Contributors

maxt86 avatar

Watchers

 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.