aria

package module
v0.0.0-...-3b9e68d Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: MIT Imports: 4 Imported by: 0

README

aria-go

Build Status Codecov Status Godoc Reference Goreportcard Badge

Go implementation of the ARIA encryption algorithm.

Installation

go get -u github.com/hallazzang/aria-go

Usage

This package is compatible with the standard crypto package.

package main

import (
	"fmt"

	"github.com/hallazzang/aria-go"
)

func main() {
	key := []byte("0123456789abcdef")
	plaintext := []byte("fedcba9876543210")

	block, err := aria.NewCipher(key)
	if err != nil {
		panic(err)
	}

	fmt.Printf("plaintext: %s\n", plaintext)

	ciphertext := make([]byte, 16)
	block.Encrypt(ciphertext, plaintext)
	fmt.Printf("ciphertext: % x\n", ciphertext)

	decrypted := make([]byte, 16)
	block.Decrypt(decrypted, ciphertext)
	fmt.Printf("decrypted: %s\n", decrypted)
}

This will print out:

plaintext: fedcba9876543210
ciphertext: 93 52 1e f2 67 65 0b d1 fc 75 20 5a d3 44 4d 9d
decrypted: fedcba9876543210

Benchmarks

Here's the benchmark result compared with aes package:

goos: windows
goarch: amd64
BenchmarkAES128  	100000000	        17.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkAES192  	100000000	        21.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkAES256  	100000000	        23.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkARIA128 	 1000000	      1225 ns/op	       0 B/op	       0 allocs/op
BenchmarkARIA192 	 1000000	      1468 ns/op	       0 B/op	       0 allocs/op
BenchmarkARIA256 	 1000000	      1610 ns/op	       0 B/op	       0 allocs/op

License

MIT

Documentation

Index

Constants

View Source
const BlockSize = 16

BlockSize is the ARIA 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 ARIA key, either 16, 24, or 32 bytes to select ARIA-128, ARIA-192, or AES-256.

Types

type KeySizeError

type KeySizeError int

KeySizeError is returned when key size in bytes isn't one of 16, 24, or 32.

func (KeySizeError) Error

func (k KeySizeError) Error() string

Jump to

Keyboard shortcuts

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