mirror of
https://github.com/getsops/sops.git
synced 2026-02-05 12:45:21 +01:00
s/GPG/PGP
This commit is contained in:
@@ -110,19 +110,19 @@ func (key *MasterKey) encryptWithCryptoOpenPGP(dataKey []byte) error {
|
||||
|
||||
// Encrypt encrypts the data key with the PGP key with the same fingerprint as the MasterKey. It looks for PGP public keys in $PGPHOME/pubring.gpg.
|
||||
func (key *MasterKey) Encrypt(dataKey []byte) error {
|
||||
log.Printf("Attempting encryption of GPG MasterKey with fingerprint %s", key.Fingerprint)
|
||||
log.Printf("Attempting encryption of PGP MasterKey with fingerprint %s", key.Fingerprint)
|
||||
openpgpErr := key.encryptWithCryptoOpenPGP(dataKey)
|
||||
if openpgpErr == nil {
|
||||
log.Printf("Encryption of GPG MasterKey with fingerprint %s succeeded", key.Fingerprint)
|
||||
log.Printf("Encryption of PGP MasterKey with fingerprint %s succeeded", key.Fingerprint)
|
||||
return nil
|
||||
}
|
||||
log.Print("Encryption with golang's openpgp package failed, falling back to the GPG binary")
|
||||
binaryErr := key.encryptWithGPGBinary(dataKey)
|
||||
if binaryErr == nil {
|
||||
log.Printf("Encryption of GPG MasterKey with fingerprint %s succeeded", key.Fingerprint)
|
||||
log.Printf("Encryption of PGP MasterKey with fingerprint %s succeeded", key.Fingerprint)
|
||||
return nil
|
||||
}
|
||||
log.Printf("Encryption of GPG MasterKey with fingerprint %s failed", key.Fingerprint)
|
||||
log.Printf("Encryption of PGP MasterKey with fingerprint %s failed", key.Fingerprint)
|
||||
return fmt.Errorf(`could not encrypt data key with PGP key.
|
||||
\tgolang.org/x/crypto/openpgp error: %s
|
||||
\tGPG binary error: %s`, openpgpErr, binaryErr)
|
||||
@@ -170,21 +170,21 @@ func (key *MasterKey) decryptWithCryptoOpenpgp() ([]byte, error) {
|
||||
log.Printf("Decryption of GPG MasterKey with fingerprint %s successful", key.Fingerprint)
|
||||
return b, nil
|
||||
}
|
||||
return nil, fmt.Errorf("The key could not be decrypted with any of the GPG entries")
|
||||
return nil, fmt.Errorf("The key could not be decrypted with any of the PGP entries")
|
||||
}
|
||||
|
||||
// Decrypt uses PGP to obtain the data key from the EncryptedKey store in the MasterKey and returns it
|
||||
func (key *MasterKey) Decrypt() ([]byte, error) {
|
||||
log.Printf("Attempting decryption of GPG MasterKey with fingerprint %s", key.Fingerprint)
|
||||
log.Printf("Attempting decryption of PGP MasterKey with fingerprint %s", key.Fingerprint)
|
||||
dataKey, openpgpErr := key.decryptWithCryptoOpenpgp()
|
||||
if openpgpErr == nil {
|
||||
log.Printf("Decryption of GPG MasterKey with fingerprint %s succeeded", key.Fingerprint)
|
||||
log.Printf("Decryption of PGP MasterKey with fingerprint %s succeeded", key.Fingerprint)
|
||||
return dataKey, nil
|
||||
}
|
||||
log.Print("Decryption with golang's openpgp package failed, falling back to the GPG binary")
|
||||
dataKey, binaryErr := key.decryptWithGPGBinary()
|
||||
if binaryErr == nil {
|
||||
log.Printf("Decryption of GPG MasterKey with fingerprint %s succeeded", key.Fingerprint)
|
||||
log.Printf("Decryption of PGP MasterKey with fingerprint %s succeeded", key.Fingerprint)
|
||||
return dataKey, nil
|
||||
}
|
||||
log.Printf("Decryption of GPG MasterKey with fingerprint %s failed", key.Fingerprint)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing/quick"
|
||||
)
|
||||
|
||||
func TestGPG(t *testing.T) {
|
||||
func TestPGP(t *testing.T) {
|
||||
key := NewMasterKeyFromFingerprint("1022470DE3F0BC54BC6AB62DE05550BC07FB1A0A")
|
||||
f := func(x []byte) bool {
|
||||
if x == nil || len(x) == 0 {
|
||||
@@ -28,7 +28,7 @@ func TestGPG(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGPGKeySourceFromString(t *testing.T) {
|
||||
func TestPGPKeySourceFromString(t *testing.T) {
|
||||
s := "C8C5 2C0A B2A4 8174 01E8 12C8 F3CC 3233 3FAD 9F1E, C8C5 2C0A B2A4 8174 01E8 12C8 F3CC 3233 3FAD 9F1E"
|
||||
ks := MasterKeysFromFingerprintString(s)
|
||||
expected := "C8C52C0AB2A4817401E812C8F3CC32333FAD9F1E"
|
||||
|
||||
Reference in New Issue
Block a user