chiark / gitweb /
tokens: fiddle with commented-out debugging
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 10 Aug 2021 00:40:54 +0000 (01:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 10 Aug 2021 00:40:54 +0000 (01:40 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs
src/bin/server.rs
src/utils.rs

index 2578f7aabc6c5421b42be7ff254b3ca12d7fd19a..2497780c52a1e54c5707b7137426247535b37dd3 100644 (file)
@@ -48,6 +48,7 @@ fn submit_request<'r, 'c:'r, C:HCC>(
   let time_t = time_t_now();
   let time_t = format!("{:x}", time_t);
   let hmac = token_hmac(c.ic.secret.0.as_bytes(), time_t.as_bytes());
   let time_t = time_t_now();
   let time_t = format!("{:x}", time_t);
   let hmac = token_hmac(c.ic.secret.0.as_bytes(), time_t.as_bytes());
+  //dbg!(DumpHex(&hmac));
   let mut token = time_t;
   write!(token, " ").unwrap();
   base64::encode_config_buf(&hmac, BASE64_CONFIG, &mut token);
   let mut token = time_t;
   write!(token, " ").unwrap();
   base64::encode_config_buf(&hmac, BASE64_CONFIG, &mut token);
index 3e71b4134776e76778cb4373c1712fd2c3e3e50e..26abf5eb7c72c07e94accd0ce38a9fc92e468adf 100644 (file)
@@ -122,6 +122,8 @@ async fn handle(
     let hmac_exp = token_hmac(secret, client_time_s.as_bytes());
     // We also definitely want a consttime memeq for the hmac value
     let hmac_ok = hmac_got.ct_eq(&hmac_exp);
     let hmac_exp = token_hmac(secret, client_time_s.as_bytes());
     // We also definitely want a consttime memeq for the hmac value
     let hmac_ok = hmac_got.ct_eq(&hmac_exp);
+    //dbg!(DumpHex(&hmac_exp), client.is_some());
+    //dbg!(DumpHex(hmac_got), hmac_ok, client_exists);
     if ! bool::from(hmac_ok & client_exists) {
       throw!(anyhow!("xxx should be a 403 error"));
     }
     if ! bool::from(hmac_ok & client_exists) {
       throw!(anyhow!("xxx should be a 403 error"));
     }
index e8508b5a6909030fcca62c32884d0b4365029445..5c1075205bb2eef874e52ade33c3fcf4f9aaf661 100644 (file)
@@ -82,7 +82,7 @@ pub fn token_hmac(key: &[u8], message: &[u8]) -> [u8; HMAC_L] {
   let mut ikey = key;  for k in &mut ikey { *k ^= 0x36; }
   let mut okey = key;  for k in &mut okey { *k ^= 0x5C; }
 
   let mut ikey = key;  for k in &mut ikey { *k ^= 0x36; }
   let mut okey = key;  for k in &mut okey { *k ^= 0x5C; }
 
-//dbg!(&key, &ikey, &okey);
+  //dbg!(DumpHex(&key), DumpHex(message), DumpHex(&ikey), DumpHex(&okey));
 
   let h1 = HmacH::new()
     .chain(&ikey)
 
   let h1 = HmacH::new()
     .chain(&ikey)