From 87b876a73b0d44094fff38ad970b8f052e271384 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 20 Sep 2021 12:30:26 -0400 Subject: [PATCH] crypto/armor: remove unused package (#6963) --- CHANGELOG_PENDING.md | 4 ++++ crypto/armor/armor.go | 39 -------------------------------------- crypto/armor/armor_test.go | 20 ------------------- 3 files changed, 4 insertions(+), 59 deletions(-) delete mode 100644 crypto/armor/armor.go delete mode 100644 crypto/armor/armor_test.go diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index af278d3fb..1c8c2b81e 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -16,6 +16,10 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi - Go API + - [crypto/armor]: \#6963 remove package which is unused, and based on + deprecated fundamentals. Downstream users should maintain this + library. (@tychoish) + - Blockchain Protocol ### FEATURES diff --git a/crypto/armor/armor.go b/crypto/armor/armor.go deleted file mode 100644 index c15d070e6..000000000 --- a/crypto/armor/armor.go +++ /dev/null @@ -1,39 +0,0 @@ -package armor - -import ( - "bytes" - "fmt" - "io/ioutil" - - "golang.org/x/crypto/openpgp/armor" -) - -func EncodeArmor(blockType string, headers map[string]string, data []byte) string { - buf := new(bytes.Buffer) - w, err := armor.Encode(buf, blockType, headers) - if err != nil { - panic(fmt.Errorf("could not encode ascii armor: %s", err)) - } - _, err = w.Write(data) - if err != nil { - panic(fmt.Errorf("could not encode ascii armor: %s", err)) - } - err = w.Close() - if err != nil { - panic(fmt.Errorf("could not encode ascii armor: %s", err)) - } - return buf.String() -} - -func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error) { - buf := bytes.NewBufferString(armorStr) - block, err := armor.Decode(buf) - if err != nil { - return "", nil, nil, err - } - data, err = ioutil.ReadAll(block.Body) - if err != nil { - return "", nil, nil, err - } - return block.Type, block.Header, data, nil -} diff --git a/crypto/armor/armor_test.go b/crypto/armor/armor_test.go deleted file mode 100644 index 8ecfaa0e1..000000000 --- a/crypto/armor/armor_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package armor - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestArmor(t *testing.T) { - blockType := "MINT TEST" - data := []byte("somedata") - armorStr := EncodeArmor(blockType, nil, data) - - // Decode armorStr and test for equivalence. - blockType2, _, data2, err := DecodeArmor(armorStr) - require.Nil(t, err, "%+v", err) - assert.Equal(t, blockType, blockType2) - assert.Equal(t, data, data2) -}