Created
October 13, 2020 12:58
-
-
Save haraldh/fb3f82cd188b89ae767d1989727f1abb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::aesm_proto::Request_InitQuoteRequest; | |
use byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; | |
use protobuf::Message; | |
use std::io::{Read, Write}; | |
use std::mem::size_of; | |
use std::os::unix::net::UnixStream; | |
mod aesm_proto; | |
fn main() -> std::io::Result<()> { | |
let mut req = aesm_proto::Request::new(); | |
let mut msg = Request_InitQuoteRequest::new(); | |
msg.set_timeout(1_000_000); | |
req.set_initQuoteReq(msg); | |
let mut stream = UnixStream::connect("/var/run/aesmd/aesm.socket")?; // this connects to aesmd on the host | |
let mut req_bytes = vec![0u8; size_of::<u32>()]; | |
req.write_to_writer(&mut req_bytes); | |
let req_len = (req_bytes.len() - size_of::<u32>()) as u32; | |
(&mut req_bytes[0..size_of::<u32>()]).write_u32::<NativeEndian>(req_len)?; | |
stream.write_all(&req_bytes)?; | |
stream.flush()?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment