encryptfs

package
v0.0.0-...-e5f5cd0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2025 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Implements a 9p file system encrypts its data on another 9p file server

Index

Constants

View Source
const PrivateKeyBits = 4096

Variables

View Source
var ErrInvalidKey = errors.New("invalid key")
View Source
var ErrMissingKey = errors.New("missing encryption key")

Functions

func GeneratePrivateKey

func GeneratePrivateKey(path string, bits int) (*rsa.PrivateKey, error)

func LoadPrivateKey

func LoadPrivateKey(path string) (*rsa.PrivateKey, error)

func PrivateKeyDecrypt

func PrivateKeyDecrypt(priv *rsa.PrivateKey, cipher []byte) ([]byte, error)

func PublicKeyEncrypt

func PublicKeyEncrypt(pub *rsa.PublicKey, msg []byte) ([]byte, error)

Types

type EncryptedFileSystem

type EncryptedFileSystem struct {
	DataMount    proxy.FileSystemMount // where to write all data (encrypted)
	KeysMount    proxy.FileSystemMount // where to write secret keys for DataMount files (encrypted)
	DecryptMount proxy.FileSystemMount // where files are temporarily unencrypted for reads and writes
	PrivKey      *rsa.PrivateKey       // required
}

Basic encrypted file system overlay:

  • DataMount is where all the encrypted data is stored. File names are NOT encrypted.
  • KeysMount is where all the encrypted keys are stored. File names are NOT encrypted. Used to decrypted DataMount.
  • DecryptMount is where all the "in-memory" opened files reside. Should be primarily something in memory or a secure location as opened files are decrypted to this location to support read-at locations
  • PrivKey is the private key used to decrypt the KeysMount.

PrivKey must be securely stored, but KeysMount and DataMount can be in untrusted locations.

func New

func New(privKey *rsa.PrivateKey, keysMount, dataMount, decryptMount proxy.FileSystemMount) *EncryptedFileSystem

func (*EncryptedFileSystem) CreateFile

func (f *EncryptedFileSystem) CreateFile(ctx context.Context, path string, flag ninep.OpenMode, mode ninep.Mode) (ninep.FileHandle, error)

func (*EncryptedFileSystem) Delete

func (f *EncryptedFileSystem) Delete(ctx context.Context, path string) error

func (*EncryptedFileSystem) Init

func (*EncryptedFileSystem) ListDir

func (*EncryptedFileSystem) MakeDir

func (f *EncryptedFileSystem) MakeDir(ctx context.Context, path string, mode ninep.Mode) error

func (*EncryptedFileSystem) OpenFile

func (f *EncryptedFileSystem) OpenFile(ctx context.Context, path string, flag ninep.OpenMode) (ninep.FileHandle, error)

func (*EncryptedFileSystem) Stat

func (f *EncryptedFileSystem) Stat(ctx context.Context, path string) (os.FileInfo, error)

func (*EncryptedFileSystem) WriteStat

func (f *EncryptedFileSystem) WriteStat(ctx context.Context, path string, s ninep.Stat) error

Jump to

Keyboard shortcuts

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