Documentation ¶
Index ¶
- Variables
- func NewBlock(se gtp.SymmetricEncryption, key []byte) (block cipher.Block, err error)
- func NewHash(h gtp.Hash) (hash.Hash, error)
- func NewHash32(h gtp.Hash) (hash.Hash32, error)
- func NewHash64(h gtp.Hash) (hash.Hash64, error)
- func NewNamedCurve(nc gtp.NamedCurve) (ecdh.Curve, error)
- type Cipher
- type CompressionStream
- type Padding
- type Signer
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 ¶
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 填充方案
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 创建签名器
Click to show internal directories.
Click to hide internal directories.