258 Commits

Author SHA1 Message Date
Miguel Pires
13209fc52c many: fix formatting w/ latest go version
Fix formatting when running the latest version (1.17) of gofmt.
2021-12-08 13:59:56 +00:00
Samuele Pedroni
81aa8c9d93 secboot: use latest secboot with tpm legacy platform and v2 fully optional (#10946)
this bumps the secboot version to the one with

tpm "legacy" platform key data support, this means using the
ActivateVolumeWithKeyData APIs even with TPM but still using
the non-JSON keys

v2 sealed keys use only when strictly necessary, otherwise
v1 keys are written

to prepare for this we reapply the changes from #10715 that were reverted in #10930
2021-10-21 14:39:39 +02:00
Samuele Pedroni
1264613b05 secboot: revert move to new version (revert #10715)
Merge pull request #10930 from anonymouse64/revert-10715-bump-secboot

Reverts #10715

Sadly the new version of secboot seems to auto-upgrade v1 keys to v2, which old recovery systems and even the currently published initrds/kernels do not understand so they fail to unlock the encrypted partitions in the initrd.

This PR includes #10929 which adds the following tests:
* test from stable snapd + stable kernel refreshing to snapd from the PR
* test from stable kernel + snapd from the PR

and for each variant then do something which triggers a reseal operation and a reboot to ensure that the new snapd will not break old recovery system kernels
2021-10-18 18:46:04 +02:00
Ian Johnson
40609c1cac Revert "secboot: move to new version" 2021-10-14 12:47:15 -05:00
Ian Johnson
7fedbe58f7 osutil/disks, many: switch to defining Partitions directly for MockDiskMapping
This will be necessary for more complicated test cases in the gadget package,
so time to rip this band-aid and get rid of the old methods.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-10-08 20:48:57 -05:00
Michael Vogt
e64a656b70 Merge pull request #10820 from mvo5/ice/check-encryption-no-longer-bool-2
devicestate: use EncryptionType
2021-09-27 13:35:20 +02:00
Michael Vogt
420e785432 secboot: run gofmt -s -w 2021-09-27 09:27:32 +02:00
Michael Vogt
0d2e49d8ea many: rename secboot.EncryptionTypeCryptsetup -> secboot.EncryptionTypeLUKS (thanks to Samuele) 2021-09-25 20:07:41 +02:00
Dimitri John Ledkov
a989e1bc13 secboot: spelling 2021-09-22 09:50:02 +01:00
Dimitri John Ledkov
91d15c658d secboot: add comment where keyfile came from
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
2021-09-22 09:19:32 +01:00
Michael Vogt
a7e9f3d16b many: make DeviceManager.checkEncryption() return EncryptionType
Instead of simply returning a "bool" from checkEncryption() return
a new encryption type that can be: None, Cryptsetup, DeviceSetupHook.

This prepares for the case when also need to support inline crypto
hardware like the Qualcomm ICE system that uses a DeviceSetupHook
instead of cryptsetup.
2021-09-21 18:27:07 +02:00
Dimitri John Ledkov
d52049308d secboot: read an array of enough looking mockSealedKeyObjects 2021-09-08 11:19:57 +01:00
Dimitri John Ledkov
65c170fa3c secboot: fix imports order 2021-09-08 10:17:56 +01:00
Dimitri John Ledkov
7740c8a9cd secboot: port to new snapcore/secboot/tpm2
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
2021-09-07 13:48:44 +01:00
Chris Coulson
3376b1946f secboot: port to snapcore/secboot/efi
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
2021-09-07 13:35:48 +01:00
Michael Vogt
ce472d819c secboot: tweak TestResealKey so that it's clearer why it fails 2021-09-07 12:41:26 +01:00
Miguel Pires
aa623a49ea many: remove unused parameters and returns 2021-09-02 17:44:34 +01:00
Miguel Pires
db9c63b734 many: remove unused code 2021-08-26 18:24:02 +01:00
Dimitri John Ledkov
e14ba8b7d4 secboot: remove duplicate import
Remove duplicate import, and use existing/long-standing snapcore
secboot import called sb.

Fixes: 37fc0edcdc

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
2021-08-20 12:26:11 +01:00
Michael Vogt
e331222b2f secboot: use half the mem for KDF in AddRecoveryKey
* osutil: rework TotalSystemMemory to TotalUsableMemory

This commit renames total TotalSystemMemory to TotalUsableMemory
and also changes the code to take the CmaTotal into account. This
is the memory reserved by the  "Contiguous Memory Allocator" and
it is not usable for normal processes. This kind of memory is
used e.g. by the framebuffer of the Raspberry Pi or by DSPs on
certain boards.

* secboot: use half the mem for KDF in AddRecoveryKey

Instead of benchmarking the KDF parameters for the recovery key
(which takes some time to run) we can also use defaults for the
KDF parameters. The defaults suggested by Chris are "4 iterations"
and half the usable memory. This commit implements the suggestions.

* secboot: update KDF memory heuristic

After discussing with Chris and Samuele we updated the KDF memory
heuristic so that it takes more parameters in mind. It now
considers the usable memory and substracts a hardcoded 384MB
that is required to have a working system (a bit of a conservative
estiamte) and then takes half of this for the KDF memory.

* osutil,secboot: fix typos

* secboot: add comment about minimum mem
2021-08-19 22:22:10 +02:00
Michael Vogt
1365ccf3fc secboot: switch main key KDF memory cost to 32KB
The main encryption key is high entropy 256bit already so there is
no need to use a strong KDF on top of this. There was a PR already
that switched this to 32MB but it turns out that 32KB is enough.
2021-08-19 13:44:19 +02:00
Michael Vogt
7e4934a94e vendor: move to snapshot-4c814e1 branch and set fixed KDF options
* vendor: move to snapshot-4c814e1 branch with KDF fixes

This commit moves our secboot code to the `snapshot-4c814e1` branch
that contains fixes around the KDF benchmarking. This will improve
the install performance.

* secboot: update code to latest api

* secboot: hardcode KDFOptions to avoid benchmarking them and speed up the process
2021-08-09 16:42:18 +02:00
Maciej Borzecki
37fc0edcdc boot: decouple model from seal/reseal handling via an auxiliary type
It is desired that the seal/reseal code only operates on the input provided in
modeenv rather than poking other external structures. The change decouples the
lower level code from accessing the model directly.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-11 13:16:53 +02:00
Samuele Pedroni
8c76d5fde8 Merge remote-tracking branch 'upstream/master' into HEAD 2021-05-27 11:19:20 +02:00
Michael Vogt
d319961250 secboot: improve error notice about dectivating the volume
Co-authored-by: Ian Johnson <person.uwsome@gmail.com>
2021-05-17 12:54:07 +02:00