Giter Club home page Giter Club logo

present.go's Introduction

PRESENT.go

GoDoc Build Status codecov Go Report Card

Go implementation of the PRESENT ultra-lightweight block cipher as defined by Bogdanov et al. [1].

Not to be confused with the Go presentation tool package and command.

Usage

This package implements the cipher.Block interface from crypto/cipher, so it can be used with the block cipher modes implemented there, just like the crypto/aes package.

Example

One of the test vectors from the PRESENT paper:

package main

import (
	"encoding/hex"
	"fmt"
	"log"

	"github.com/yi-jiayu/PRESENT.go"
)

func encodeHex(data []byte) string {
	dst := make([]byte, hex.EncodedLen(len(data)))
	hex.Encode(dst, data)
	return string(dst)
}

func main() {
	key := make([]byte, 10)
	fmt.Printf("%-10s : %s\n", "Key", encodeHex(key))
	cipher, err := present.NewCipher(key)
	if err != nil {
		log.Fatal(err)
	}
	plaintext := make([]byte, 8)
	fmt.Printf("%-10s : %s\n", "Plaintext", encodeHex(plaintext))
	ciphertext := make([]byte, 8)
	cipher.Encrypt(ciphertext, plaintext)
	fmt.Printf("%-10s : %s\n", "Ciphertext", encodeHex(ciphertext))
}

Output:

Key        : 00000000000000000000
Plaintext  : 0000000000000000
Ciphertext : 5579c1387b228445

References

  1. Bogdanov A. et al. (2007) PRESENT: An Ultra-Lightweight Block Cipher. In: Paillier P., Verbauwhede I. (eds) Cryptographic Hardware and Embedded Systems - CHES 2007. CHES 2007. Lecture Notes in Computer Science, vol 4727. Springer, Berlin, Heidelberg (pdf)

present.go's People

Contributors

yi-jiayu avatar

Stargazers

 avatar

Watchers

 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.