diff --git a/CHANGELOG.md b/CHANGELOG.md index 5632df812..f1b38c70d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ FEATURES: * builder/amazon: Copy AMI to multiple regions with `ami_regions`. [GH-322] * builder/virtualbox,vmware: Can now use SSH keys as an auth mechanism for SSH using `ssh_key_path`. [GH-70] +* builder/virtualbox,vmware: Support SHA512 as a checksum type. [GH-356] * builder/vmware: The root hard drive type can now be specified with "disk_type_id" for advanced users. [GH-328] * provisioner/salt-masterless: Ability to specfy a minion config. [GH-264] diff --git a/common/download.go b/common/download.go index fb34c7965..fe4087d97 100644 --- a/common/download.go +++ b/common/download.go @@ -5,6 +5,7 @@ import ( "crypto/md5" "crypto/sha1" "crypto/sha256" + "crypto/sha512" "encoding/hex" "errors" "fmt" @@ -60,6 +61,8 @@ func HashForType(t string) hash.Hash { return sha1.New() case "sha256": return sha256.New() + case "sha512": + return sha512.New() default: return nil } diff --git a/common/download_test.go b/common/download_test.go index 055272b17..f1fec941e 100644 --- a/common/download_test.go +++ b/common/download_test.go @@ -81,6 +81,19 @@ func TestHashForType(t *testing.T) { } } + if h := HashForType("sha512"); h == nil { + t.Fatalf("sha512 hash is nil") + } else { + h.Write([]byte("foo")) + result := h.Sum(nil) + + expected := "f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19594a7eb539453e1ed7" + actual := hex.EncodeToString(result) + if actual != expected { + t.Fatalf("bad hash: %s", actual) + } + } + if HashForType("fake") != nil { t.Fatalf("fake hash is not nil") } diff --git a/website/source/docs/builders/virtualbox.html.markdown b/website/source/docs/builders/virtualbox.html.markdown index ff29bf647..8b38740fb 100644 --- a/website/source/docs/builders/virtualbox.html.markdown +++ b/website/source/docs/builders/virtualbox.html.markdown @@ -47,7 +47,7 @@ Required: checksum is specified with `iso_checksum_type`, documented below. * `iso_checksum_type` (string) - The type of the checksum specified in - `iso_checksum`. Valid values are "md5", "sha1", or "sha256" currently. + `iso_checksum`. Valid values are "md5", "sha1", "sha256", or "sha512" currently. * `iso_url` (string) - A URL to the ISO containing the installation image. This URL can be either an HTTP URL or a file URL (or path to a file). diff --git a/website/source/docs/builders/vmware.html.markdown b/website/source/docs/builders/vmware.html.markdown index ca67fa414..baadb0d93 100644 --- a/website/source/docs/builders/vmware.html.markdown +++ b/website/source/docs/builders/vmware.html.markdown @@ -50,7 +50,7 @@ Required: checksum is specified with `iso_checksum_type`, documented below. * `iso_checksum_type` (string) - The type of the checksum specified in - `iso_checksum`. Valid values are "md5", "sha1", or "sha256" currently. + `iso_checksum`. Valid values are "md5", "sha1", "sha256", or "sha512" currently. * `iso_url` (string) - A URL to the ISO containing the installation image. This URL can be either an HTTP URL or a file URL (or path to a file).