cipher

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNonceSize = 12
	ATypeIPv4    = 1
	ATypeDomain  = 3
	ATypeIpv6    = 4
)

Variables

View Source
var (
	CiphersConf = map[string]CipherConf{
		"chacha20-ietf-poly1305": {KeyLen: 32, SaltLen: 32, NonceLen: 12, TagLen: 16, NewCipher: chacha20poly1305.New, NewPartialCipher: NewPC20P1305},
		"chacha20-poly1305":      {KeyLen: 32, SaltLen: 32, NonceLen: 12, TagLen: 16, NewCipher: chacha20poly1305.New, NewPartialCipher: NewPC20P1305},
		"aes-256-gcm":            {KeyLen: 32, SaltLen: 32, NonceLen: 12, TagLen: 16, NewCipher: NewGcm, NewPartialCipher: NewPGcm},
		"aes-128-gcm":            {KeyLen: 16, SaltLen: 16, NonceLen: 12, TagLen: 16, NewCipher: NewGcm, NewPartialCipher: NewPGcm},
	}
	ZeroNonce  [MaxNonceSize]byte
	ReusedInfo = []byte("ss-subkey")
)

Functions

func EVPBytesToKey

func EVPBytesToKey(password string, keyLen int) (key []byte)

func MD5Sum

func MD5Sum(d []byte) []byte

func NewGcm

func NewGcm(key []byte) (cipher.AEAD, error)

func NewPC20P1305 added in v0.1.3

func NewPC20P1305(key []byte) (smaead.PartialAEAD, error)

func NewPGcm added in v0.1.3

func NewPGcm(key []byte) (smaead.PartialAEAD, error)

Types

type CipherConf

type CipherConf struct {
	KeyLen           int
	SaltLen          int
	NonceLen         int
	TagLen           int
	NewCipher        func(key []byte) (cipher.AEAD, error)
	NewPartialCipher func(key []byte) (smaead.PartialAEAD, error)
}

func (*CipherConf) UnsafeVerifyATyp added in v0.1.3

func (conf *CipherConf) UnsafeVerifyATyp(buf []byte, masterKey []byte, salt []byte, cipherText []byte, subKey *[]byte) bool

Warning: UnsafeVerifyATyp brings less than 25% performance improvement in most cases. It is dangerous and NOT recommended. Do not use it if you feel unnecessary.

func (*CipherConf) Verify

func (conf *CipherConf) Verify(buf []byte, masterKey []byte, salt []byte, cipherText []byte, subKey *[]byte) ([]byte, bool)

Jump to

Keyboard shortcuts

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