Skip to content

Pure Go implementation of shannon stream cipher

License

Notifications You must be signed in to change notification settings

chatoooo/shannon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shannon

Build Status Go Report Card

Pure Go implementation of Shannon stream cipher. No-brainer port of rust-shannon.

Shannon cipher is used in Spotify Connect to encrypt communication between player and Spotify AP server. Shannon cipher is variant of Sober stream cipher.

Example

Encryption

import "github.com/chatoooo/shannon"
...
key := []byte{0x65, 0x87, 0xd8, 0x8f, 0x6c, 0x32, 0x9d, 0x8a, 0xe4, 0x6b}
message := []byte("My secret message")
cipher := shannon.New(key)
cipher.Encrypt(message)
// message contains ciphertext now
mac := make([]byte, 16)
cipher.Final(mac)
// mac contains MAC of the message

Decryption

import "github.com/chatoooo/shannon"
...
key := []byte{0x65, 0x87, 0xd8, 0x8f, 0x6c, 0x32, 0x9d, 0x8a, 0xe4, 0x6b}
// message is encrypted
message := []byte{0x91, 0x9d, 0xa9, 0xb6, 0x29, 0xfc, 0x9c, 0xdd, 0x17, 0x8c, 0x15, 0x31, 0x9a, 0xae, 0xcc, 0x6e, 0xd4}
receivedMac := []byte{0xbe, 0x7b, 0xef, 0x39, 0xee, 0xfe, 0x54, 0xfd, 0x8d, 0xb0, 0xbc, 0x6f, 0xd5, 0x30, 0x35, 0x19}
cipher := shannon.New(key)
cipher.Decrypt(message)
// message contains plaintext now
mac := make([]byte, 16)
if cipher.CheckMac(receivedMac) == nil {
	fmt.Println("MAC OK")
}

About

Pure Go implementation of shannon stream cipher

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages