Documentation
¶
Index ¶
- Constants
- func Decrypt(keystore *Keystore, password string) ([]byte, error)
- func ProcessPassword(password string) []byte
- func RandomBytes(length int) []byte
- type AES128
- type ChecksumFunction
- type CipherFunction
- type Crypto
- type CryptoJSON
- type CryptoOption
- type CryptoOptions
- type Hex
- type IV
- type KDFunction
- type Keystore
- type KeystoreOption
- type KeystoreOptions
- type Module
- type ModuleJSON
- type Option
- type Options
- type PBKDF2
- type PublicKey
- type Salt
- type Scrypt
- type Sha256
Constants ¶
const ( AES128KeyLen = 16 AES128Name = "aes-128-ctr" )
AES128 params
const ( ScryptDKLen = 32 ScryptN = 1 << 18 ScryptR = 8 ScryptP = 1 ScryptName = "scrypt" )
Default Scrypt params
const ( PBKDF2DKLen = 32 PBKDF2C = 1 << 18 PBKDF2PRF = "hmac-sha256" PBKDF2Name = "pbkdf2" )
Default Scrypt params
const KeystoreVersion = 4
KeystoreVersion
const Sha256Name = "sha256"
Sha256 params
Variables ¶
This section is empty.
Functions ¶
func ProcessPassword ¶
ProcessPassword encodes password in NFKD form and removes all control characters
func RandomBytes ¶
RandomBytse generates random bytes sequence of given length
Types ¶
type AES128 ¶
type AES128 struct {
InitialValue IV `json:"iv"`
}
AES-128 params
type ChecksumFunction ¶
Checksum function interface
type CipherFunction ¶
type CipherFunction interface {
Function() string
Encrypt(data, key []byte) ([]byte, error)
Decrypt(key, data []byte) ([]byte, error)
}
Cipher function interface
type Crypto ¶
type Crypto struct {
KDF *Module[KDFunction] `json:"kdf"`
Cipher *Module[CipherFunction] `json:"cipher"`
Checksum *Module[ChecksumFunction] `json:"checksum"`
}
Crypto modules of keystore
func NewCrypto ¶
func NewCrypto(options ...CryptoOption) (*Crypto, error)
NewCrypto with options or default
func (*Crypto) UnmarshalJSON ¶
impl json.Unmarshaler for Crypto
type CryptoJSON ¶
type CryptoJSON struct {
KDF *ModuleJSON `json:"kdf"`
Cipher *ModuleJSON `json:"cipher"`
Checksum *ModuleJSON `json:"checksum"`
}
CryptoJSON representation
type CryptoOption ¶
Type aliases
func WithChecksum ¶
func WithChecksum(checksum ChecksumFunction) CryptoOption
WithChecksum sets ChecksumFunction
func WithCipher ¶
func WithCipher(cipher CipherFunction) CryptoOption
WithCipher sets CipherFunction
type KDFunction ¶
Key derivation function interface
type Keystore ¶
type Keystore struct {
Crypto *Crypto `json:"crypto"`
Description string `json:"description,omitempty"`
PublicKey PublicKey `json:"pubkey,omitempty"`
Path string `json:"path"`
UUID uuid.UUID `json:"uuid"`
Version uint64 `json:"version"`
}
KeystoreV4
type KeystoreOption ¶
Type aliases
func WithCrypto ¶
func WithCrypto(opts ...CryptoOption) KeystoreOption
WithCrypto creates and sets new Crypto with given options
func WithDescription ¶
func WithDescription(description string) KeystoreOption
WithDescription sets Description
type Module ¶
type Module[T any] struct { Function string `json:"function"` Params T `json:"params"` Message Hex `json:"message"` }
Generic crypto module
type ModuleJSON ¶
type ModuleJSON struct {
Function string `json:"function"`
Params json.RawMessage `json:"params"`
Message Hex `json:"message"`
}
ModuleJSON representation
type PBKDF2 ¶
type PBKDF2 struct {
DKLen int `json:"dklen"`
C int `json:"c"`
PRF string `json:"prf"`
Salt Salt `json:"salt"`
}
PBKDF2 params