Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

many: move key data to key slots #14217

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
ba57663
t/n/m/uc-update-assets-secure: sign new grub also with old key
valentindavid Nov 24, 2023
1b82c06
go.mod: move to latest secboot/go-tpm2/go-efilib
mvo5 Sep 21, 2023
11eaefa
fixup! t/n/m/uc-update-assets-secure: sign new grub also with old key
valentindavid Jan 11, 2024
c0a1194
fixup! t/n/m/uc-update-assets-secure: sign new grub also with old key
valentindavid Jan 11, 2024
188bf17
fixup! go.mod: move to latest secboot/go-tpm2/go-efilib
valentindavid Jan 11, 2024
840b593
secboot: remove dead code
valentindavid Jan 23, 2024
380033f
fixup! secboot: remove dead code
valentindavid Jan 23, 2024
ed49858
many: attempt to use secboot api for new key format
valentindavid May 7, 2024
ea1de8a
fixup! many: attempt to use secboot api for new key format
valentindavid May 8, 2024
6c735df
fixup! many: attempt to use secboot api for new key format
valentindavid May 8, 2024
c85b2cf
actually write the tokens
valentindavid May 8, 2024
ae8a947
Keep on using files for keys
valentindavid May 15, 2024
5f4a9b7
fixes
valentindavid May 17, 2024
509c7e7
Reset slot in the end
valentindavid May 17, 2024
63d13f5
Fix saving of primary keys
valentindavid May 23, 2024
87f9cef
fix version of branch
valentindavid May 23, 2024
cbc7775
Fix hook protect key function
valentindavid May 23, 2024
e98b5fa
Allow both sealed object and key data to be stored
valentindavid May 24, 2024
6fab6c6
fixup format
valentindavid May 24, 2024
9ccf2ec
Fix test binary
valentindavid May 24, 2024
870c5fc
Remove dead code
valentindavid May 24, 2024
73826a7
Do not leave test files behind
valentindavid May 24, 2024
5113c81
fix nosecboot
valentindavid May 27, 2024
33b1fee
fix nosecboot
valentindavid May 27, 2024
c0a7304
fix hooks
valentindavid May 27, 2024
d109ec6
fix fmt
valentindavid May 27, 2024
eb3aba8
fix mac build
valentindavid May 28, 2024
8894917
fix nosecboot build
valentindavid May 28, 2024
7f65074
fixups
valentindavid May 28, 2024
98c7d68
fixups
valentindavid May 28, 2024
3e4ffcb
Allow reseal of tpm objects
valentindavid May 28, 2024
42747af
fixup reseal
valentindavid May 29, 2024
62699d8
Remove dead code
valentindavid May 29, 2024
bc03860
Use same primary key for fallback keys
valentindavid May 30, 2024
01e9596
fix nosecboot
valentindavid May 30, 2024
bec2d4b
fixup formatting
valentindavid May 30, 2024
3e89124
fix botched rebase
valentindavid Jun 3, 2024
0bf3a5a
fix build
valentindavid Jun 3, 2024
3cc52ea
fix test
valentindavid Jun 3, 2024
596547f
snapd.service: enable keyring sharing
valentindavid Jun 4, 2024
e439248
overlord/devicestate: manage old save key on factory reset
valentindavid Jun 4, 2024
f504882
secboot: add and remove recovery with new slots when possible
valentindavid Jun 4, 2024
39c3944
add some todos
valentindavid Jun 5, 2024
4b92d7c
secboot: fix enrolling of recovery key
valentindavid Jun 5, 2024
a5cfad3
overlord/devicestate: fix key slots management of save partition duri…
valentindavid Jun 7, 2024
26a8d4a
fixup! overlord/devicestate: fix key slots management of save partiti…
valentindavid Jun 7, 2024
780689e
fixup! overlord/devicestate: fix key slots management of save partiti…
valentindavid Jun 7, 2024
805d07a
overlord/devicestate: work-around missing crypsetup feature
valentindavid Jun 7, 2024
d093975
fixup! overlord/devicestate: work-around missing crypsetup feature
valentindavid Jun 7, 2024
4c0d1af
fixup! overlord/devicestate: work-around missing crypsetup feature
valentindavid Jun 10, 2024
8087595
secboot: fix reading of pcr index handle from key file
valentindavid Jun 10, 2024
adb7b3d
tests: test factory reset after update
valentindavid Jun 14, 2024
74988be
secboot: do not user boot modes yet
valentindavid Jun 20, 2024
36e7f0a
fakestore: add some missing features
valentindavid Jun 20, 2024
16f5c20
secboot: implement remodel with hooks
valentindavid Jun 20, 2024
2ca29d4
add spread tests for remodel with hooks
valentindavid Jun 20, 2024
31e83ce
fix go.sum
valentindavid Jun 21, 2024
4965295
fix formatting
valentindavid Jun 21, 2024
3a34069
fix shell
valentindavid Jun 21, 2024
1cb159f
fix nosecboot
valentindavid Jun 21, 2024
7ce6bf8
secboot: allow resealing of old hook keys
valentindavid Jun 24, 2024
5b44849
tests/nested/manual/core-factory-reset-new-secboot: force snakeoil ke…
valentindavid Jun 24, 2024
f60e20e
fixup! tests/nested/manual/core-factory-reset-new-secboot: force snak…
valentindavid Jun 25, 2024
5989b87
fix secboot import leaks
valentindavid Jun 25, 2024
96bc116
fixup! fix secboot import leaks
valentindavid Jun 25, 2024
164bf8c
fix nosecboot build
valentindavid Jun 25, 2024
1991500
tests/nested/manual/muinstaller-core: use built snapd snap
valentindavid Jun 25, 2024
60db907
fixup! tests/nested/manual/muinstaller-core: use built snapd snap
valentindavid Jun 26, 2024
859f094
Fix key slot name for fallback save key
valentindavid Jul 12, 2024
87f0b5e
Add AAD to data passed to fde-setup and fde-reveal-key
valentindavid Jul 12, 2024
78599ab
Use plainkey for default save key
valentindavid Jul 12, 2024
6d6852e
go.mod: update secboot back to master
valentindavid Jul 12, 2024
87fdce5
overlord: add fdemgr
valentindavid Jul 17, 2024
56489ab
many: move key data to key slots
valentindavid Jul 19, 2024
7809434
fixup formatting
valentindavid Jul 19, 2024
012e8ce
fixup formatting
valentindavid Jul 19, 2024
2dc97d0
fix compilation
valentindavid Jul 19, 2024
17f9d6b
fix test on nosecboot
valentindavid Jul 19, 2024
1ce0a5a
fixup compilation
valentindavid Jul 19, 2024
19201f8
fixup
valentindavid Jul 19, 2024
01af2f6
fixup role
valentindavid Jul 22, 2024
68efc8e
unlock without file when legacy key file does not exist
valentindavid Jul 22, 2024
38e0b29
use correct boot mode
valentindavid Jul 22, 2024
84c5d46
fixup formatting
valentindavid Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions boot/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/snapcore/snapd/gadget/device"
"github.com/snapcore/snapd/logger"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/secboot/keys"
"github.com/snapcore/snapd/secboot"
"github.com/snapcore/snapd/strutil"
)

