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

Unified Diff: net/cert/x509_util_openssl_unittest.cc

Issue 21561003: Add a utility method to convert SPKI from DER to JWK, so far implemented only for EC P256v1 (which … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@domain-bound-public-key
Patch Set: Created 7 years, 5 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
« net/cert/x509_util_openssl.cc ('K') | « net/cert/x509_util_openssl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/x509_util_openssl_unittest.cc
diff --git a/net/cert/x509_util_openssl_unittest.cc b/net/cert/x509_util_openssl_unittest.cc
index f237602ecbd8f63608517e2fdd86efb740bc94c1..e379849b865942b5f50cac3154aa584b853b0db8 100644
--- a/net/cert/x509_util_openssl_unittest.cc
+++ b/net/cert/x509_util_openssl_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
#include "crypto/ec_private_key.h"
#include "net/cert/x509_util.h"
#include "net/cert/x509_util_openssl.h"
@@ -54,4 +55,40 @@ TEST(X509UtilOpenSSLTest, CreateDomainBoundCertNotImplemented) {
}
+static const unsigned char spki_ec[] = {
+ 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86,
+ 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a,
+ 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
+ 0x42, 0x00, 0x04,
+ 0x29, 0x5d, 0x6e, 0xfe, 0x33, 0x77, 0x26, 0xea,
+ 0x5b, 0xa4, 0xe6, 0x1b, 0x34, 0x6e, 0x7b, 0xa0,
+ 0xa3, 0x8f, 0x33, 0x49, 0xa0, 0x9c, 0xae, 0x98,
+ 0xbd, 0x46, 0x0d, 0xf6, 0xd4, 0x5a, 0xdc, 0x8a,
+ 0x1f, 0x8a, 0xb2, 0x20, 0x51, 0xb7, 0xd2, 0x87,
+ 0x0d, 0x53, 0x7e, 0x5d, 0x94, 0xa3, 0xe0, 0x34,
+ 0x16, 0xa1, 0xcc, 0x10, 0x48, 0xcd, 0x70, 0x9c,
+ 0x05, 0xd3, 0xd2, 0xca, 0xdf, 0x44, 0x2f, 0xf4
+};
+
+// For OpenSSL, x509_util::ConvertSPKIFromDERToJWK() is not yet implemented
+// and should return false. This unit test ensures that a stub implementation
+// is present.
+TEST(X509UtilOpenSSLTest, ConvertSPKIFromDERToJWKNotImplemented) {
+ base::StringPiece spki;
+ base::DictionaryValue public_key_jwk;
+
+ // The empty SPKI is trivially non-convertible...
+ EXPECT_FALSE(x509_util::ConvertSPKIFromDERToJWK(
+ spki,
+ &public_key_jwk));
+ EXPECT_TRUE(public_key_jwk.empty());
+ // but even a valid SPKI is non-convertible via the stub OpenSSL
+ // implementation.
+ spki.set(reinterpret_cast<const char*>(spki_ec), sizeof(spki_ec));
+ EXPECT_FALSE(x509_util::ConvertSPKIFromDERToJWK(
+ spki,
+ &public_key_jwk));
+ EXPECT_TRUE(public_key_jwk.empty());
+}
+
} // namespace net
« net/cert/x509_util_openssl.cc ('K') | « net/cert/x509_util_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698