common: support SHA512 as checksum type [Gh-356]
This commit is contained in:
parent
ce89b357c0
commit
01e998a81c
|
@ -8,6 +8,7 @@ FEATURES:
|
||||||
* builder/amazon: Copy AMI to multiple regions with `ami_regions`. [GH-322]
|
* 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
|
* builder/virtualbox,vmware: Can now use SSH keys as an auth mechanism for
|
||||||
SSH using `ssh_key_path`. [GH-70]
|
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
|
* builder/vmware: The root hard drive type can now be specified with
|
||||||
"disk_type_id" for advanced users. [GH-328]
|
"disk_type_id" for advanced users. [GH-328]
|
||||||
* provisioner/salt-masterless: Ability to specfy a minion config. [GH-264]
|
* provisioner/salt-masterless: Ability to specfy a minion config. [GH-264]
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"crypto/sha512"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -60,6 +61,8 @@ func HashForType(t string) hash.Hash {
|
||||||
return sha1.New()
|
return sha1.New()
|
||||||
case "sha256":
|
case "sha256":
|
||||||
return sha256.New()
|
return sha256.New()
|
||||||
|
case "sha512":
|
||||||
|
return sha512.New()
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
if HashForType("fake") != nil {
|
||||||
t.Fatalf("fake hash is not nil")
|
t.Fatalf("fake hash is not nil")
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ Required:
|
||||||
checksum is specified with `iso_checksum_type`, documented below.
|
checksum is specified with `iso_checksum_type`, documented below.
|
||||||
|
|
||||||
* `iso_checksum_type` (string) - The type of the checksum specified in
|
* `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.
|
* `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).
|
This URL can be either an HTTP URL or a file URL (or path to a file).
|
||||||
|
|
|
@ -50,7 +50,7 @@ Required:
|
||||||
checksum is specified with `iso_checksum_type`, documented below.
|
checksum is specified with `iso_checksum_type`, documented below.
|
||||||
|
|
||||||
* `iso_checksum_type` (string) - The type of the checksum specified in
|
* `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.
|
* `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).
|
This URL can be either an HTTP URL or a file URL (or path to a file).
|
||||||
|
|
Loading…
Reference in New Issue