add KeyGenerator for AndroidKeyStore

This commit is contained in:
Julian Winkler
2025-06-18 08:59:22 +02:00
committed by Mis012
parent a57da8fcb5
commit d898966e04
5 changed files with 125 additions and 3 deletions

View File

@@ -0,0 +1,68 @@
package android.security.keystore;
public class KeyGenParameterSpec {
private String keystoreAlias;
private int purposes;
private int keySize;
private String[] blockModes;
private String[] encryptionPaddings;
private boolean userAuthenticationRequired;
public static class Builder {
private KeyGenParameterSpec spec = new KeyGenParameterSpec();
public Builder(String keystoreAlias, int purposes) {
spec.keystoreAlias = keystoreAlias;
spec.purposes = purposes;
}
public Builder setKeySize(int keySize) {
spec.keySize = keySize;
return this;
}
public Builder setBlockModes(String[] blockModes) {
spec.blockModes = blockModes;
return this;
}
public Builder setEncryptionPaddings(String[] encryptionPaddings) {
spec.encryptionPaddings = encryptionPaddings;
return this;
}
public Builder setUserAuthenticationRequired(boolean userAuthenticationRequired) {
spec.userAuthenticationRequired = userAuthenticationRequired;
return this;
}
public KeyGenParameterSpec build() {
return spec;
}
}
public int getKeySize() {
return keySize;
}
public String[] getBlockModes() {
return blockModes;
}
public int getPurposes() {
return purposes;
}
public String[] getEncryptionPaddings() {
return encryptionPaddings;
}
public boolean isUserAuthenticationRequired() {
return userAuthenticationRequired;
}
public String getKeystoreAlias() {
return keystoreAlias;
}
}