kscrypto

package module
v0.0.0-...-78570e5 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

GO-AES-GCM-streaming-mode

WHY ? Current Golang standard library does not support AES-GCM algorithm as streaming mode as openssl provides. Calling openssl library function from Golang have CGO calls overhead and impact performance. This library provide support of following algorithms: AES-GCM, AES-CBC, AES-ECB, TDES-CBC and TDES-ECB

Documentation

Index

Constants

View Source
const AES_BLOCK_SIZE = 16 //nolint:golint,stylecheck
View Source
const DOUBLE_DES_KEY_LEN = 16 //nolint:golint,stylecheck
View Source
const TDES_BLOCK_SIZE = 8 //nolint:golint,stylecheck

Variables

This section is empty.

Functions

func GetAlgoAndMode

func GetAlgoAndMode(alg BlockCipherAlg) (string, string)

Function will take algorithm as input and

Return algo and mode in return

func GetKeyAndIVSize

func GetKeyAndIVSize(alg BlockCipherAlg) (int, int)

func NewECBDecrypter

func NewECBDecrypter(b cipher.Block) cipher.BlockMode

func NewECBEncrypter

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

Types

type BlockCipherAlg

type BlockCipherAlg string
const (
	AES_256_CBC  BlockCipherAlg = "aes-256-cbc"
	AES_192_CBC  BlockCipherAlg = "aes-192-cbc"
	AES_128_CBC  BlockCipherAlg = "aes-128-cbc"
	AES_256_ECB  BlockCipherAlg = "aes-256-ecb"
	AES_192_ECB  BlockCipherAlg = "aes-192-ecb"
	AES_128_ECB  BlockCipherAlg = "aes-128-ecb"
	TDES_CBC     BlockCipherAlg = "des-ede3-cbc"
	TDES_112_CBC BlockCipherAlg = "des-ede-cbc"
	TDES_192_ECB BlockCipherAlg = "des-ede3"
	TDES_128_ECB BlockCipherAlg = "des-ede"
)

type BlockCipherPadding

type BlockCipherPadding string
const (
	PKCS7_CRYPTO_PADDING BlockCipherPadding = "pkcs7"
	NO_CRYPTO_PADDING    BlockCipherPadding = "none"
)

type GoCryptoBlockCipherDecryptionCtx

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

func NewGoCryptoBlockCipherDecryptor

func NewGoCryptoBlockCipherDecryptor() *GoCryptoBlockCipherDecryptionCtx

func (*GoCryptoBlockCipherDecryptionCtx) Final

func (dc *GoCryptoBlockCipherDecryptionCtx) Final() ([]byte, error)

Final routine for decrytion

func (*GoCryptoBlockCipherDecryptionCtx) Init

Initialization routine for decrytion

func (*GoCryptoBlockCipherDecryptionCtx) Update

func (dc *GoCryptoBlockCipherDecryptionCtx) Update(ct []byte, final bool) ([]byte, error)

Update routine for decrytion

type GoCryptoBlockCipherDecryptor

type GoCryptoBlockCipherDecryptor interface {
	Init(alg BlockCipherAlg, pad BlockCipherPadding, key, iv []byte) error
	Update(ct []byte, final bool) ([]byte, error)
	Final() ([]byte, error)
}

type GoCryptoBlockCipherEncryptionCtx

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

Encryption context

func NewGoCryptoBlockCipherEncryptor

func NewGoCryptoBlockCipherEncryptor() *GoCryptoBlockCipherEncryptionCtx

func (*GoCryptoBlockCipherEncryptionCtx) Final

func (ec *GoCryptoBlockCipherEncryptionCtx) Final() ([]byte, error)

Final routine for encrytion

func (*GoCryptoBlockCipherEncryptionCtx) Init

Encryption context initialization

func (*GoCryptoBlockCipherEncryptionCtx) Update

func (ec *GoCryptoBlockCipherEncryptionCtx) Update(pt []byte, final bool) ([]byte, error)

Update routine for encrytion

type GoCryptoBlockCipherEncryptor

type GoCryptoBlockCipherEncryptor interface {
	Init(alg BlockCipherAlg, pad BlockCipherPadding, key, iv []byte) error
	Update(pt []byte, final bool) ([]byte, error)
	Final() ([]byte, error)
}

Jump to

Keyboard shortcuts

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