Documentation ¶
Overview ¶
Package cipher defines all ciphers used in Mute.
Index ¶
- Variables
- func AES256CBCDecrypt(key, ciphertext []byte) (plaintext []byte)
- func AES256CBCEncrypt(key, plaintext []byte, rand io.Reader) (ciphertext []byte)
- func AES256CTRDecrypt(key, ciphertext []byte) (plaintext []byte)
- func AES256CTREncrypt(key, plaintext []byte, rand io.Reader) (ciphertext []byte)
- func AES256CTRStream(key, iv []byte) cipher.Stream
- func CKDF(nonce []byte) (k1, k2 []byte)
- func ECDH(privateKey, peersPublicKey, ownPublicKey *[32]byte) (*[32]byte, error)
- func HMAC(key, buffer []byte) []byte
- func Nonce(rand io.Reader) []byte
- func RandPass(rand io.Reader) string
- func SHA1(buffer []byte) []byte
- func SHA256(buffer []byte) []byte
- func SHA512(buffer []byte) []byte
- type Curve25519Key
- type Ed25519Key
- func (ed25519Key *Ed25519Key) PrivateKey() *[64]byte
- func (ed25519Key *Ed25519Key) PublicKey() *[32]byte
- func (ed25519Key *Ed25519Key) SetPrivateKey(key []byte) error
- func (ed25519Key *Ed25519Key) SetPublicKey(key []byte) error
- func (ed25519Key *Ed25519Key) Sign(message []byte) []byte
- func (ed25519Key *Ed25519Key) Verify(message []byte, sig []byte) bool
- type NaClBoxKey
Constants ¶
This section is empty.
Variables ¶
var RandFail = eofReader{}
RandFail is a Reader that doesn't deliver any data
var RandReader = rand.Reader
RandReader defines the CSPRNG used in Mute.
var RandZero = zeroReader{}
RandZero is a Reader that always returns 0.
Functions ¶
func AES256CBCDecrypt ¶
AES256CBCDecrypt decrypts the given ciphertext with AES-256 in CBC mode and returns the resulting plaintext. The supplied key must be 32 bytes long and the ciphertext must be prepended by the corresponding IV.
func AES256CBCEncrypt ¶
AES256CBCEncrypt encrypts the given plaintext with AES-256 in CBC mode. The supplied key must be 32 bytes long. The returned ciphertext is prepended by a randomly generated IV.
func AES256CTRDecrypt ¶
AES256CTRDecrypt decrypts the given ciphertext with AES-256 in CTR mode and returns the resulting plaintext. The supplied key must be 32 bytes long and the ciphertext must be prepended by the corresponding IV.
func AES256CTREncrypt ¶
AES256CTREncrypt encrypts the given plaintext with AES-256 in CTR mode. The supplied key must be 32 bytes long. The returned ciphertext is prepended by a randomly generated IV.
func AES256CTRStream ¶
AES256CTRStream creates a new AES-256 stream in CTR mode. The supplied key must be 32 bytes long and the iv 16 bytes.
func CKDF ¶
CKDF (Cheap Key Derivation Function) generates two keys k1 and k2 from the given nonce. Specification: https://github.com/mutecomm/mute/blob/master/doc/ciphers.md#ckdf-cheap-key-derivation-function
func ECDH ¶
ECDH computes a Diffie-Hellman (DH) key exchange over the elliptic curve (EC) curve25519. If ownPublicKey is given it is used to check for the key reflection attack. Otherwise it is derived from privateKey.
Types ¶
type Curve25519Key ¶
type Curve25519Key struct {
// contains filtered or unexported fields
}
Curve25519Key holds a Curve25519 key pair.
func Curve25519Generate ¶
func Curve25519Generate(rand io.Reader) (*Curve25519Key, error)
Curve25519Generate generates a new Curve25519 key pair.
func (*Curve25519Key) PrivateKey ¶
func (c *Curve25519Key) PrivateKey() *[32]byte
PrivateKey returns the private key of an curve25519Key.
func (*Curve25519Key) PublicKey ¶
func (c *Curve25519Key) PublicKey() *[32]byte
PublicKey returns the public key of an curve25519Key.
func (*Curve25519Key) SetPrivateKey ¶
func (c *Curve25519Key) SetPrivateKey(key []byte) error
SetPrivateKey sets the private key of curve25519Key to key. SetPrivateKey returns an error, if len(key) != 32.
func (*Curve25519Key) SetPublicKey ¶
func (c *Curve25519Key) SetPublicKey(key []byte) error
SetPublicKey sets the public key of curve25519Key to key. SetPublicKey returns an error, if len(key) != 32.
type Ed25519Key ¶
type Ed25519Key struct {
// contains filtered or unexported fields
}
Ed25519Key holds a Ed25519 key pair.
func Ed25519Generate ¶
func Ed25519Generate(rand io.Reader) (*Ed25519Key, error)
Ed25519Generate generates a new Ed25519 key pair.
func (*Ed25519Key) PrivateKey ¶
func (ed25519Key *Ed25519Key) PrivateKey() *[64]byte
PrivateKey returns the private key of an ed25519Key.
func (*Ed25519Key) PublicKey ¶
func (ed25519Key *Ed25519Key) PublicKey() *[32]byte
PublicKey returns the public key of an ed25519Key.
func (*Ed25519Key) SetPrivateKey ¶
func (ed25519Key *Ed25519Key) SetPrivateKey(key []byte) error
SetPrivateKey sets the private key of ed25519Key to key. SetPrivateKey returns an error, if len(key) != ed25519.PrivateKeySize.
func (*Ed25519Key) SetPublicKey ¶
func (ed25519Key *Ed25519Key) SetPublicKey(key []byte) error
SetPublicKey sets the public key of ed25519Key to key. SetPublicKey returns an error, if len(key) != ed25519.PublicKeySize.
func (*Ed25519Key) Sign ¶
func (ed25519Key *Ed25519Key) Sign(message []byte) []byte
Sign signs the given message with ed25519Key and returns the signature.
type NaClBoxKey ¶
type NaClBoxKey struct {
// contains filtered or unexported fields
}
NaClBoxKey holds the public and private keys for a NaCl-box.
func NaClBoxGenerate ¶
func NaClBoxGenerate(rand io.Reader) (*NaClBoxKey, error)
NaClBoxGenerate generates a new NaClBox key pair.
func (*NaClBoxKey) PrivateKey ¶
func (naClBoxKey *NaClBoxKey) PrivateKey() []byte
PrivateKey returns the private key of a NaClBox.
func (*NaClBoxKey) PublicKey ¶
func (naClBoxKey *NaClBoxKey) PublicKey() []byte
PublicKey returns the public key of a NaClBox.
func (*NaClBoxKey) SetPrivateKey ¶
func (naClBoxKey *NaClBoxKey) SetPrivateKey(key []byte) error
SetPrivateKey sets the private key of naclbox to key. SetPrivateKey returns an error, if len(key) != 32.
func (*NaClBoxKey) SetPublicKey ¶
func (naClBoxKey *NaClBoxKey) SetPublicKey(key []byte) error
SetPublicKey sets the public key of naclbox to key. SetPublicKey returns an error, if len(key) != 32.