Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1888)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java

Issue 2047763002: Switch AwTokenBindingManager's internals to PKCS#8. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ecprivatekey
Patch Set: fix build Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | android_webview/native/token_binding_manager_bridge.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java b/android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java
index a622781171ed4283d393306a354cf779e65753f2..e6e042521be78c3112cd8047fb3f38defe8b144c 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java
@@ -11,24 +11,15 @@ import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
-import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
-import javax.crypto.Cipher;
-import javax.crypto.EncryptedPrivateKeyInfo;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.PBEKeySpec;
-
/**
* AwTokenBindingManager manages the token binding protocol.
*
@@ -42,8 +33,6 @@ import javax.crypto.spec.PBEKeySpec;
@JNINamespace("android_webview")
public final class AwTokenBindingManager {
private static final String TAG = "TokenBindingManager";
- private static final String PASSWORD = "";
- private static final String ALGORITHM = "PBEWITHSHAAND3-KEYTRIPLEDES-CBC";
private static final String ELLIPTIC_CURVE = "EC";
public void enableTokenBinding() {
@@ -79,19 +68,12 @@ public final class AwTokenBindingManager {
}
KeyPair keyPair = null;
try {
- EncryptedPrivateKeyInfo epkInfo = new EncryptedPrivateKeyInfo(privateKeyBytes);
- SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance(ALGORITHM);
- Key key = secretKeyFactory.generateSecret(new PBEKeySpec(PASSWORD.toCharArray()));
- Cipher cipher = Cipher.getInstance(ALGORITHM);
- cipher.init(Cipher.DECRYPT_MODE, key, epkInfo.getAlgParameters());
KeyFactory factory = KeyFactory.getInstance(ELLIPTIC_CURVE);
- PrivateKey privateKey = factory.generatePrivate(epkInfo.getKeySpec(cipher));
- PublicKey publicKey =
- factory.generatePublic(new X509EncodedKeySpec(publicKeyBytes));
+ PrivateKey privateKey =
+ factory.generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes));
+ PublicKey publicKey = factory.generatePublic(new X509EncodedKeySpec(publicKeyBytes));
keyPair = new KeyPair(publicKey, privateKey);
- } catch (NoSuchAlgorithmException | InvalidKeySpecException | IOException
- | NoSuchPaddingException | InvalidKeyException
- | InvalidAlgorithmParameterException ex) {
+ } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
Log.e(TAG, "Failed converting key ", ex);
}
callback.onReceiveValue(keyPair);
« no previous file with comments | « no previous file | android_webview/native/token_binding_manager_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698