cryptography

package
v0.0.0-...-715658b Latest Latest
Warning

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

Go to latest
Published: May 8, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypto

type Crypto struct {
	PasswordLength int // in bytes
	KeyFolder      string
	SyncFolder     string
	Logger         func(message string)
	Verbose        bool

	PrivateKey *rsa.PrivateKey
	PublicKey  *rsa.PublicKey
}

func (*Crypto) AESDecrypt

func (c *Crypto) AESDecrypt(ciphertext []byte, password []byte) ([]byte, error)

func (*Crypto) AESEncrypt

func (c *Crypto) AESEncrypt(plaintext []byte, password []byte) ([]byte, error)

func (*Crypto) CreateHMAC

func (c *Crypto) CreateHMAC(messageBytes []byte, password []byte) []byte

Create an HMAC https://golang.org/pkg/crypto/hmac/

func (*Crypto) CreateSignature

func (c *Crypto) CreateSignature(contentBytes []byte) ([]byte, error)

Function to sign bytes using the RSA Private Key. https://golang.org/pkg/crypto/rsa/#SignPSS

func (*Crypto) DecryptFile

func (c *Crypto) DecryptFile(pathToFile string, password []byte) ([]byte, error)

func (*Crypto) DecryptRSA

func (c *Crypto) DecryptRSA(ciphertext []byte) ([]byte, error)

Wrapper function for DecryptRSAOaep

func (*Crypto) DecryptRSAOaep

func (c *Crypto) DecryptRSAOaep(ciphertext []byte, label []byte) ([]byte, error)

func (*Crypto) DeletePublickKeyForContact

func (c *Crypto) DeletePublickKeyForContact(path string, fileName string) error

func (*Crypto) EncryptFile

func (c *Crypto) EncryptFile(pathToFile string, password []byte) ([]byte, error)

func (*Crypto) EncryptFileBytes

func (c *Crypto) EncryptFileBytes(fileBytes []byte, password []byte) ([]byte, error)

func (*Crypto) EncryptRSA

func (c *Crypto) EncryptRSA(publicKey *rsa.PublicKey, plaintext []byte) ([]byte, error)

Wrapper function for EncryptRSAOaep

func (*Crypto) EncryptRSAOaep

func (c *Crypto) EncryptRSAOaep(publicKey *rsa.PublicKey, plaintext []byte, label []byte) ([]byte, error)

OAEP: Optimal Asymmetric Encryption Padding

https://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding Add an element of randomness which can be used to convert a deterministic encryption scheme (e.g., traditional RSA) into a probabilistic scheme.

func (*Crypto) GeneratePassword

func (c *Crypto) GeneratePassword() ([]byte, error)

func (*Crypto) GenerateRandomBytes

func (c *Crypto) GenerateRandomBytes(n int) ([]byte, error)

func (*Crypto) GetPublicKeyBytes

func (c *Crypto) GetPublicKeyBytes() ([]byte, error)

Function that returns the bytes for the publicKey so it can be sent to the server

func (*Crypto) Hash

func (c *Crypto) Hash(contentBytes []byte) ([]byte, crypto.Hash)

Our default hashing function.

func (*Crypto) Init

func (c *Crypto) Init(passwordLength int, keysFolder, syncFolder string, verbosity bool)

func (*Crypto) InitRSAKeyPair

func (c *Crypto) InitRSAKeyPair(id string)

func (*Crypto) LoadPublicKey

func (c *Crypto) LoadPublicKey(path string, fileName string) (*rsa.PublicKey, error)

Loads a public-key using a file-name. Assumes they are stored in the keys folder. Returns a pointer to that public-key.

func (*Crypto) SavePublicKeys

func (c *Crypto) SavePublicKeys(keyList []utils.KeyServer) error

Function to save public-keys that have been retrieved from the server

func (*Crypto) VerifyHMAC

func (c *Crypto) VerifyHMAC(messageBytes []byte, hmacBytes []byte, password []byte) bool

func (*Crypto) VerifySignature

func (c *Crypto) VerifySignature(contentBytes []byte, signatureBytes []byte, publicKey *rsa.PublicKey) error

https://golang.org/pkg/crypto/rsa/#VerifyPSS

Jump to

Keyboard shortcuts

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