crypto

package
v0.0.0-...-5b5faa7 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCiphertextLengthIsInvalid = errors.New("ciphertext length is invalid")
View Source
var ErrDecodeASN1Failed = errors.New("decode ASN1 data failed")

Functions

func AES128CBCDecrypt

func AES128CBCDecrypt(key, iv, ciphertext []byte) ([]byte, error)

func AES128CBCEncrypt

func AES128CBCEncrypt(key, iv, plaintext []byte) ([]byte, error)

func AESGCMDecrypt

func AESGCMDecrypt(key, nounce, ciphertext []byte) ([]byte, error)

AESGCMDecrypt chromium > 80 https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/sync/os_crypt_win.cc

func AESGCMEncrypt

func AESGCMEncrypt(key, nonce, plaintext []byte) ([]byte, error)

AESGCMEncrypt encrypts plaintext using AES encryption in GCM mode.

func DES3Decrypt

func DES3Decrypt(key, iv, ciphertext []byte) ([]byte, error)

func DES3Encrypt

func DES3Encrypt(key, iv, plaintext []byte) ([]byte, error)

func DecryptWithChromium

func DecryptWithChromium(key, ciphertext []byte) ([]byte, error)

func DecryptWithDPAPI

func DecryptWithDPAPI(ciphertext []byte) ([]byte, error)

DecryptWithDPAPI (Data Protection Application Programming Interface) is a simple cryptographic application programming interface available as a built-in component in Windows 2000 and later versions of Microsoft Windows operating systems

func DecryptWithYandex

func DecryptWithYandex(key, ciphertext []byte) ([]byte, error)

DecryptWithYandex decrypts the password with AES-GCM

func PBKDF2Key

func PBKDF2Key(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte

PBKDF2Key derives a key from the password, salt and iteration count, returning a []byte of length keylen that can be used as cryptographic key. The key is derived based on the method described as PBKDF2 with the HMAC variant using the supplied hash function.

For example, to use a HMAC-SHA-1 based PBKDF2 key derivation function, you can get a derived key for e.g. AES-256 (which needs a 32-byte key) by doing:

dk := pbkdf2.Key([]byte("some password"), salt, 4096, 32, sha1.New)

Remember to get a good random salt. At least 8 bytes is recommended by the RFC.

Using a higher iteration count will increase the cost of an exhaustive search but will also make derivation proportionally slower. Copy from https://golang.org/x/crypto/pbkdf2

Types

type ASN1PBE

type ASN1PBE interface {
	Decrypt(globalSalt []byte) ([]byte, error)

	Encrypt(globalSalt, plaintext []byte) ([]byte, error)
}

func NewASN1PBE

func NewASN1PBE(b []byte) (pbe ASN1PBE, err error)

Jump to

Keyboard shortcuts

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