ciphers

package
v0.0.0-...-5f1f6bc Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

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

Variables

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

Functions

func NewGcm

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

Types

type CipherConf

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

func (*CipherConf) Verify

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

type DecOrEnc

type DecOrEnc int
const (
	Decrypt DecOrEnc = iota
	Encrypt
)

type NoneStream

type NoneStream struct {
	cipher.Stream
}

func (*NoneStream) XORKeyStream

func (*NoneStream) XORKeyStream(dst, src []byte)

type StreamCipher

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

func NewStreamCipher

func NewStreamCipher(method, password string) (c *StreamCipher, err error)

NewStreamCipher creates a cipher that can be used in Dial() etc. Use cipher.Clone() to create a new cipher with the same method and password to avoid the cost of repeated cipher initialization.

func (*StreamCipher) Clone

func (c *StreamCipher) Clone() *StreamCipher

Clone creates a new cipher at it's initial state.

func (*StreamCipher) Decrypt

func (c *StreamCipher) Decrypt(dst, src []byte)

func (*StreamCipher) DecryptInited

func (c *StreamCipher) DecryptInited() bool

func (*StreamCipher) Encrypt

func (c *StreamCipher) Encrypt(dst, src []byte)

func (*StreamCipher) EncryptInited

func (c *StreamCipher) EncryptInited() bool

func (*StreamCipher) IV

func (c *StreamCipher) IV() []byte

func (*StreamCipher) InfoIVLen

func (c *StreamCipher) InfoIVLen() int

func (*StreamCipher) InfoKeyLen

func (c *StreamCipher) InfoKeyLen() int

func (*StreamCipher) InitDecrypt

func (c *StreamCipher) InitDecrypt(iv []byte) (err error)

func (*StreamCipher) InitEncrypt

func (c *StreamCipher) InitEncrypt() (iv []byte, err error)

InitEncrypt initializes the block cipher with CFB mode, returns IV.

func (*StreamCipher) Key

func (c *StreamCipher) Key() []byte

func (*StreamCipher) NewDecryptor

func (c *StreamCipher) NewDecryptor(iv []byte) (dec cipher.Stream, err error)

func (*StreamCipher) NewEncryptor

func (c *StreamCipher) NewEncryptor(iv []byte) (enc cipher.Stream, err error)

func (*StreamCipher) SetIV

func (c *StreamCipher) SetIV(iv []byte)

func (*StreamCipher) SetKey

func (c *StreamCipher) SetKey(key []byte)

Jump to

Keyboard shortcuts

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