Documentation
¶
Overview ¶
Package cipher defines all ciphers used in Mute.
Index ¶
- Variables
- 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 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.