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

Side by Side Diff: net/ssl/ssl_platform_key_util_unittest.cc

Issue 2391213002: Report curve types in ECDSA SSLPrivateKeys. (Closed)
Patch Set: rebase Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « net/ssl/ssl_platform_key_util.cc ('k') | net/ssl/ssl_platform_key_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/ssl/ssl_platform_key_util.h"
6
7 #include <openssl/ecdsa.h>
8 #include <stddef.h>
9
10 #include "base/memory/ref_counted.h"
11 #include "net/cert/x509_certificate.h"
12 #include "net/ssl/ssl_private_key.h"
13 #include "net/test/cert_test_util.h"
14 #include "net/test/test_data_directory.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace net {
18
19 namespace {
20
21 bool GetClientCertInfoFromFile(const char* filename,
22 SSLPrivateKey::Type* out_type,
23 size_t* out_max_length) {
24 scoped_refptr<X509Certificate> cert =
25 ImportCertFromFile(GetTestCertsDirectory(), filename);
26 if (!cert) {
27 ADD_FAILURE() << "Could not read " << filename;
28 return false;
29 }
30
31 return GetClientCertInfo(cert.get(), out_type, out_max_length);
32 }
33
34 } // namespace
35
36 TEST(SSLPlatformKeyUtil, GetClientCertInfo) {
37 SSLPrivateKey::Type type;
38 size_t max_length;
39
40 ASSERT_TRUE(GetClientCertInfoFromFile("client_1.pem", &type, &max_length));
41 EXPECT_EQ(SSLPrivateKey::Type::RSA, type);
42 EXPECT_EQ(2048u / 8u, max_length);
43
44 ASSERT_TRUE(GetClientCertInfoFromFile("client_4.pem", &type, &max_length));
45 EXPECT_EQ(SSLPrivateKey::Type::ECDSA_P256, type);
46 EXPECT_EQ(ECDSA_SIG_max_len(256u / 8u), max_length);
47 }
48
49 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/ssl_platform_key_util.cc ('k') | net/ssl/ssl_platform_key_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698