项目作者: yi-jiayu

项目描述 :
Golang implementation of the PRESENT ultra-lightweight block cipher
高级语言: Go
项目地址: git://github.com/yi-jiayu/PRESENT.go.git
创建时间: 2018-08-29T12:00:46Z
项目社区:https://github.com/yi-jiayu/PRESENT.go

开源协议:MIT License

下载


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:

  1. package main
  2. import (
  3. "encoding/hex"
  4. "fmt"
  5. "log"
  6. "github.com/yi-jiayu/PRESENT.go"
  7. )
  8. func encodeHex(data []byte) string {
  9. dst := make([]byte, hex.EncodedLen(len(data)))
  10. hex.Encode(dst, data)
  11. return string(dst)
  12. }
  13. func main() {
  14. key := make([]byte, 10)
  15. fmt.Printf("%-10s : %s\n", "Key", encodeHex(key))
  16. cipher, err := present.NewCipher(key)
  17. if err != nil {
  18. log.Fatal(err)
  19. }
  20. plaintext := make([]byte, 8)
  21. fmt.Printf("%-10s : %s\n", "Plaintext", encodeHex(plaintext))
  22. ciphertext := make([]byte, 8)
  23. cipher.Encrypt(ciphertext, plaintext)
  24. fmt.Printf("%-10s : %s\n", "Ciphertext", encodeHex(ciphertext))
  25. }

Output:

  1. Key : 00000000000000000000
  2. Plaintext : 0000000000000000
  3. 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)