Skip to content

Commit 1d0e1f1

Browse files
carmenyhcopybara-github
authored andcommitted
Rename teeEnforced to hardwareEnforced.
PiperOrigin-RevId: 776162949
1 parent 6541eca commit 1d0e1f1

19 files changed

+36
-42
lines changed

src/main/kotlin/Extension.kt

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,17 @@ data class DeviceIdentity(
114114
@JvmStatic
115115
fun parseFrom(description: KeyDescription) =
116116
DeviceIdentity(
117-
description.teeEnforced.attestationIdBrand,
118-
description.teeEnforced.attestationIdDevice,
119-
description.teeEnforced.attestationIdProduct,
120-
description.teeEnforced.attestationIdSerial,
117+
description.hardwareEnforced.attestationIdBrand,
118+
description.hardwareEnforced.attestationIdDevice,
119+
description.hardwareEnforced.attestationIdProduct,
120+
description.hardwareEnforced.attestationIdSerial,
121121
setOfNotNull(
122-
description.teeEnforced.attestationIdImei,
123-
description.teeEnforced.attestationIdSecondImei,
122+
description.hardwareEnforced.attestationIdImei,
123+
description.hardwareEnforced.attestationIdSecondImei,
124124
),
125-
description.teeEnforced.attestationIdMeid,
126-
description.teeEnforced.attestationIdManufacturer,
127-
description.teeEnforced.attestationIdModel,
125+
description.hardwareEnforced.attestationIdMeid,
126+
description.hardwareEnforced.attestationIdManufacturer,
127+
description.hardwareEnforced.attestationIdModel,
128128
)
129129
}
130130
}
@@ -139,8 +139,7 @@ data class KeyDescription(
139139
val attestationChallenge: ByteString,
140140
val uniqueId: ByteString,
141141
val softwareEnforced: AuthorizationList,
142-
// TODO: Rename to hardwareEnforced b/c could be TEE or StrongBox.
143-
val teeEnforced: AuthorizationList,
142+
val hardwareEnforced: AuthorizationList,
144143
) {
145144
fun asExtension(): Extension {
146145
return Extension(OID, /* critical= */ false, encodeToAsn1())
@@ -155,7 +154,7 @@ data class KeyDescription(
155154
add(attestationChallenge.toAsn1())
156155
add(uniqueId.toAsn1())
157156
add(softwareEnforced.toAsn1())
158-
add(teeEnforced.toAsn1())
157+
add(hardwareEnforced.toAsn1())
159158
}
160159
.let { DERSequence(it.toTypedArray()).encoded }
161160

@@ -178,7 +177,7 @@ data class KeyDescription(
178177
from(ASN1Sequence.getInstance(bytes))
179178
} catch (e: NullPointerException) {
180179
// Workaround for a NPE in BouncyCastle.
181-
// http://google3/third_party/java_src/bouncycastle/core/src/main/java/org/bouncycastle/asn1/ASN1UniversalType.java;l=24;rcl=484684674
180+
// https://github.com/bcgit/bc-java/blob/228211ecb973fe87fdd0fc4ab16ba0446ec1a29c/core/src/main/java/org/bouncycastle/asn1/ASN1UniversalType.java#L24
182181
throw IllegalArgumentException(e)
183182
}
184183

@@ -192,7 +191,7 @@ data class KeyDescription(
192191
attestationChallenge = seq.getObjectAt(4).toByteString(),
193192
uniqueId = seq.getObjectAt(5).toByteString(),
194193
softwareEnforced = seq.getObjectAt(6).toAuthorizationList(),
195-
teeEnforced = seq.getObjectAt(7).toAuthorizationList(),
194+
hardwareEnforced = seq.getObjectAt(7).toAuthorizationList(),
196195
)
197196
}
198197
}
@@ -204,14 +203,10 @@ data class KeyDescription(
204203
* @see https://source.android.com/docs/security/features/keystore/attestation#securitylevel-values
205204
*/
206205
enum class SecurityLevel(val value: Int) {
207-
// LINT.IfChange(security_level)
208206
SOFTWARE(0),
209207
TRUSTED_ENVIRONMENT(1),
210208
STRONG_BOX(2);
211209

212-
// LINT.ThenChange(//depot/google3/identity/cryptauth/apparat/apparat.proto:key_type,
213-
// //depot/google3/identity/cryptauth/apparat/storage/apparat_storage_api.proto:keymaster_security_level)
214-
215210
internal fun toAsn1() = ASN1Enumerated(value)
216211
}
217212

src/main/kotlin/Verifier.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ open class Verifier(
121121
}
122122

123123
if (
124-
keyDescription.teeEnforced.origin == null ||
125-
keyDescription.teeEnforced.origin != Origin.GENERATED
124+
keyDescription.hardwareEnforced.origin == null ||
125+
keyDescription.hardwareEnforced.origin != Origin.GENERATED
126126
) {
127127
return VerificationResult.ExtensionConstraintViolation(
128-
"origin != GENERATED: ${keyDescription.teeEnforced.origin}"
128+
"origin != GENERATED: ${keyDescription.hardwareEnforced.origin}"
129129
)
130130
}
131131

@@ -138,8 +138,10 @@ open class Verifier(
138138
)
139139
}
140140
val rootOfTrust =
141-
keyDescription.teeEnforced.rootOfTrust
142-
?: return VerificationResult.ExtensionConstraintViolation("teeEnforced.rootOfTrust is null")
141+
keyDescription.hardwareEnforced.rootOfTrust
142+
?: return VerificationResult.ExtensionConstraintViolation(
143+
"hardwareEnforced.rootOfTrust is null"
144+
)
143145
val deviceInformation =
144146
if (certPath.provisioningMethod() == ProvisioningMethod.REMOTELY_PROVISIONED) {
145147
certPath.attestationCert().provisioningInfo()

src/main/kotlin/provider/KeyAttestationCertPathValidator.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ private class BasicChecker(
256256
* KAVS does not check the validity of the final certificate in the path. For the purposes of
257257
* migration this path validator is intended to be bug compatible with KAVS, so we do not check
258258
* the validity of the final certificate either.
259-
* http://google3/java/com/google/wireless/android/work/boq/unspoofableid/common/VerifyCertificateChain.java;l=173;rcl=679670181
260259
*
261260
* TODO: b/355190989 - explore if is viable to check the validity of the final certificate.
262261
*/

src/main/kotlin/provider/RevocationChecker.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import java.security.cert.X509Certificate
2727
*
2828
* Currently, this class is a clone of the as-built revocation checker from KAVS. It is only
2929
* intended to be for migrating the bespoke KAVS path validation logic to this provider.
30-
*
31-
* http://google3/java/com/google/wireless/android/work/boq/unspoofableid/common/VerifyCertificateChain.java;l=107;rcl=677835266
3230
*/
3331
class RevocationChecker(private val revokedSerials: Set<String>) : PKIXRevocationChecker() {
3432
override fun init(forward: Boolean) {

src/main/kotlin/testing/KeyAttestationCertFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ internal class KeyAttestationCertFactory(val fakeCalendar: FakeCalendar = FakeCa
130130
attestationChallenge = ByteString.copyFromUtf8("A random 40-byte challenge for no reason"),
131131
uniqueId = ByteString.empty(),
132132
softwareEnforced = AuthorizationList(),
133-
teeEnforced =
133+
hardwareEnforced =
134134
AuthorizationList(
135135
rootOfTrust =
136136
RootOfTrust(

src/main/kotlin/testing/KeyAttestationCertPathFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class KeyAttestationCertPathFactory(val fakeCalendar: FakeCalendar = FakeCalenda
5050
/* critical= */ false,
5151
ProvisioningInfoMap(
5252
certificatesIssued = 1,
53-
manufacturer = keyDescription.teeEnforced.attestationIdManufacturer,
53+
manufacturer = keyDescription.hardwareEnforced.attestationIdManufacturer,
5454
)
5555
.encodeToAsn1(),
5656
),

src/test/kotlin/ExtensionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ExtensionTest {
6767
fun parseFrom_containsAllowWhileOnBody_success() {
6868
val unused =
6969
testData.resolve("allow_while_on_body.pem").inputStream().asX509Certificate().keyDescription()
70-
// assertThat(keyDescription.teeEnforced.allowWhileOnBody).isTrue()
70+
// assertThat(keyDescription.hardwareEnforced.allowWhileOnBody).isTrue()
7171
}
7272

7373
@Test
@@ -142,7 +142,7 @@ class ExtensionTest {
142142
attestationChallenge = ByteString.empty(),
143143
uniqueId = ByteString.empty(),
144144
softwareEnforced = authorizationList,
145-
teeEnforced = authorizationList,
145+
hardwareEnforced = authorizationList,
146146
)
147147
assertThat(KeyDescription.parseFrom(keyDescription.encodeToAsn1())).isEqualTo(keyDescription)
148148
}

testdata/akita/sdk34/SB_RSA_NONE.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"signatures": ["EDk47kU35Z6O55L2VFBPuDRvxrNG0LvEQV/DOfz8jsE="]
1818
}
1919
},
20-
"teeEnforced": {
20+
"hardwareEnforced": {
2121
"purposes": ["2"],
2222
"keySize": "2048",
2323
"algorithms": "1",

testdata/akita/sdk34/TEE_EC_NONE.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"signatures": ["EDk47kU35Z6O55L2VFBPuDRvxrNG0LvEQV/DOfz8jsE="]
1818
}
1919
},
20-
"teeEnforced": {
20+
"hardwareEnforced": {
2121
"purposes": ["2"],
2222
"keySize": "256",
2323
"algorithms": "3",

testdata/akita/sdk34/TEE_RSA_BASE+IMEI.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"signatures": []
1313
}
1414
},
15-
"teeEnforced": {
15+
"hardwareEnforced": {
1616
"purposes": ["2"],
1717
"keySize": "2048",
1818
"algorithms": "1",

0 commit comments

Comments
 (0)