keyidentifier

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 14 Imported by: 0

README

Keyidentifier

keyidentifier is a small go package designed to extract information about encryption keys.

It's primary usage is to identify whether or not a key is encrypted. But it additionally tries to return the key type and size.

If there's interest, we can extract it from launcher and move it to it's own repository.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyIdentifier

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

keyidentifier attempts to identify a key. It uses a set of herusitics to try to guiess what kind, what size, and whether or not it's encrypted.

func New

func New(opts ...Option) (*KeyIdentifier, error)

func (*KeyIdentifier) Identify

func (kIdentifer *KeyIdentifier) Identify(keyBytes []byte) (*KeyInfo, error)

Identify uses a manually curated set of heuristics to determine what kind of key something is. Generally speaking, we consider `err == nil` as success, and throw away errors as unparsable keys.

func (*KeyIdentifier) IdentifyFile

func (kIdentifer *KeyIdentifier) IdentifyFile(path string) (*KeyInfo, error)

type KeyInfo

type KeyInfo struct {
	Type              string // Key type. rsa/dsa/etc
	Format            string // file format
	Bits              int    // number of bits in the key
	Encryption        string // key encryption algorythem
	Encrypted         *bool  // is the key encrypted
	Comment           string // comments attached to the key
	Parser            string // what parser we used to determine information
	FingerprintSHA256 string // the fingerprint of the key, as a SHA256 hash
	FingerprintMD5    string // the fingerprint of the key, as an MD5 hash
}

func ParseOpenSSHPrivateKey

func ParseOpenSSHPrivateKey(keyBytes []byte) (*KeyInfo, error)

ParseOpenSSHPrivateKey returns key information from an openssh private key. It is adapted from https://github.com/golang/crypto/blob/master/ssh/keys.go

func ParsePuttyPrivateKey

func ParsePuttyPrivateKey(keyBytes []byte) (*KeyInfo, error)

ParseSshComPrivateKey returns key information from a putty (ppk) formatted key file.

func ParseSshComPrivateKey

func ParseSshComPrivateKey(keyBytes []byte) (*KeyInfo, error)

type Option

type Option func(*KeyIdentifier)

func WithLogger

func WithLogger(logger log.Logger) Option

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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