sshcrypt

package module
v0.0.0-...-ca12f3e Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2015 License: BSD-3-Clause Imports: 12 Imported by: 0

README

sshcrypt

Goals

Provides APIs so you can use ssh keys generated by ssh-keygen for encryption.

Much of the code simply borrows and exposes private stuff in Google's Go crypto extensions and the TLS library.

Example

TODO

TODO

  • Support non-RSA keys
  • Add examples
  • Expose Marshal methods (same way ssh.PublicKey does)

Documentation

Overview

sshcrypt provides some helper functions to use / parse ssh keys in order to use them for encryption.

A lot of this is just exposing stuff in crypto/ssh.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalAuthorizedKey

func MarshalAuthorizedKey(key ssh.PublicKey) []byte

MarshalAuthorizedKey serializes key for inclusion in an OpenSSH authorized_keys file. The return value ends with newline.

Types

type PrivateKey

type PrivateKey interface {
	Type() string
	DecryptBytes(ciphertext []byte) ([]byte, error)
}

func ParsePrivateKey

func ParsePrivateKey(pemBytes []byte, passphrase string) (PrivateKey, error)

// ParsPrivateKey returns a private key from a PEM encoded private key. It // supports RSA (PKCS#1), DSA (OpenSSL), and ECDSA private keys.

type PublicKey

type PublicKey interface {
	Type() string
	EncryptBytes(ciphertext []byte) ([]byte, error)
}

func ParseAuthorizedKey

func ParseAuthorizedKey(in []byte) (out PublicKey, comment string, options []string, rest []byte, err error)

ParseAuthorizedKeys parses a public key from an authorized_keys file used in OpenSSH according to the sshd(8) manual page.

func ParsePublicKey

func ParsePublicKey(in []byte) (out PublicKey, err error)

ParsePublicKey parses an SSH public key formatted for use in the SSH wire protocol according to RFC 4253, section 6.6.

type RSAPrivateKey

type RSAPrivateKey rsa.PrivateKey

func (*RSAPrivateKey) DecryptBytes

func (r *RSAPrivateKey) DecryptBytes(ciphertext []byte) ([]byte, error)

func (*RSAPrivateKey) Type

func (r *RSAPrivateKey) Type() string

type RSAPublicKey

type RSAPublicKey rsa.PublicKey

func (*RSAPublicKey) EncryptBytes

func (r *RSAPublicKey) EncryptBytes(in []byte) ([]byte, error)

func (*RSAPublicKey) GetCryptoPublicKey

func (r *RSAPublicKey) GetCryptoPublicKey() *rsa.PublicKey

func (*RSAPublicKey) GetSshPublicKey

func (r *RSAPublicKey) GetSshPublicKey() *ssh.PublicKey

func (*RSAPublicKey) Marshal

func (r *RSAPublicKey) Marshal() []byte

func (*RSAPublicKey) Type

func (r *RSAPublicKey) Type() string

func (*RSAPublicKey) Verify

func (r *RSAPublicKey) Verify(data []byte, sig *ssh.Signature) error

Jump to

Keyboard shortcuts

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