tpm-helpers/tpm_encrypt_test.go

27 lines
638 B
Go
Raw Permalink Normal View History

2023-01-18 14:45:17 +00:00
package tpm_test
import (
. "github.com/kairos-io/tpm-helpers"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("TPM Encryption", func() {
Context("Blob", func() {
It("encrypts a blob", func() {
var encryptedBlob []byte
2023-01-18 14:45:17 +00:00
var err error
By("Encrypting the blob", func() {
encryptedBlob, err = EncryptBlob([]byte("foo"), EmulatedTPM)
2023-01-18 14:45:17 +00:00
Expect(err).ToNot(HaveOccurred())
})
By("Decrypting the blob", func() {
foo, err := DecryptBlob(encryptedBlob, EmulatedTPM)
2023-01-18 14:45:17 +00:00
Expect(err).ToNot(HaveOccurred())
Expect(foo).To(Equal([]byte("foo")))
})
CloseEmulatedDevice()
})
})
})