method

package
v0.2.42 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: LGPL-2.1 Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GzipCompressionLevel    = gzip.DefaultCompression   // gzip压缩级别
	DeflateCompressionLevel = flate.DefaultCompression  // deflate压缩级别
	BrotliCompressionLevel  = brotli.DefaultCompression // brotli压缩级别
	LZ4CompressionLevel     = lz4.Level4                // lz4压缩级别
)
View Source
var (
	ErrInvalidMethod = errors.New("gtp: invalid method")
)

Functions

func NewBlock

func NewBlock(se gtp.SymmetricEncryption, key []byte) (block cipher.Block, err error)

NewBlock 创建分组

func NewHash

func NewHash(h gtp.Hash) (hash.Hash, error)

NewHash 创建Hash

func NewHash32

func NewHash32(h gtp.Hash) (hash.Hash32, error)

NewHash32 创建Hash32

func NewHash64

func NewHash64(h gtp.Hash) (hash.Hash64, error)

NewHash64 创建Hash64

func NewNamedCurve

func NewNamedCurve(nc gtp.NamedCurve) (ecdh.Curve, error)

NewNamedCurve 创建曲线

Types

type Cipher

type Cipher interface {
	// Transforming 变换数据
	Transforming(dst, src, nonce []byte) (int, error)
	// BlockSize block大小
	BlockSize() int
	// NonceSize nonce大小
	NonceSize() int
	// Overhead overhead大小
	Overhead() int
	// Pad 是否需要填充
	Pad() bool
	// Unpad 是否需要解除填充
	Unpad() bool
	// InputSize 输入大小
	InputSize(size int) int
	// OutputSize 输出大小
	OutputSize(size int) int
}

Cipher 对称密码算法

func NewBlockCipherMode

func NewBlockCipherMode(bcm gtp.BlockCipherMode, block cipher.Block, iv []byte) (encryptor, decrypter Cipher, err error)

NewBlockCipherMode 创建分组密码模式

func NewCipher

func NewCipher(se gtp.SymmetricEncryption, bcm gtp.BlockCipherMode, key, iv []byte) (encryptor, decrypter Cipher, err error)

NewCipher 创建对称密码算法

type CompressionStream

type CompressionStream interface {
	// WrapReader 包装解压缩流
	WrapReader(r io.Reader) (io.Reader, error)
	// WrapWriter 包装压缩流
	WrapWriter(w io.Writer) (io.WriteCloser, error)
}

CompressionStream 压缩/解压缩流

func NewCompressionStream

func NewCompressionStream(c gtp.Compression) (CompressionStream, error)

NewCompressionStream 创建压缩/解压缩流

type Padding

type Padding interface {
	// Pad 填充
	Pad(buf []byte, ori int) error
	// Unpad 解除填充
	Unpad(padded []byte) ([]byte, error)
}

Padding 填充方案

func NewPadding

func NewPadding(pm gtp.PaddingMode) (Padding, error)

NewPadding 创建填充方案

type Signer

type Signer interface {
	// GenerateKey 生成私钥
	GenerateKey() (crypto.PrivateKey, error)
	// Sign 签名
	Sign(priv crypto.PrivateKey, data []byte) ([]byte, error)
	// Verify 验证签名
	Verify(pub crypto.PublicKey, data, sig []byte) error
}

Signer 签名器

func NewSigner

func NewSigner(ae gtp.AsymmetricEncryption, padding gtp.PaddingMode, hash gtp.Hash) (Signer, error)

NewSigner 创建签名器

Jump to

Keyboard shortcuts

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