summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Android (Google) Code Review <android-gerrit@google.com> 2009-06-16 08:37:33 -0700
committer The Android Open Source Project <initial-contribution@android.com> 2009-06-16 08:37:33 -0700
commitb91f20fd0bb16f92371aad090dee9802dd57a629 (patch)
tree38dea349650b8f0d21fa82ca3bf8ce6a55d7adb9
parented776592e18369d02be9c263056d3c2c2dd969ba (diff)
parent8742e120608328e2505f15903a33e538e68bd519 (diff)
am 8742e120: Merge change 4311 into donut
Merge commit '8742e120608328e2505f15903a33e538e68bd519' * commit '8742e120608328e2505f15903a33e538e68bd519': Add keygen API to Keystore.
-rw-r--r--keystore/java/android/security/Keystore.java42
-rw-r--r--keystore/java/android/security/UnsupportedKeyStrengthException.java27
2 files changed, 69 insertions, 0 deletions
diff --git a/keystore/java/android/security/Keystore.java b/keystore/java/android/security/Keystore.java
index 3f83473199ae..8de20af30d07 100644
--- a/keystore/java/android/security/Keystore.java
+++ b/keystore/java/android/security/Keystore.java
@@ -46,6 +46,13 @@ public abstract class Keystore {
*/
public abstract String[] getAllUserkeyKeys();
+ public abstract String[] getSupportedKeyStrenghs();
+
+ public abstract String generateKeyPair(String keyStrength, String challenge,
+ String organizations) throws UnsupportedKeyStrengthException;
+
+ public abstract void addCertificate(String cert);
+
private static class FileKeystore extends Keystore {
private static final String SERVICE_NAME = "keystore";
private static final String LIST_CERTIFICATES = "listcerts";
@@ -99,5 +106,40 @@ public abstract class Keystore {
return NOTFOUND;
}
}
+
+ @Override
+ public String[] getSupportedKeyStrenghs() {
+ // TODO: real implementation
+ return new String[] {"High Grade", "Medium Grade"};
+ }
+
+ @Override
+ public String generateKeyPair(String keyStrength, String challenge,
+ String organizations) throws UnsupportedKeyStrengthException {
+ // TODO: real implementation
+ return "-----BEGIN CERTIFICATE REQUEST-----"
+ + "\nMIICzjCCAbYCAQAwgYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh"
+ + "\nMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMRYw"
+ + "\nFAYDVQQLEw1SZW1vdGUgQWNjZXNzMRAwDgYDVQQLEwdHbGFwdG9wMQ0wCwYDVQQD"
+ + "\nEwR0ZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAznwy7a16O35u"
+ + "\nODLQOw6yHAxozrrX1J+c0reiIh8GYohwKrBedFnQ/FnTls6bxY4fNHD+SZvFFgvU"
+ + "\nECBFOfRmRm7AFo51qT0t2a8qgvDLM6L1qGkmy94W28Q3OlcpF2QianHYdjyGT+Ac"
+ + "\nYDek1Zi/E/mdPzuVM/K8tkB7n8ktC0PTm1ZtdMRauE5R0WrEhWuF6In/2gy1Q/Zh"
+ + "\noy7/zQqpbPl2ouulvkx1Y3OXHM6XPNFLoHS1gH0HyAuBUokO0QmetRn6ngJSvz7e"
+ + "\nVD7QYRppGp+g4BxqaV9XSxhaaKrMs4PAld9enV51X9qjvjCRBve2QxtuJgMfGJdU"
+ + "\njGr/JweZoQIDAQABoAAwDQYJKoZIhvcNAQEFBQADggEBADtxOtEseoLOVYh6sh4b"
+ + "\nWCdngK87uHn2bdGipFwKdNTxQDdxNQLAKdoGYIfbVsC1cDgFiufeNwVukxxymdnm"
+ + "\nk0GGK+0O0tZKENv8ysgfbgEsHpJH9FoR5Y5XEq1etejkcgCp59dyhrSk0DLyVm0D"
+ + "\nIfTC/nsK95H7AAGOkbbDFo2otyLNNrthYncQ9diAG0UzzLacA+86JXZmD3HyC48u"
+ + "\nI9hsivVnTTfl9afcfVAhfxbQ6HgkhZZjbjFjfABSd4v8wKlAAqK58VxCajNVOVcV"
+ + "\ncCzOWf6NpE7xEHCf32i8bWDP6hi0WgQcdpQwnZNKhhTLGNb23Uty6HYlJhbxexC7"
+ + "\nUoM="
+ + "\n-----END CERTIFICATE REQUEST-----";
+ }
+
+ @Override
+ public void addCertificate(String cert) {
+ // TODO: real implementation
+ }
}
}
diff --git a/keystore/java/android/security/UnsupportedKeyStrengthException.java b/keystore/java/android/security/UnsupportedKeyStrengthException.java
new file mode 100644
index 000000000000..d0732c22e968
--- /dev/null
+++ b/keystore/java/android/security/UnsupportedKeyStrengthException.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security;
+
+/**
+ * Thrown when the specified key strength is not supported by the system.
+ * {@hide}
+ */
+public class UnsupportedKeyStrengthException extends Exception {
+ public UnsupportedKeyStrengthException(String msg) {
+ super(msg);
+ }
+}