cmd

package
v2.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Pre-defined errors

Functions

func Cryptsetup

func Cryptsetup(d Disk, md *Metadata, ek, tpmKek []byte) error

Cryptsetup invokes cryptsetup to open crypt device. ek is the encrypted encryption key.

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func InitModules

func InitModules()

InitModules load kernel modules for dm-crypt.

Types

type Disk

type Disk struct {
	// contains filtered or unexported fields
}

Disk represents a physical disk to be encrypted.

func FindDisks

func FindDisks(excludes []string) ([]Disk, error)

FindDisks looks up the system to find disks to be encrypted.

func (Disk) CryptDevice

func (d Disk) CryptDevice() string

CryptDevice returns the crypt device filename of this disk.

func (Disk) CryptName

func (d Disk) CryptName() string

CryptName returns the crypt device name of this disk.

func (Disk) Device

func (d Disk) Device() string

Device returns a device filename of this disk.

func (Disk) Name

func (d Disk) Name() string

Name returns the name of this disk.

func (Disk) SectorSize

func (d Disk) SectorSize() int

SectorSize returns the physical block size of this disk.

func (Disk) Size512

func (d Disk) Size512() int64

Size512 returns the device size / 512.

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver setup crypt devices.

func NewDriver

func NewDriver(sabakanURL, cipher string, keySize int, tpmdev string, disks []Disk) (*Driver, error)

NewDriver creates Driver.

It may return nil when the serial code of the machine cannot be identified, or sabakanURL is not valid.

func (*Driver) Setup

func (d *Driver) Setup(ctx context.Context) error

Setup setup crypt devices.

type Metadata

type Metadata struct {
	// contains filtered or unexported fields
}

Metadata represents metadata block at the head of disk.

func NewMetadata

func NewMetadata(cipher string, keySize int, tpmVersion TpmVersionID) (*Metadata, error)

NewMetadata initializes a new Metadata.

func ReadMetadata

func ReadMetadata(f *os.File) (*Metadata, error)

ReadMetadata read metadata from f. If metadata does not exist, this returns ErrNotFound.

func (*Metadata) Cipher

func (m *Metadata) Cipher() string

Cipher returns cipher suite for this disk.

func (*Metadata) DecryptKey

func (m *Metadata) DecryptKey(ek, tpmKek []byte) ([]byte, error)

DecryptKey decrypts encrypted key.

func (*Metadata) EncryptKey

func (m *Metadata) EncryptKey(key, tpmKek []byte) ([]byte, error)

EncryptKey encrypts key.

func (*Metadata) HexID

func (m *Metadata) HexID() string

HexID returns hexadecimal encoded ID.

func (*Metadata) ID

func (m *Metadata) ID() string

ID returns randomly assigned ID of this disk.

func (*Metadata) Kek

func (m *Metadata) Kek() string

Kek returns key encryption key.

func (*Metadata) TpmVersion added in v2.4.5

func (m *Metadata) TpmVersion() TpmVersionID

TpmVersion returns TPM version ID.

func (*Metadata) Write

func (m *Metadata) Write(f *os.File) error

Write writes metadata to f.

type TpmVersionID added in v2.4.5

type TpmVersionID int

TpmVersionID represents TPM versions.

const (
	TpmNone TpmVersionID = 0
	Tpm12   TpmVersionID = 1
	Tpm20   TpmVersionID = 2
)

TPM versions.

func (TpmVersionID) String added in v2.4.5

func (v TpmVersionID) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL