Skip to content

Commit

Permalink
Merge pull request #277 from valentindavid/valentindavid/missing-inli…
Browse files Browse the repository at this point in the history
…ne-crypto-engine

crypt.go: do not forget option InlineCryptoEngine
  • Loading branch information
chrisccoulson authored Dec 1, 2023
2 parents 14fd3d6 + 43ea3f9 commit 22aa666
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@ func InitializeLUKS2Container(devicePath, label string, key DiskUnlockKey, optio
MetadataKiBSize: options.MetadataKiBSize,
KeyslotsAreaKiBSize: options.KeyslotsAreaKiBSize,
KDFOptions: options.KDFOptions,
InitialKeyslotName: options.InitialKeyslotName}
InitialKeyslotName: options.InitialKeyslotName,
InlineCryptoEngine: options.InlineCryptoEngine}
}

if options.KDFOptions == nil {
Expand Down
11 changes: 11 additions & 0 deletions crypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3540,6 +3540,11 @@ var _ = Suite(&cryptSuiteUnmockedExpensive{})

func (s *cryptSuiteUnmockedBase) testInitializeLUKS2Container(c *C, options *InitializeLUKS2ContainerOptions) {
restore := MockLUKS2Format(func(devicePath, label string, key []byte, opts *luks2.FormatOptions) error {
// We only test that InlineCryptoEngine is passed
// through. But it will likely not work, so we disable
// it.
c.Check(opts.InlineCryptoEngine, Equals, options != nil && options.InlineCryptoEngine)
opts.InlineCryptoEngine = false
var expectedTargetDuration time.Duration
if options != nil && options.KDFOptions != nil {
expectedTargetDuration = options.KDFOptions.TargetDuration
Expand Down Expand Up @@ -3652,6 +3657,12 @@ func (s *cryptSuiteUnmocked) TestInitializeLUKS2ContainerWithCustomKDFIterations
KDFOptions: &KDFOptions{MemoryKiB: 32, ForceIterations: 8}})
}

func (s *cryptSuiteUnmocked) TestInitializeLUKS2ContainerInlineCryptoEngine(c *C) {
s.testInitializeLUKS2Container(c, &InitializeLUKS2ContainerOptions{
InlineCryptoEngine: true,
})
}

type testAddLUKS2ContainerUnlockKeyUnmockedData struct {
keyslotName string
options *KDFOptions
Expand Down

0 comments on commit 22aa666

Please sign in to comment.