Documentation
¶
Overview ¶
Example ¶
package main
import (
"log"
"github.com/ny0m/aes"
)
func main() {
// Generate a key from a collection of bytes.
// For AES, key are either 16, 24, or 32 bytes long.
// Hopefully it's easy to remember.
key := aes.NewKey([]byte("ABSENTMINDEDNESS"))
// Create a cipher with the key.
// This can be used to encrypt messages.
c := aes.NewCipher(key)
// Create a 128-bit block from a message that we'd like to send.
block := aes.NewBlock([]byte("a secret message"))
// Finally, use the cipher to encrypt the block.
out := c.Encrypt(block)
// Et voila!
log.Println(out)
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DotProduct ¶
Types ¶
type Block ¶
type Block [16]byte
Block is just a byte array. AES is a 128-bit symmetric block cipher, which means that it takes 128 bits as input, and returns 128 bits output, irrespective of key size.
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
Cipher consists of a parsed key and its derived schedule. Depending on key size, will perform a different number of rounds during encryption and decryption.
type Key ¶
type Key []Word
Key is a group of 32-bit words that is used to generate a key schedule, which is in turn used to encrypt the state during successive rounds.
type Word ¶
type Word = uint32
Word is an array of 4 bytes represented as a single uint32.
func Rcon ¶
Rcon returns the round constant, which is a 4-bit polynomial represented as a power of two raised by the round number, mod poly.
The result is shifted three bytes to the left, since these constants are always of the form x³.
func RotateWord ¶
RotateWord moves the most significant 8 bits of a word to the least significant.
func SubstituteWord ¶
SubstituteWord applies the substitution algorithm from FIPS-197 Section 5.2.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
aes
command
|
|
|
Package matrix contains data structures to make reasoning through the AES paper a bit simpler on a high level, at the cost of some efficiency.
|
Package matrix contains data structures to make reasoning through the AES paper a bit simpler on a high level, at the cost of some efficiency. |