[Libguestfs] [PATCH 3/4] mllib: add SHA1 support in Checksums

Pino Toscano ptoscano at redhat.com
Fri Sep 30 09:31:01 UTC 2016


This way Checksums can be used in v2v.
---
 mllib/checksums.ml  | 5 +++++
 mllib/checksums.mli | 1 +
 2 files changed, 6 insertions(+)

diff --git a/mllib/checksums.ml b/mllib/checksums.ml
index 014e73e..dfa8c3a 100644
--- a/mllib/checksums.ml
+++ b/mllib/checksums.ml
@@ -22,21 +22,25 @@ open Common_utils
 open Printf
 
 type csum_t =
+| SHA1 of string
 | SHA256 of string
 | SHA512 of string
 
 exception Mismatched_checksum of (csum_t * string)
 
 let string_of_csum_t = function
+  | SHA1 _ -> "sha1"
   | SHA256 _ -> "sha256"
   | SHA512 _ -> "sha512"
 
 let string_of_csum = function
+  | SHA1 c -> c
   | SHA256 c -> c
   | SHA512 c -> c
 
 let of_string csum_type csum_value =
   match String.lowercase_ascii csum_type with
+  | "sha1" -> SHA1 csum_value
   | "sha256" -> SHA256 csum_value
   | "sha512" -> SHA512 csum_value
   | _ -> invalid_arg csum_type
@@ -44,6 +48,7 @@ let of_string csum_type csum_value =
 let verify_checksum csum filename =
   let prog, csum_ref =
     match csum with
+    | SHA1 c -> "sha1sum", c
     | SHA256 c -> "sha256sum", c
     | SHA512 c -> "sha512sum", c
   in
diff --git a/mllib/checksums.mli b/mllib/checksums.mli
index 298d7df..0074837 100644
--- a/mllib/checksums.mli
+++ b/mllib/checksums.mli
@@ -17,6 +17,7 @@
  *)
 
 type csum_t =
+| SHA1 of string
 | SHA256 of string
 | SHA512 of string
 
-- 
2.7.4




More information about the Libguestfs mailing list