security

package
v0.0.0-...-ee25e63 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Secp256k1 = "secp256k1"
	Ed25519   = "ed25519"
)
View Source
const (
	PublicKeySize  = ed25519.PublicKeySize
	PrivateKeySize = ed25519.PrivateKeySize
	SignatureSize  = ed25519.SignatureSize
)

Variables

This section is empty.

Functions

func AppendToSignedHash

func AppendToSignedHash(s SignedHash, i Identity) error

func DecryptBlock

func DecryptBlock(key []byte, nonce []byte, cipherdata []byte) ([]byte, error)

func EcDecrypt

func EcDecrypt(identity Identity, data []byte) ([]byte, error)

func EcEncrypt

func EcEncrypt(identity Identity, data []byte) ([]byte, error)

func EncryptBlock

func EncryptBlock(key []byte, nonce []byte, data []byte) ([]byte, error)

func GenerateBytesKey

func GenerateBytesKey(size int) []byte

func NewHash

func NewHash() hash.Hash

func SameIdentity

func SameIdentity(a, b Identity) bool

func SetIdentity

func SetIdentity(i Identity) error

func Sign

func Sign(identity Identity, data []byte) ([]byte, error)

func Trust

func Trust(i Identity, trusted bool) error

func Verify

func Verify(id string, data []byte, sig []byte) bool

func VerifySignedHash

func VerifySignedHash(s SignedHash, trusts []Identity, hash []byte) bool

Types

type HashStream

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

func NewHashStream

func NewHashStream(r io.Reader, w io.Writer) (*HashStream, error)

func (*HashStream) Hash

func (s *HashStream) Hash() []byte

func (*HashStream) Read

func (s *HashStream) Read(p []byte) (n int, err error)

func (*HashStream) Size

func (s *HashStream) Size() int64

func (*HashStream) Write

func (s *HashStream) Write(p []byte) (n int, err error)

type Identity

type Identity struct {
	Nick          string `json:"n"`
	Email         string `json:"m"`
	SignatureKey  Key    `json:"s"`
	EncryptionKey Key    `json:"e"`
}

func IdentityFromBase64

func IdentityFromBase64(b64 string) (Identity, error)

func NewIdentity

func NewIdentity(nick string) (Identity, error)

func (Identity) Base64

func (i Identity) Base64() (string, error)

func (Identity) Id

func (i Identity) Id() string

func (Identity) Public

func (i Identity) Public() Identity

type Key

type Key struct {
	Public  []byte `json:"pu"`
	Private []byte `json:"pr,omitempty"`
}

type PrivateKey

type PrivateKey ed25519.PrivateKey

type Public

type Public struct {
	Id    PublicKey
	Nick  string
	Email string
}

type PublicKey

type PublicKey ed25519.PublicKey

type SignedData

type SignedData struct {
	Signature [SignatureSize]byte
	Signer    PublicKey
}

type SignedHash

type SignedHash struct {
	Hash      []byte               `json:"h"`
	Evidences []SignedHashEvidence `json:"e"`
}

func NewSignedHash

func NewSignedHash(hash []byte, i Identity) (SignedHash, error)

type SignedHashEvidence

type SignedHashEvidence struct {
	Key       []byte `json:"k"`
	Signature []byte `json:"s"`
}

type StreamReader

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

func EncryptingReader

func EncryptingReader(keyId uint64, keyFunc func(uint64) []byte, r io.Reader) (*StreamReader, error)

EncryptedWriter wraps w with an OFB cipher stream.

func (*StreamReader) Read

func (sr *StreamReader) Read(p []byte) (n int, err error)

type StreamWriter

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

func DecryptingWriter

func DecryptingWriter(keyFunc func(uint64) []byte, w io.Writer) (*StreamWriter, error)

EncryptedWriter wraps w with an OFB cipher stream.

func (*StreamWriter) Write

func (sr *StreamWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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