keystore

package
v0.0.0-...-f6e252a Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrivatekeyFromKeystore

func GetPrivatekeyFromKeystore(password string, keystore JSON) (string, error)

GetPrivatekeyFromKeystore decrypts the encrypted private key based on the user's password and necessary parameters.

func MakeKeyStore

func MakeKeyStore(password, privateKey []byte) (string, error)

MakeKeyStore encrypts the incoming password and private key to generate a json file in the program directory and returns the filename.

Types

type CipherParams

type CipherParams struct {
	// aes-128-ctr initialization vector
	Iv []byte
}

CipherParams is used to store the necessary parameters required by the aes-128-ctr encryption algorithm.

type JSON

type JSON struct {
	Kdfparam     *KdfParam    `json:"kdfparam"`
	CipherParams CipherParams `json:"cipher_params"`
	Cipher       string       `json:"cipher"`
	CipherText   []byte       `json:"cipher_text"`
	Kdf          string       `json:"kdf"`
	Mac          []byte       `json:"mac"`
	Version      string       `json:"version"`
	Project      string       `json:"project"`
}

JSON is used for json encoding storage and local.

func CreateKeyStore

func CreateKeyStore(password, privateKey []byte) (JSON, error)

CreateKeyStore create a keystore structure

func ReadJSON

func ReadJSON(fileName string) (JSON, error)

ReadJSON is used to read a json file with the specified file name and return the keystore data structure.

type KdfParam

type KdfParam struct {
	N      int    `json:"n"`
	R      int    `json:"r"`
	P      int    `json:"p"`
	KeyLen int    `json:"keyLen"`
	Salt   []byte `json:"salt"`
}

KdfParam is used to store the parameters used by the PBKDF2 algorithm to generate the certificate.

Jump to

Keyboard shortcuts

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