Documentation ¶
Index ¶
- type Crypto
- func (c *Crypto) AESDecrypt(ciphertext []byte, password []byte) ([]byte, error)
- func (c *Crypto) AESEncrypt(plaintext []byte, password []byte) ([]byte, error)
- func (c *Crypto) CreateHMAC(messageBytes []byte, password []byte) []byte
- func (c *Crypto) CreateSignature(contentBytes []byte) ([]byte, error)
- func (c *Crypto) DecryptFile(pathToFile string, password []byte) ([]byte, error)
- func (c *Crypto) DecryptRSA(ciphertext []byte) ([]byte, error)
- func (c *Crypto) DecryptRSAOaep(ciphertext []byte, label []byte) ([]byte, error)
- func (c *Crypto) DeletePublickKeyForContact(path string, fileName string) error
- func (c *Crypto) EncryptFile(pathToFile string, password []byte) ([]byte, error)
- func (c *Crypto) EncryptFileBytes(fileBytes []byte, password []byte) ([]byte, error)
- func (c *Crypto) EncryptRSA(publicKey *rsa.PublicKey, plaintext []byte) ([]byte, error)
- func (c *Crypto) EncryptRSAOaep(publicKey *rsa.PublicKey, plaintext []byte, label []byte) ([]byte, error)
- func (c *Crypto) GeneratePassword() ([]byte, error)
- func (c *Crypto) GenerateRandomBytes(n int) ([]byte, error)
- func (c *Crypto) GetPublicKeyBytes() ([]byte, error)
- func (c *Crypto) Hash(contentBytes []byte) ([]byte, crypto.Hash)
- func (c *Crypto) Init(passwordLength int, keysFolder, syncFolder string, verbosity bool)
- func (c *Crypto) InitRSAKeyPair(id string)
- func (c *Crypto) LoadPublicKey(path string, fileName string) (*rsa.PublicKey, error)
- func (c *Crypto) SavePublicKeys(keyList []utils.KeyServer) error
- func (c *Crypto) VerifyHMAC(messageBytes []byte, hmacBytes []byte, password []byte) bool
- func (c *Crypto) VerifySignature(contentBytes []byte, signatureBytes []byte, publicKey *rsa.PublicKey) error
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 (*Crypto) AESEncrypt ¶
func (*Crypto) CreateHMAC ¶
Create an HMAC https://golang.org/pkg/crypto/hmac/
func (*Crypto) CreateSignature ¶
Function to sign bytes using the RSA Private Key. https://golang.org/pkg/crypto/rsa/#SignPSS
func (*Crypto) DecryptFile ¶
func (*Crypto) DecryptRSA ¶
Wrapper function for DecryptRSAOaep
func (*Crypto) DecryptRSAOaep ¶
func (*Crypto) DeletePublickKeyForContact ¶
func (*Crypto) EncryptFile ¶
func (*Crypto) EncryptFileBytes ¶
func (*Crypto) EncryptRSA ¶
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 (*Crypto) GetPublicKeyBytes ¶
Function that returns the bytes for the publicKey so it can be sent to the server
func (*Crypto) InitRSAKeyPair ¶
func (*Crypto) LoadPublicKey ¶
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 ¶
Function to save public-keys that have been retrieved from the server