Skip to content

Commit 1bf59da

Browse files
committed
feat: init OhMyKeymint
Signed-off-by: qwq233 <[email protected]>
1 parent 0ba1888 commit 1bf59da

File tree

76 files changed

+5208
-1482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5208
-1482
lines changed

module/src/main/cpp/binder_interceptor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ BinderInterceptor::handleIntercept(sp<BBinder> target, uint32_t code, const Parc
259259
CHECK(tmpData.writeUint32(code));
260260
CHECK(tmpData.writeUint32(flags));
261261
CHECK(tmpData.writeInt32(IPCThreadState::self()->getCallingUid()));
262+
CHECK(tmpData.writeCString(IPCThreadState::self()->getCallingSid()));
262263
CHECK(tmpData.writeInt32(IPCThreadState::self()->getCallingPid()));
263264
CHECK(tmpData.writeUint64(data.dataSize()));
264265
CHECK(tmpData.appendFrom(&data, 0, data.dataSize()));
@@ -290,6 +291,7 @@ BinderInterceptor::handleIntercept(sp<BBinder> target, uint32_t code, const Parc
290291
CHECK(tmpData.writeUint32(code));
291292
CHECK(tmpData.writeUint32(flags));
292293
CHECK(tmpData.writeInt32(IPCThreadState::self()->getCallingUid()));
294+
// CHECK(tmpData.writeCString(IPCThreadState::self()->getCallingSid()));
293295
CHECK(tmpData.writeInt32(IPCThreadState::self()->getCallingPid()));
294296
CHECK(tmpData.writeInt32(result));
295297
CHECK(tmpData.writeUint64(data.dataSize()));

service/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import android.databinding.tool.ext.capitalizeUS
2-
import org.gradle.kotlin.dsl.register
32
import org.jetbrains.kotlin.daemon.common.toHexString
43
import java.security.MessageDigest
54

@@ -31,7 +30,7 @@ fun calculateChecksum(variantLowered: String): String {
3130

3231
android {
3332
namespace = "io.github.a13e300.tricky_store"
34-
compileSdk = 35
33+
compileSdk = 36
3534

3635
defaultConfig {
3736
applicationId = "io.github.a13e300.tricky_store"
@@ -74,6 +73,7 @@ android {
7473
}
7574

7675
buildFeatures {
76+
aidl = true
7777
buildConfig = true
7878
}
7979

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.security.keymint;
18+
19+
/**
20+
* Algorithms provided by IKeyMintDevice implementations.
21+
* @hide
22+
*/
23+
24+
@Backing(type="int")
25+
enum Algorithm {
26+
/** Asymmetric algorithms. */
27+
RSA = 1,
28+
/** 2 removed, do not reuse. */
29+
EC = 3,
30+
31+
/** Block cipher algorithms */
32+
AES = 32,
33+
TRIPLE_DES = 33,
34+
35+
/** MAC algorithms */
36+
HMAC = 128,
37+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.security.keymint;
18+
19+
import android.hardware.security.keymint.KeyParameter;
20+
21+
/**
22+
* Contains a key blob with Tag::ATTEST_KEY that can be used to sign an attestation certificate,
23+
* and the DER-encoded X.501 Subject Name that will be placed in the Issuer field of the attestation
24+
* certificate.
25+
* @hide
26+
*/
27+
28+
@RustDerive(Clone=true, Eq=true, PartialEq=true, Ord=true, PartialOrd=true, Hash=true)
29+
parcelable AttestationKey {
30+
/**
31+
* Key blob containing a key pair with KeyPurpose::ATTEST_KEY
32+
*/
33+
byte[] keyBlob;
34+
35+
/**
36+
* Key parameters needed to use the key in keyBlob, notably Tag::APPLICATION_ID and
37+
* Tag::APPLICATION_DATA, if they were provided during generation of the key in keyBlob.
38+
*/
39+
KeyParameter[] attestKeyParams;
40+
41+
/**
42+
* The issuerSubjectName to use in the generated attestation.
43+
*/
44+
byte[] issuerSubjectName;
45+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.security.keymint;
18+
19+
import android.hardware.security.keymint.IKeyMintOperation;
20+
import android.hardware.security.keymint.KeyParameter;
21+
22+
/**
23+
* This is all the results returned by the IKeyMintDevice begin() function.
24+
* @hide
25+
*/
26+
27+
parcelable BeginResult {
28+
/**
29+
* This is the challenge used to verify authorization of an operation.
30+
* See IKeyMintOperation.aidl entrypoints updateAad() and update().
31+
*/
32+
long challenge;
33+
34+
/**
35+
* begin() uses this field to return additional data from the operation
36+
* initialization, notably to return the IV or nonce from operations
37+
* that generate an IV or nonce.
38+
*/
39+
KeyParameter[] params;
40+
IKeyMintOperation operation;
41+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (C) 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.security.keymint;
18+
19+
/**
20+
* Symmetric block cipher modes provided by IKeyMintDevice implementations.
21+
* @hide
22+
*/
23+
24+
@Backing(type="int")
25+
enum BlockMode {
26+
/*
27+
* Unauthenticated modes, usable only for encryption/decryption and not generally recommended
28+
* except for compatibility with existing other protocols.
29+
*/
30+
ECB = 1,
31+
CBC = 2,
32+
CTR = 3,
33+
34+
/*
35+
* Authenticated modes, usable for encryption/decryption and signing/verification. Recommended
36+
* over unauthenticated modes for all purposes.
37+
*/
38+
GCM = 32,
39+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.security.keymint;
18+
19+
/**
20+
* This encodes an IKeyMintDevice certificate, generated for a KeyMint asymmetric public key.
21+
* @hide
22+
*/
23+
24+
parcelable Certificate {
25+
/**
26+
* EncodedCertificate contains the bytes of a DER-encoded X.509 certificate.
27+
*/
28+
byte[] encodedCertificate;
29+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.security.keymint;
18+
19+
/**
20+
* Digests provided by keyMint implementations.
21+
* @hide
22+
*/
23+
24+
@Backing(type="int")
25+
enum Digest {
26+
NONE = 0,
27+
MD5 = 1,
28+
SHA1 = 2,
29+
SHA_2_224 = 3,
30+
SHA_2_256 = 4,
31+
SHA_2_384 = 5,
32+
SHA_2_512 = 6,
33+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (C) 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.hardware.security.keymint;
18+
19+
/**
20+
* Supported EC curves, used in ECDSA
21+
* @hide
22+
*/
23+
24+
@Backing(type="int")
25+
enum EcCurve {
26+
P_224 = 0,
27+
P_256 = 1,
28+
P_384 = 2,
29+
P_521 = 3,
30+
CURVE_25519 = 4,
31+
}

0 commit comments

Comments
 (0)