Skip to content

Commit 150a476

Browse files
JingMatrixMhmRddEnginex0
authored
Fix key parameters in authorization list (#176)
Previous commit 57b92ab wrongly encoded the key parameter `PADDING`, which should be a single SET OF INTEGER (like PURPOSE and DIGEST). Moreover, we now include the key parameter BLOCK_MODE in KeyEntryResponse with correct order (found in key generation of `mobstore_encrypt` by GMS). Co-authored-by: Mohammed Riad <1@mhmrdd.me> Co-authored-by: Enginex0 <enginex0@users.noreply.github.com>
1 parent 7209171 commit 150a476

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

app/src/main/java/org/matrix/TEESimulator/attestation/AttestationBuilder.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,13 @@ object AttestationBuilder {
193193
)
194194
}
195195

196-
params.padding.forEach {
196+
if (params.padding.isNotEmpty()) {
197197
list.add(
198-
DERTaggedObject(true, AttestationConstants.TAG_PADDING, ASN1Integer(it.toLong()))
198+
DERTaggedObject(
199+
true,
200+
AttestationConstants.TAG_PADDING,
201+
DERSet(params.padding.map { ASN1Integer(it.toLong()) }.toTypedArray()),
202+
)
199203
)
200204
}
201205

app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ private fun KeyMintAttestation.toAuthorizations(
452452
}
453453

454454
this.purpose.forEach { authList.add(createAuth(Tag.PURPOSE, KeyParameterValue.keyPurpose(it))) }
455+
this.blockMode.forEach {
456+
authList.add(createAuth(Tag.BLOCK_MODE, KeyParameterValue.blockMode(it)))
457+
}
455458
this.digest.forEach { authList.add(createAuth(Tag.DIGEST, KeyParameterValue.digest(it))) }
456459
this.padding.forEach {
457460
authList.add(createAuth(Tag.PADDING, KeyParameterValue.paddingMode(it)))

0 commit comments

Comments
 (0)