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

Unified Diff: chrome/browser/extensions/api/cast_channel/cast_auth_util_nss.cc

Issue 254083007: Auth work to support new auth protocol (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use hard-coded public keys Created 6 years, 7 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 | chrome/browser/extensions/api/cast_channel/cast_channel.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/cast_channel/cast_auth_util_nss.cc
diff --git a/chrome/browser/extensions/api/cast_channel/cast_auth_util_nss.cc b/chrome/browser/extensions/api/cast_channel/cast_auth_util_nss.cc
index af1e0f362e58c6b20566f067ae2f586be9acaa88..e1520c2072e013f17efd7b6058229eef0e9b6901 100644
--- a/chrome/browser/extensions/api/cast_channel/cast_auth_util_nss.cc
+++ b/chrome/browser/extensions/api/cast_channel/cast_auth_util_nss.cc
@@ -15,40 +15,186 @@
#include "chrome/browser/extensions/api/cast_channel/cast_message_util.h"
#include "crypto/nss_util.h"
#include "crypto/scoped_nss_types.h"
+#include "net/base/hash_value.h"
+#include "net/cert/asn1_util.h"
+#include "net/cert/x509_certificate.h"
namespace {
-// Public key of the certificate with which the peer cert should be signed.
-static const unsigned char kCAPublicKeyDER[] = {
- 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xbc, 0x22, 0x80,
- 0xbd, 0x80, 0xf6, 0x3a, 0x21, 0x00, 0x3b, 0xae, 0x76, 0x5e, 0x35, 0x7f,
- 0x3d, 0xc3, 0x64, 0x5c, 0x55, 0x94, 0x86, 0x34, 0x2f, 0x05, 0x87, 0x28,
- 0xcd, 0xf7, 0x69, 0x8c, 0x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 0x6e, 0x7e, 0x4d, 0x0a, 0xe3, 0xc6, 0x1c, 0xa9,
- 0x93, 0xfa, 0x3a, 0xa5, 0x91, 0x5d, 0x1c, 0xbd, 0x66, 0xeb, 0xcc, 0x60,
- 0xdc, 0x86, 0x74, 0xca, 0xcf, 0xf8, 0x92, 0x1c, 0x98, 0x7d, 0x57, 0xfa,
- 0x61, 0x47, 0x9e, 0xab, 0x80, 0xb7, 0xe4, 0x48, 0x80, 0x2a, 0x92, 0xc5,
- 0x1b, 0x02, 0x03, 0x01, 0x00, 0x01 };
+// Fingerprints and public keys of the allowed / trusted ICAs.
+static const net::SHA1HashValue kFingerprintICA1 = { {
+ 0x57,0x16,0xE2,0xAD,0x73,0x2E,0xBE,0xDA,0xEB,0x18,
+ 0xE8,0x47,0x15,0xA8,0xDE,0x90,0x3B,0x5E,0x2A,0xF4
+} };
+static const unsigned char kPublicKeyICA1[] = {
+ 0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xBC,0x22,0x80,
+ 0xBD,0x80,0xF6,0x3A,0x21,0x00,0x3B,0xAE,0x76,0x5E,0x35,0x7F,
+ 0x3D,0xC3,0x64,0x5C,0x55,0x94,0x86,0x34,0x2F,0x05,0x87,0x28,
+ 0xCD,0xF7,0x69,0x8C,0x17,0xB3,0x50,0xA7,0xB8,0x82,0xFA,0xDF,
+ 0xC7,0x43,0x2D,0xD6,0x7E,0xAB,0xA0,0x6F,0xB7,0x13,0x72,0x80,
+ 0xA4,0x47,0x15,0xC1,0x20,0x99,0x50,0xCD,0xEC,0x14,0x62,0x09,
+ 0x5B,0xA4,0x98,0xCD,0xD2,0x41,0xB6,0x36,0x4E,0xFF,0xE8,0x2E,
+ 0x32,0x30,0x4A,0x81,0xA8,0x42,0xA3,0x6C,0x9B,0x33,0x6E,0xCA,
+ 0xB2,0xF5,0x53,0x66,0xE0,0x27,0x53,0x86,0x1A,0x85,0x1E,0xA7,
+ 0x39,0x3F,0x4A,0x77,0x8E,0xFB,0x54,0x66,0x66,0xFB,0x58,0x54,
+ 0xC0,0x5E,0x39,0xC7,0xF5,0x50,0x06,0x0B,0xE0,0x8A,0xD4,0xCE,
+ 0xE1,0x6A,0x55,0x1F,0x8B,0x17,0x00,0xE6,0x69,0xA3,0x27,0xE6,
+ 0x08,0x25,0x69,0x3C,0x12,0x9D,0x8D,0x05,0x2C,0xD6,0x2E,0xA2,
+ 0x31,0xDE,0xB4,0x52,0x50,0xD6,0x20,0x49,0xDE,0x71,0xA0,0xF9,
+ 0xAD,0x20,0x40,0x12,0xF1,0xDD,0x25,0xEB,0xD5,0xE6,0xB8,0x36,
+ 0xF4,0xD6,0x8F,0x7F,0xCA,0x43,0xDC,0xD7,0x10,0x5B,0xE6,0x3F,
+ 0x51,0x8A,0x85,0xB3,0xF3,0xFF,0xF6,0x03,0x2D,0xCB,0x23,0x4F,
+ 0x9C,0xAD,0x18,0xE7,0x93,0x05,0x8C,0xAC,0x52,0x9A,0xF7,0x4C,
+ 0xE9,0x99,0x7A,0xBE,0x6E,0x7E,0x4D,0x0A,0xE3,0xC6,0x1C,0xA9,
+ 0x93,0xFA,0x3A,0xA5,0x91,0x5D,0x1C,0xBD,0x66,0xEB,0xCC,0x60,
+ 0xDC,0x86,0x74,0xCA,0xCF,0xF8,0x92,0x1C,0x98,0x7D,0x57,0xFA,
+ 0x61,0x47,0x9E,0xAB,0x80,0xB7,0xE4,0x48,0x80,0x2A,0x92,0xC5,
+ 0x1B,0x02,0x03,0x01,0x00,0x01
+};
+
+static const net::SHA1HashValue kFingerprintICA2 = { {
+ 0x1B,0xA2,0x9E,0xC9,0x8E,0x4E,0xB3,0x80,0xEE,0x55,
+ 0xB2,0x97,0xFD,0x2E,0x2B,0x2C,0xB6,0x8E,0x0B,0x2F
+} };
+static const unsigned char kPublicKeyICA2[] = {
+ 0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xBC,0x22,0x80,
+ 0xBD,0x80,0xF6,0x3A,0x21,0x00,0x3B,0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,0xA9,
+ 0x93,0xFA,0x3A,0xA5,0x91,0x5D,0x1C,0xBD,0x66,0xEB,0xCC,0x60,
+ 0xDC,0x86,0x74,0xCA,0xCF,0xF8,0x92,0x1C,0x98,0x7D,0x57,0xFA,
+ 0x61,0x47,0x9E,0xAB,0x80,0xB7,0xE4,0x48,0x80,0x2A,0x92,0xC5,
+ 0x1B,0x02,0x03,0x01,0x00,0x01
+};
+
+static const net::SHA1HashValue kFingerprintICA3 = { {
+ 0x97,0x05,0xCE,0xF6,0x3F,0xA9,0x5E,0x0F,0xE7,0x61,
+ 0xFB,0x08,0x44,0x31,0xBE,0xDE,0x01,0xB8,0xFB,0xEB
+} };
+static const unsigned char kPublicKeyICA3[] = {
+ 0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xB7,0xE8,0xC3,
+ 0xE4,0x2C,0xDE,0x74,0x53,0xF2,0x49,0x95,0x6D,0xD1,0xDA,0x69,
+ 0x57,0x0D,0x86,0xE5,0xED,0xB4,0xB9,0xE6,0x73,0x9F,0x6C,0xAD,
+ 0x3B,0x64,0x85,0x03,0x0D,0x08,0x44,0xAF,0x18,0x69,0x82,0xAD,
+ 0xA9,0x74,0x64,0x37,0x47,0xE1,0xE7,0x26,0x19,0x33,0x3C,0xE2,
+ 0xD0,0xB5,0x84,0x3C,0xD7,0xAC,0x63,0xAE,0xC4,0x32,0x23,0xF6,
+ 0xDC,0x14,0x10,0x4B,0x95,0x7F,0xE8,0x98,0xD7,0x7A,0x9E,0x43,
+ 0x3D,0x68,0x8B,0x2A,0x70,0xF7,0x1E,0x43,0x70,0xBA,0xA5,0xA5,
+ 0x93,0xAD,0x8A,0xD4,0x9F,0xAC,0x83,0x16,0xF3,0x48,0x5F,0xC5,
+ 0xE0,0xA5,0x44,0xB8,0x4F,0xD9,0xD8,0x75,0x90,0x25,0x8B,0xE3,
+ 0x1C,0x6C,0xDA,0x88,0xFF,0x09,0x2B,0xCA,0x1E,0x48,0xDD,0x76,
+ 0x0F,0x68,0x56,0x7B,0x15,0x9D,0xCA,0x6B,0x1C,0xF7,0x48,0xC2,
+ 0x89,0xC6,0x93,0x0A,0x31,0xF2,0x78,0x27,0x45,0x3D,0xF1,0x0D,
+ 0x5B,0x6E,0x55,0x32,0xEF,0x49,0xA0,0xD6,0xAF,0xA6,0x30,0x91,
+ 0xF2,0x21,0x2F,0xDB,0xA4,0x29,0xB9,0x9B,0x22,0xBC,0xCD,0x0B,
+ 0xA6,0x8B,0xA6,0x22,0x79,0xFD,0xCF,0x95,0x93,0x96,0xB3,0x23,
+ 0xC9,0xC6,0x30,0x8E,0xC0,0xE9,0x1F,0xEC,0xFB,0xF5,0x88,0xDD,
+ 0x97,0x72,0x16,0x29,0x08,0xFA,0x42,0xE7,0x4F,0xCA,0xAE,0xD7,
+ 0x0F,0x23,0x48,0x9B,0x82,0xA7,0x37,0x4A,0xDD,0x60,0x04,0x75,
+ 0xDC,0xDE,0x09,0x98,0xD2,0x16,0x23,0x04,0x70,0x4D,0x99,0x9F,
+ 0x4A,0x82,0x28,0xE6,0xBE,0x8F,0x9D,0xBF,0xA1,0x4B,0xA2,0xBA,
+ 0xF5,0xB2,0x51,0x1E,0x4E,0xE7,0x80,0x9E,0x7A,0x38,0xA1,0xC7,
+ 0x09,0x02,0x03,0x01,0x00,0x01
+};
+
+static const net::SHA1HashValue kFingerprintICA4 = { {
+ 0x01,0xF5,0x28,0x56,0x33,0x80,0x9B,0x31,0xE7,0xD9,
+ 0xF7,0x4E,0xAA,0xDD,0x97,0x37,0xA0,0x28,0xE7,0x24
+} };
+static const unsigned char kPublicKeyICA4[] = {
+ 0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xB0,0x0E,0x5E,
+ 0x07,0x3A,0xDF,0xA4,0x5F,0x68,0xF7,0x21,0xC7,0x64,0xDB,0xB6,
+ 0x76,0xEF,0xEE,0x8B,0x93,0xF8,0xF6,0x1B,0x88,0xE1,0x93,0xB7,
+ 0x17,0xF0,0x15,0x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x3C,0x0C,0x25,0xE1,0x57,0xF6,
+ 0x8A,0x7E,0x49,0xC0,0xCC,0x83,0x11,0x35,0xE7,0x91,0x6D,0x2E,
+ 0x65,0x02,0x03,0x01,0x00,0x01
+};
+
+// Info for trusted ICA certs.
+struct ICACertInfo {
+ net::SHA1HashValue fingerprint;
+ SECItem public_key;
+};
+
+// List of allowed / trusted ICAs.
+static const ICACertInfo kAllowedICAs[] = {
+ { kFingerprintICA1,
+ { siDERCertBuffer,
+ const_cast<unsigned char*>(kPublicKeyICA1),
+ sizeof(kPublicKeyICA1) } },
+ { kFingerprintICA2,
+ { siDERCertBuffer,
+ const_cast<unsigned char*>(kPublicKeyICA2),
+ sizeof(kPublicKeyICA2) } },
+ { kFingerprintICA3,
+ { siDERCertBuffer,
+ const_cast<unsigned char*>(kPublicKeyICA3),
+ sizeof(kPublicKeyICA3) } },
+ { kFingerprintICA4,
+ { siDERCertBuffer,
+ const_cast<unsigned char*>(kPublicKeyICA4),
+ sizeof(kPublicKeyICA4) } },
+};
typedef scoped_ptr<
CERTCertificate,
crypto::NSSDestroyer<CERTCertificate, CERT_DestroyCertificate> >
ScopedCERTCertificate;
+// Returns the index of the ICA whose fingerprint matches |fingerprint|.
+// Returns -1, if no such ICA is found.
+static int GetICAWithFingerprint(const net::SHA1HashValue& fingerprint) {
+ for (size_t i = 0; i < arraysize(kAllowedICAs); ++i) {
+ if (fingerprint.Equals(kAllowedICAs[i].fingerprint))
+ return i;
Ryan Sleevi 2014/05/07 23:34:49 TYPE-CASTING: Downcasting a size_t to an int has b
mark a. foltz 2014/05/07 23:48:31 Also see checked_cast in safe_conversions.h. http
Munjal (Google) 2014/05/08 16:54:00 Done. I chose to use static_cast since I know that
+ }
+ return -1;
+}
+
+// Check whether the public key in the given cert is the same as |pk|.
+static bool CheckCertPublicKey(const std::string& ica, const SECItem& pk) {
+ base::StringPiece cert_public_key;
+ if (!net::asn1::ExtractSPKIFromDERCert(ica, &cert_public_key)) {
+ VLOG(1) << "Could not extract public key from cert";
+ return false;
+ }
+ base::StringPiece public_key(
+ reinterpret_cast<const char*>(pk.data), pk.len);
+ return cert_public_key.ends_with(public_key);
+}
+
// Parses out DeviceAuthMessage from CastMessage
static bool ParseAuthMessage(
const extensions::api::cast_channel::CastMessage& challenge_reply,
@@ -81,9 +227,46 @@ static bool ParseAuthMessage(
// Authenticates the given credentials:
// 1. |signature| verification of |data| using |certificate|.
// 2. |certificate| is signed by a trusted CA.
-bool VerifyCredentials(const std::string& certificate,
- const std::string& signature,
- const std::string& data) {
+bool VerifyCredentials(
+ const extensions::api::cast_channel::AuthResponse& response,
+ const std::string& data) {
+ const std::string& certificate = response.client_auth_certificate();
+ const std::string& signature = response.signature();
+
+ const SECItem* trusted_ca_key_der;
+
+ // If the list of intermediates is empty then use kPublicKeyICA1 as
+ // the trusted CA (legacy case).
+ // Otherwise, use the first intermediate in the list as long as it
+ // is in the allowed list of intermediates.
+ int num_intermediates = response.intermediate_certificate_size();
+ VLOG(1) << "Response has " << num_intermediates << " intermediates";
+ if (num_intermediates <= 0) {
+ trusted_ca_key_der = &kAllowedICAs[0].public_key;
+ } else {
+ // If the list of intermediates is not empty, then the fingerprint of
+ // the first intermediate should be one of the hard-coded list of
+ // fingerprints.
+ if (response.intermediate_certificate_size() > 0) {
Ryan Sleevi 2014/05/07 23:34:49 This condition is unnecessary (it's handled by lin
Munjal (Google) 2014/05/08 16:54:00 Good catch. Residue of a bit of refactoring.
+ const std::string& ica = response.intermediate_certificate(0);
+ scoped_refptr<net::X509Certificate> ica_cert
+ = net::X509Certificate::CreateFromBytes(ica.data(), ica.length());
+ int index = GetICAWithFingerprint(ica_cert->fingerprint());
+ if (index == -1) {
+ VLOG(1) << "Disallowed intermdiate cert";
+ return false;
+ }
+ trusted_ca_key_der = &kAllowedICAs[index].public_key;
+
+ // Sanity check that the public key in the response is the same as the
+ // hard-coded public key.
+ if (!CheckCertPublicKey(ica, *trusted_ca_key_der)) {
Ryan Sleevi 2014/05/07 23:34:49 It's not necessary to perform this check, since yo
Munjal (Google) 2014/05/08 16:54:00 Removed.
+ VLOG(1) << "Unexpected public key in intermediate cert";
+ return false;
+ }
+ }
+ }
+
crypto::EnsureNSSInit();
SECItem der_cert;
der_cert.type = siDERCertBuffer;
@@ -101,18 +284,15 @@ bool VerifyCredentials(const std::string& certificate,
}
// Check that the certificate is signed by trusted CA.
- SECItem trusted_ca_key_der_item;
- trusted_ca_key_der_item.type = siDERCertBuffer;
- trusted_ca_key_der_item.data = const_cast<unsigned char*>(kCAPublicKeyDER);
- trusted_ca_key_der_item.len = sizeof(kCAPublicKeyDER);
crypto::ScopedSECKEYPublicKey ca_public_key(
- SECKEY_ImportDERPublicKey(&trusted_ca_key_der_item, CKK_RSA));
+ SECKEY_ImportDERPublicKey(trusted_ca_key_der, CKK_RSA));
SECStatus verified = CERT_VerifySignedDataWithPublicKey(
&cert->signatureWrap, ca_public_key.get(), NULL);
if (verified != SECSuccess) {
VLOG(1)<< "Cert not signed by trusted CA";
return false;
}
+ VLOG(1) << "Cert signed by trusted CA";
// Verify that the |signature| matches |data|.
crypto::ScopedSECKEYPublicKey public_key(CERT_ExtractPublicKey(cert.get()));
@@ -137,6 +317,7 @@ bool VerifyCredentials(const std::string& certificate,
VLOG(1) << "Signed blobs did not match.";
return false;
}
+ VLOG(1) << "Signature verification succeeded";
return true;
}
@@ -157,9 +338,7 @@ bool AuthenticateChallengeReply(const CastMessage& challenge_reply,
return false;
const AuthResponse& response = auth_message.response();
- return VerifyCredentials(response.client_auth_certificate(),
- response.signature(),
- peer_cert);
+ return VerifyCredentials(response, peer_cert);
}
} // namespace cast_channel
« no previous file with comments | « no previous file | chrome/browser/extensions/api/cast_channel/cast_channel.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698