Finish refactoring of DomCodeToUsLayoutKeyboardCode().
[chromium-blink-merge.git] / extensions / browser / api / cast_channel / cast_auth_util_unittest.cc
blob77ac76291d97b41046e34948fdfa758a680549a4
1 // Copyright 2014 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.
5 #include "extensions/browser/api/cast_channel/cast_auth_util.h"
7 #include <string>
9 #include "base/macros.h"
10 #include "extensions/browser/api/cast_channel/cast_auth_ica.h"
11 #include "extensions/common/api/cast_channel/cast_channel.pb.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace extensions {
15 namespace core_api {
16 namespace cast_channel {
17 namespace {
19 const unsigned char kIntermediateCertificate[] = {
20 0x30, 0x82, 0x03, 0x87, 0x30, 0x82, 0x02, 0x6f, 0xa0, 0x03,
21 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x30, 0x0d, 0x06, 0x09,
22 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05,
23 0x00, 0x30, 0x7c, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
24 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11,
25 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c,
26 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30,
27 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f,
28 0x75, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65,
29 0x77, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a,
30 0x0c, 0x0a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49,
31 0x6e, 0x63, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04,
32 0x0b, 0x0c, 0x09, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20,
33 0x54, 0x56, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04,
34 0x03, 0x0c, 0x0e, 0x45, 0x75, 0x72, 0x65, 0x6b, 0x61, 0x20,
35 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17,
36 0x0d, 0x31, 0x32, 0x31, 0x32, 0x31, 0x39, 0x30, 0x30, 0x34,
37 0x37, 0x31, 0x32, 0x5a, 0x17, 0x0d, 0x33, 0x32, 0x31, 0x32,
38 0x31, 0x34, 0x30, 0x30, 0x34, 0x37, 0x31, 0x32, 0x5a, 0x30,
39 0x7d, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06,
40 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
41 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66,
42 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06,
43 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f, 0x75, 0x6e,
44 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31,
45 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a,
46 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63,
47 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c,
48 0x09, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x54, 0x56,
49 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
50 0x0f, 0x45, 0x75, 0x72, 0x65, 0x6b, 0x61, 0x20, 0x47, 0x65,
51 0x6e, 0x31, 0x20, 0x49, 0x43, 0x41, 0x30, 0x82, 0x01, 0x22,
52 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
53 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00,
54 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xbc,
55 0x22, 0x80, 0xbd, 0x80, 0xf6, 0x3a, 0x21, 0x00, 0x3b, 0xae,
56 0x76, 0x5e, 0x35, 0x7f, 0x3d, 0xc3, 0x64, 0x5c, 0x55, 0x94,
57 0x86, 0x34, 0x2f, 0x05, 0x87, 0x28, 0xcd, 0xf7, 0x69, 0x8c,
58 0x17, 0xb3, 0x50, 0xa7, 0xb8, 0x82, 0xfa, 0xdf, 0xc7, 0x43,
59 0x2d, 0xd6, 0x7e, 0xab, 0xa0, 0x6f, 0xb7, 0x13, 0x72, 0x80,
60 0xa4, 0x47, 0x15, 0xc1, 0x20, 0x99, 0x50, 0xcd, 0xec, 0x14,
61 0x62, 0x09, 0x5b, 0xa4, 0x98, 0xcd, 0xd2, 0x41, 0xb6, 0x36,
62 0x4e, 0xff, 0xe8, 0x2e, 0x32, 0x30, 0x4a, 0x81, 0xa8, 0x42,
63 0xa3, 0x6c, 0x9b, 0x33, 0x6e, 0xca, 0xb2, 0xf5, 0x53, 0x66,
64 0xe0, 0x27, 0x53, 0x86, 0x1a, 0x85, 0x1e, 0xa7, 0x39, 0x3f,
65 0x4a, 0x77, 0x8e, 0xfb, 0x54, 0x66, 0x66, 0xfb, 0x58, 0x54,
66 0xc0, 0x5e, 0x39, 0xc7, 0xf5, 0x50, 0x06, 0x0b, 0xe0, 0x8a,
67 0xd4, 0xce, 0xe1, 0x6a, 0x55, 0x1f, 0x8b, 0x17, 0x00, 0xe6,
68 0x69, 0xa3, 0x27, 0xe6, 0x08, 0x25, 0x69, 0x3c, 0x12, 0x9d,
69 0x8d, 0x05, 0x2c, 0xd6, 0x2e, 0xa2, 0x31, 0xde, 0xb4, 0x52,
70 0x50, 0xd6, 0x20, 0x49, 0xde, 0x71, 0xa0, 0xf9, 0xad, 0x20,
71 0x40, 0x12, 0xf1, 0xdd, 0x25, 0xeb, 0xd5, 0xe6, 0xb8, 0x36,
72 0xf4, 0xd6, 0x8f, 0x7f, 0xca, 0x43, 0xdc, 0xd7, 0x10, 0x5b,
73 0xe6, 0x3f, 0x51, 0x8a, 0x85, 0xb3, 0xf3, 0xff, 0xf6, 0x03,
74 0x2d, 0xcb, 0x23, 0x4f, 0x9c, 0xad, 0x18, 0xe7, 0x93, 0x05,
75 0x8c, 0xac, 0x52, 0x9a, 0xf7, 0x4c, 0xe9, 0x99, 0x7a, 0xbe,
76 0x6e, 0x7e, 0x4d, 0x0a, 0xe3, 0xc6, 0x1c, 0xa9, 0x93, 0xfa,
77 0x3a, 0xa5, 0x91, 0x5d, 0x1c, 0xbd, 0x66, 0xeb, 0xcc, 0x60,
78 0xdc, 0x86, 0x74, 0xca, 0xcf, 0xf8, 0x92, 0x1c, 0x98, 0x7d,
79 0x57, 0xfa, 0x61, 0x47, 0x9e, 0xab, 0x80, 0xb7, 0xe4, 0x48,
80 0x80, 0x2a, 0x92, 0xc5, 0x1b, 0x02, 0x03, 0x01, 0x00, 0x01,
81 0xa3, 0x13, 0x30, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d,
82 0x13, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01,
83 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
84 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01,
85 0x00, 0x8b, 0xd4, 0xa1, 0xb1, 0xcf, 0x5d, 0xcd, 0x7b, 0x6c,
86 0x48, 0x4a, 0x41, 0x1f, 0x53, 0x2f, 0x18, 0x2d, 0x32, 0x45,
87 0xff, 0x9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, 0x07, 0x14,
105 0x20, 0xbb, 0x22, 0xa5, 0xa6, 0x8f, 0xd6, 0xb5, 0xdb, 0xa9,
106 0x74, 0x78, 0xe2, 0x93, 0x0d, 0xe5, 0x23, 0x2f, 0x05, 0x17,
107 0xe0, 0xb2, 0x97, 0x67, 0x34, 0x4d, 0x0f, 0x9c, 0x76, 0x43,
108 0x7b, 0xa6, 0x21, 0x4a, 0x56, 0x05, 0xf6, 0x2a, 0x7c, 0xf2,
109 0x7f, 0x12, 0x94, 0x82, 0x26, 0x29, 0x07, 0xf0, 0x0b, 0x6c,
110 0x6c, 0x79, 0x14, 0xb0, 0x74, 0xd5, 0x6c,
113 const unsigned char kClientAuthCertificate[] = {
114 0x30, 0x82, 0x03, 0x7a, 0x30, 0x82, 0x02, 0x62, 0x02, 0x04,
115 0x51, 0x1d, 0x0e, 0xe2, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
116 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30,
117 0x7d, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06,
118 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
119 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66,
120 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06,
121 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f, 0x75, 0x6e,
122 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31,
123 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a,
124 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63,
125 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c,
126 0x09, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x54, 0x56,
127 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
128 0x0f, 0x45, 0x75, 0x72, 0x65, 0x6b, 0x61, 0x20, 0x47, 0x65,
129 0x6e, 0x31, 0x20, 0x49, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d,
130 0x31, 0x33, 0x30, 0x32, 0x31, 0x34, 0x31, 0x36, 0x32, 0x30,
131 0x35, 0x30, 0x5a, 0x17, 0x0d, 0x33, 0x33, 0x30, 0x32, 0x30,
132 0x39, 0x31, 0x36, 0x32, 0x30, 0x35, 0x30, 0x5a, 0x30, 0x77,
133 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13,
134 0x09, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x54, 0x56,
135 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
136 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
137 0x04, 0x08, 0x13, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f,
138 0x72, 0x6e, 0x69, 0x61, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
139 0x55, 0x04, 0x0a, 0x13, 0x0a, 0x47, 0x6f, 0x6f, 0x67, 0x6c,
140 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x16, 0x30, 0x14, 0x06,
141 0x03, 0x55, 0x04, 0x07, 0x13, 0x0d, 0x4d, 0x6f, 0x75, 0x6e,
142 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31,
143 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x14, 0x09,
144 0x65, 0x76, 0x74, 0x5f, 0x65, 0x31, 0x32, 0x36, 0x36, 0x30,
145 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
146 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82,
147 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01,
148 0x01, 0x00, 0xb8, 0x7d, 0x8a, 0x50, 0xfc, 0x58, 0xf2, 0x03,
149 0x67, 0x7f, 0x9f, 0xe4, 0xab, 0xd0, 0xd6, 0xd2, 0xd5, 0x8a,
150 0x7e, 0x30, 0x26, 0x4c, 0x54, 0xd1, 0xd0, 0xd4, 0x40, 0x92,
151 0x6c, 0x7d, 0x18, 0x78, 0xe3, 0x96, 0xc1, 0x0d, 0xd6, 0x7d,
152 0xca, 0x20, 0x32, 0x51, 0x30, 0xb5, 0x51, 0xcc, 0xe5, 0x21,
153 0xf1, 0x61, 0x20, 0x5f, 0x18, 0x60, 0x42, 0x94, 0x8d, 0x8b,
154 0x4c, 0x7a, 0x3f, 0xea, 0x11, 0xf6, 0x5a, 0xa0, 0x17, 0x60,
155 0x7b, 0x55, 0xcf, 0x96, 0x6e, 0x59, 0xaa, 0x0a, 0xd7, 0x3c,
156 0x69, 0xd9, 0x9d, 0x24, 0x4b, 0xc2, 0xde, 0xc1, 0x4c, 0xaa,
157 0x14, 0xd3, 0x77, 0xa9, 0x7a, 0x94, 0x68, 0x79, 0x73, 0xb3,
158 0xf5, 0x09, 0x28, 0xfc, 0x18, 0x20, 0xbd, 0xef, 0xf5, 0xf0,
159 0xf8, 0xd3, 0x53, 0x9e, 0x5f, 0x55, 0xcb, 0x11, 0xab, 0xea,
160 0x7b, 0xfe, 0x21, 0x44, 0x30, 0x2a, 0xd4, 0x46, 0x06, 0xd5,
161 0x26, 0xd9, 0xb9, 0xa8, 0xc6, 0x8a, 0xc8, 0x3a, 0x93, 0xef,
162 0xe8, 0xa0, 0x48, 0xb9, 0x41, 0x26, 0x69, 0x3e, 0x84, 0x36,
163 0x20, 0xeb, 0xc7, 0x1d, 0x6e, 0xc7, 0xd6, 0x1e, 0x4d, 0x2d,
164 0xe2, 0x56, 0x25, 0xcf, 0xf3, 0x03, 0xb1, 0xc8, 0x47, 0x53,
165 0x63, 0xe9, 0x0f, 0x67, 0x34, 0x12, 0xd3, 0x50, 0xea, 0xb3,
166 0x0a, 0x43, 0xc4, 0x3f, 0x5a, 0xbe, 0xd2, 0x88, 0x7e, 0xc8,
167 0x02, 0xc7, 0xf7, 0x21, 0x31, 0xab, 0x62, 0xbd, 0xb1, 0x17,
168 0xa9, 0x77, 0x80, 0x7d, 0x95, 0x6f, 0x66, 0x33, 0x82, 0xc1,
169 0x2f, 0xaa, 0x72, 0xb7, 0xbf, 0x23, 0xef, 0x93, 0x04, 0x33,
170 0x29, 0xc0, 0x68, 0x3f, 0x39, 0xaa, 0x35, 0x23, 0x8a, 0xbe,
171 0x07, 0x2d, 0x96, 0x80, 0x13, 0x81, 0x33, 0x6c, 0xb4, 0xca,
172 0x77, 0xa1, 0xca, 0x0d, 0xd4, 0x6a, 0xd6, 0xf3, 0xc7, 0x81,
173 0xcd, 0x38, 0xc6, 0xf1, 0xf5, 0xd0, 0x1a, 0x85, 0x02, 0x03,
174 0x01, 0x00, 0x01, 0xa3, 0x0d, 0x30, 0x0b, 0x30, 0x09, 0x06,
175 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0d,
176 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
177 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x4a, 0xb0,
178 0xb2, 0xb3, 0x3c, 0x3c, 0x64, 0x80, 0x4d, 0xc0, 0x4a, 0x4f,
179 0xc2, 0xb7, 0x8c, 0xb2, 0x8b, 0x6a, 0x9a, 0x0a, 0x44, 0xbc,
180 0x28, 0x1c, 0x61, 0xb0, 0x4f, 0xd5, 0x85, 0x36, 0x5f, 0xe9,
181 0xa1, 0x66, 0x83, 0x6f, 0xd9, 0x88, 0x49, 0x30, 0x7a, 0x64,
182 0x7c, 0x20, 0x20, 0xb7, 0x71, 0xa9, 0xcd, 0x13, 0x5a, 0x2e,
183 0xfd, 0xdc, 0xa6, 0x04, 0x80, 0xc3, 0xa0, 0xa4, 0x71, 0xfd,
184 0xd5, 0x96, 0x80, 0x24, 0x30, 0xea, 0xd6, 0x3a, 0x7a, 0x67,
185 0xa9, 0xb2, 0xfc, 0x8d, 0xdf, 0x4e, 0xe1, 0x5d, 0x5d, 0x92,
186 0xc6, 0xc1, 0xc9, 0x87, 0x9a, 0xde, 0x92, 0xa1, 0x78, 0x3e,
187 0xb9, 0x30, 0xa4, 0x1d, 0xb7, 0x9b, 0xc3, 0x5f, 0x05, 0x48,
188 0x37, 0x9c, 0x2a, 0xd0, 0x28, 0x5f, 0xf1, 0x54, 0xf6, 0xa7,
189 0x71, 0x54, 0xbe, 0xf3, 0x1a, 0x0b, 0x4b, 0x07, 0x8c, 0xaf,
190 0xa0, 0x3d, 0x44, 0x3a, 0xac, 0x7b, 0x69, 0x12, 0x2c, 0xeb,
191 0x17, 0x9b, 0x96, 0x23, 0x99, 0xf0, 0xae, 0x07, 0xbc, 0x13,
192 0x46, 0x7d, 0xb2, 0x0a, 0xeb, 0x92, 0xa8, 0x0f, 0xa7, 0x31,
193 0xe6, 0xce, 0x66, 0xf3, 0xf6, 0xf4, 0xd7, 0xeb, 0xbd, 0x89,
194 0xed, 0xa3, 0xcf, 0x08, 0xc7, 0xad, 0xfe, 0x09, 0x89, 0x0a,
195 0xf3, 0x27, 0x70, 0x6d, 0x84, 0x34, 0xff, 0x0e, 0xe1, 0xf0,
196 0x6f, 0x4a, 0x53, 0x46, 0x1d, 0x24, 0x12, 0x0c, 0x0a, 0x38,
197 0xfa, 0xec, 0x73, 0x55, 0xe2, 0x3f, 0xd8, 0xfb, 0x8a, 0xb4,
198 0x09, 0xb2, 0xe3, 0xdd, 0x76, 0x82, 0x6e, 0xce, 0x6e, 0xaa,
199 0x15, 0xe2, 0x41, 0x6a, 0x67, 0x06, 0x16, 0x59, 0xf6, 0x07,
200 0xef, 0xe2, 0x0b, 0x5d, 0x1c, 0x43, 0x0d, 0x65, 0x32, 0x7b,
201 0x08, 0x03, 0x67, 0xe8, 0xb6, 0xec, 0xf7, 0xd2, 0x17, 0xef,
202 0xe0, 0x79, 0x1c, 0xf0, 0x8b, 0xfd, 0xce, 0x09, 0x3e, 0xaa,
203 0x3d, 0x25, 0xd7, 0xd1,
206 const unsigned char kSignature[] = {
207 0x76, 0x93, 0x7f, 0x8e, 0x3e, 0x8f, 0x77, 0x64, 0x33, 0xb4,
208 0x6d, 0x09, 0xf5, 0x38, 0xa2, 0xde, 0x1b, 0xaa, 0x3e, 0x1f,
209 0xfc, 0x5c, 0xd7, 0x17, 0xaa, 0x28, 0x2a, 0xf3, 0x9f, 0x76,
210 0xa1, 0x4e, 0x41, 0xab, 0xd2, 0x03, 0xf2, 0x63, 0xf6, 0x24,
211 0x61, 0x97, 0xc0, 0x8a, 0xde, 0x11, 0x2e, 0x72, 0xff, 0x98,
212 0xeb, 0xd8, 0x18, 0xd5, 0x75, 0x91, 0xcd, 0x08, 0x43, 0x84,
213 0xe2, 0xc4, 0x1e, 0x7c, 0xe4, 0x9e, 0xeb, 0xe8, 0x09, 0x45,
214 0xe5, 0x6d, 0x62, 0x37, 0x02, 0xeb, 0xfc, 0x0a, 0x12, 0xf5,
215 0x91, 0x19, 0x4c, 0x17, 0xfa, 0x5e, 0x2d, 0x4b, 0x80, 0xb9,
216 0x1a, 0xd2, 0x47, 0xf7, 0xf9, 0x2f, 0x9f, 0xed, 0xd8, 0x2c,
217 0xbf, 0x2e, 0x16, 0x3b, 0x5b, 0x96, 0x5b, 0x9c, 0xe0, 0x73,
218 0x4e, 0x15, 0x34, 0x99, 0xde, 0xce, 0x88, 0x5e, 0x6f, 0xcb,
219 0x01, 0x36, 0x10, 0x07, 0x71, 0x6a, 0x86, 0xf6, 0x3a, 0x9d,
220 0x7f, 0xef, 0xa3, 0x81, 0xd8, 0xff, 0xc0, 0x8c, 0x75, 0x9f,
221 0xa0, 0xe4, 0xd0, 0x94, 0x9b, 0x11, 0xe4, 0x68, 0x44, 0x43,
222 0xcf, 0x9b, 0x39, 0x3a, 0xb5, 0xa7, 0xa4, 0xd4, 0x74, 0x7f,
223 0x86, 0x2a, 0x6a, 0x4b, 0x25, 0x00, 0x15, 0xee, 0x55, 0x30,
224 0x87, 0xef, 0x3d, 0xcb, 0x53, 0xfe, 0x88, 0x5e, 0x71, 0x82,
225 0x09, 0x0c, 0x5b, 0xef, 0x43, 0xda, 0xc8, 0x98, 0x23, 0x54,
226 0x6a, 0xc4, 0x47, 0x8e, 0xbb, 0x4d, 0x5f, 0x2c, 0x1e, 0xaa,
227 0x3f, 0xc2, 0xdb, 0xbe, 0x34, 0xf8, 0xac, 0xca, 0x0c, 0x0d,
228 0xf8, 0x04, 0xec, 0xba, 0xc4, 0x44, 0xd6, 0x22, 0x9e, 0x12,
229 0xc7, 0x14, 0x70, 0x77, 0x56, 0xc6, 0x56, 0xcc, 0x23, 0x12,
230 0x7a, 0xef, 0xb0, 0xa0, 0x87, 0x21, 0x05, 0x15, 0xb4, 0xb7,
231 0x9e, 0xb0, 0xe1, 0x56, 0xe6, 0x36, 0x73, 0x29, 0xb8, 0x81,
232 0x94, 0x26, 0x3d, 0xa4, 0x4c, 0xd6,
235 const unsigned char kPeerCert[] = {
236 0x30, 0x82, 0x02, 0xda, 0x30, 0x82, 0x01, 0xc2, 0xa0, 0x03,
237 0x02, 0x01, 0x02, 0x02, 0x04, 0x01, 0xc1, 0x6f, 0x87, 0x30,
238 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
239 0x01, 0x0b, 0x05, 0x00, 0x30, 0x2f, 0x31, 0x2d, 0x30, 0x2b,
240 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x24, 0x31, 0x37, 0x63,
241 0x63, 0x36, 0x62, 0x35, 0x35, 0x2d, 0x33, 0x38, 0x33, 0x34,
242 0x2d, 0x31, 0x31, 0x30, 0x63, 0x2d, 0x64, 0x62, 0x64, 0x64,
243 0x2d, 0x65, 0x32, 0x32, 0x61, 0x61, 0x37, 0x32, 0x37, 0x62,
244 0x31, 0x39, 0x62, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x34, 0x31,
245 0x30, 0x33, 0x30, 0x30, 0x38, 0x35, 0x30, 0x30, 0x37, 0x5a,
246 0x17, 0x0d, 0x31, 0x34, 0x31, 0x31, 0x30, 0x31, 0x30, 0x38,
247 0x35, 0x30, 0x30, 0x37, 0x5a, 0x30, 0x2f, 0x31, 0x2d, 0x30,
248 0x2b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x24, 0x31, 0x37,
249 0x63, 0x63, 0x36, 0x62, 0x35, 0x35, 0x2d, 0x33, 0x38, 0x33,
250 0x34, 0x2d, 0x31, 0x31, 0x30, 0x63, 0x2d, 0x64, 0x62, 0x64,
251 0x64, 0x2d, 0x65, 0x32, 0x32, 0x61, 0x61, 0x37, 0x32, 0x37,
252 0x62, 0x31, 0x39, 0x62, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d,
253 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
254 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82,
255 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb9, 0x3b, 0x11,
256 0x16, 0xe0, 0x76, 0xc3, 0x19, 0xe9, 0x25, 0xb2, 0x59, 0x46,
257 0x7d, 0xcf, 0x4f, 0xf5, 0x86, 0x3d, 0x73, 0xd7, 0x6e, 0x78,
258 0x20, 0x95, 0x38, 0x80, 0x58, 0x02, 0xe7, 0x05, 0x80, 0x8b,
259 0x06, 0x54, 0x75, 0xa0, 0x7e, 0x2a, 0x43, 0x5e, 0x72, 0xa4,
260 0x6e, 0x07, 0xf2, 0x9a, 0x98, 0x39, 0x86, 0x81, 0x1e, 0x62,
261 0xd7, 0x16, 0xa7, 0x18, 0x14, 0xa7, 0x59, 0xa5, 0xc6, 0x49,
262 0x56, 0xd1, 0x0d, 0x45, 0xea, 0x0d, 0xa6, 0x6a, 0x7c, 0xae,
263 0xac, 0xc8, 0xdc, 0x39, 0xb6, 0xa6, 0xb4, 0xa1, 0x71, 0x71,
264 0xff, 0xfb, 0xa0, 0xb3, 0x02, 0xb3, 0xaa, 0x20, 0xfe, 0xfa,
265 0xcd, 0x18, 0xff, 0x8a, 0xa2, 0x19, 0x82, 0x4f, 0x44, 0x9c,
266 0x97, 0xa4, 0x63, 0xce, 0xe5, 0x76, 0xe5, 0x96, 0x92, 0xc1,
267 0x92, 0x88, 0x2a, 0x5a, 0xb9, 0xde, 0xf3, 0x24, 0xf5, 0xc5,
268 0xfe, 0xfd, 0x42, 0x81, 0x07, 0x51, 0x47, 0x23, 0x15, 0x15,
269 0x5e, 0x5e, 0xf0, 0xf9, 0xac, 0xbe, 0xdb, 0xb6, 0x9d, 0xee,
270 0x92, 0xab, 0xf8, 0xcf, 0x08, 0x1a, 0xf6, 0x14, 0xf2, 0x9c,
271 0x5a, 0xbd, 0x73, 0xa4, 0xd1, 0x02, 0x0b, 0xff, 0xbc, 0x31,
272 0x91, 0xa5, 0xf3, 0x07, 0xef, 0x9f, 0xc4, 0xad, 0x56, 0xf9,
273 0x86, 0xf9, 0xc6, 0xee, 0x27, 0xeb, 0xd7, 0xe9, 0xd8, 0x57,
274 0xb3, 0x0f, 0x96, 0x8e, 0x57, 0x27, 0x5e, 0x5e, 0x75, 0x4e,
275 0x00, 0xd5, 0x4c, 0xbb, 0x2f, 0xb3, 0xcc, 0xd5, 0x91, 0xa5,
276 0x89, 0x62, 0x47, 0x7d, 0x4c, 0x43, 0x77, 0xd9, 0x3d, 0x75,
277 0xcb, 0x6c, 0x85, 0xaa, 0x9c, 0x4f, 0xec, 0x80, 0x30, 0xf2,
278 0xeb, 0x6f, 0xec, 0xe7, 0xd1, 0xd8, 0xbe, 0xc8, 0x9d, 0x14,
279 0x6d, 0x09, 0xc8, 0xc4, 0x95, 0xcf, 0x21, 0xe6, 0xf8, 0xf0,
280 0x25, 0xa3, 0xa2, 0xf6, 0x4f, 0x44, 0xbf, 0x00, 0xca, 0xe7,
281 0x68, 0x7b, 0x33, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d,
282 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
283 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x02, 0xd1,
284 0x74, 0x56, 0x74, 0x82, 0x03, 0x2b, 0x53, 0x34, 0x82, 0x9e,
285 0x16, 0xa2, 0x43, 0x24, 0x6c, 0xf1, 0x2c, 0x5f, 0xc2, 0xa5,
286 0x09, 0xc4, 0x72, 0x62, 0x1d, 0xc7, 0x10, 0x57, 0x9a, 0x40,
287 0x55, 0x83, 0xa7, 0x5f, 0x46, 0x44, 0x96, 0xeb, 0xcd, 0x09,
288 0x40, 0xdd, 0xa8, 0xdb, 0x6a, 0xaa, 0xb5, 0xaf, 0x8d, 0x7c,
289 0xb1, 0xa2, 0xc4, 0xff, 0xcc, 0xa5, 0x70, 0x85, 0xa6, 0x30,
290 0x95, 0x69, 0x8b, 0x61, 0x7f, 0x4c, 0x34, 0x95, 0xeb, 0xb1,
291 0x7f, 0x07, 0x4e, 0x60, 0x90, 0x34, 0xc5, 0x3b, 0x37, 0x66,
292 0x94, 0xd7, 0x18, 0x8d, 0x39, 0x64, 0x3b, 0x6e, 0xdc, 0x52,
293 0xf6, 0x46, 0x64, 0x33, 0x50, 0x97, 0xc4, 0xce, 0xba, 0x66,
294 0xc2, 0x91, 0x2a, 0x1b, 0xde, 0xdc, 0x37, 0x26, 0x31, 0x12,
295 0xa8, 0x70, 0x77, 0x7f, 0x4d, 0xc0, 0x65, 0x8e, 0x25, 0x09,
296 0xc5, 0x90, 0x77, 0xf3, 0x60, 0x4d, 0x20, 0xf3, 0x27, 0x7a,
297 0x34, 0x02, 0xea, 0xfe, 0xa1, 0x48, 0x8b, 0x63, 0xc2, 0xf7,
298 0x70, 0xb2, 0x23, 0x65, 0x55, 0xc8, 0x1b, 0xd1, 0x21, 0xe3,
299 0x1b, 0xf0, 0x50, 0xbb, 0x63, 0xe2, 0x7f, 0x02, 0xe0, 0xa5,
300 0xb7, 0x33, 0x67, 0x16, 0x0b, 0xba, 0xfe, 0x5f, 0x9d, 0xa2,
301 0x6f, 0x38, 0xb7, 0x3e, 0x3f, 0x17, 0x6a, 0x6d, 0xe1, 0xa2,
302 0xc4, 0xee, 0x77, 0xe6, 0x80, 0xe1, 0x2c, 0x3d, 0x93, 0x3d,
303 0x17, 0xc3, 0x58, 0x6f, 0x87, 0x0a, 0xe5, 0xa9, 0x7e, 0xef,
304 0xd4, 0x33, 0x94, 0xc3, 0xeb, 0xd5, 0xb4, 0x1a, 0xef, 0x38,
305 0xfb, 0xb4, 0xa9, 0x40, 0xa9, 0x56, 0x41, 0x32, 0xd8, 0xd5,
306 0x16, 0x42, 0xcd, 0xb5, 0xdc, 0x49, 0x64, 0x01, 0x68, 0x2b,
307 0x42, 0xa9, 0xcf, 0x64, 0x12, 0x6a, 0x7c, 0xc8, 0xd8, 0x3b,
308 0xfc, 0x14, 0x67, 0xb4, 0x4e, 0x3a, 0x75, 0x32, 0xda, 0xfe,
309 0x43, 0xb2, 0x35, 0xa1,
312 class CastAuthUtilTest : public testing::Test {
313 public:
314 CastAuthUtilTest () {}
315 ~CastAuthUtilTest () override {}
317 void SetUp() override {
320 protected:
321 static AuthResponse CreateAuthResponse() {
322 std::string keys =
323 "CrMCCiBSnZzWf+XraY5w3SbX2PEmWfHm5SNIv2pc9xbhP0EOcxKOAjCCAQoCggEBALwigL"
324 "2A9johADuudl41fz3DZFxVlIY0LwWHKM33aYwXs1CnuIL638dDLdZ+q6B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j+KAv"
340 "hqKJfRcrGkUXVK++wCHERwxcvfk7e6lN6adcCVYP9pZPMhE/UyAJY6/uE1X0cw==";
341 EXPECT_TRUE(SetTrustedCertificateAuthorities(keys, signature));
343 AuthResponse response;
344 response.add_intermediate_certificate(
345 std::string(reinterpret_cast<const char*>(kIntermediateCertificate),
346 arraysize(kIntermediateCertificate)));
347 response.set_client_auth_certificate(
348 std::string(reinterpret_cast<const char*>(kClientAuthCertificate),
349 arraysize(kClientAuthCertificate)));
350 response.set_signature(std::string(
351 reinterpret_cast<const char*>(kSignature), arraysize(kSignature)));
352 return response;
355 static std::string CreatePeerCert() {
356 return std::string(reinterpret_cast<const char*>(kPeerCert),
357 arraysize(kPeerCert));
360 // Mangles a string by inverting the first byte.
361 static void MangleString(std::string* str) {
362 (*str)[0] = ~(*str)[0];
366 TEST_F(CastAuthUtilTest, VerifySuccess) {
367 AuthResponse auth_response = CreateAuthResponse();
368 AuthResult result = VerifyCredentials(
369 auth_response, CreatePeerCert());
370 EXPECT_TRUE(result.success());
373 TEST_F(CastAuthUtilTest, VerifyBadCA) {
374 AuthResponse auth_response = CreateAuthResponse();
375 MangleString(auth_response.mutable_intermediate_certificate(0));
376 AuthResult result = VerifyCredentials(
377 auth_response, CreatePeerCert());
378 EXPECT_FALSE(result.success());
379 EXPECT_EQ(AuthResult::ERROR_CERT_NOT_SIGNED_BY_TRUSTED_CA, result.error_type);
382 TEST_F(CastAuthUtilTest, VerifyBadClientAuthCert) {
383 AuthResponse auth_response = CreateAuthResponse();
384 MangleString(auth_response.mutable_client_auth_certificate());
385 AuthResult result = VerifyCredentials(
386 auth_response, CreatePeerCert());
387 EXPECT_FALSE(result.success());
388 EXPECT_EQ(AuthResult::ERROR_CERT_PARSING_FAILED,
389 result.error_type);
392 TEST_F(CastAuthUtilTest, VerifyBadSignature) {
393 AuthResponse auth_response = CreateAuthResponse();
394 MangleString(auth_response.mutable_signature());
395 AuthResult result = VerifyCredentials(
396 auth_response, CreatePeerCert());
397 EXPECT_FALSE(result.success());
398 EXPECT_EQ(AuthResult::ERROR_SIGNED_BLOBS_MISMATCH,
399 result.error_type);
402 TEST_F(CastAuthUtilTest, VerifyBadPeerCert) {
403 AuthResponse auth_response = CreateAuthResponse();
404 std::string peer_cert = CreatePeerCert();
405 MangleString(&peer_cert);
406 AuthResult result = VerifyCredentials(
407 auth_response, peer_cert);
408 EXPECT_FALSE(result.success());
409 EXPECT_EQ(AuthResult::ERROR_SIGNED_BLOBS_MISMATCH,
410 result.error_type);
413 } // namespace
414 } // namespace cast_channel
415 } // namespace core_api
416 } // namespace extensions