Skip to content

Commit

Permalink
sign_encrypt.py: fix incorrect tag value output in the display command.
Browse files Browse the repository at this point in the history
Fix a bug where the display command shows incorrect tag value when the
input is an encrypted TA.

Signed-off-by: Sungmin Han <[email protected]>
Acked-by: Jerome Forissier <[email protected]>
  • Loading branch information
meeneemaru authored and jforissier committed Jan 13, 2025
1 parent 96e8f74 commit a0f3154
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/sign_encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def display_ta():

if enc_algo not in enc_tee_alg.values():
raise Exception('Unrecognized encrypt algorithm: 0x{:08x}'
.format(enc_value))
.format(enc_algo))

flags_name = 'Unkown'
if flags in enc_key_type.values():
Expand All @@ -617,18 +617,19 @@ def display_ta():
print(' tag_size: {} (bytes)'.format(tag_len))
if tag_len != TAG_SIZE:
raise Exception("Unexpected tag len: {}".format(tag_len))
tag = self.inf[-tag_len:]
tag = self.inf[offs:offs+tag_len]
print(' tag: {}'
.format(binascii.hexlify(tag).decode('ascii')))
ciphertext = self.inf[offs:-tag_len]
offs += tag_len

ciphertext = self.inf[offs:]
print(' TA offset: {} (0x{:x}) bytes'.format(offs, offs))
print(' TA size: {} (0x{:x}) bytes'
.format(len(ciphertext), len(ciphertext)))
if len(ciphertext) != img_size:
raise Exception("Unexpected ciphertext size: ",
"got {}, expected {}"
.format(len(ciphertext), img_size))
offs += tag_len
else:
img = self.inf[offs:]
print(' TA offset: {} (0x{:x}) bytes'.format(offs, offs))
Expand Down

0 comments on commit a0f3154

Please sign in to comment.