This is an automated email from the ASF dual-hosted git repository.

yuanz pushed a commit to branch release-v0.3.0
in repository 
https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git

commit c7ed82f095fe9b9729af99b41c9e83d47fb3b532
Author: Yuan Zhuang <[email protected]>
AuthorDate: Wed Jun 26 09:07:02 2024 +0000

    examples: remove test code
---
 examples/hello_world-rs/ta/src/main.rs |  7 +--
 examples/tls_client-rs/ta/src/main.rs  | 78 ++--------------------------------
 tests/cleanup_all.sh                   |  2 +-
 3 files changed, 6 insertions(+), 81 deletions(-)

diff --git a/examples/hello_world-rs/ta/src/main.rs 
b/examples/hello_world-rs/ta/src/main.rs
index 25feb55..c184713 100644
--- a/examples/hello_world-rs/ta/src/main.rs
+++ b/examples/hello_world-rs/ta/src/main.rs
@@ -48,12 +48,7 @@ fn destroy() {
 
 #[ta_invoke_command]
 fn invoke_command(cmd_id: u32, params: &mut Parameters) -> Result<()> {
-    trace_println!("[+] TA invoke command1111 1111111");
-    trace_println!("cmd_id: {}", cmd_id);
-    let mut m = HashMap::new();
-    trace_println!("after create m: {:?}", m);
-    m.insert(0, 0);
-    trace_println!("m: {:?}", m);
+    trace_println!("[+] TA invoke command");
     let mut values = unsafe { params.0.as_value().unwrap() };
     match Command::from(cmd_id) {
         Command::IncValue => {
diff --git a/examples/tls_client-rs/ta/src/main.rs 
b/examples/tls_client-rs/ta/src/main.rs
index aecd332..16aba0d 100644
--- a/examples/tls_client-rs/ta/src/main.rs
+++ b/examples/tls_client-rs/ta/src/main.rs
@@ -65,17 +65,6 @@ fn invoke_command(cmd_id: u32, _params: &mut Parameters) -> 
Result<()> {
 
 // copied from 
https://github.com/rustls/rustls/blob/v/0.21.0/examples/src/bin/simpleclient.rs
 fn tls_client() {
-    trace_println!("tls_client enter");
-
-    // let map: HashMap<[u8;32], [u8;1024]> = HashMap::new();
-    // trace_println!("tls_client before HashMap::new");
-    // let mut m = HashMap::new();
-    // trace_println!("tls_client after HashMap::new");
-    // m.insert([0u8;32], [0u8;1024]);
-    // trace_println!("tls_client after HashMap::insert");
-
-    // let map: HashMap<[u8;32], [u8;1024]> = HashMap::with_capacity(32);
-    // trace_println!("tls_client after HashMap::with_capacity");
     let mut root_store = RootCertStore::empty();
     root_store.add_server_trust_anchors(
         webpki_roots::TLS_SERVER_ROOTS
@@ -89,13 +78,14 @@ fn tls_client() {
                 )
             }),
     );
-    trace_println!("before rustls::ClientConfig::builder");
+    trace_println!("[+] root_store added");
+
     let config = rustls::ClientConfig::builder()
         .with_safe_defaults()
         .with_root_certificates(root_store)
         .with_no_client_auth();
-
-    trace_println!("before Arc::new config");
+    trace_println!("[+] config created");
+    
     let server_name = "google.com".try_into().unwrap();
     let mut conn = rustls::ClientConnection::new(Arc::new(config), 
server_name).unwrap();
     let mut sock = TcpStream::connect("google.com", 443).unwrap();
@@ -124,66 +114,6 @@ fn tls_client() {
     trace_println!("{}", String::from_utf8_lossy(&plaintext));
 }
 
-// fn tls_client() {
-//     trace_println!("tls_client");
-
-//     let mut root_store = rustls::RootCertStore::empty();
-//     root_store.add_server_trust_anchors(
-//         webpki_roots::TLS_SERVER_ROOTS
-//             .0
-//             .iter()
-//             .map(|ta| {
-//                 
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
-//                     ta.subject,
-//                     ta.spki,
-//                     ta.name_constraints,
-//                 )
-//             })
-//     );
-//     trace_println!("before rustls::ClientConfig::builder");
-//     let config = rustls::ClientConfig::builder()
-//     .with_safe_defaults()
-//     .with_root_certificates(root_store)
-//     .with_no_client_auth();
-//     trace_println!("before Arc::new config");
-
-//     // let mut config = rustls::ClientConfig::new();
-//     // trace_println!("before add_root_certificate");
-//     // config
-//     //     .root_store
-//     //     .add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
-//     // trace_println!("before Arc::new config");
-//     let rc_config = Arc::new(config);
-//     trace_println!("before webpki::DNSNameRef");
-//     let dns_name = 
webpki::DNSNameRef::try_from_ascii_str("google.com").unwrap();
-//     trace_println!("before rustls::ClientSession");
-//     let mut conn = rustls::ClientConnection::new(rc_config, dns_name);
-//     trace_println!("before TcpStream::connect");
-//     let mut sock = TcpStream::connect("google.com", 443).unwrap();
-//     trace_println!("before rustls::Stream::new");
-//     let mut tls = rustls::Stream::new(&mut conn, &mut sock);
-//     tls.write_all(b"GET / HTTP/1.0\r\nHost: google.com\r\nAccept-Encoding: 
identity\r\n\r\n")
-//         .unwrap();
-//     tls.flush().unwrap();
-
-//     let mut response = Vec::new();
-//     let mut chunk = [0u8; 1024];
-
-//     trace_println!("before read");
-//     loop {
-//         trace_println!("in loop");
-//         match tls.read(&mut chunk) {
-//             Ok(0) => break,
-//             Ok(n) => response.extend_from_slice(&chunk[..n]),
-//             Err(_) => {
-//                 trace_println!("Error");
-//                 panic!();
-//             }
-//         }
-//     }
-//     trace_println!("{}", String::from_utf8_lossy(&response));
-// }
-
 // TA configurations
 const TA_FLAGS: u32 = 0;
 const TA_DATA_SIZE: u32 = 18 * 1024 * 1024;
diff --git a/tests/cleanup_all.sh b/tests/cleanup_all.sh
index 39229c2..5f3b524 100755
--- a/tests/cleanup_all.sh
+++ b/tests/cleanup_all.sh
@@ -19,5 +19,5 @@
 
 set -xe
 
-rm -rf screenlog.0 shared /tmp/serial.log
+rm -rf screenlog.0 shared /tmp/serial.log openssl.log
 rm -rf optee-qemuv8-*


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to