From 3fa97128ef6b8efe6f4c0e115b0f57bdaf145735 Mon Sep 17 00:00:00 2001 From: Dimitris Karakasilis Date: Thu, 19 Jan 2023 16:01:50 +0200 Subject: [PATCH] Rename functions from encode to encrypt to better reflect reality Signed-off-by: Dimitris Karakasilis --- tpm_encrypt.go | 6 +++--- tpm_encrypt_test.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tpm_encrypt.go b/tpm_encrypt.go index f8ae3ab..01de860 100644 --- a/tpm_encrypt.go +++ b/tpm_encrypt.go @@ -12,8 +12,8 @@ import ( "github.com/pkg/errors" ) -// DecodeBlob decodes a blob using a key stored in the TPM -func DecodeBlob(blob []byte, opts ...TPMOption) ([]byte, error) { +// DecryptBlob decrypts a blob using a key stored in the TPM +func DecryptBlob(blob []byte, opts ...TPMOption) ([]byte, error) { o, err := DefaultTPMOption(opts...) if err != nil { return []byte{}, err @@ -35,7 +35,7 @@ func DecodeBlob(blob []byte, opts ...TPMOption) ([]byte, error) { return private.Decrypt(rand.Reader, blob, &rsa.OAEPOptions{Hash: o.hash}) } -func EncodeBlob(blob []byte, opts ...TPMOption) ([]byte, error) { +func EncryptBlob(blob []byte, opts ...TPMOption) ([]byte, error) { o, err := DefaultTPMOption(opts...) if err != nil { return []byte{}, err diff --git a/tpm_encrypt_test.go b/tpm_encrypt_test.go index f6ff7c8..e57934c 100644 --- a/tpm_encrypt_test.go +++ b/tpm_encrypt_test.go @@ -9,14 +9,14 @@ import ( var _ = Describe("TPM Encryption", func() { Context("Blob", func() { It("encrypts a blob", func() { - var encodedBlob []byte + var encryptedBlob []byte var err error - By("Encoding the blob", func() { - encodedBlob, err = EncodeBlob([]byte("foo"), EmulatedTPM) + By("Encrypting the blob", func() { + encryptedBlob, err = EncryptBlob([]byte("foo"), EmulatedTPM) Expect(err).ToNot(HaveOccurred()) }) - By("Decoding the blob", func() { - foo, err := DecodeBlob(encodedBlob, EmulatedTPM) + By("Decrypting the blob", func() { + foo, err := DecryptBlob(encryptedBlob, EmulatedTPM) Expect(err).ToNot(HaveOccurred()) Expect(foo).To(Equal([]byte("foo"))) })