bsaes

package module
v0.0.0-...-0a714cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2019 License: MIT Imports: 6 Imported by: 26

README

bsaes - BitSliced AES

Yawning Angel (yawning at schwanenlied dot me)

The AES operations in this package are not implemented using constant-time algorithms. An exception is when running on systems with enabled hardware support for AES that makes these operations constant-time.

-- https://golang.org/pkg/crypto/aes/

bsaes is a portable pure-Go constant time AES implementation based on the excellent code from BearSSL. On appropriate systems, with a sufficiently recent Go runtime, it will transparently call crypto/aes when NewCipher is invoked.

Features:

  • Constant time.

  • 32 bit and 64 bit variants, with the appropriate one selected at runtime.

  • Provides crypto/cipher.Block.

  • crypto/cipher.ctrAble support for less-slow CTR-AES mode.

  • crypto/cipher.cbcDecAble support for less-slow CBC-AES decryption.

  • crypto/cipher.gcmAble support for less-slow GCM-AES. This includes a constant time GHASH.

  • The raw guts of the implementations provided as sub-packages, for people to use to implement other things.

Benchmarks:

Primitive Version ns/op MB/s
ECB-AES128 ct32 914 17.50
ECB-AES256 ct32 1268 12.62
CTR-AES128 (16 KiB) ct32 472010 34.17
CBC-AES128 Decrypt (16 KiB) ct32 583238 28.09
GCM-AES128 (16 KiB) ct32 605676 27.05
ECB-AES128 ct64 932 17.16
ECB-AES256 ct64 1258 12.72
CTR-AES128 (16 KiB) ct64 296016 55.35
CBC-AES128 Decrypt (16 KiB) ct64 350047 46.81
GCM-AES128 (16 KiB) ct64 435660 37.61

All numbers taken on an Intel i7-5600U with Turbo Boost disabled, running on linux/amd64.

Documentation

Overview

Package bsaes is a pure-Go bitsliced constant time AES implementation.

Index

Constants

View Source
const BlockSize = aes.BlockSize

BlockSize is the AES block size in bytes.

Variables

This section is empty.

Functions

func NewCipher

func NewCipher(key []byte) (cipher.Block, error)

NewCipher creates and returns a new cipher.Block. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func UsingRuntime

func UsingRuntime() bool

UsingRuntime returns true iff this package is falling through to the runtime's implementation due to hardware support for constant time operation on the current system.

Types

This section is empty.

Directories

Path Synopsis
Package ct32 is a 32 bit optimized AES implementation that processes 2 blocks at a time.
Package ct32 is a 32 bit optimized AES implementation that processes 2 blocks at a time.
Package ct64 is a 64 bit optimized AES implementation that processes 4 blocks at a time.
Package ct64 is a 64 bit optimized AES implementation that processes 4 blocks at a time.
Package ghash is a constant time 64 bit optimized GHASH implementation.
Package ghash is a constant time 64 bit optimized GHASH implementation.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL