sim: Capture payload in TLV code

Since the signing code will also need a copy of the message, make a
local copy of it in the signature verification code, and compute the
digest all in one shot.

Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/src/tlv.rs b/sim/src/tlv.rs
index 2df43cc..f637443 100644
--- a/sim/src/tlv.rs
+++ b/sim/src/tlv.rs
@@ -37,7 +37,7 @@
     flags: Flags,
     kinds: Vec<TlvKinds>,
     size: u16,
-    hasher: digest::Context,
+    payload: Vec<u8>,
 }
 
 impl TlvGen {
@@ -47,7 +47,7 @@
             flags: Flags::SHA256,
             kinds: vec![TlvKinds::SHA256],
             size: 4 + 32,
-            hasher: digest::Context::new(&digest::SHA256),
+            payload: vec![],
         }
     }
 
@@ -63,7 +63,7 @@
 
     /// Add bytes to the covered hash.
     pub fn add_bytes(&mut self, bytes: &[u8]) {
-        self.hasher.update(bytes);
+        self.payload.extend_from_slice(bytes);
     }
 
     /// Compute the TLV given the specified block of data.
@@ -71,7 +71,7 @@
         let mut result: Vec<u8> = vec![];
 
         if self.kinds.contains(&TlvKinds::SHA256) {
-            let hash = self.hasher.finish();
+            let hash = digest::digest(&digest::SHA256, &self.payload);
             let hash = hash.as_ref();
 
             assert!(hash.len() == 32);