Skip to content

Commit

Permalink
feat: bring disk encryption support
Browse files Browse the repository at this point in the history
Mostly copy-paste from `v1` of `go-blockdevice`, but with some fixes to
adapt to new code in other places.

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Aug 22, 2024
1 parent bc73f6d commit 8ea1320
Show file tree
Hide file tree
Showing 16 changed files with 932 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-08-20T10:44:02Z by kres 7be2a05.
# Generated on 2024-08-22T10:15:10Z by kres 9cc7f48.

*
!internal
!blkid
!block
!encryption
!partitioning
!go.mod
!go.sum
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-08-20T12:11:08Z by kres 7be2a05.
# Generated on 2024-08-22T10:15:10Z by kres 9cc7f48.

ARG TOOLCHAIN

Expand Down Expand Up @@ -60,6 +60,7 @@ RUN --mount=type=cache,target=/go/pkg go mod verify
COPY ./internal ./internal
COPY ./blkid ./blkid
COPY ./block ./block
COPY ./encryption ./encryption
COPY ./partitioning ./partitioning
RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null

Expand Down
5 changes: 3 additions & 2 deletions blkid/internal/filesystems/luks/luks.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/siderolabs/go-blockdevice/v2/blkid/internal/magic"
"github.com/siderolabs/go-blockdevice/v2/blkid/internal/probe"
"github.com/siderolabs/go-blockdevice/v2/internal/luks2"
)

var luksMagic = magic.Magic{
Expand All @@ -37,13 +38,13 @@ func (p *Probe) Name() string {

// Probe runs the further inspection and returns the result if successful.
func (p *Probe) Probe(r probe.Reader, _ magic.Magic) (*probe.Result, error) {
buf := make([]byte, LUKS2HEADER_SIZE)
buf := make([]byte, luks2.LUKS2HEADER_SIZE)

if _, err := r.ReadAt(buf, 0); err != nil {
return nil, err
}

hdr := Luks2Header(buf)
hdr := luks2.Luks2Header(buf)

if hdr.Get_version() != 2 {
return nil, nil //nolint:nilnil
Expand Down
6 changes: 6 additions & 0 deletions encryption/encryption.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Package encryption provides abstraction level for various disk encryption methods.
package encryption
Loading

0 comments on commit 8ea1320

Please sign in to comment.