2017-06-17 16:52:30 +02:00
|
|
|
package discovery
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"golang.org/x/crypto/openpgp"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Verify the data using the provided openpgp detached signature and the
|
|
|
|
// embedded hashicorp public key.
|
2018-11-14 20:52:46 +01:00
|
|
|
func verifySig(data, sig []byte, armor string) (*openpgp.Entity, error) {
|
|
|
|
el, err := openpgp.ReadArmoredKeyRing(strings.NewReader(armor))
|
2017-06-17 16:52:30 +02:00
|
|
|
if err != nil {
|
2019-03-21 17:17:15 +01:00
|
|
|
return nil, err
|
2017-06-17 16:52:30 +02:00
|
|
|
}
|
|
|
|
|
2018-11-14 20:52:46 +01:00
|
|
|
return openpgp.CheckDetachedSignature(el, bytes.NewReader(data), bytes.NewReader(sig))
|
2017-06-17 16:52:30 +02:00
|
|
|
}
|