Skip to content

Commit

Permalink
app: support SAK from api 29 and above
Browse files Browse the repository at this point in the history
Signed-off-by: BlackMesa123 <[email protected]>
  • Loading branch information
salvogiangri committed Jun 20, 2023
1 parent cc1f9ba commit 3d10401
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class HomeViewModel(pm: PackageManager) : ViewModel() {

@Throws(GeneralSecurityException::class)
private fun generateKey(alias: String, useStrongBox: Boolean, includeProps: Boolean) {
if (SamsungUtils.isSecAttestationSupported()) {
if (Build.VERSION.SDK_INT >= 29 &&
SamsungUtils.isSecAttestationSupported()) {
val now = Date()
val originationEnd = Date(now.time + 1000000)
val consumptionEnd = Date(now.time + 2000000)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.samsung.android.security.keystore;

import android.security.keystore.KeyGenParameterSpec;

import androidx.annotation.RequiresApi;
import javax.security.auth.x500.X500Principal;

@RequiresApi(29)
public class AttestParameterSpec {
public AttestParameterSpec(String algorithm, byte[] challenge, boolean reqAttestDevice,
boolean checkIntegrity, boolean devicePropertiesAttestationIncluded,
Expand Down Expand Up @@ -38,6 +39,7 @@ public boolean isVerifiableIntegrity() {
throw new RuntimeException("Stub!");
}

@RequiresApi(33)
public boolean isDevicePropertiesAttestationIncluded() {
throw new RuntimeException("Stub!");
}
Expand Down Expand Up @@ -71,6 +73,7 @@ public Builder setVerifiableIntegrity(boolean checked) {
throw new RuntimeException("Stub!");
}

@RequiresApi(33)
public Builder setDevicePropertiesAttestationIncluded(
boolean devicePropertiesAttestationIncluded) {
throw new RuntimeException("Stub!");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.samsung.android.security.keystore;

import android.content.Context;

import androidx.annotation.RequiresApi;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyStoreException;
import java.security.ProviderException;
import java.security.cert.Certificate;

@RequiresApi(28)
public class AttestationUtils {
public static final String DEFAULT_KEYSTORE = "AndroidKeyStore";
public static final String PUBKEY_DIGEST_ALGORITHM = "SHA-256";
Expand All @@ -17,6 +18,7 @@ public Iterable<byte[]> attestKey(String alias, byte[] challenge)
throw new RuntimeException("Stub!");
}

@RequiresApi(29)
public Iterable<byte[]> attestKey(AttestParameterSpec spec)
throws IllegalArgumentException, ProviderException, NullPointerException {
throw new RuntimeException("Stub!");
Expand All @@ -28,6 +30,7 @@ public Iterable<byte[]> attestDevice(String alias, byte[] challenge)
throw new RuntimeException("Stub!");
}

@RequiresApi(29)
public Iterable<byte[]> attestDevice(AttestParameterSpec spec)
throws IllegalArgumentException, ProviderException, NullPointerException,
DeviceIdAttestationException {
Expand All @@ -39,28 +42,34 @@ public void storeCertificateChain(String alias, Iterable<byte[]> iterable)
throw new RuntimeException("Stub!");
}

@RequiresApi(29)
public KeyPair generateKeyPair(String alias, byte[] challenge)
throws IllegalArgumentException, ProviderException, NullPointerException {
throw new RuntimeException("Stub!");
}

@RequiresApi(29)
public KeyPair generateKeyPair(AttestParameterSpec spec)
throws IllegalArgumentException, ProviderException, NullPointerException {
throw new RuntimeException("Stub!");
}

@RequiresApi(29)
public Certificate[] getCertificateChain(String alias) {
throw new RuntimeException("Stub!");
}

@RequiresApi(29)
public Key getKey(String alias) throws KeyStoreException {
throw new RuntimeException("Stub!");
}

@RequiresApi(29)
public void deleteKey(String alias) throws KeyStoreException {
throw new RuntimeException("Stub!");
}

@RequiresApi(33)
public boolean isSupportDeviceAttestation(Context context) {
throw new RuntimeException("Stub!");
}
Expand Down

0 comments on commit 3d10401

Please sign in to comment.