Expand Down Expand Up @@ -256,7 +256,7 @@ func isAssetHashTrackedInMap(bam bootAssetsMap, assetName, assetHash string) boo
type TrustedAssetsInstallObserver interface {
BootLoaderSupportsEfiVariables() bool
ObserveExistingTrustedRecoveryAssets(recoveryRootDir string) error
ChosenEncryptionKeys(key, saveKey keys.EncryptionKey)
ChosenEncryptionKeys(resetter, saveResetter secboot.KeyResetter)
UpdateBootEntry() error
Observe(op gadget.ContentOperation, partRole, root, relativeTarget string, data *gadget.ContentChange) (gadget.ContentChangeAction, error)
}
Expand All @@ -279,9 +279,9 @@ type trustedAssetsInstallObserverImpl struct {
trustedRecoveryAssets map[string]string
trackedRecoveryAssets bootAssetsMap

useEncryption bool
dataEncryptionKey keys.EncryptionKey
saveEncryptionKey keys.EncryptionKey
useEncryption bool
dataKeyResetter secboot.KeyResetter
saveKeyResetter secboot.KeyResetter

seedBootloader bootloader.Bootloader
}
Expand Down Expand Up @@ -368,10 +368,10 @@ func (o *trustedAssetsInstallObserverImpl) currentTrustedRecoveryBootAssetsMap()
return o.trackedRecoveryAssets
}

