{"modulePath":"github.com/flashbots/cvm-reverse-proxy","version":"v0.1.9","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package cryptsetup\n\nPackage cryptsetup provides a wrapper around libcryptsetup. The package is used to manage encrypted disks for Constellation.\n\nSince libcryptsetup is not thread safe, this package uses a global lock to prevent concurrent use. There should only be one instance using this package per process.\n\n### Copyright (c) Edgeless Systems GmbH {#hdr-Copyright__c__Edgeless_Systems_GmbH}\n\nSPDX-License-Identifier: AGPL-3.0-only\n\n## Constants\n\n```go\nconst (\n\t// ConstellationStateDiskTokenID is the ID of Constellation's state disk token.\n\tConstellationStateDiskTokenID = 0\n\t// SetDiskInitialized is a flag to set the Constellation state disk token to initialized.\n\tSetDiskInitialized = true\n\t// SetDiskNotInitialized is a flag to set the Constellation state disk token to not initialized.\n\tSetDiskNotInitialized = false\n\n\t// FormatIntegrity is a flag to enable dm-integrity for a crypt device when formatting.\n\tFormatIntegrity = true\n\t// FormatNoIntegrity is a flag to disable dm-integrity for a crypt device when formatting.\n\tFormatNoIntegrity = false\n)\n```\n\n```go\nconst (\n\t// ReadWriteQueueBypass is a flag to disable the write and read workqueues for a crypt device.\n\tReadWriteQueueBypass = C.CRYPT_ACTIVATE_NO_WRITE_WORKQUEUE | C.CRYPT_ACTIVATE_NO_READ_WORKQUEUE\n)\n```\n\n## Types\n\n```go\ntype CryptSetup struct {\n\t// contains filtered or unexported fields\n}\n```\nCryptSetup manages encrypted devices.\n\n```go\nfunc New() *CryptSetup\n```\nNew creates a new CryptSetup. Before first use, call Init() or InitByName() to open a crypt device.\n\n```go\nfunc (c *CryptSetup) ActivateByPassphrase(deviceName string, keyslot int, passphrase string, flags int) error\n```\nActivateByPassphrase actives a crypt device using a passphrase.\n\n```go\nfunc (c *CryptSetup) ActivateByVolumeKey(deviceName, volumeKey string, volumeKeySize, flags int) error\n```\nActivateByVolumeKey activates a crypt device using a volume key. Set volumeKey to empty string to use the internal key.\n\n```go\nfunc (c *CryptSetup) ConstellationStateDiskTokenIsInitialized() bool\n```\nConstellationStateDiskTokenIsInitialized returns true if the Constellation state disk token is set to initialized.\n\n```go\nfunc (c *CryptSetup) Deactivate(deviceName string) error\n```\nDeactivate deactivates a crypt device, removing the mapped device.\n\n```go\nfunc (c *CryptSetup) Format(integrity bool) error\n```\nFormat formats a disk as a LUKS2 crypt device. Optionally set integrity to true to enable dm-integrity for the device.\n\n```go\nfunc (c *CryptSetup) Free()\n```\nFree frees resources from a previously opened crypt device.\n\n```go\nfunc (c *CryptSetup) GetDeviceName() string\n```\nGetDeviceName gets the path to the underlying device.\n\n```go\nfunc (c *CryptSetup) GetUUID() (string, error)\n```\nGetUUID gets the device's LUKS2 UUID. The UUID is returned in lowercase.\n\n```go\nfunc (c *CryptSetup) Init(devicePath string) (free func(), err error)\n```\nInit opens a crypt device by device path.\n\n```go\nfunc (c *CryptSetup) InitByName(name string) (free func(), err error)\n```\nInitByName opens an active crypt device using its mapped name.\n\n```go\nfunc (c *CryptSetup) KeyslotAddByVolumeKey(keyslot int, volumeKey string, passphrase string) error\n```\nKeyslotAddByVolumeKey adds a key slot to a device, allowing later activations using the chosen passphrase. Set volumeKey to empty string to use the internal key.\n\n```go\nfunc (c *CryptSetup) KeyslotChangeByPassphrase(currentKeyslot, newKeyslot int, currentPassphrase, newPassphrase string) error\n```\nKeyslotChangeByPassphrase changes the passphrase for a keyslot.\n\n```go\nfunc (c *CryptSetup) LoadLUKS2() error\n```\nLoadLUKS2 loads the device as LUKS2 crypt device.\n\n```go\nfunc (c *CryptSetup) Resize(name string, newSize uint64) error\n```\nResize resizes a device to the given size. name must be equal to the mapped device name. Set newSize to 0 to use the maximum available size.\n\n```go\nfunc (c *CryptSetup) SetConstellationStateDiskToken(diskIsInitialized bool) error\n```\nSetConstellationStateDiskToken sets the Constellation state disk token.\n\n```go\nfunc (c *CryptSetup) TokenJSONGet(token int) (string, error)\n```\nTokenJSONGet gets the JSON data for a token.\n\n```go\nfunc (c *CryptSetup) TokenJSONSet(token int, json string) (int, error)\n```\nTokenJSONSet sets the JSON data for a token. The JSON data must be a valid LUKS2 token. Required fields are:\n\n  - type \\[string] the token type (tokens with luks2- prefix are reserved)\n  - keyslots \\[array] the array of keyslot objects names that are assigned to the token\n\nReturns the allocated token ID on success.\n\n```go\nfunc (c *CryptSetup) Wipe(\n\tname string, blockWipeSize int, flags int, logCallback func(size, offset uint64), logFrequency time.Duration,\n) (err error)\n```\nWipe overwrites the device with zeros to initialize integrity checksums.\n\n","path":"github.com/flashbots/cvm-reverse-proxy/internal/cryptsetup","name":"cryptsetup","synopsis":"Package cryptsetup provides a wrapper around libcryptsetup.","isRedistributable":true}
