mirror of
https://github.com/kairos-io/tpm-helpers.git
synced 2025-08-02 06:31:59 +00:00
Rename functions from encode to encrypt
to better reflect reality Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
18d63f3a8c
commit
3fa97128ef
@ -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
|
||||
|
@ -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")))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user