crypto

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package crypto provides the cryptographic functions required within the SDK.

There are two kinds of decrypted data:

  • Metadata means any small string data, typically file metadata, but also e.g. directory names.
  • Data means file content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveKEKAndAuthFromPassword added in v0.0.5

func DeriveKEKAndAuthFromPassword(password string, salt string) (*EncryptionKey, DerivedPassword, error)

func DeriveMKAndAuthFromPassword added in v0.0.5

func DeriveMKAndAuthFromPassword(password string, salt string) (*MasterKey, DerivedPassword, error)

func GenerateRandomBytes added in v0.0.5

func GenerateRandomBytes(length int) []byte

func GenerateRandomString

func GenerateRandomString(length int) string

GenerateRandomString generates a cryptographically secure random string based on a selection of alphanumerical characters.

func RSAKeyPairFromStrings added in v0.0.5

func RSAKeyPairFromStrings(privKey string, pubKey string) (*rsa.PrivateKey, *rsa.PublicKey, error)

func RunSHA521

func RunSHA521(b []byte) []byte

Types

type AllKeysFailedError

type AllKeysFailedError struct {
	Errors []error // errors thrown in the process
}

AllKeysFailedError denotes that no key passed to [DecryptMetadataAllKeys] worked.

func (*AllKeysFailedError) Error

func (e *AllKeysFailedError) Error() string

type DerivedPassword added in v0.0.5

type DerivedPassword string

type EncryptedString

type EncryptedString string

EncryptedString denotes that a string is encrypted and can't be used meaningfully before being decrypted.

func NewEncryptedStringV2 added in v0.0.5

func NewEncryptedStringV2(encrypted []byte, nonce [12]byte) EncryptedString

func NewEncryptedStringV3 added in v0.0.5

func NewEncryptedStringV3(encrypted []byte, nonce [12]byte) EncryptedString

type EncryptionKey added in v0.0.5

type EncryptionKey struct {
	Bytes  [32]byte
	Cipher cipher.AEAD
}

func MakeEncryptionKeyFromBytes added in v0.0.5

func MakeEncryptionKeyFromBytes(key [32]byte) (*EncryptionKey, error)

func MakeEncryptionKeyFromStr added in v0.0.5

func MakeEncryptionKeyFromStr(key string) (*EncryptionKey, error)

func MakeEncryptionKeyFromUnknownStr added in v0.0.5

func MakeEncryptionKeyFromUnknownStr(key string) (*EncryptionKey, error)

func MakeNewFileKey added in v0.0.13

func MakeNewFileKey(authVersion int) (*EncryptionKey, error)

func NewEncryptionKey added in v0.0.5

func NewEncryptionKey() (*EncryptionKey, error)

func (*EncryptionKey) DecryptData added in v0.0.5

func (key *EncryptionKey) DecryptData(data []byte) ([]byte, error)

func (*EncryptionKey) DecryptMeta added in v0.0.5

func (key *EncryptionKey) DecryptMeta(metadata EncryptedString) (string, error)

func (*EncryptionKey) EncryptData added in v0.0.5

func (key *EncryptionKey) EncryptData(data []byte) []byte

func (*EncryptionKey) EncryptMeta added in v0.0.5

func (key *EncryptionKey) EncryptMeta(metadata string) EncryptedString

func (*EncryptionKey) ToString added in v0.0.5

func (key *EncryptionKey) ToString() string

func (*EncryptionKey) ToStringWithAuthVersion added in v0.0.5

func (key *EncryptionKey) ToStringWithAuthVersion(authVersion int) string

type MasterKey added in v0.0.5

type MasterKey struct {
	Bytes        [64]byte
	DerivedBytes [32]byte
	// contains filtered or unexported fields
}

func NewMasterKey added in v0.0.5

func NewMasterKey(key [64]byte) (*MasterKey, error)

func (*MasterKey) DecryptMeta added in v0.0.5

func (m *MasterKey) DecryptMeta(metadata EncryptedString) (string, error)

func (*MasterKey) DecryptMetaV1 added in v0.0.5

func (m *MasterKey) DecryptMetaV1(metadata EncryptedString) (string, error)

func (*MasterKey) DecryptMetaV2 added in v0.0.5

func (m *MasterKey) DecryptMetaV2(metadata EncryptedString) (string, error)

func (*MasterKey) EncryptMeta added in v0.0.5

func (m *MasterKey) EncryptMeta(metadata string) EncryptedString

type MasterKeys added in v0.0.5

type MasterKeys []MasterKey

v1 and v2

func NewMasterKeys added in v0.0.5

func NewMasterKeys(encryptionKey *MasterKey, stringKeys string) (MasterKeys, error)

func (*MasterKeys) DecryptMeta added in v0.0.5

func (ms *MasterKeys) DecryptMeta(encrypted EncryptedString) (string, error)

DecryptMeta should be avoided, and Filen.DecryptMeta should be used instead, but this is necessary for RSA Keypair decryption

func (*MasterKeys) DecryptMetaV1 added in v0.0.5

func (ms *MasterKeys) DecryptMetaV1(metadata EncryptedString) (string, error)

func (*MasterKeys) DecryptMetaV2 added in v0.0.5

func (ms *MasterKeys) DecryptMetaV2(metadata EncryptedString) (string, error)

func (*MasterKeys) EncryptMeta added in v0.0.5

func (ms *MasterKeys) EncryptMeta(metadata string) EncryptedString

Jump to

Keyboard shortcuts

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