Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
KeyChain.getPrivateKey segfault in 4.1
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
James  
View profile  
 More options Oct 5 2012, 5:13 pm
From: James <caprifin...@gmail.com>
Date: Fri, 5 Oct 2012 14:13:12 -0700 (PDT)
Local: Fri, Oct 5 2012 5:13 pm
Subject: KeyChain.getPrivateKey segfault in 4.1

There is a problem in 4.1 with apps that need to create a signature using a
private key in the KeyChain.  In particular, apps that establish SSL client
sessions (such as OpenVPN) would use code such as this to allow an SSL
negotiation to use a client cert/key from the keychain:

import java.security.PrivateKey;
import javax.crypto.Cipher;

. . .

PrivateKey privateKey = KeyChain.getPrivateKey(context, alias);
if (privateKey) {
  byte[] data;
  Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING");
  cipher.init(Cipher.ENCRYPT_MODE, privateKey);
  byte[] signed_bytes = cipher.doFinal(data);

}

This code now fails badly on 4.1 (testing on Nexus 7) even though
KeyChain.getPrivateKey returns a non-null value for privateKey.  It not
only fails to work, but causes a segfault later when privateKey is garbage
collected.

There are essentially two problems here...

1. KeyChain.getPrivateKey(this, alias) returns an object that segfaults
when collected by the GC.  The segfault occurs in RSA_free in libcrypto.
 This is 100% reproducible for me on Nexus 7.  This behavior has been
documented in other posts, e.g.
http://code.google.com/p/android/issues/detail?id=36545

2. I understand that the new OpenSSL engine supports only signing,
verifying and key import and that java.security.Signature is now the
preferred class for obtaining an RSA signature.  That's fine, however the
RSA signature used for verification of an SSL session is typically
generated by the cipher object
javax.crypto.Cipher.getInstance("RSA/ECB/PKCS1PADDING") acting as an
encryptor.  Can java.security.Signature replicate this behavior?  This
issue is also documented here:
http://stackoverflow.com/questions/11261774/using-android-4-1-keychain


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James  
View profile  
 More options Oct 9 2012, 6:08 am
From: James <caprifin...@gmail.com>
Date: Tue, 9 Oct 2012 03:08:45 -0700 (PDT)
Local: Tues, Oct 9 2012 6:08 am
Subject: Re: KeyChain.getPrivateKey segfault in 4.1

Fixes for these issues have been checked in:

http://code.google.com/p/android/issues/detail?id=36545


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »