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 ¶
- func DecryptData(data []byte, key []byte) ([]byte, error)
- func DecryptMetadata(metadata EncryptedString, key []byte) (string, error)
- func DecryptMetadataAllKeys(metadata EncryptedString, keys [][]byte) (string, error)
- func DeriveKeyFromPassword(password string, salt string, iterations int, bitLength int) []byte
- func EncryptData(data []byte, key []byte) ([]byte, error)
- func GeneratePasswordAndMasterKey(rawPassword string, salt string) (derivedMasterKey []byte, derivedPassword string)
- func GenerateRandomString(length int) string
- func RunSHA521(b []byte) []byte
- type AllKeysFailedError
- type EncryptedString
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptData ¶
DecryptData decrypts file data.
func DecryptMetadata ¶
func DecryptMetadata(metadata EncryptedString, key []byte) (string, error)
DecryptMetadata decrypts metadata.
func DecryptMetadataAllKeys ¶
func DecryptMetadataAllKeys(metadata EncryptedString, keys [][]byte) (string, error)
DecryptMetadataAllKeys calls DecryptMetadata using all provided keys.
func DeriveKeyFromPassword ¶
DeriveKeyFromPassword derives a valid key from the raw password.
func EncryptData ¶
EncryptData encrypts file data.
func GeneratePasswordAndMasterKey ¶
func GeneratePasswordAndMasterKey(rawPassword string, salt string) (derivedMasterKey []byte, derivedPassword string)
GeneratePasswordAndMasterKey derives a password and a master key from the raw password (used for login).
func GenerateRandomString ¶
GenerateRandomString generates a cryptographically secure random string based on a selection of alphanumerical characters.
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 EncryptedString ¶
type EncryptedString string
EncryptedString denotes that a string is encrypted and can't be used meaningfully before being decrypted.
func EncryptMetadata ¶
func EncryptMetadata(metadata string, key []byte) (EncryptedString, error)
EncryptMetadata encrypts metadata.