func (o *trustedAssetsInstallObserverImpl) ChosenEncryptionKeys(key, saveKey keys.EncryptionKey) {
func (o *trustedAssetsInstallObserverImpl) ChosenEncryptionKeys(resetter, saveResetter secboot.KeyResetter) {
o.useEncryption = true
o.dataEncryptionKey = key
o.saveEncryptionKey = saveKey
o.dataKeyResetter = resetter
o.saveKeyResetter = saveResetter
}

func (o *trustedAssetsInstallObserverImpl) UpdateBootEntry() error {
Expand Down
19 changes: 12 additions & 7 deletions boot/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/snapcore/snapd/gadget"
"github.com/snapcore/snapd/logger"
"github.com/snapcore/snapd/secboot"
"github.com/snapcore/snapd/secboot/keys"
"github.com/snapcore/snapd/seed"
"github.com/snapcore/snapd/snap"
"github.com/snapcore/snapd/testutil"
Expand Down Expand Up @@ -474,13 +473,16 @@ func (s *assetsSuite) TestInstallObserverNonTrustedBootloader(c *C) {
obs, err := boot.TrustedAssetsInstallObserverForModel(uc20Model, d, useEncryption)
c.Assert(err, IsNil)
c.Assert(obs, NotNil)
obs.ChosenEncryptionKeys(keys.EncryptionKey{1, 2, 3, 4}, keys.EncryptionKey{5, 6, 7, 8})

dataResetter := &secboot.MockKeyResetter{}
saveResetter := &secboot.MockKeyResetter{}
obs.ChosenEncryptionKeys(dataResetter, saveResetter)

observerImpl, ok := obs.(*boot.TrustedAssetsInstallObserverImpl)
c.Assert(ok, Equals, true)

c.Check(observerImpl.CurrentDataEncryptionKey(), DeepEquals, keys.EncryptionKey{1, 2, 3, 4})
c.Check(observerImpl.CurrentSaveEncryptionKey(), DeepEquals, keys.EncryptionKey{5, 6, 7, 8})
c.Check(observerImpl.CurrentDataKeyResetter(), Equals, dataResetter)
c.Check(observerImpl.CurrentSaveKeyResetter(), Equals, saveResetter)
}

func (s *assetsSuite) TestInstallObserverTrustedButNoAssets(c *C) {
Expand All @@ -499,13 +501,16 @@ func (s *assetsSuite) TestInstallObserverTrustedButNoAssets(c *C) {
obs, err := boot.TrustedAssetsInstallObserverForModel(uc20Model, d, useEncryption)
c.Assert(err, IsNil)
c.Assert(obs, NotNil)
obs.ChosenEncryptionKeys(keys.EncryptionKey{1, 2, 3, 4}, keys.EncryptionKey{5, 6, 7, 8})

dataResetter := &secboot.MockKeyResetter{}
saveResetter := &secboot.MockKeyResetter{}
obs.ChosenEncryptionKeys(dataResetter, saveResetter)

observerImpl, ok := obs.(*boot.TrustedAssetsInstallObserverImpl)
c.Assert(ok, Equals, true)

c.Check(observerImpl.CurrentDataEncryptionKey(), DeepEquals, keys.EncryptionKey{1, 2, 3, 4})
c.Check(observerImpl.CurrentSaveEncryptionKey(), DeepEquals, keys.EncryptionKey{5, 6, 7, 8})
c.Check(observerImpl.CurrentDataKeyResetter(), Equals, dataResetter)
c.Check(observerImpl.CurrentSaveKeyResetter(), Equals, saveResetter)
}

func (s *assetsSuite) TestInstallObserverTrustedReuseNameErr(c *C) {
Expand Down
8 changes: 4 additions & 4 deletions boot/bootstate20.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2019-2023 Canonical Ltd
* Copyright (C) 2019-2024 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
Expand Down Expand Up @@ -69,12 +69,12 @@ func modeenvUnlock() {
modeenvMu.Unlock()
}

func isModeeenvLocked() bool {
func IsModeeenvLocked() bool {
return atomic.LoadInt32(&modeenvLocked) == 1
}

func loadModeenv() (*Modeenv, error) {
if !isModeeenvLocked() {
if !IsModeeenvLocked() {
return nil, fmt.Errorf("internal error: cannot read modeenv without the lock")
}
modeenv, err := ReadModeenv("")
Expand Down Expand Up @@ -184,7 +184,7 @@ func newBootStateUpdate20(m *Modeenv) (*bootStateUpdate20, error) {

// commit will write out boot state persistently to disk.
func (u20 *bootStateUpdate20) commit() error {
if !isModeeenvLocked() {
if !IsModeeenvLocked() {
return fmt.Errorf("internal error: cannot commit modeenv without the lock")
}

Expand Down
8 changes: 5 additions & 3 deletions boot/export_sb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package boot

import (
"context"

"github.com/canonical/go-efilib"
"github.com/canonical/go-efilib/linux"

Expand All @@ -33,19 +35,19 @@ var (
SetEfiBootOrderVariable = setEfiBootOrderVariable
)

func MockEfiListVariables(f func() ([]efi.VariableDescriptor, error)) (restore func()) {
func MockEfiListVariables(f func(ctx context.Context) ([]efi.VariableDescriptor, error)) (restore func()) {
restore = testutil.Backup(&efiListVariables)
efiListVariables = f
return restore
}

func MockEfiReadVariable(f func(name string, guid efi.GUID) ([]byte, efi.VariableAttributes, error)) (restore func()) {
func MockEfiReadVariable(f func(ctx context.Context, name string, guid efi.GUID) ([]byte, efi.VariableAttributes, error)) (restore func()) {
restore = testutil.Backup(&efiReadVariable)
efiReadVariable = f
return restore
}

func MockEfiWriteVariable(f func(name string, guid efi.GUID, attrs efi.VariableAttributes, data []byte) error) (restore func()) {
func MockEfiWriteVariable(f func(ctx context.Context, name string, guid efi.GUID, attrs efi.VariableAttributes, data []byte) error) (restore func()) {
restore = testutil.Backup(&efiWriteVariable)
efiWriteVariable = f
return restore
Expand Down
17 changes: 8 additions & 9 deletions boot/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/snapcore/snapd/bootloader"
"github.com/snapcore/snapd/kernel/fde"
"github.com/snapcore/snapd/secboot"
"github.com/snapcore/snapd/secboot/keys"
"github.com/snapcore/snapd/seed"
"github.com/snapcore/snapd/snap"
"github.com/snapcore/snapd/testutil"
Expand Down Expand Up @@ -104,12 +103,12 @@ func (o *trustedAssetsInstallObserverImpl) CurrentTrustedRecoveryBootAssetsMap()
return o.currentTrustedRecoveryBootAssetsMap()
}

func (o *trustedAssetsInstallObserverImpl) CurrentDataEncryptionKey() keys.EncryptionKey {
return o.dataEncryptionKey
func (o *TrustedAssetsInstallObserverImpl) CurrentDataKeyResetter() secboot.KeyResetter {
return o.dataKeyResetter
}

func (o *trustedAssetsInstallObserverImpl) CurrentSaveEncryptionKey() keys.EncryptionKey {
return o.saveEncryptionKey
func (o *TrustedAssetsInstallObserverImpl) CurrentSaveKeyResetter() secboot.KeyResetter {
return o.saveKeyResetter
}

func MockSecbootProvisionTPM(f func(mode secboot.TPMProvisionMode, lockoutAuthFile string) error) (restore func()) {
Expand All @@ -118,7 +117,7 @@ func MockSecbootProvisionTPM(f func(mode secboot.TPMProvisionMode, lockoutAuthFi
return restore
}

func MockSecbootSealKeys(f func(keys []secboot.SealKeyRequest, params *secboot.SealKeysParams) error) (restore func()) {
func MockSecbootSealKeys(f func(keys []secboot.SealKeyRequest, params *secboot.SealKeysParams) ([]byte, error)) (restore func()) {
old := secbootSealKeys
secbootSealKeys = f
return func() {
Expand Down Expand Up @@ -253,10 +252,10 @@ func MockRunFDESetupHook(f fde.RunSetupHookFunc) (restore func()) {
}

func MockResealKeyToModeenvUsingFDESetupHook(f func(string, *Modeenv, bool) error) (restore func()) {
old := resealKeyToModeenvUsingFDESetupHook
resealKeyToModeenvUsingFDESetupHook = f
old := ResealKeyToModeenvUsingFDESetupHook
ResealKeyToModeenvUsingFDESetupHook = f
return func() {
resealKeyToModeenvUsingFDESetupHook = old
ResealKeyToModeenvUsingFDESetupHook = old
}
}

Expand Down
2 changes: 1 addition & 1 deletion boot/makebootable.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func makeRunnableSystem(model *asserts.Model, bootWith *BootableSet, observer Tr
flags.SnapsDir = snapBlobDir
}
// seal the encryption key to the parameters specified in modeenv
if err := sealKeyToModeenv(observerImpl.dataEncryptionKey, observerImpl.saveEncryptionKey, model, modeenv, flags); err != nil {
if err := sealKeyToModeenv(observerImpl.dataKeyResetter, observerImpl.saveKeyResetter, model, modeenv, flags); err != nil {
return err
}
}
Expand Down
72 changes: 28 additions & 44 deletions boot/makebootable_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2014-2022 Canonical Ltd
* Copyright (C) 2014-2022, 2024 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
Expand Down Expand Up @@ -40,7 +40,6 @@ import (
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/release"
"github.com/snapcore/snapd/secboot"
"github.com/snapcore/snapd/secboot/keys"
"github.com/snapcore/snapd/seed"
"github.com/snapcore/snapd/snap"
"github.com/snapcore/snapd/snap/snapfile"
Expand Down Expand Up @@ -627,14 +626,10 @@ version: 5.0
err = obs.ObserveExistingTrustedRecoveryAssets(boot.InitramfsUbuntuSeedDir)
c.Assert(err, IsNil)

// set encryption key
myKey := keys.EncryptionKey{}
myKey2 := keys.EncryptionKey{}
for i := range myKey {
myKey[i] = byte(i)
myKey2[i] = byte(128 + i)
}
obs.ChosenEncryptionKeys(myKey, myKey2)
// set key resetter
dataResetter := &secboot.MockKeyResetter{}
saveResetter := &secboot.MockKeyResetter{}
obs.ChosenEncryptionKeys(dataResetter, saveResetter)

// set a mock recovery kernel
readSystemEssentialCalls := 0
Expand Down Expand Up @@ -699,38 +694,30 @@ version: 5.0

// set mock key sealing
sealKeysCalls := 0
restore = boot.MockSecbootSealKeys(func(keys []secboot.SealKeyRequest, params *secboot.SealKeysParams) error {
restore = boot.MockSecbootSealKeys(func(keys []secboot.SealKeyRequest, params *secboot.SealKeysParams) ([]byte, error) {
c.Assert(provisionCalls, Equals, 1, Commentf("TPM must have been provisioned before"))
sealKeysCalls++
switch sealKeysCalls {
case 1:
c.Check(keys, HasLen, 1)
c.Check(keys[0].Key, DeepEquals, myKey)
c.Check(keys[0].KeyFile, Equals,
filepath.Join(s.rootdir, "/run/mnt/ubuntu-boot/device/fde/ubuntu-data.sealed-key"))
c.Check(keys[0].Resetter, Equals, dataResetter)
c.Check(keys[0].KeyFile, Equals, "")
if factoryReset {
c.Check(params.PCRPolicyCounterHandle, Equals, secboot.AltRunObjectPCRPolicyCounterHandle)
} else {
c.Check(params.PCRPolicyCounterHandle, Equals, secboot.RunObjectPCRPolicyCounterHandle)
}
case 2:
c.Check(keys, HasLen, 2)
c.Check(keys[0].Key, DeepEquals, myKey)
c.Check(keys[1].Key, DeepEquals, myKey2)
c.Check(keys[0].KeyFile, Equals,
filepath.Join(s.rootdir,
"/run/mnt/ubuntu-seed/device/fde/ubuntu-data.recovery.sealed-key"))
c.Check(keys[0].Resetter, Equals, dataResetter)
c.Check(keys[0].KeyFile, Equals, "")
c.Check(keys[1].Resetter, Equals, saveResetter)
if factoryReset {
c.Check(params.PCRPolicyCounterHandle, Equals, secboot.AltFallbackObjectPCRPolicyCounterHandle)
c.Check(keys[1].KeyFile, Equals,
filepath.Join(s.rootdir,
"/run/mnt/ubuntu-seed/device/fde/ubuntu-save.recovery.sealed-key.factory-reset"))

c.Check(keys[1].KeyFile, Equals, "")
} else {
c.Check(params.PCRPolicyCounterHandle, Equals, secboot.FallbackObjectPCRPolicyCounterHandle)
c.Check(keys[1].KeyFile, Equals,
filepath.Join(s.rootdir,
"/run/mnt/ubuntu-seed/device/fde/ubuntu-save.recovery.sealed-key"))
c.Check(keys[1].KeyFile, Equals, "")
}
default:
c.Errorf("unexpected additional call to secboot.SealKeys (call # %d)", sealKeysCalls)
Expand Down Expand Up @@ -783,7 +770,7 @@ version: 5.0

c.Assert(params.ModelParams[0].Model.Model(), Equals, "my-model-uc20")

return nil
return nil, nil
})
defer restore()

Expand Down Expand Up @@ -1152,14 +1139,10 @@ version: 5.0
err = obs.ObserveExistingTrustedRecoveryAssets(boot.InitramfsUbuntuSeedDir)
c.Assert(err, IsNil)

// set encryption key
myKey := keys.EncryptionKey{}
myKey2 := keys.EncryptionKey{}
for i := range myKey {
myKey[i] = byte(i)
myKey2[i] = byte(128 + i)
}
obs.ChosenEncryptionKeys(myKey, myKey2)
// set key resetter
dataResetter := &secboot.MockKeyResetter{}
saveResetter := &secboot.MockKeyResetter{}
obs.ChosenEncryptionKeys(dataResetter, saveResetter)

// set a mock recovery kernel
readSystemEssentialCalls := 0
Expand All @@ -1179,16 +1162,15 @@ version: 5.0
defer restore()
// set mock key sealing
sealKeysCalls := 0
restore = boot.MockSecbootSealKeys(func(keys []secboot.SealKeyRequest, params *secboot.SealKeysParams) error {
restore = boot.MockSecbootSealKeys(func(keys []secboot.SealKeyRequest, params *secboot.SealKeysParams) ([]byte, error) {
sealKeysCalls++
switch sealKeysCalls {
case 1:
c.Check(keys, HasLen, 1)
c.Check(keys[0].Key, DeepEquals, myKey)
c.Check(keys[0].Resetter, Equals, dataResetter)
case 2:
c.Check(keys, HasLen, 2)
c.Check(keys[0].Key, DeepEquals, myKey)
c.Check(keys[1].Key, DeepEquals, myKey2)
c.Check(keys, HasLen, 1)
c.Check(keys[0].Resetter, Equals, saveResetter)
default:
c.Errorf("unexpected additional call to secboot.SealKeys (call # %d)", sealKeysCalls)
}
Expand Down Expand Up @@ -1217,7 +1199,7 @@ version: 5.0
})
c.Assert(params.ModelParams[0].Model.Model(), Equals, "my-model-uc20")

return fmt.Errorf("seal error")
return nil, fmt.Errorf("seal error")
})
defer restore()

Expand Down Expand Up @@ -1350,7 +1332,9 @@ version: 5.0
err = obs.ObserveExistingTrustedRecoveryAssets(boot.InitramfsUbuntuSeedDir)
c.Assert(err, IsNil)

obs.ChosenEncryptionKeys(keys.EncryptionKey{}, keys.EncryptionKey{})
dataResetter := &secboot.MockKeyResetter{}
saveResetter := &secboot.MockKeyResetter{}
obs.ChosenEncryptionKeys(dataResetter, saveResetter)

// set a mock recovery kernel
readSystemEssentialCalls := 0
Expand All @@ -1370,7 +1354,7 @@ version: 5.0
defer restore()
// set mock key sealing
sealKeysCalls := 0
restore = boot.MockSecbootSealKeys(func(keys []secboot.SealKeyRequest, params *secboot.SealKeysParams) error {
restore = boot.MockSecbootSealKeys(func(keys []secboot.SealKeyRequest, params *secboot.SealKeysParams) ([]byte, error) {
sealKeysCalls++
switch sealKeysCalls {
case 1, 2:
Expand All @@ -1394,7 +1378,7 @@ version: 5.0

c.Assert(params.ModelParams[0].Model.Model(), Equals, "my-model-uc20")

return nil
return nil, nil
})
defer restore()

Expand Down
Loading
Loading