rsautil

package
v0.0.0-...-fe628ba Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(passphrase []byte, n int) (pri, pub []byte, err error)

GenerateKey generates a private/public key pair with the given passphrase. n is the bit size of the RSA key. When n is less than 0, 4096 is used.

func ParsePrivateKey

func ParsePrivateKey(bs []byte) (*rsa.PrivateKey, error)

ParsePrivateKey parses the PEM encoded RSA private key.

func ParsePrivateKeyTTY

func ParsePrivateKeyTTY(name string, bs []byte) (
	*rsa.PrivateKey, error,
)

ParsePrivateKeyTTY parses a private key and asks for the passphrase if the key is an encrypted PEM.

func ParsePublicKey

func ParsePublicKey(bs []byte) (*rsa.PublicKey, error)

ParsePublicKey parses a marshalled public key in SSH authorized key format.

func PublicKeyHash

func PublicKeyHash(k *rsa.PublicKey) ([]byte, error)

PublicKeyHash returns the public key hash of a key.

func PublicKeyHashString

func PublicKeyHashString(k *rsa.PublicKey) (string, error)

PublicKeyHashString returns the public key hash string of a key.

func ReadPrivateKey

func ReadPrivateKey(f string) (*rsa.PrivateKey, error)

ReadPrivateKey parses the PEM encded RSA private key file.

func ReadPrivateKeyTTY

func ReadPrivateKeyTTY(pemFile string) (*rsa.PrivateKey, error)

ReadPrivateKeyTTY reads a private key from a key file.

func ReadPublicKey

func ReadPublicKey(f string) (*rsa.PublicKey, error)

ReadPublicKey parses a marshalled public key file in SSH authorized key file format.

Types

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey carries a public key.

func NewPublicKey

func NewPublicKey(bs []byte) (*PublicKey, error)

NewPublicKey parses a new public key from SSH authorized key format.

func ParsePublicKeys

func ParsePublicKeys(bs []byte) ([]*PublicKey, error)

ParsePublicKeys parses a list of public keys.

func (*PublicKey) HashStr

func (k *PublicKey) HashStr() string

HashStr returns the base64 encoding of the key hash.

func (*PublicKey) Key

func (k *PublicKey) Key() *rsa.PublicKey

Key returns the public key parsed from the bytes.

Jump to

Keyboard shortcuts

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