summaryrefslogtreecommitdiff
path: root/repackaged_platform/bcprov/src/main/java/com/android/internal/org/bouncycastle/jcajce/provider/keystore/bc/BcKeyStoreSpi.java
diff options
context:
space:
mode:
Diffstat (limited to 'repackaged_platform/bcprov/src/main/java/com/android/internal/org/bouncycastle/jcajce/provider/keystore/bc/BcKeyStoreSpi.java')
-rw-r--r--repackaged_platform/bcprov/src/main/java/com/android/internal/org/bouncycastle/jcajce/provider/keystore/bc/BcKeyStoreSpi.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/repackaged_platform/bcprov/src/main/java/com/android/internal/org/bouncycastle/jcajce/provider/keystore/bc/BcKeyStoreSpi.java b/repackaged_platform/bcprov/src/main/java/com/android/internal/org/bouncycastle/jcajce/provider/keystore/bc/BcKeyStoreSpi.java
index 44be654a..6c2c25b0 100644
--- a/repackaged_platform/bcprov/src/main/java/com/android/internal/org/bouncycastle/jcajce/provider/keystore/bc/BcKeyStoreSpi.java
+++ b/repackaged_platform/bcprov/src/main/java/com/android/internal/org/bouncycastle/jcajce/provider/keystore/bc/BcKeyStoreSpi.java
@@ -935,6 +935,33 @@ public class BcKeyStoreSpi
dOut.close();
}
+ // BEGIN Android-added: new API for KeyStore probing.
+ /**
+ * Probe the first few bytes of the keystore data stream for a valid
+ * keystore encoding. Only the primary keystore implementation is probed.
+ */
+ public boolean engineProbe(InputStream stream) throws IOException {
+ if (stream == null) {
+ throw new NullPointerException("input stream must not be null");
+ }
+ DataInputStream dIn = new DataInputStream(stream);
+ int version = dIn.readInt();
+
+ if (version != STORE_VERSION) {
+ if (version != 0 && version != 1) {
+ return false;
+ }
+ }
+ byte[] salt = new byte[dIn.readInt()];
+
+ if (salt.length != STORE_SALT_SIZE) {
+ return false;
+ }
+
+ return true;
+ }
+ // END Android-added: new API for KeyStore probing.
+
/**
* the BouncyCastle store. This wont work with the key tool as the
* store is stored encrypted on disk, so the password is mandatory,
@@ -1055,6 +1082,30 @@ public class BcKeyStoreSpi
cOut.close();
}
+
+ // BEGIN Android-added: new API for KeyStore probing.
+ @Override
+ public boolean engineProbe(InputStream stream) throws IOException {
+ if (stream == null) {
+ throw new NullPointerException("input stream must not be null");
+ }
+ DataInputStream dIn = new DataInputStream(stream);
+ int version = dIn.readInt();
+
+ if (version != STORE_VERSION) {
+ if (version != 0 && version != 1) {
+ return false;
+ }
+ }
+ byte[] salt = new byte[dIn.readInt()];
+
+ if (salt.length != STORE_SALT_SIZE) {
+ return false;
+ }
+
+ return true;
+ }
+ // END Android-added: new API for KeyStore probing.
}
/**