[sw/host] Update spiflash hash function.

The last frame had an invalid hash calculation due to the frame number
update performed after the hash had been set. This commit moves the hash
calculation to fix this issue.
diff --git a/sw/host/spiflash/updater.cc b/sw/host/spiflash/updater.cc
index bb37c63..2025ca9 100644
--- a/sw/host/spiflash/updater.cc
+++ b/sw/host/spiflash/updater.cc
@@ -4,6 +4,7 @@
 
 #include "updater.h"
 
+#include <algorithm>
 #include <assert.h>
 
 namespace opentitan {
@@ -29,13 +30,17 @@
   // Populate header number, offset and hash.
   f->hdr.frame_num = frame_number;
   f->hdr.offset = code_offset;
+  return copy_size;
+}
+
+// Calculate hash for frame |f| and store it in the frame header hash field.
+void HashFrame(Frame *f) {
   SHA256_CTX sha256;
   SHA256_Init(&sha256);
   SHA256_Update(&sha256, &f->hdr.frame_num, sizeof(f->hdr.frame_num));
   SHA256_Update(&sha256, &f->hdr.offset, sizeof(f->hdr.offset));
   SHA256_Update(&sha256, f->data, f->PayloadSize());
   SHA256_Final(f->hdr.hash, &sha256);
-  return copy_size;
 }
 
 }  // namespace
@@ -81,6 +86,10 @@
   // Update last frame to sentinel EOF value.
   Frame &last_frame = frames->back();
   last_frame.hdr.frame_num = 0x80000000 | last_frame.hdr.frame_num;
+
+  for (Frame& f : *frames) {
+    HashFrame(&f);
+  }
   return true;
 }