evp

package
v0.0.0-...-e61308d Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2017 License: MIT Imports: 5 Imported by: 3

Documentation

Overview

package evp provides wrappers around OpenSSL's generic evp interfaces for symmetric/asymetric ciphers and digests

Index

Constants

View Source
const (
	EVP_CIPH_STREAM_CIPHER int = 0x0
	EVP_CIPH_ECB_MODE      int = 0x1
	EVP_CIPH_CBC_MODE      int = 0x2
	EVP_CIPH_CFB_MODE      int = 0x3
	EVP_CIPH_OFB_MODE      int = 0x4
	EVP_CIPH_CTR_MODE      int = 0x5
	EVP_CIPH_GCM_MODE      int = 0x6
	EVP_CIPH_CCM_MODE      int = 0x7

	EVP_CIPH_XTS_MODE int = 0x10001
	EVP_CIPH_MODE     int = 0xF0007
)

Variables

View Source
var (
	ErrCipherRequired    = errors.New("Cipher is required")
	ErrProblemEncrypting = errors.New("problem encrypting")
	ErrProblemDecrypting = errors.New("problem decrypting")
	ErrFailure           = errors.New("failure")
)

Functions

func CleanUpCipherCtx

func CleanUpCipherCtx(ctx *CipherCtx)

func OpenSSLAddAllAlgorithms

func OpenSSLAddAllAlgorithms()

func OpenSSLAddAllCiphers

func OpenSSLAddAllCiphers()

func OpenSSLAddAllDigests

func OpenSSLAddAllDigests()

Types

type Cipher

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

func CipherByName

func CipherByName(name string) *Cipher

func CipherByNid

func CipherByNid(nid int) *Cipher

func (*Cipher) BlockSize

func (cipher *Cipher) BlockSize() int

func (*Cipher) IVLength

func (cipher *Cipher) IVLength() int

func (*Cipher) KeyLength

func (cipher *Cipher) KeyLength() int

func (*Cipher) Nid

func (cipher *Cipher) Nid() int

type CipherCtx

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

func NewCipherCtx

func NewCipherCtx() *CipherCtx

NewCipherCtx initializes a new cipher

func (*CipherCtx) BlockSize

func (ctx *CipherCtx) BlockSize() int

func (*CipherCtx) Cipher

func (ctx *CipherCtx) Cipher() *Cipher

func (*CipherCtx) Decrypt

func (ctx *CipherCtx) Decrypt(dst, src []byte) error

func (*CipherCtx) DecryptFinal

func (ctx *CipherCtx) DecryptFinal(out []byte) (int, error)

func (*CipherCtx) DecryptInit

func (ctx *CipherCtx) DecryptInit(cipher *Cipher, key []byte, iv []byte) error

func (*CipherCtx) DecryptUpdate

func (ctx *CipherCtx) DecryptUpdate(dst []byte, src []byte) (int, error)

func (*CipherCtx) Encrypt

func (ctx *CipherCtx) Encrypt(dst, src []byte) error

func (*CipherCtx) EncryptFinal

func (ctx *CipherCtx) EncryptFinal(out []byte) (int, error)

func (*CipherCtx) EncryptInit

func (ctx *CipherCtx) EncryptInit(cipher *Cipher, key []byte, iv []byte) error

func (*CipherCtx) EncryptUpdate

func (ctx *CipherCtx) EncryptUpdate(out []byte, in []byte) (int, error)

func (*CipherCtx) IVLength

func (ctx *CipherCtx) IVLength() int

func (*CipherCtx) KeyLength

func (ctx *CipherCtx) KeyLength() int

func (*CipherCtx) Mode

func (ctx *CipherCtx) Mode() int

func (*CipherCtx) SetPadding

func (ctx *CipherCtx) SetPadding(pad int) int

func (*CipherCtx) Type

func (ctx *CipherCtx) Type() int

type Digest

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

Interface to message digest algorithms

func (*Digest) BlockSize

func (self *Digest) BlockSize() int

func (*Digest) Name

func (self *Digest) Name() string

func (*Digest) Size

func (self *Digest) Size() int

func (*Digest) Type

func (self *Digest) Type() int

type PKey

type PKey struct {
	PKey *C.EVP_PKEY
}

Wrapper around OpenSSL's EVP_PKEY

func LoadPrivateKeyDER

func LoadPrivateKeyDER(buf []byte) (*PKey, error)

func LoadPrivateKeyPEM

func LoadPrivateKeyPEM(buf []byte) (*PKey, error)

Helper function to load a private key from it's bytes

func (*PKey) DumpPEM

func (self *PKey) DumpPEM() ([]byte, error)

Jump to

Keyboard shortcuts

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