sec

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: Apache-2.0 Imports: 26 Imported by: 8

Documentation

Overview

Decoder for PKCS#5 encrypted PKCS#8 private keys.

Index

Constants

This section is empty.

Variables

View Source
var KeyPassword = []byte{}

For testing, a key can be set here. If this is empty, the key will be queried via prompt.

Functions

func EncTypeString added in v0.0.9

func EncTypeString(typ EncType) string

func EncryptAES

func EncryptAES(plain []byte, secret []byte, nonce []byte) ([]byte, error)

func RawKeyHash

func RawKeyHash(pubKeyBytes []byte) []byte

func SigTypeString added in v0.0.9

func SigTypeString(typ SigType) string

func VerifySigs

func VerifySigs(key PubSignKey, sigs []Sig, hash []byte) (int, error)

Types

type EncType added in v0.0.9

type EncType int
const (
	ENC_TYPE_AES_128 EncType = iota
	ENC_TYPE_AES_256
	ENC_TYPE_RSA_2048
)

func EncStringType added in v0.0.9

func EncStringType(s string) (EncType, error)

type PrivEncKey added in v0.0.2

type PrivEncKey struct {
	Rsa *rsa.PrivateKey
}

XXX: Only RSA supported for now.

func ParsePrivEncKey added in v0.0.2

func ParsePrivEncKey(keyBytes []byte) (PrivEncKey, error)

func ReadPrivEncKey added in v0.0.2

func ReadPrivEncKey(filename string) (PrivEncKey, error)

ReadPubEncKey reads a private encryption key from a file.

func ReadPrivEncKeys added in v0.0.2

func ReadPrivEncKeys(filenames []string) ([]PrivEncKey, error)

ReadPubSignKeys reads a set of private encryption keys from several files.

func (*PrivEncKey) Decrypt added in v0.0.2

func (k *PrivEncKey) Decrypt(ciph []byte) ([]byte, error)

func (*PrivEncKey) PubEncKey added in v0.0.9

func (key *PrivEncKey) PubEncKey() PubEncKey

type PrivSignKey added in v0.0.2

type PrivSignKey struct {
	// Only one of these members is non-nil.
	Rsa     *rsa.PrivateKey
	Ec      *ecdsa.PrivateKey
	Ed25519 *ed25519.PrivateKey
}

func ParsePrivSignKey added in v0.0.2

func ParsePrivSignKey(keyBytes []byte) (PrivSignKey, error)

func ReadPrivSignKey added in v0.0.2

func ReadPrivSignKey(filename string) (PrivSignKey, error)

ReadPrivSignKey reads a private signing key from a file.

func ReadPrivSignKeys added in v0.0.2

func ReadPrivSignKeys(filenames []string) ([]PrivSignKey, error)

ReadPubSignKeys reads a set of private signing keys from several files.

func (*PrivSignKey) AssertValid added in v0.0.2

func (key *PrivSignKey) AssertValid()

func (*PrivSignKey) PubBytes added in v0.0.2

func (key *PrivSignKey) PubBytes() ([]byte, error)

func (*PrivSignKey) PubKey added in v0.0.2

func (key *PrivSignKey) PubKey() PubSignKey

func (*PrivSignKey) SigLen added in v0.0.2

func (key *PrivSignKey) SigLen() uint16

type PubEncKey added in v0.0.2

type PubEncKey struct {
	Rsa *rsa.PublicKey
	Ec  *ecdsa.PublicKey
	Aes cipher.Block
}

func ParsePubEncKey added in v0.0.2

func ParsePubEncKey(keyBytes []byte) (PubEncKey, error)

func ReadPubEncKey added in v0.0.2

func ReadPubEncKey(filename string) (PubEncKey, error)

ReadPubEncKey reads a public encryption key from a file.

func ReadPubEncKeys added in v0.0.2

func ReadPubEncKeys(filenames []string) ([]PubEncKey, error)

ReadPubSignKeys reads a set of public encryption keys from several files.

func (*PubEncKey) AssertValid added in v0.0.2

func (key *PubEncKey) AssertValid()

func (*PubEncKey) EncType added in v0.0.9

func (key *PubEncKey) EncType() (EncType, error)

func (*PubEncKey) Encrypt added in v0.0.2

func (k *PubEncKey) Encrypt(plain []byte) ([]byte, error)

type PubSignKey

type PubSignKey struct {
	Rsa     *rsa.PublicKey
	Ec      *ecdsa.PublicKey
	Ed25519 ed25519.PublicKey
}

func ParsePubSignKey added in v0.0.2

func ParsePubSignKey(keyBytes []byte) (PubSignKey, error)

func ReadPubSignKey added in v0.0.2

func ReadPubSignKey(filename string) (PubSignKey, error)

ReadPubSignKey reads a public signing key from a file.

func ReadPubSignKeys added in v0.0.2

func ReadPubSignKeys(filenames []string) ([]PubSignKey, error)

ReadPubSignKeys reads a set of public signing keys from several files.

func (*PubSignKey) AssertValid

func (key *PubSignKey) AssertValid()

func (*PubSignKey) Bytes

func (key *PubSignKey) Bytes() ([]byte, error)

func (*PubSignKey) Hash added in v0.0.9

func (key *PubSignKey) Hash() ([]byte, error)

func (*PubSignKey) SigType added in v0.0.9

func (key *PubSignKey) SigType() (SigType, error)

type Sig

type Sig struct {
	Type    SigType
	KeyHash []byte
	Data    []byte
}

type SigType added in v0.0.9

type SigType int
const (
	SIG_TYPE_RSA2048 SigType = iota
	SIG_TYPE_RSA3072
	SIG_TYPE_ECDSA224
	SIG_TYPE_ECDSA256
	SIG_TYPE_ED25519
)

func SigStringType added in v0.0.9

func SigStringType(s string) (SigType, error)

Jump to

Keyboard shortcuts

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