nacl

package
v0.0.0-...-084f901 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2017 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultMTU = 512

write boxes at 512 bytes at a time

Variables

View Source
var BadHandshake = errors.New("Bad handshake")
View Source
var Closed = errors.New("socket closed")
View Source
var ShortRead = errors.New("short read")
View Source
var ShortWrite = errors.New("short write")

Functions

func CryptoBox

func CryptoBox(msg, nounce, pk, sk []byte) ([]byte, error)

encrypts a message to a user given their public key is known returns an encrypted box

func CryptoBoxOpen

func CryptoBoxOpen(box, nounce, sk, pk []byte) ([]byte, error)

open an encrypted box

func CryptoBoxOverhead

func CryptoBoxOverhead() int

return how many bytes overhead does CryptoBox have

func CryptoBoxPrivKeySize

func CryptoBoxPrivKeySize() int

size of crypto_box private keys

func CryptoBoxPubKeySize

func CryptoBoxPubKeySize() int

size of crypto_box public keys

func CryptoSignDetached

func CryptoSignDetached(msg, sk []byte) []byte

sign data detached with secret key sk

func CryptoSignFucky

func CryptoSignFucky(msg, sk []byte) []byte

sign data with secret key sk return detached sig this uses crypto_sign instead pf crypto_sign_detached

func CryptoSignPrivKeySize

func CryptoSignPrivKeySize() int

size of crypto_sign private keys

func CryptoSignPubKeySize

func CryptoSignPubKeySize() int

size of crypto_sign public keys

func CryptoSignPublicLen

func CryptoSignPublicLen() int

func CryptoSignSecretLen

func CryptoSignSecretLen() int

func CryptoSignSeedLen

func CryptoSignSeedLen() int

func CryptoVerify

func CryptoVerify(smsg, pk []byte) bool

verify a signed message

func CryptoVerifyDetached

func CryptoVerifyDetached(msg, sig, pk []byte) bool

verfiy a detached signature return true on valid otherwise false

func CryptoVerifyFucky

func CryptoVerifyFucky(msg, sig, pk []byte) bool

verify a fucky detached sig

func GetBoxPubkey

func GetBoxPubkey(sk []byte) []byte

get public key from secret key

func GetSignPubkey

func GetSignPubkey(sk []byte) ([]byte, error)

get public key from secret key

func NewBoxNounce

func NewBoxNounce() []byte

generate a new nounce

func NounceLen

func NounceLen() int

length of a nounce

func RandBytes

func RandBytes(size int) []byte

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

wrapper arround malloc/free

func Malloc

func Malloc(size int) *Buffer

wrapper arround nacl.malloc

func NewBuffer

func NewBuffer(buff []byte) *Buffer

create a new buffer copying from a byteslice

func (*Buffer) Bytes

func (self *Buffer) Bytes() []byte

get immutable byte slice

func (*Buffer) Data

func (self *Buffer) Data() []byte

get underlying byte slice

func (*Buffer) Free

func (self *Buffer) Free()

zero out memory and then free

func (*Buffer) Length

func (self *Buffer) Length() int

func (*Buffer) String

func (self *Buffer) String() string

type CryptoConn

type CryptoConn struct {
	// contains filtered or unexported fields
}

func (*CryptoConn) Close

func (cc *CryptoConn) Close() (err error)

func (*CryptoConn) LocalAddr

func (cc *CryptoConn) LocalAddr() net.Addr

func (*CryptoConn) Read

func (cc *CryptoConn) Read(d []byte) (n int, err error)

func (*CryptoConn) RemoteAddr

func (cc *CryptoConn) RemoteAddr() net.Addr

func (*CryptoConn) SetDeadline

func (cc *CryptoConn) SetDeadline(t time.Time) (err error)

func (*CryptoConn) SetReadDeadline

func (cc *CryptoConn) SetReadDeadline(t time.Time) (err error)

func (*CryptoConn) SetWriteDeadline

func (cc *CryptoConn) SetWriteDeadline(t time.Time) (err error)

func (*CryptoConn) Write

func (cc *CryptoConn) Write(d []byte) (n int, err error)

type CryptoListener

type CryptoListener struct {
	// contains filtered or unexported fields
}

func Server

func Server(l net.Listener, local_sk []byte, trust func(pk []byte) bool) (s *CryptoListener)

create a listener

func (*CryptoListener) Accept

func (cl *CryptoListener) Accept() (c net.Conn, err error)

accept inbound authenticated and trusted connections

func (*CryptoListener) Close

func (cl *CryptoListener) Close() (err error)

type CryptoStream

type CryptoStream struct {
	// contains filtered or unexported fields
}

wrapper arround crypto_box provides an authenticated encrypted stream this is a TOY

func Client

func Client(stream io.ReadWriteCloser, local_sk, remote_pk []byte) (c *CryptoStream)

create a client

func (*CryptoStream) Close

func (cs *CryptoStream) Close() (err error)

func (*CryptoStream) Handshake

func (cs *CryptoStream) Handshake() (err error)

initiate protocol handshake

func (*CryptoStream) Read

func (cs *CryptoStream) Read(data []byte) (n int, err error)

implements io.Reader

func (*CryptoStream) Write

func (cs *CryptoStream) Write(data []byte) (n int, err error)

implements io.Writer

type KeyPair

type KeyPair struct {
	// contains filtered or unexported fields
}

func GenBoxKeypair

func GenBoxKeypair() *KeyPair

func GenSignKeypair

func GenSignKeypair() *KeyPair

generate a keypair

func LoadBoxKey

func LoadBoxKey(sk []byte) *KeyPair

load keypair from secret key

func LoadSignKey

func LoadSignKey(seed []byte) *KeyPair

make keypair from seed

func SeedBoxKey

func SeedBoxKey(seed []byte) *KeyPair

make keypair from seed

func (*KeyPair) Free

func (self *KeyPair) Free()

free this keypair from memory

func (*KeyPair) Public

func (self *KeyPair) Public() []byte

func (*KeyPair) Secret

func (self *KeyPair) Secret() []byte

func (*KeyPair) Seed

func (self *KeyPair) Seed() []byte

func (*KeyPair) String

func (self *KeyPair) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL