security - Using Android 4.1 Keychain -
i using android 4.1 keychain , following code worked fine under 4.0 gives me nullpointer exception (cipher can't read internal attribute)
privatekey = keychain.getprivatekey(context,malias); byte[] data = // biary data cipher rsasinger = javax.crypto.cipher.getinstance("rsa/ecb/pkcs1padding"); rsasinger.init(cipher.encrypt_mode, privkey); byte[] signed_bytes = rsasinger.dofinal(data);
i handling private key keychain opaque , use java security api. need need use keychain api in different way?
after further debugging , contacted google engenier (thanks!) turned out android registers differents java crypto providers , openssl provider able use privatekeys keystore.
but hacks , using /system/lib/ssl/engines/libkeystore.so
should possible work around problem.
see http://code.google.com/p/ics-openvpn/source/browse/jni/jbcrypto.cpp , proccesssignjellybean in http://code.google.com/p/ics-openvpn/source/browse/src/de/blinkt/openvpn/openvpnmanagementthread.java#446 solution.
Comments
Post a Comment