-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c104211
commit 3a8cdce
Showing
11 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
play-services-api/src/main/aidl/com/google/android/gms/potokens/PoToken.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.potokens; | ||
|
||
parcelable PoToken; |
14 changes: 14 additions & 0 deletions
14
...services-api/src/main/aidl/com/google/android/gms/potokens/internal/IPoTokensService.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.potokens.internal; | ||
|
||
import com.google.android.gms.common.api.internal.IStatusCallback; | ||
import com.google.android.gms.potokens.internal.ITokenCallbacks; | ||
|
||
interface IPoTokensService { | ||
void responseStatus(IStatusCallback call, int code) = 1; | ||
void responseStatusToken(ITokenCallbacks call, int i, in byte[] bArr) = 2; | ||
} |
13 changes: 13 additions & 0 deletions
13
...-services-api/src/main/aidl/com/google/android/gms/potokens/internal/ITokenCallbacks.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.potokens.internal; | ||
|
||
import com.google.android.gms.common.api.Status; | ||
import com.google.android.gms.potokens.PoToken; | ||
|
||
interface ITokenCallbacks { | ||
void responseToken(in Status status, in PoToken token) = 1; | ||
} |
20 changes: 20 additions & 0 deletions
20
play-services-api/src/main/java/com/google/android/gms/potokens/PoToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.potokens; | ||
|
||
import org.microg.safeparcel.AutoSafeParcelable; | ||
|
||
public class PoToken extends AutoSafeParcelable { | ||
|
||
@Field(1) | ||
public byte[] data; | ||
|
||
public PoToken(byte[] data) { | ||
this.data = data; | ||
} | ||
|
||
public static Creator<PoToken> CREATOR = findCreator(PoToken.class); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
option java_package = "com.google.android.gms.potokens"; | ||
|
||
option java_multiple_files = true; | ||
|
||
message CipherKey { | ||
optional int32 key = 1; | ||
optional bytes value = 3; | ||
} | ||
|
||
message KeyData { | ||
optional string typeUrl = 1; | ||
optional CipherKey value = 2; | ||
optional int32 keyMaterialType = 3; | ||
} | ||
|
||
message Key { | ||
optional KeyData data = 1; | ||
optional int32 status = 2; | ||
optional int32 keyId = 3; | ||
optional int32 outputPrefixType = 4; | ||
} | ||
|
||
message KeySet { | ||
optional int32 keyId = 1; | ||
repeated Key keyList = 2; | ||
} | ||
|
||
message PoTokenInfo { | ||
optional int32 key = 6; | ||
optional int32 time = 1; | ||
optional bytes inputData = 2; | ||
optional string pkgName = 3; | ||
optional bytes pkgSignSha256 = 4; | ||
optional bytes tokenData = 5; | ||
} | ||
|
||
message GetPoIntegrityTokenRequest { | ||
optional int32 mode = 1; | ||
optional bytes dgResult = 2; | ||
optional bytes dgRandKey = 3; | ||
} | ||
|
||
message GetPoIntegrityTokenResponse { | ||
optional bytes desc = 1; | ||
optional int32 code = 2; | ||
optional bytes backup = 3; | ||
// optional bytes d = 4; | ||
// optional bytes e = 5; | ||
} | ||
|
||
message PoTokenResult { | ||
optional bytes encryptData = 1; | ||
optional bytes tokenData = 2; | ||
} | ||
|
||
message PoTokenResultWrap { | ||
optional PoTokenResult data = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...vices-core/src/main/kotlin/com/google/android/gms/potokens/internal/PoTokensApiService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.potokens.internal | ||
|
||
import android.util.Log | ||
import androidx.lifecycle.lifecycleScope | ||
import com.google.android.gms.common.Feature | ||
import com.google.android.gms.common.api.CommonStatusCodes | ||
import com.google.android.gms.common.internal.ConnectionInfo | ||
import com.google.android.gms.common.internal.GetServiceRequest | ||
import com.google.android.gms.common.internal.IGmsCallbacks | ||
import com.google.android.gms.potokens.utils.PoTokenConstants | ||
import org.microg.gms.BaseService | ||
import org.microg.gms.common.GmsService | ||
|
||
const val TAG = "PoTokensApi" | ||
|
||
class PoTokensApiService : BaseService(TAG, GmsService.POTOKENS) { | ||
override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) { | ||
val connectionInfo = ConnectionInfo() | ||
connectionInfo.features = arrayOf(Feature(PoTokenConstants.PO_TOKENS, 1)) | ||
Log.d(TAG, "PoTokensApiService handleServiceRequest") | ||
callback.onPostInitCompleteWithConnectionInfo( | ||
CommonStatusCodes.SUCCESS, PoTokensApiServiceImpl( | ||
applicationContext, request.packageName, lifecycleScope | ||
), connectionInfo | ||
) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...s-core/src/main/kotlin/com/google/android/gms/potokens/internal/PoTokensApiServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.potokens.internal | ||
|
||
import android.content.Context | ||
import android.util.Log | ||
import androidx.lifecycle.LifecycleCoroutineScope | ||
import com.google.android.gms.common.api.Status | ||
import com.google.android.gms.common.api.internal.IStatusCallback | ||
import com.google.android.gms.potokens.PoToken | ||
import com.google.android.gms.potokens.utils.PoTokenHelper | ||
import org.microg.gms.profile.ProfileManager | ||
|
||
class PoTokensApiServiceImpl( | ||
private val context: Context, | ||
private val packageName: String, | ||
private val lifecycleCoroutineScope: LifecycleCoroutineScope | ||
) : IPoTokensService.Stub() { | ||
|
||
override fun responseStatus(call: IStatusCallback, code: Int) { | ||
Log.e(TAG, "responseStatus success") | ||
call.onResult(Status.SUCCESS) | ||
} | ||
|
||
override fun responseStatusToken(call: ITokenCallbacks, i: Int, bArr: ByteArray) { | ||
Log.d(TAG, "responseStatusToken packageName: $packageName") | ||
ProfileManager.ensureInitialized(context) | ||
|
||
lifecycleCoroutineScope.launchWhenCreated { | ||
Log.d(TAG, "responseStatusToken start") | ||
val bytes = PoTokenHelper.get(context).callPoToken(context, packageName, bArr) | ||
Log.d(TAG, "responseStatusToken result: ${bytes.size}") | ||
call.responseToken(Status.SUCCESS, PoToken(bytes)) | ||
Log.d(TAG, "responseStatusToken end") | ||
} | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
play-services-core/src/main/kotlin/com/google/android/gms/potokens/utils/PoTokenConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.potokens.utils | ||
|
||
object PoTokenConstants { | ||
const val PO_TOKENS = "PO_TOKENS" | ||
const val TOKEN_URL = | ||
"https://deviceintegritytokens-pa.googleapis.com/v1/getPoIntegrityToken?alt=proto&key=AIzaSyBtL0AK6Hzgr69rQyeyhi-V1lmtsPGZd1M" | ||
const val TYPE_URL = "type.googleapis.com/google.crypto.tink.AesGcmKey" | ||
const val KEY_TOKEN = "po-token-fast" | ||
const val KEY_FAST = "po-fast-key" | ||
const val KEY_FALLBACK = "extraKeysRetainedInFallback" | ||
const val KEY_DESC = "tokenDesc" | ||
const val KEY_BACKUP = "tokenBackup" | ||
const val KEY_SET_STR = "keySetStr" | ||
} |
Oops, something went wrong.