summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2014-03-20 11:06:41 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-20 11:06:41 -0700
commit072e1da26e80adb4009d063428c2ef8fb65c3d6c (patch)
tree31da42c8fe9bb0a0a40a3a1784ad2a0b7e6a0bc4 /media
parent737d3e5da366124d164555009fa5ee4552143cc8 (diff)
parentb17cf207372268d91177de7efa692b2483785991 (diff)
downloadframeworks_base-072e1da26e80adb4009d063428c2ef8fb65c3d6c.zip
frameworks_base-072e1da26e80adb4009d063428c2ef8fb65c3d6c.tar.gz
frameworks_base-072e1da26e80adb4009d063428c2ef8fb65c3d6c.tar.bz2
am b17cf207: am 9ee72b65: am 665b0757: am 81fbdade: resolved conflicts for merge of 534f3e94 to jb-mr1-dev
* commit 'b17cf207372268d91177de7efa692b2483785991': Verify certificates
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioService.java43
-rw-r--r--media/java/android/media/IAudioService.aidl2
2 files changed, 45 insertions, 0 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index ef97d2a..9ec5be3 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -45,6 +45,8 @@ import android.content.res.Configuration;
import android.database.ContentObserver;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
+import android.net.http.CertificateChainValidator;
+import android.net.http.SslError;
import android.os.Binder;
import android.os.Bundle;
import android.os.Environment;
@@ -72,9 +74,11 @@ import android.view.VolumePanel;
import com.android.internal.telephony.ITelephony;
+import java.io.ByteArrayInputStream;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.HashMap;
@@ -105,6 +109,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
protected static final boolean DEBUG_RC = false;
/** Debug volumes */
protected static final boolean DEBUG_VOL = false;
+ /** Debug cert verification */
+ private static final boolean DEBUG_CERTS = false;
/** How long to delay before persisting a change in volume/ringer mode. */
private static final int PERSIST_DELAY = 500;
@@ -6018,6 +6024,43 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
pw.println(Integer.toHexString(mRingerModeMutedStreams));
}
+ public int verifyX509CertChain(int numcerts, byte [] chain, String domain, String authType) {
+
+ if (DEBUG_CERTS) {
+ Log.v(TAG, "java side verify for "
+ + numcerts + " certificates (" + chain.length + " bytes"
+ + ")for "+ domain + "/" + authType);
+ }
+
+ byte[][] certChain = new byte[numcerts][];
+
+ ByteBuffer buf = ByteBuffer.wrap(chain);
+ for (int i = 0; i < numcerts; i++) {
+ int certlen = buf.getInt();
+ if (DEBUG_CERTS) {
+ Log.i(TAG, "cert " + i +": " + certlen);
+ }
+ certChain[i] = new byte[certlen];
+ buf.get(certChain[i]);
+ }
+
+ try {
+ SslError err = CertificateChainValidator.verifyServerCertificates(certChain,
+ domain, authType);
+ if (DEBUG_CERTS) {
+ Log.i(TAG, "verified: " + err);
+ }
+ if (err == null) {
+ return -1;
+ } else {
+ return err.getPrimaryError();
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "failed to verify chain: " + e);
+ }
+ return SslError.SSL_INVALID;
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl
index ea99069..d723cd4 100644
--- a/media/java/android/media/IAudioService.aidl
+++ b/media/java/android/media/IAudioService.aidl
@@ -34,6 +34,8 @@ import android.view.KeyEvent;
*/
interface IAudioService {
+ int verifyX509CertChain(int chainsize, in byte[] chain, String host, String authtype);
+
void adjustVolume(int direction, int flags);
oneway void adjustLocalOrRemoteStreamVolume(int streamType, int direction);