utils

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: MPL-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// AESCTRKeyLength is the length of the AES256-CTR key used.
	AESCTRKeyLength = 32
	// AESCTRIVLength is the length of the AES256-CTR IV used.
	AESCTRIVLength = 16
	// HMACKeyLength is the length of the HMAC key used.
	HMACKeyLength = 32
	// SHAHashLength is the length of the SHA hash used.
	SHAHashLength = 32
)

Variables

This section is empty.

Functions

func DecodeBase58RecoveryKey

func DecodeBase58RecoveryKey(recoveryKey string) []byte

DecodeBase58RecoveryKey recovers the secret storage from a recovery key.

func DeriveKeysSHA256

func DeriveKeysSHA256(key []byte, name string) ([AESCTRKeyLength]byte, [HMACKeyLength]byte)

DeriveKeysSHA256 derives an AES and a HMAC key from the given recovery key.

func EncodeBase58RecoveryKey

func EncodeBase58RecoveryKey(key []byte) string

EncodeBase58RecoveryKey recovers the secret storage from a recovery key.

func GenA256CTRIV

func GenA256CTRIV() (iv [AESCTRIVLength]byte)

GenA256CTRIV generates a random IV for AES256-CTR with the last bit set to zero.

func GenAttachmentA256CTR

func GenAttachmentA256CTR() (key [AESCTRKeyLength]byte, iv [AESCTRIVLength]byte)

GenAttachmentA256CTR generates a new random AES256-CTR key and IV suitable for encrypting attachments.

func HMACSHA256B64

func HMACSHA256B64(input []byte, hmacKey [HMACKeyLength]byte) string

HMACSHA256B64 calculates the base64 of the SHA256 hmac of the input with the given key.

func PBKDF2SHA512

func PBKDF2SHA512(password []byte, salt []byte, iters int, keyLenBits int) []byte

PBKDF2SHA512 generates a key of the given bit-length using the given passphrase, salt and iteration count.

func XorA256CTR

func XorA256CTR(source []byte, key [AESCTRKeyLength]byte, iv [AESCTRIVLength]byte) []byte

XorA256CTR encrypts the input with the keystream generated by the AES256-CTR algorithm with the given arguments.

Types

This section is empty.

Jump to

Keyboard shortcuts

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