Documentation
¶
Index ¶
- Constants
- Variables
- func Create(base any, password []byte) ([]byte, error)
- func CreateFS(base any, aeadType AeadType, log2n int, password, masterkey []byte, ...) ([]byte, error)
- func CreateReverse(base any, password []byte) ([]byte, error)
- func MasterKey(base any, password []byte) ([]byte, error)
- func New(base any, password []byte) (fs.FS, error)
- func NewFS(base any, password []byte) (*internal.FS, error)
- func NewWithMasterKey(base any, masterkey []byte) (*internal.FS, error)
- func ParseMasterKey(input []byte) []byte
- func Passwd(base any, oldpass, newpass, masterkey []byte) ([]byte, error)
- func PrintMasterKey(key []byte, indent string, stdout, stderr io.Writer)
- func ReadPassword(fd int) []byte
- type AeadType
Constants ¶
const DefaultLog2N = 16
Default log2n parameter for Create and CreateReverse.
Variables ¶
var ( ErrInvalidFS = internal.ErrInvalidFS ErrBadPassword = internal.ErrBadPassword ErrDirNotEmpty = internal.ErrDirNotEmpty ErrMustBeAesSiv = internal.ErrMustBeAesSiv ErrNotDirectory = internal.ErrNotDirectory )
Common fscrypt errors.
var ( ErrBadDirIv = internal.ErrBadDirIv ErrBadKeySize = internal.ErrBadKeySize ErrUnsupportedVersion = internal.ErrUnsupportedVersion ErrUnknownAeadBackend = internal.ErrUnknownAeadBackend )
Extra fscrypt errors.
Functions ¶
func Create ¶ added in v0.2.0
Create a new gocryptfs.
"base" should be a writable FS-like object, like os.Root. Use os.OpenRoot to get one.
Returns the master key. Print it to user in hex then wipe it.
func CreateFS ¶ added in v0.2.0
func CreateFS(base any, aeadType AeadType, log2n int, password, masterkey []byte, reverse bool) ([]byte, error)
Advanced gocryptfs creation.
The default AeadType in gocryptfs is AeadTypeGcm.
log2n is log_2 scrypt N value, 10 <= log2n <= 28. The recommended value is 16 (DefaultLog2N).
"masterkey" should be nil, unless you know what you are doing.
Be sure to wipe the returned master key.
If "reverse" is true, "aeadType" must be AeadTypeSiv.
func CreateReverse ¶ added in v0.2.0
Create a new "reverse mode" gocryptfs.
"base" should be a writable FS-like object, like os.Root. Use os.OpenRoot to get one.
Returns the master key. Print it to user in hex then wipe it.
func MasterKey ¶ added in v0.2.0
Get master key of a certain FS. Make sure to wipe the returned key.
Should only be used in specialized tools.
func New ¶
New fscrypt instance. It implements fs.FS, fs.ReadDirFS, fs.StatFS.
"base" can be fs.FS or os.Root with gocryptfs content inside.
You can get a "base" by using os.DirFS or os.OpenRoot. Other fs.FS implementation also works.
Files opened implements fs.File and io.ReaderAt.
See also NewFS, [NewDuckFS], and ReadPassword.
May return ErrBadPassword, fs.ErrInvalid, or other errors.
func NewFS ¶ added in v0.2.0
New fscrypt instance, but returning pointer to internal.FS struct.
There are more public functions than fs.FS, but they are unstable. For a stable interface wrapper, use [duckfs.FS].
If your "base" has an OpenFile function (like os.Root.OpenFile), you can call internal.FS.OpenFile or internal.FS.Create, and the resulting file implements io.Writer, io.WriterAt.
The similar applies for internal.FS.Mkdir, etc.
For other writing functions like Chmod, use relative functions of your "base" and internal.FS.EncryptName.
func NewWithMasterKey ¶ added in v0.2.0
New fscrypt instance with explicit master key, useful for rescuing the file system.
Only use this in specialized tools.
func ParseMasterKey ¶ added in v0.2.0
Parse master key from user input, which is hex and may contain misc chars (dash, space, newline, quote).
Returns raw master key, make sure to wipe it.
May return nil indicating invalid input, like less than 64 hex digits.
func Passwd ¶ added in v0.2.0
Change password and/or masterkey of a gocryptfs.
"masterkey" can be nil, or an AeadTypeGcm key (32 bytes).
Be cautious supplying "masterkey", as changing master key doesn't require "oldpass", and a bad master key can break a fs irreversibly.
Automatically identifies reverse mode fs.
Returns the master key, print it to user once and wipe it.
func PrintMasterKey ¶ added in v0.2.0
Print the master key to stdout, and formatting (indent and dash) to stderr.
00000000-00000000-00000000-00000000- 00000000-00000000-00000000-00000000
Indent can be:
"\n "
Suggested io params: os.Stdout, os.Stderr, io.Discard, *os.File.
func ReadPassword ¶
Read password from commandline, hiding user input if possible.
Only fd 0 (stdin) is supported at the moment.
You may want to use golang.org/x/term.ReadPassword instead.
Be sure to wipe the returned password after use:
pw := fscrypt.ReadPassword(0)
fs_, err := fscrypt.New(os.DirFS("/tmp/crypt"), pw)
// wipe the password just after use, even before checking error from [New]
for i := range pw {
pw[i] = 0
}
if err != nil {
panic(err)
}
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
fscrypt-cat
command
|
|
|
fscrypt-http
command
|
|
|
fscrypt-init
command
|
|
|
fscrypt-ls
command
|
|
|
fscrypt-passwd
command
|
|