crypto

package
v0.0.0-...-d1be498 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRSAPrivateKeyFormat    = errors.New("indalid RSA private key format")
	ErrInvalidRSAPrivateKeyBlockType = errors.New("invalid block type")
)

Functions

func NewRSAKeyManager

func NewRSAKeyManager() *rsaKeyManager

Types

type AESCryptor

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

func NewAESCryptor

func NewAESCryptor(key string) *AESCryptor

func (*AESCryptor) Decrypt

func (c *AESCryptor) Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error)

func (*AESCryptor) Encrypt

func (c *AESCryptor) Encrypt(ctx context.Context, plaintext []byte) ([]byte, error)

type BcryptoHashGenerator

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

func NewBcryptoHashGenerator

func NewBcryptoHashGenerator() *BcryptoHashGenerator

func (*BcryptoHashGenerator) Compare

func (g *BcryptoHashGenerator) Compare(ctx context.Context, hashed []byte, value []byte) error

func (*BcryptoHashGenerator) Generate

func (g *BcryptoHashGenerator) Generate(ctx context.Context, value []byte) ([]byte, error)

type Cryptor

type Cryptor interface {
	Encrypt(ctx context.Context, plaintext []byte) ([]byte, error)
	Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error)
}

type HashGenerator

type HashGenerator interface {
	Generate(ctx context.Context, value []byte) ([]byte, error)
	Compare(ctx context.Context, value []byte, hashed []byte) error
}

type RSAKeyManager

type RSAKeyManager interface {
	GenerateRSAPrivateKey(bits int) (*rsa.PrivateKey, error)
	ReadPemFile(filename string) (*rsa.PrivateKey, error)
	ReadPemBytes(b []byte) (*rsa.PrivateKey, error)
	ConvertFormat(privateKey *rsa.PrivateKey, format RSAPrivateKeyFormat) ([]byte, error)
}

type RSAPrivateKeyBlockType

type RSAPrivateKeyBlockType int
const (
	RSAPrivateKeyKeyTypeUnknown RSAPrivateKeyBlockType = iota
	RSAPrivateKeyBlockTypePKCS1
	RSAPrivateKeyBlockTypePKCS8
)

func ParseRSAPrivateKeyBlockType

func ParseRSAPrivateKeyBlockType(v string) RSAPrivateKeyBlockType

func (RSAPrivateKeyBlockType) String

func (f RSAPrivateKeyBlockType) String() string

type RSAPrivateKeyFormat

type RSAPrivateKeyFormat int
const (
	RSAPrivateKeyFormatUnsupported RSAPrivateKeyFormat = iota
	RSAPrivateKeyFormatDer
	RSAPrivateKeyFormatPem
)

func ParseRSAPrivateKeyFormat

func ParseRSAPrivateKeyFormat(v string) RSAPrivateKeyFormat

func (RSAPrivateKeyFormat) String

func (f RSAPrivateKeyFormat) String() string

Jump to

Keyboard shortcuts

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