mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
mllib: add SHA1 support in Checksums
This way Checksums can be used in v2v.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*)
|
||||
|
||||
type csum_t =
|
||||
| SHA1 of string
|
||||
| SHA256 of string
|
||||
| SHA512 of string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user