-
Notifications
You must be signed in to change notification settings - Fork 276
*: add LUKS #960
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
*: add LUKS #960
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Copyright 2020 Red Hat, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package types | ||
|
|
||
| import ( | ||
| "strings" | ||
|
|
||
| "github.com/coreos/ignition/v2/config/shared/errors" | ||
| "github.com/coreos/ignition/v2/config/util" | ||
|
|
||
| "github.com/coreos/vcontext/path" | ||
| "github.com/coreos/vcontext/report" | ||
| ) | ||
|
|
||
| func (l Luks) Key() string { | ||
| return l.Name | ||
| } | ||
|
|
||
| func (l Luks) IgnoreDuplicates() map[string]struct{} { | ||
| return map[string]struct{}{ | ||
| "Options": {}, | ||
| } | ||
| } | ||
|
|
||
| func (l Luks) Validate(c path.ContextPath) (r report.Report) { | ||
| if strings.Contains(l.Name, "/") { | ||
| r.AddOnError(c.Append("name"), errors.ErrLuksNameContainsSlash) | ||
| } | ||
| r.AddOnError(c.Append("label"), l.validateLabel()) | ||
| if util.NilOrEmpty(l.Device) { | ||
| r.AddOnError(c.Append("device"), errors.ErrDiskDeviceRequired) | ||
| } else { | ||
| r.AddOnError(c.Append("device"), validatePath(*l.Device)) | ||
| } | ||
|
|
||
| // fail if there is no valid keyfile & no clevis entries | ||
| if err := l.KeyFile.validateRequiredSource(); err != nil && l.emptyClevis() { | ||
| r.AddOnError(c.Append("keys"), errors.ErrInvalidLuksVolume) | ||
| } | ||
| return | ||
| } | ||
|
|
||
| func (l Luks) emptyClevis() bool { | ||
| if l.Clevis == nil { | ||
| return true | ||
| } | ||
|
|
||
| return len(l.Clevis.Tang) == 0 && (l.Clevis.Tpm2 == nil || !*l.Clevis.Tpm2) | ||
| } | ||
|
|
||
| func (l Luks) validateLabel() error { | ||
| if util.NilOrEmpty(l.Label) { | ||
| return nil | ||
| } | ||
|
|
||
| if len(*l.Label) > 47 { | ||
| // LUKS2_LABEL_L has a maximum length of 48 (including the null terminator) | ||
| // https://gitlab.com/cryptsetup/cryptsetup/-/blob/1633f030e89ad2f11ae649ba9600997a41abd3fc/lib/luks2/luks2.h#L86 | ||
| return errors.ErrLuksLabelTooLong | ||
| } | ||
|
|
||
| return nil | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,12 @@ package types | |
|
|
||
| // generated by "schematyper --package=types config/v3_2_experimental/schema/ignition.json -o config/v3_2_experimental/types/schema.go --root-type=Config" -- DO NOT EDIT | ||
|
|
||
| type Clevis struct { | ||
| Tang []Tang `json:"tang,omitempty"` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not block on this, but I think Hmm, and then the rootmap code could also check if LUKS devices in the root block device tree are Tang-pinned and adds
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops, yeah, forgot about |
||
| Threshold *int `json:"threshold,omitempty"` | ||
| Tpm2 *bool `json:"tpm2,omitempty"` | ||
| } | ||
|
|
||
| type Config struct { | ||
| Ignition Ignition `json:"ignition"` | ||
| Passwd Passwd `json:"passwd,omitempty"` | ||
|
|
@@ -87,6 +93,18 @@ type LinkEmbedded1 struct { | |
| Target string `json:"target"` | ||
| } | ||
|
|
||
| type Luks struct { | ||
| Clevis *Clevis `json:"clevis,omitempty"` | ||
| Device *string `json:"device,omitempty"` | ||
| KeyFile Resource `json:"keyFile,omitempty"` | ||
| Label *string `json:"label,omitempty"` | ||
| Name string `json:"name"` | ||
| Options []LuksOption `json:"options,omitempty"` | ||
| UUID *string `json:"uuid,omitempty"` | ||
| } | ||
|
|
||
| type LuksOption string | ||
|
|
||
| type MountOption string | ||
|
|
||
| type NoProxyItem string | ||
|
|
@@ -182,6 +200,7 @@ type Storage struct { | |
| Files []File `json:"files,omitempty"` | ||
| Filesystems []Filesystem `json:"filesystems,omitempty"` | ||
| Links []Link `json:"links,omitempty"` | ||
| Luks []Luks `json:"luks,omitempty"` | ||
| Raid []Raid `json:"raid,omitempty"` | ||
| } | ||
|
|
||
|
|
@@ -193,6 +212,11 @@ type TLS struct { | |
| CertificateAuthorities []Resource `json:"certificateAuthorities,omitempty"` | ||
| } | ||
|
|
||
| type Tang struct { | ||
| Thumbprint *string `json:"thumbprint,omitempty"` | ||
| URL string `json:"url,omitempty"` | ||
| } | ||
|
|
||
| type Timeouts struct { | ||
| HTTPResponseHeaders *int `json:"httpResponseHeaders,omitempty"` | ||
| HTTPTotal *int `json:"httpTotal,omitempty"` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright 2020 Red Hat, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package types | ||
|
|
||
| import ( | ||
| "net/url" | ||
|
|
||
| "github.com/coreos/ignition/v2/config/shared/errors" | ||
| "github.com/coreos/ignition/v2/config/util" | ||
|
|
||
| "github.com/coreos/vcontext/path" | ||
| "github.com/coreos/vcontext/report" | ||
| ) | ||
|
|
||
| func (t Tang) Key() string { | ||
| return t.URL | ||
| } | ||
|
|
||
| func (t Tang) Validate(c path.ContextPath) (r report.Report) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT about allowing an anonymous thumbprint? I can go either way on this. Tang is based on zero knowledge; the Tang server doesn't know the secret. Some "sugar" could allow for querying for the thumbprint. Another big of sugar would be check the Tang server at this point to check the thumbprint and bail on the operation if there's a mismatch before doing the encryption and handing off to Clevis. Note: consider this comment a nit for future consideration.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure I'm following, are you suggesting that we allow just the specification of the server and auto trust it despite not being given a thumbprint? I'm not sure I'd be in favor of that. I think I'd rather put the extra workload on the user at config generation time to know the URL & thumbprint.
I'd probably punt from the initial PR but I like the concept.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Right :) Let's get this out of the door. Just an idea for future improvement. |
||
| r.AddOnError(c.Append("url"), validateTangURL(t.URL)) | ||
| if util.NilOrEmpty(t.Thumbprint) { | ||
| r.AddOnError(c.Append("thumbprint"), errors.ErrTangThumbprintRequired) | ||
| } | ||
| return | ||
| } | ||
|
|
||
| func validateTangURL(s string) error { | ||
| u, err := url.Parse(s) | ||
| if err != nil { | ||
| return errors.ErrInvalidUrl | ||
| } | ||
|
|
||
| switch u.Scheme { | ||
| case "http", "https": | ||
| return nil | ||
| default: | ||
| return errors.ErrInvalidScheme | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.