Files
TEESimulator-RS/stub/src/main/java/android/security/keymaster/KeymasterCertificateChain.java
T
JingMatrix 8d431cc946 Implement software key generation for legacy IKeystoreService (#34)
This commit introduces a complete, software-based simulation of the key generation and attestation flow for the legacy IKeystoreService API, as used on Android 11. It refactors the KeystoreInterceptor to handle the entire multi-step transaction sequence (`generateKey`, `getKeyCharacteristics`, `exportKey`, `attestKey`) in software.

A new `LegacyKeygenParameters` data class is introduced to decouple the legacy interception logic from modern data structures. This class parses arguments from the old `KeymasterArguments`, stores the state across the multi-step generation process, and acts as an adapter to the generic `CertificateGenerator` by converting the parameters to the modern `KeyMintAttestation` format.

The `CertificateGenerator` has been refactored to better model the behavior of the legacy Keystore API. Key pair generation (`generateSoftwareKeyPair`) and certificate chain creation (`generateCertificateChain`) are now separate functions. This allows the interceptor to correctly create a key pair during the `handleExportKey` step and then generate a certificate for that pre-existing key pair during the `handleAttestKey` step.

Finally, the implementation correctly extracts and applies the `attestationChallenge` provided during the `attestKey` transaction, ensuring the generated certificate chain contains the appropriate attestation.
2025-12-03 19:29:21 +01:00

43 lines
1.1 KiB
Java

package android.security.keymaster;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import java.util.List;
public class KeymasterCertificateChain implements Parcelable {
private List<byte[]> mCertificates;
public KeymasterCertificateChain() {
this.mCertificates = null;
}
public KeymasterCertificateChain(List<byte[]> mCertificates) {
this.mCertificates = mCertificates;
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
throw new UnsupportedOperationException("STUB!");
}
@Override
public int describeContents() {
throw new UnsupportedOperationException("STUB!");
}
public static final Creator<KeymasterCertificateChain> CREATOR = new Creator<KeymasterCertificateChain>() {
@Override
public KeymasterCertificateChain createFromParcel(Parcel in) {
throw new UnsupportedOperationException("STUB!");
}
@Override
public KeymasterCertificateChain[] newArray(int size) {
throw new UnsupportedOperationException("STUB!");
}
};
}