mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-01 19:46:07 -04:00
cryptsetup: unify code (#2043)
* Add common backend for interacting with cryptsetup * Use common cryptsetup backend in bootstrapper * Use common cryptsetup backend in disk-mapper * Use common cryptsetup backend in csi lib --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
f52c6752e2
commit
ac1128d07f
34 changed files with 1061 additions and 1307 deletions
|
@ -22,7 +22,7 @@ type Mounter interface {
|
|||
|
||||
// DeviceMapper is an interface for device mapping operations.
|
||||
type DeviceMapper interface {
|
||||
DiskUUID() string
|
||||
DiskUUID() (string, error)
|
||||
FormatDisk(passphrase string) error
|
||||
MapDisk(target string, passphrase string) error
|
||||
UnmapDisk(target string) error
|
||||
|
|
|
@ -78,7 +78,10 @@ func New(log *logger.Logger, csp string, diskPath string, fs afero.Afero,
|
|||
// PrepareExistingDisk requests and waits for a decryption key to remap the encrypted state disk.
|
||||
// Once the disk is mapped, the function taints the node as initialized by updating it's PCRs.
|
||||
func (s *Manager) PrepareExistingDisk(recover RecoveryDoer) error {
|
||||
uuid := s.mapper.DiskUUID()
|
||||
uuid, err := s.mapper.DiskUUID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.log.With(zap.String("uuid", uuid)).Infof("Preparing existing state disk")
|
||||
endpoint := net.JoinHostPort("0.0.0.0", strconv.Itoa(constants.RecoveryPort))
|
||||
|
||||
|
@ -124,7 +127,8 @@ func (s *Manager) PrepareExistingDisk(recover RecoveryDoer) error {
|
|||
|
||||
// PrepareNewDisk prepares an instances state disk by formatting the disk as a LUKS device using a random passphrase.
|
||||
func (s *Manager) PrepareNewDisk() error {
|
||||
s.log.With(zap.String("uuid", s.mapper.DiskUUID())).Infof("Preparing new state disk")
|
||||
uuid, _ := s.mapper.DiskUUID()
|
||||
s.log.With(zap.String("uuid", uuid)).Infof("Preparing new state disk")
|
||||
|
||||
// generate and save temporary passphrase
|
||||
passphrase := make([]byte, crypto.RNGLengthDefault)
|
||||
|
|
|
@ -394,8 +394,8 @@ type stubMapper struct {
|
|||
uuid string
|
||||
}
|
||||
|
||||
func (s *stubMapper) DiskUUID() string {
|
||||
return s.uuid
|
||||
func (s *stubMapper) DiskUUID() (string, error) {
|
||||
return s.uuid, nil
|
||||
}
|
||||
|
||||
func (s *stubMapper) FormatDisk(string) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue