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

Side by Side Diff: net/base/keygen_handler_test_util.cc

Issue 18121007: *WIP* Store NSS slots per profile. Move keygen to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanups, add test for chrome keygen class Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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/base/keygen_handler_test_util.h"
6
7 #include "base/base64.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace net {
11
12 void AssertValidSignedPublicKeyAndChallenge(const std::string& result,
13 int key_size_in_bits,
14 const std::string& challenge) {
15 ASSERT_GT(result.length(), 0U);
16 // Assertions assume 768 bit key size.
17 ASSERT_EQ(key_size_in_bits, 768);
18
19 // Verify it's valid base64:
20 std::string spkac;
21 ASSERT_TRUE(base::Base64Decode(result, &spkac));
22 // In lieu of actually parsing and validating the DER data,
23 // just check that it exists and has a reasonable length.
24 // (It's almost always 590 bytes, but the DER encoding of the random key
25 // and signature could sometimes be a few bytes different.)
26 ASSERT_GE(spkac.length(), 200U);
27 ASSERT_LE(spkac.length(), 300U);
28
29 // NOTE:
30 // The value of |result| can be validated by prefixing 'SPKAC=' to it
31 // and piping it through
32 // openssl spkac -verify
33 // whose output should look like:
34 // Netscape SPKI:
35 // Public Key Algorithm: rsaEncryption
36 // RSA Public Key: (2048 bit)
37 // Modulus (2048 bit):
38 // 00:b6:cc:14:c9:43:b5:2d:51:65:7e:11:8b:80:9e: .....
39 // Exponent: 65537 (0x10001)
40 // Challenge String: some challenge
41 // Signature Algorithm: md5WithRSAEncryption
42 // 92:f3:cc:ff:0b:d3:d0:4a:3a:4c:ba:ff:d6:38:7f:a5:4b:b5: .....
43 // Signature OK
44 //
45 // The value of |spkac| can be ASN.1-parsed with:
46 // openssl asn1parse -inform DER
47 }
48
49 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698