Documentation
¶
Index ¶
- Variables
- func AES128CBCDecrypt(key, iv, ciphertext []byte) ([]byte, error)
- func AES128CBCEncrypt(key, iv, plaintext []byte) ([]byte, error)
- func AESGCMDecrypt(key, nounce, ciphertext []byte) ([]byte, error)
- func AESGCMEncrypt(key, nonce, plaintext []byte) ([]byte, error)
- func DES3Decrypt(key, iv, ciphertext []byte) ([]byte, error)
- func DES3Encrypt(key, iv, plaintext []byte) ([]byte, error)
- func DecryptWithChromium(key, encryptPass []byte) ([]byte, error)
- func DecryptWithDPAPI(_ []byte) ([]byte, error)
- func PBKDF2Key(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte
- type ASN1PBE
Constants ¶
This section is empty.
Variables ¶
var ErrCiphertextLengthIsInvalid = errors.New("ciphertext length is invalid")
var ErrDecodeASN1Failed = errors.New("decode ASN1 data failed")
Functions ¶
func AES128CBCDecrypt ¶ added in v0.4.6
func AES128CBCEncrypt ¶ added in v0.4.6
func AESGCMDecrypt ¶ added in v0.4.6
AESGCMDecrypt chromium > 80 https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_win.cc
func AESGCMEncrypt ¶ added in v0.4.6
AESGCMEncrypt encrypts plaintext using AES encryption in GCM mode.
func DES3Decrypt ¶ added in v0.4.6
func DES3Encrypt ¶ added in v0.4.6
func DecryptWithChromium ¶ added in v0.4.6
func DecryptWithDPAPI ¶ added in v0.4.6
func PBKDF2Key ¶ added in v0.4.6
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