diff options
author | Hung-ying Tyan <tyanh@google.com> | 2009-06-16 16:14:14 +0800 |
---|---|---|
committer | Hung-ying Tyan <tyanh@google.com> | 2009-06-16 17:14:38 +0800 |
commit | 1d51e50d5d484c5d9e620b1d6736adc9aa99ae84 (patch) | |
tree | 20793d63fda275271d8433554591b9157feeb375 /keystore/java | |
parent | 0304325dd72ff8713c8444e909d387af1447f86f (diff) | |
download | frameworks_base-1d51e50d5d484c5d9e620b1d6736adc9aa99ae84.zip frameworks_base-1d51e50d5d484c5d9e620b1d6736adc9aa99ae84.tar.gz frameworks_base-1d51e50d5d484c5d9e620b1d6736adc9aa99ae84.tar.bz2 |
Add keygen API to Keystore.
Diffstat (limited to 'keystore/java')
-rw-r--r-- | keystore/java/android/security/Keystore.java | 42 | ||||
-rw-r--r-- | keystore/java/android/security/UnsupportedKeyStrengthException.java | 27 |
2 files changed, 69 insertions, 0 deletions
diff --git a/keystore/java/android/security/Keystore.java b/keystore/java/android/security/Keystore.java index 3f83473..8de20af 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 0000000..d0732c2 --- /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); + } +} |