crypto

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: PostgreSQL Imports: 12 Imported by: 0

Documentation

Overview

Package crypto contains code and structs shared between the manage and agent modules.

Index

Constants

View Source
const (
	PublicKeyBanner  = "PUBLIC KEY"
	PrivateKeyBanner = "PRIVATE KEY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

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

Key represents a single key and its various forms.

func (*Key) Error

func (k *Key) Error() error

Errors returns errors present, or nil otherwise.

func (*Key) ErrorMessage

func (k *Key) ErrorMessage() string

ErrorMessage returns the error message.

func (*Key) HasErrors

func (k *Key) HasErrors() bool

HasErrors returns true if errors are present.

func (*Key) Marshal

func (k *Key) Marshal() *Key

Marshal will encode a key to PEM format.

func (*Key) Reader

func (k *Key) Reader() []byte

Reader will return the raw (binary) key. TODO: This may not be needed.

func (*Key) String

func (k *Key) String() string

String will return the keys in PEM format.

func (*Key) Unmarshal

func (k *Key) Unmarshal() *Key

Unmarshal will decode a PEM and return the key.

type KeyPair

type KeyPair struct {
	Public  *Key
	Private *Key
	// contains filtered or unexported fields
}

KeyPair manages the encryption routines for one public/private key pair.

func NewKeyPair

func NewKeyPair(name string) *KeyPair

NewKeyPair starts a new encryption request

func (*KeyPair) Bytes

func (kp *KeyPair) Bytes() []byte

Bytes will convert the TRMM structure to a []byte slice.

func (*KeyPair) Error

func (kp *KeyPair) Error() error

Errors returns errors present, or nil otherwise.

func (*KeyPair) ErrorMessage

func (kp *KeyPair) ErrorMessage() string

ErrorMessage returns the error message.

func (*KeyPair) FromPEM

func (kp *KeyPair) FromPEM(pair PEMPair) *KeyPair

FromPEM will set the public/private keys form the string in PEM format. func (kp *KeyPair) SetFromPEM(public string, private string) *KeyPair {

func (*KeyPair) GenerateKeyPair

func (kp *KeyPair) GenerateKeyPair() *KeyPair

GenerateKeyPair will generate a public/private encryption key pair.

func (*KeyPair) HasErrors

func (kp *KeyPair) HasErrors() bool

HasErrors returns true if errors are present.

func (*KeyPair) Marshal

func (kp *KeyPair) Marshal() *KeyPair

Marshal will encode a key to PEM format.

func (*KeyPair) String

func (kp *KeyPair) String() (string, string)

String will convert the Key structure to a string.

func (*KeyPair) ToHCL

func (kp *KeyPair) ToHCL() *KeyPair

ToHCL will convert the Key structure to HCL. TODO: Is this needed?

func (*KeyPair) ToJSON

func (kp *KeyPair) ToJSON() *KeyPair

ToJSON will convert the Key structure to JSON.

func (*KeyPair) ToPEM

func (kp *KeyPair) ToPEM(pair *PEMPair) *KeyPair

ToPEM will get the public/private keys and return them as a PEMPair func (kp *KeyPair) ToPEM(public string, private string) *KeyPair {

func (*KeyPair) ToYAML

func (kp *KeyPair) ToYAML() *KeyPair

ToYAML will convert the Key structure to YAML.

func (*KeyPair) Unmarshal

func (kp *KeyPair) Unmarshal() *KeyPair

Unmarshal will decode a PEM and save the key.

type Message

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

Message starts a new encrypted Message request.

func NewMessage

func NewMessage() *Message

NewMessage starts a Message request.

func (*Message) DecodeBase64

func (m *Message) DecodeBase64() *Message

DecodeBase64 will base64 decode the encrypted message.

func (*Message) Decrypt

func (m *Message) Decrypt(encrypted []byte) *Message

Decrypt will Encrypt the message. decrypted > encrypted > EncodeBase64 > transport > DecodeBase64 > encrypted > decrypted

func (*Message) EncodeBase64

func (m *Message) EncodeBase64() *Message

EncodeBase64 will base64 encode the encrypted message.

func (*Message) Encrypt

func (m *Message) Encrypt(message []byte) *Message

Encrypt will Encrypt the message. decrypted > encrypted > EncodeBase64 > transport > DecodeBase64 > encrypted > decrypted

func (*Message) Error

func (m *Message) Error() error

Errors returns errors present, or nil otherwise.

func (*Message) ErrorMessage

func (m *Message) ErrorMessage() string

ErrorMessage returns the error message.

func (*Message) HasErrors

func (m *Message) HasErrors() bool

HasErrors returns true if errors are present.

func (*Message) SetMessage

func (m *Message) SetMessage(message []byte) *Message

SetMessage sets the message key for the encryption.

func (*Message) SetPrivateKey

func (m *Message) SetPrivateKey(private *Key) *Message

SetPrivateKey sets the private key for the encryption.

func (*Message) SetPublicKey

func (m *Message) SetPublicKey(public *Key) *Message

SetPublicKey sets the public key for the encryption.

func (*Message) String

func (m *Message) String() string

String will return the encoded message as a string.

type PEMPair

type PEMPair struct {
	Public  string `json:"public_key"`
	Private string `json:"private_key"`
}

PEMPair is a pair of encryption keys as strings in PEM, base64 or other format. This is used to pass key pairs to other modules easily.

Jump to

Keyboard shortcuts

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