This is an automated email from the ASF dual-hosted git repository. utzig pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git
The following commit(s) were added to refs/heads/master by this push: new 56555f5 added HasEncryptionPayload function to check for possible HW encryption 56555f5 is described below commit 56555f5f45008ce9f277a4c51c3d5593734752d1 Author: Mark Blake <4048475+weekendsuperh...@users.noreply.github.com> AuthorDate: Mon Aug 16 12:32:21 2021 -0700 added HasEncryptionPayload function to check for possible HW encryption --- image/image.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/image/image.go b/image/image.go index d54eb82..4842cde 100644 --- a/image/image.go +++ b/image/image.go @@ -813,3 +813,27 @@ func (img *Image) Bin() ([]byte, error) { return b.Bytes(), nil } + +// HasEncryptionPayload indicates whether an image's contains a HW encryption payload. +func (img *Image) HasEncryptionPayload() bool { + enc := false + res, _ := img.FindAllUniqueTlv(IMAGE_TLV_SECRET_ID_LEGACY) + if res != nil { + nonce, _ := img.FindAllUniqueTlv(IMAGE_TLV_AES_NONCE_LEGACY) + if nonce != nil { + enc = true + } + + } + if !enc { + res, _ = img.FindAllUniqueTlv(IMAGE_TLV_SECRET_ID) + if res != nil { + nonce, _ := img.FindAllUniqueTlv(IMAGE_TLV_AES_NONCE) + if nonce != nil { + enc = true + } + + } + } + return enc +}