crypto

package
v0.0.0-...-11ccece Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: AGPL-3.0 Imports: 10 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 DecryptData

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

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

func DeriveKeyFromPassword(password string, salt string, iterations int, bitLength int) []byte

DeriveKeyFromPassword derives a valid key from the raw password.

func EncryptData

func EncryptData(data []byte, key []byte) ([]byte, error)

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

func GenerateRandomString(length int) string

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

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 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.

Jump to

Keyboard shortcuts

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