https://github.com/anatol/luks.go
Pure Golang library to manage LUKS partitions
https://github.com/anatol/luks.go
Last synced: 3 months ago
JSON representation
Pure Golang library to manage LUKS partitions
- Host: GitHub
- URL: https://github.com/anatol/luks.go
- Owner: anatol
- License: mit
- Created: 2020-08-21T23:36:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-07T05:30:18.000Z (over 1 year ago)
- Last Synced: 2024-10-14T20:32:22.628Z (about 1 year ago)
- Language: Go
- Size: 107 KB
- Stars: 86
- Watchers: 6
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-cn - luks.go
- awesome-go-plus - luks.go - Pure Golang library to manage LUKS partitions.  (Security / HTTP Clients)
- fucking-awesome-go - luks.go - Pure Golang library to manage LUKS partitions. (Security / HTTP Clients)
- awesome-go - anatol/luks.go
- awesome-go - luks.go - Pure Golang library to manage LUKS partitions. (Security / HTTP Clients)
- awesome-go-with-stars - luks.go - Pure Golang library to manage LUKS partitions. (Security / HTTP Clients)
- awesome-go - luks.go - Pure Golang library to manage LUKS partitions. (Security / HTTP Clients)
README
# Pure Go library for LUKS volume management
`luks.go` is a pure-Go library that helps to deal with LUKS-encrypted volumes.
Currently, this library is focusing on the read-only path i.e. unlocking a partition without doing
any modifications to LUKS metadata header.
Here is an example that demonstrates the API usage:
```go
dev, err := luks.Open("/dev/sda1")
if err != nil {
// handle error
}
defer dev.Close()
// set LUKS flags before unlocking the volume
if err := dev.FlagsAdd(luks.FlagAllowDiscards); err != nil {
log.Print(err)
}
// UnsealVolume+SetupMapper is equivalent of `cryptsetup open /dev/sda1 volumename`
volume, err = dev.UnsealVolume(/* slot */ 0, []byte("password"))
if err == luks.ErrPassphraseDoesNotMatch {
log.Printf("The password is incorrect")
} else if err != nil {
log.Print(err)
} else {
err := volume.SetupMapper("volumename")
// at this point system should have a file `/dev/mapper/volumename`.
}
// equivalent of `cryptsetup close volumename`
if err := luks.Lock("volumename"); err != nil {
log.Print(err)
}
```
## License
See [LICENSE](LICENSE).