-
Notifications
You must be signed in to change notification settings - Fork 40
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
Random Key #266
Random Key #266
Changes from 3 commits
60a8a55
5404013
60d9b8f
b41b675
d960dee
9f66e67
f15261c
6b2066c
1e751b6
8363ed7
a069ee6
b01ecf7
21818b8
c9b7847
49e6713
86d29aa
1ace522
9726eb6
6605708
ac0070c
0e54dc7
7486724
6e0933a
4ae0591
959c95b
fb255c6
03266ee
8927595
e784fac
b99318d
1d75380
f6f2402
c7c195a
333fed8
2f31eef
ae7e706
fecd906
8aec76f
a7841df
f03cf63
6d63fd1
e2b4f27
96d4ebb
3e77863
784467f
6b3a0b7
a62ff0f
ae48efb
1e856ab
1a759ac
8c5c9ad
f6168c5
b200f28
655615b
611f790
4d757c3
e8ee133
32a0177
7815052
102ba80
90beca9
267b145
1395505
91abad0
b339099
c778d80
3da0463
dffb872
452f3a3
0b3d568
72de360
4b3e12a
5da3d05
71fdfbc
ca04399
47cfc7e
8718e4d
73ab1ec
2c314d5
40a66ce
5425d62
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 |
---|---|---|
|
@@ -4,30 +4,44 @@ extern crate serde_json; | |
|
||
use libc::syscall; | ||
|
||
use anyhow::Result; | ||
use nix::mount::MsFlags; | ||
use std::error::Error; | ||
use std::ffi::CString; | ||
use std::fs; | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
use std::io::{ErrorKind, Read}; | ||
|
||
use std::ffi::CString; | ||
use std::mem::size_of; | ||
use std::path::Path; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
// TODO: Get the rootfs key and other parameters through RA/LA or PAL | ||
let rootfs_key = b"c7-32-b3-ed-44-df-ec-7b-25-2d-9a-32-38-8d-58-61"; | ||
let rootfs_upper_layer = "/sefs/upper"; | ||
let rootfs_lower_layer = "/sefs/lower"; | ||
let rootfs_entry = "/"; | ||
|
||
// Get the key of FS image if needed | ||
// Create and mount directory for fs key from agent enclave | ||
fs::create_dir("/mnt"); | ||
let fs_type = String::from("hostfs"); | ||
let source = Path::new("/host"); | ||
let mount_path = Path::new("/mnt"); | ||
let flags = MsFlags::empty(); | ||
let source_c = CString::new(source.to_str().unwrap()).unwrap(); | ||
let mountpoint_c = CString::new(mount_path.to_str().unwrap()).unwrap(); | ||
nix::mount::mount( | ||
Some(fs_type.as_str()), | ||
mountpoint_c.as_c_str(), | ||
Some(fs_type.as_str()), | ||
flags, | ||
Some("dir=/keys"), | ||
) | ||
.unwrap_or_else(|e| panic!("mount failed: {e}")); | ||
|
||
let KEY_FILE: &str = "/mnt/key.txt"; | ||
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. Double check this path matches the path in confidential-containers/guest-components#385 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. To boot/app enclave to run this need to match so if the e2e flow is working that means that the path is corresponding |
||
// Get the key of FS image | ||
let key = { | ||
const IMAGE_KEY_FILE: &str = "/etc/image_key"; | ||
// TODO: Get the key through RA or LA | ||
let mut file = File::create(IMAGE_KEY_FILE)?; | ||
// Writes key. | ||
file.write_all(rootfs_key)?; | ||
|
||
let key_str = load_key(IMAGE_KEY_FILE)?; | ||
let key_str = load_key(KEY_FILE)?; | ||
let mut key: sgx_key_128bit_t = Default::default(); | ||
parse_str_to_bytes(&key_str, &mut key)?; | ||
Some(key) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
includes: | ||
- base.yaml | ||
targets: | ||
- target: / | ||
mkdirs: | ||
- keys | ||
- target: /bin | ||
copy: | ||
- files: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
includes: | ||
- base.yaml | ||
targets: | ||
- target: / | ||
mkdirs: | ||
- keys | ||
- target: /bin | ||
copy: | ||
- files: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note for later reference that we want to update this after confidential-containers/guest-components#385 is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to reflect that, I moved this PR to Draft.