Skip to content

Commit 82d8a2d

Browse files
committed
Documentation.
1 parent 811e6e6 commit 82d8a2d

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

vfs/adiantum/api.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
// Package adiantum wraps an SQLite VFS to offer encryption at rest.
22
//
33
// The "adiantum" [vfs.VFS] wraps the default VFS using the
4-
// Adiantum tweakable length-preserving encryption.
4+
// Adiantum tweakable, length-preserving encryption.
55
//
6-
// Importing package adiantum registers that VFS.
6+
// Importing package adiantum registers that VFS:
77
//
88
// import _ "github.com/ncruces/go-sqlite3/vfs/adiantum"
99
//
1010
// To open an encrypted database you need to provide key material.
11-
// This is done through [URI] parameters:
11+
//
12+
// The simplest way to do that is to specify the key through an [URI] parameter:
1213
//
1314
// - key: key material in binary (32 bytes)
1415
// - hexkey: key material in hex (64 hex digits)
1516
// - textkey: key material in text (any length)
1617
//
18+
// However, this makes your key easily accessible to other parts of
19+
// your application (e.g. through [vfs.Filename.URIParameters]).
20+
//
21+
// To avoid this, use any of the following PRAGMAs:
22+
//
23+
// PRAGMA key='D41d8cD98f00b204e9800998eCf8427e';
24+
// PRAGMA hexkey='e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
25+
// PRAGMA textkey='your-secret-key';
26+
//
1727
// [URI]: https://sqlite.org/uri.html
1828
package adiantum
1929

vfs/adiantum/hbsh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ func (h *hbshFile) Pragma(name string, value string) (string, error) {
8787

8888
func (h *hbshFile) ReadAt(p []byte, off int64) (n int, err error) {
8989
if h.hbsh == nil {
90-
// If it's trying to read the header, pretend the file is empty,
91-
// so the key can be specified later.
9290
if off == 0 && len(p) == 100 {
91+
// SQLite is trying to read the header of a database.
92+
// Pretend the file is empty so the key can be specified later.
9393
return 0, io.EOF
9494
}
9595
return 0, sqlite3.CANTOPEN

vfs/memdb/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// among multiple database connections in the same process,
55
// as long as the database name begins with "/".
66
//
7-
// Importing package memdb registers the VFS.
7+
// Importing package memdb registers the VFS:
88
//
99
// import _ "github.com/ncruces/go-sqlite3/vfs/memdb"
1010
package memdb

vfs/readervfs/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// The "reader" [vfs.VFS] permits accessing any [io.ReaderAt]
44
// as an immutable SQLite database.
55
//
6-
// Importing package readervfs registers the VFS.
6+
// Importing package readervfs registers the VFS:
77
//
88
// import _ "github.com/ncruces/go-sqlite3/vfs/readervfs"
99
package readervfs

0 commit comments

Comments
 (0)