Package list python-castellan / 82f483a
Add unit tests for managed objects Change-Id: I1c49e17fbeef3a7b583706de84165c588bf3e8e0 Kaitlin Farr 6 years ago
10 changed file(s) with 571 addition(s) and 72 deletion(s). Raw diff Collapse all Expand all
1919
2020 class TestCase(base.BaseTestCase):
2121
22 """Test case base class for all tests."""
22 """Test case base class for all unit tests."""
23
24
25 class CertificateTestCase(TestCase):
26
27 def _create_cert(self):
28 raise NotImplementedError()
29
30 def setUp(self):
31 super(CertificateTestCase, self).setUp()
32
33 self.cert = self._create_cert()
34
35
36 class KeyTestCase(TestCase):
37
38 def _create_key(self):
39 raise NotImplementedError()
40
41 def setUp(self):
42 super(KeyTestCase, self).setUp()
43
44 self.key = self._create_key()
+0
-71
castellan/tests/unit/key_manager/test_key.py less more
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Test cases for the symmetric key class.
17 """
18
19 from castellan.common.objects import symmetric_key as sym_key
20 from castellan.tests import base
21
22
23 class KeyTestCase(base.TestCase):
24
25 def _create_key(self):
26 raise NotImplementedError()
27
28 def setUp(self):
29 super(KeyTestCase, self).setUp()
30
31 self.key = self._create_key()
32
33
34 class SymmetricKeyTestCase(KeyTestCase):
35
36 def _create_key(self):
37 return sym_key.SymmetricKey(self.algorithm,
38 self.bit_length,
39 self.encoded)
40
41 def setUp(self):
42 self.algorithm = 'AES'
43 self.encoded = bytes(b'0' * 64)
44 self.bit_length = len(self.encoded) * 8
45
46 super(SymmetricKeyTestCase, self).setUp()
47
48 def test_get_format(self):
49 self.assertEqual('RAW', self.key.format)
50
51 def test_get_encoded(self):
52 self.assertEqual(self.encoded, self.key.get_encoded())
53
54 def test_get_algorithm(self):
55 self.assertEqual(self.algorithm, self.key.algorithm)
56
57 def test_get_bit_length(self):
58 self.assertEqual(self.bit_length, self.key.bit_length)
59
60 def test___eq__(self):
61 self.assertTrue(self.key == self.key)
62
63 self.assertFalse(self.key is None)
64 self.assertFalse(None == self.key)
65
66 def test___ne__(self):
67 self.assertFalse(self.key != self.key)
68
69 self.assertTrue(self.key is not None)
70 self.assertTrue(None != self.key)
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Test cases for the opaque data class.
17 """
18
19 from castellan.common.objects import opaque_data
20 from castellan.tests import base
21
22
23 class OpaqueDataTestCase(base.TestCase):
24
25 def _create_data(self):
26 return opaque_data.OpaqueData(self.data)
27
28 def setUp(self):
29 self.data = bytes(b"secret opaque data")
30 self.opaque_data = self._create_data()
31
32 super(OpaqueDataTestCase, self).setUp()
33
34 def test_get_format(self):
35 self.assertEqual('Opaque', self.opaque_data.format)
36
37 def test_get_encoded(self):
38 self.assertEqual(self.data, self.opaque_data.get_encoded())
39
40 def test___eq__(self):
41 self.assertTrue(self.opaque_data == self.opaque_data)
42
43 self.assertFalse(self.opaque_data is None)
44 self.assertFalse(None == self.opaque_data)
45
46 def test___ne__(self):
47 self.assertFalse(self.opaque_data != self.opaque_data)
48
49 self.assertTrue(self.opaque_data is not None)
50 self.assertTrue(None != self.opaque_data)
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Test cases for the passphrase class.
17 """
18
19 from castellan.common.objects import passphrase
20 from castellan.tests import base
21
22
23 class PassphraseTestCase(base.TestCase):
24
25 def _create_passphrase(self):
26 return passphrase.Passphrase(self.passphrase_data)
27
28 def setUp(self):
29 self.passphrase_data = bytes(b"secret passphrase")
30 self.passphrase = self._create_passphrase()
31
32 super(PassphraseTestCase, self).setUp()
33
34 def test_get_format(self):
35 self.assertEqual('RAW', self.passphrase.format)
36
37 def test_get_encoded(self):
38 self.assertEqual(self.passphrase_data, self.passphrase.get_encoded())
39
40 def test___eq__(self):
41 self.assertTrue(self.passphrase == self.passphrase)
42
43 self.assertFalse(self.passphrase is None)
44 self.assertFalse(None == self.passphrase)
45
46 def test___ne__(self):
47 self.assertFalse(self.passphrase != self.passphrase)
48
49 self.assertTrue(self.passphrase is not None)
50 self.assertTrue(None != self.passphrase)
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Test cases for the private key class.
17 """
18
19 from castellan.common.objects import private_key
20 from castellan.tests import base
21 from castellan.tests import utils
22
23
24 class PrivateKeyTestCase(base.KeyTestCase):
25
26 def _create_key(self):
27 return private_key.PrivateKey(self.algorithm,
28 self.length,
29 self.encoded)
30
31 def setUp(self):
32 self.algorithm = 'RSA'
33 self.length = 2048
34 self.encoded = bytes(utils.get_private_key_der())
35
36 super(PrivateKeyTestCase, self).setUp()
37
38 def test_get_algorithm(self):
39 self.assertEqual(self.algorithm, self.key.algorithm)
40
41 def test_get_length(self):
42 self.assertEqual(self.length, self.key.bit_length)
43
44 def test_get_format(self):
45 self.assertEqual('PKCS8', self.key.format)
46
47 def test_get_encoded(self):
48 self.assertEqual(self.encoded, self.key.get_encoded())
49
50 def test___eq__(self):
51 self.assertTrue(self.key == self.key)
52
53 self.assertFalse(self.key is None)
54 self.assertFalse(None == self.key)
55
56 def test___ne__(self):
57 self.assertFalse(self.key != self.key)
58
59 self.assertTrue(self.key is not None)
60 self.assertTrue(None != self.key)
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Test cases for the public key class.
17 """
18
19 from castellan.common.objects import public_key
20 from castellan.tests import base
21 from castellan.tests import utils
22
23
24 class PublicKeyTestCase(base.KeyTestCase):
25
26 def _create_key(self):
27 return public_key.PublicKey(self.algorithm, self.length, self.encoded)
28
29 def setUp(self):
30 self.algorithm = 'RSA'
31 self.length = 2048
32 self.encoded = bytes(utils.get_public_key_der())
33
34 super(PublicKeyTestCase, self).setUp()
35
36 def test_get_algorithm(self):
37 self.assertEqual(self.algorithm, self.key.algorithm)
38
39 def test_get_length(self):
40 self.assertEqual(self.length, self.key.bit_length)
41
42 def test_get_format(self):
43 self.assertEqual('SubjectPublicKeyInfo', self.key.format)
44
45 def test_get_encoded(self):
46 self.assertEqual(self.encoded, self.key.get_encoded())
47
48 def test___eq__(self):
49 self.assertTrue(self.key == self.key)
50
51 self.assertFalse(self.key is None)
52 self.assertFalse(None == self.key)
53
54 def test___ne__(self):
55 self.assertFalse(self.key != self.key)
56
57 self.assertTrue(self.key is not None)
58 self.assertTrue(None != self.key)
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Test cases for the symmetric key class.
17 """
18
19 from castellan.common.objects import symmetric_key as sym_key
20 from castellan.tests import base
21
22
23 class SymmetricKeyTestCase(base.KeyTestCase):
24
25 def _create_key(self):
26 return sym_key.SymmetricKey(self.algorithm,
27 self.bit_length,
28 self.encoded)
29
30 def setUp(self):
31 self.algorithm = 'AES'
32 self.encoded = bytes(b'0' * 64)
33 self.bit_length = len(self.encoded) * 8
34
35 super(SymmetricKeyTestCase, self).setUp()
36
37 def test_get_format(self):
38 self.assertEqual('RAW', self.key.format)
39
40 def test_get_encoded(self):
41 self.assertEqual(self.encoded, self.key.get_encoded())
42
43 def test_get_algorithm(self):
44 self.assertEqual(self.algorithm, self.key.algorithm)
45
46 def test_get_bit_length(self):
47 self.assertEqual(self.bit_length, self.key.bit_length)
48
49 def test___eq__(self):
50 self.assertTrue(self.key == self.key)
51
52 self.assertFalse(self.key is None)
53 self.assertFalse(None == self.key)
54
55 def test___ne__(self):
56 self.assertFalse(self.key != self.key)
57
58 self.assertTrue(self.key is not None)
59 self.assertTrue(None != self.key)
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Test cases for the X.509 certificate class.
17 """
18
19 from castellan.common.objects import x_509
20 from castellan.tests import base
21 from castellan.tests import utils
22
23
24 class X509TestCase(base.CertificateTestCase):
25
26 def _create_cert(self):
27 return x_509.X509(self.data)
28
29 def setUp(self):
30 self.data = utils.get_certificate_der()
31
32 super(X509TestCase, self).setUp()
33
34 def test_get_format(self):
35 self.assertEqual('X.509', self.cert.format)
36
37 def test_get_encoded(self):
38 self.assertEqual(self.data, self.cert.get_encoded())
39
40 def test___eq__(self):
41 self.assertTrue(self.cert == self.cert)
42
43 self.assertFalse(self.cert is None)
44 self.assertFalse(None == self.cert)
45
46 def test___ne__(self):
47 self.assertFalse(self.cert != self.cert)
48
49 self.assertTrue(self.cert is not None)
50 self.assertTrue(None != self.cert)
0 # Copyright (c) 2015
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15
16 """
17 These utilility functions are borrowed from Barbican's testing utilites.
18 """
19
20
21 def get_certificate_der():
22 """Returns an X509 certificate in DER format
23
24 This certificate was created by issuing the following openssl commands:
25 openssl genrsa -out private.pem 2048
26 openssl req -new -x509 -key private.pem -out cert.pem \
27 -days 1000 -subj '/CN=example.com'
28 openssl x509 -outform der -in cert.pem -out cert.der
29 The byte string returned by this function is the contents
30 of the cert.der file.
31 """
32 cert_der = (
33 b'\x30\x82\x02\xff\x30\x82\x01\xe7\xa0\x03\x02\x01\x02\x02\x09'
34 b'\x00\xe2\xea\x5c\xa2\x7d\xab\xdf\xe7\x30\x0d\x06\x09\x2a\x86'
35 b'\x48\x86\xf7\x0d\x01\x01\x0b\x05\x00\x30\x16\x31\x14\x30\x12'
36 b'\x06\x03\x55\x04\x03\x0c\x0b\x65\x78\x61\x6d\x70\x6c\x65\x2e'
37 b'\x63\x6f\x6d\x30\x1e\x17\x0d\x31\x35\x30\x34\x31\x31\x30\x32'
38 b'\x31\x35\x32\x39\x5a\x17\x0d\x31\x38\x30\x31\x30\x35\x30\x32'
39 b'\x31\x35\x32\x39\x5a\x30\x16\x31\x14\x30\x12\x06\x03\x55\x04'
40 b'\x03\x0c\x0b\x65\x78\x61\x6d\x70\x6c\x65\x2e\x63\x6f\x6d\x30'
41 b'\x82\x01\x22\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01'
42 b'\x01\x05\x00\x03\x82\x01\x0f\x00\x30\x82\x01\x0a\x02\x82\x01'
43 b'\x01\x00\xb3\x6b\x65\x68\x0d\x79\x81\x50\xc9\xb0\x8c\x5b\xbd'
44 b'\x17\xa3\x0c\xe6\xaf\xc0\x67\x55\xa3\x9d\x60\x36\x60\xd7\x4d'
45 b'\xcb\x6d\xfb\x4e\xb1\x8d\xfe\x7a\x1b\x0c\x3b\xfc\x14\x10\x69'
46 b'\x50\xf9\x87\x35\x9d\x38\x1f\x52\xf2\xc4\x57\x0f\xf1\x17\x85'
47 b'\xad\xc2\x17\xa6\x27\xec\x45\xeb\xb6\x94\x05\x9a\xa9\x13\xf1'
48 b'\xa2\xfb\xb9\x0a\xe0\x21\x7d\xe7\x0a\xbf\xe4\x61\x8c\xb5\x4b'
49 b'\x27\x42\x3e\x31\x92\x1b\xef\x64\x4e\x2a\x97\xd9\x4e\x66\xfb'
50 b'\x76\x19\x45\x80\x60\xf7\xbe\x40\xb9\xd4\x10\x9f\x84\x65\x56'
51 b'\xdf\x9c\x39\xd8\xe6\x3f\xdb\x7c\x79\x31\xe3\xb8\xca\xfc\x79'
52 b'\x9b\x23\xdc\x72\x7c\x4c\x55\x0e\x36\x2a\xe0\xeb\xcc\xaa\xa3'
53 b'\x06\x54\xa3\x98\x19\xdc\xa4\x66\x31\xd0\x98\x02\x4f\xeb\x32'
54 b'\x16\x61\xec\x97\xca\xce\x92\xa0\x8f\x3c\x52\xe8\xdb\x86\x10'
55 b'\x9f\xee\x3f\xa6\xbd\x40\x63\x06\x99\x01\xb3\x13\x97\xdc\xe8'
56 b'\x2e\xd1\x10\x8f\xab\x31\x49\xcb\x87\x71\x2f\x5e\xf2\x78\xa9'
57 b'\xb4\x3c\x65\xb1\xb2\xd0\x82\xa1\x95\x68\x67\x44\xd7\x5e\xec'
58 b'\xb4\x2f\x79\x40\x7e\xd4\xbc\x84\xdb\xb9\x8c\xdd\x8d\x9c\x01'
59 b'\x15\xcd\x52\x83\x3f\x06\x67\xfd\xa1\x2d\x2b\x07\xba\x32\x62'
60 b'\x21\x07\x2f\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06'
61 b'\x03\x55\x1d\x0e\x04\x16\x04\x14\x94\xab\x60\x34\x6f\x65\xe8'
62 b'\xfa\xc2\xaf\x98\xa8\x0d\xf1\x6a\xbc\x97\xa8\xfc\xda\x30\x1f'
63 b'\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x94\xab\x60\x34'
64 b'\x6f\x65\xe8\xfa\xc2\xaf\x98\xa8\x0d\xf1\x6a\xbc\x97\xa8\xfc'
65 b'\xda\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff'
66 b'\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x0b\x05\x00'
67 b'\x03\x82\x01\x01\x00\x63\x8a\xea\xa1\x97\x33\x55\x39\x52\xeb'
68 b'\x1c\x34\x32\x1a\xbd\x1f\x4c\x00\x85\x25\xd0\xd1\x12\x7b\xa1'
69 b'\x66\x9e\x1d\xf7\x5f\xbe\x0e\x63\x02\x4f\xe6\xdc\x4c\x6d\x3e'
70 b'\x18\x2a\x77\xad\xf1\x4e\xb8\x45\xa9\x24\xb2\xcb\x3d\xd4\x8e'
71 b'\x9c\x8b\x27\x89\xbb\x0e\xb3\x22\x8f\x5e\xe0\x41\x5f\x99\x26'
72 b'\x75\x82\x28\x8d\xb7\x63\x51\x34\xb0\x9e\x17\x31\xf4\x94\xc0'
73 b'\x7c\xa4\xa6\xc5\x75\x92\x0b\x4a\xe7\x28\x27\x9f\x01\xfe\x38'
74 b'\x32\x6e\x9f\xaa\xfa\x13\xc9\x36\xde\x19\x24\x0f\xea\x71\xf3'
75 b'\x73\xb7\x8b\x68\xaf\xde\x7d\xca\xcc\xbd\x87\x5c\xb7\xe4\xde'
76 b'\x4e\x41\xe3\xa9\x1f\x0b\xbb\x8a\x63\x66\xf4\x5d\x51\x06\x9d'
77 b'\x40\x78\x43\xc8\xdf\x8e\x34\xa7\x4a\x0f\xd4\xeb\x8e\xf7\xcf'
78 b'\x8a\x6d\x1b\xec\x0a\xbc\xf3\x93\xe3\x48\xde\x90\xa3\x86\x7d'
79 b'\x1d\x74\x7a\xfa\x72\xbe\x6d\x3c\xfd\x1f\x25\x00\x4c\xc7\xc3'
80 b'\x18\xd4\x2d\xd0\xbd\xef\xc9\xf5\x71\x6c\xd3\xb1\x90\x20\x5c'
81 b'\x60\x8e\x21\x16\xd1\x9f\x90\xec\xdd\xe8\x1e\xeb\xda\xc6\x35'
82 b'\xc0\x62\x9d\x4c\xb1\xe4\xb9\x3e\x26\xe3\xff\x40\xfd\x23\xb3'
83 b'\xbe\x71\xfe\x7a\x99\xc9\xa8\x84\xbd\x8f\x0f\xb5\x89\x18\xfc'
84 b'\xc5\xc0\xc0\xe8\xf3\x53')
85 return cert_der
86
87
88 def get_private_key_der():
89 """Returns a private key in DER format
90
91 This key was created by issuing the following openssl commands:
92 openssl genrsa -out private.pem 2048
93 openssl pkcs8 -in private.pem -topk8 -nocrypt \
94 -outform DER -out private_pk8.der
95 The byte string returned by this function is the contents
96 of the private_pk8.der file.
97 """
98 key_der = (
99 b'\x30\x82\x04\xbf\x02\x01\x00\x30\x0d\x06\x09\x2a\x86\x48\x86'
100 b'\xf7\x0d\x01\x01\x01\x05\x00\x04\x82\x04\xa9\x30\x82\x04\xa5'
101 b'\x02\x01\x00\x02\x82\x01\x01\x00\xb3\x6b\x65\x68\x0d\x79\x81'
102 b'\x50\xc9\xb0\x8c\x5b\xbd\x17\xa3\x0c\xe6\xaf\xc0\x67\x55\xa3'
103 b'\x9d\x60\x36\x60\xd7\x4d\xcb\x6d\xfb\x4e\xb1\x8d\xfe\x7a\x1b'
104 b'\x0c\x3b\xfc\x14\x10\x69\x50\xf9\x87\x35\x9d\x38\x1f\x52\xf2'
105 b'\xc4\x57\x0f\xf1\x17\x85\xad\xc2\x17\xa6\x27\xec\x45\xeb\xb6'
106 b'\x94\x05\x9a\xa9\x13\xf1\xa2\xfb\xb9\x0a\xe0\x21\x7d\xe7\x0a'
107 b'\xbf\xe4\x61\x8c\xb5\x4b\x27\x42\x3e\x31\x92\x1b\xef\x64\x4e'
108 b'\x2a\x97\xd9\x4e\x66\xfb\x76\x19\x45\x80\x60\xf7\xbe\x40\xb9'
109 b'\xd4\x10\x9f\x84\x65\x56\xdf\x9c\x39\xd8\xe6\x3f\xdb\x7c\x79'
110 b'\x31\xe3\xb8\xca\xfc\x79\x9b\x23\xdc\x72\x7c\x4c\x55\x0e\x36'
111 b'\x2a\xe0\xeb\xcc\xaa\xa3\x06\x54\xa3\x98\x19\xdc\xa4\x66\x31'
112 b'\xd0\x98\x02\x4f\xeb\x32\x16\x61\xec\x97\xca\xce\x92\xa0\x8f'
113 b'\x3c\x52\xe8\xdb\x86\x10\x9f\xee\x3f\xa6\xbd\x40\x63\x06\x99'
114 b'\x01\xb3\x13\x97\xdc\xe8\x2e\xd1\x10\x8f\xab\x31\x49\xcb\x87'
115 b'\x71\x2f\x5e\xf2\x78\xa9\xb4\x3c\x65\xb1\xb2\xd0\x82\xa1\x95'
116 b'\x68\x67\x44\xd7\x5e\xec\xb4\x2f\x79\x40\x7e\xd4\xbc\x84\xdb'
117 b'\xb9\x8c\xdd\x8d\x9c\x01\x15\xcd\x52\x83\x3f\x06\x67\xfd\xa1'
118 b'\x2d\x2b\x07\xba\x32\x62\x21\x07\x2f\x02\x03\x01\x00\x01\x02'
119 b'\x82\x01\x00\x30\xe9\x54\x29\xbb\x92\xa6\x28\x29\xf3\x91\x2f'
120 b'\xe9\x2a\xaa\x6e\x77\xec\xed\x9c\xbe\x01\xee\x83\x2e\x0f\xd4'
121 b'\x62\x06\xd5\x22\xaf\x5f\x44\x00\x5d\xb5\x45\xee\x8c\x57\xc3'
122 b'\xe9\x92\x03\x94\x52\x8f\x5b\x9f\x5e\x73\x84\x06\xdf\xf7\xaf'
123 b'\x9b\xe7\xb4\x83\xd1\xee\x0c\x41\x3b\x72\xf8\x83\x56\x98\x45'
124 b'\x31\x98\x66\xdb\x19\x15\xe4\xcb\x77\xd2\xbc\x61\x3c\x1e\xa9'
125 b'\xc5\xa5\x1c\x2f\xec\x3f\x92\x91\xfe\x5c\x38\xcc\x50\x97\x49'
126 b'\x07\xc0\x38\x3f\x74\x31\xfb\x17\xc8\x79\x60\x50\x6f\xcc\x1d'
127 b'\xfc\x42\xd5\x4a\x07\xd1\x2d\x13\x5e\xa9\x82\xf4\xd0\xa5\xd5'
128 b'\xb3\x4e\x3f\x14\xe0\x44\x86\xa4\xa2\xaa\x2f\xe8\x1d\x82\x78'
129 b'\x83\x13\x6b\x4a\x82\x0d\x5f\xbd\x4f\x1d\x56\xda\x12\x29\x08'
130 b'\xca\x0c\xe2\xe0\x76\x55\xc8\xcb\xad\xdc\xb1\x3a\x71\xe1\xf3'
131 b'\x7d\x28\xfb\xd5\xfb\x67\xf9\x48\xb4\x4f\x39\x0b\x39\xbf\x8d'
132 b'\xa0\x13\xf7\xd6\x16\x87\x0b\xfb\x1f\x0a\xba\x4a\x83\xb4\x2d'
133 b'\x50\xff\x6a\xf5\xd4\x6a\xe9\xd6\x5c\x23\x5e\xea\xe5\xde\xe8'
134 b'\x11\xd1\x13\x78\x34\x4a\x85\x3d\xaf\x9b\xb6\xf1\xd9\xb2\xc6'
135 b'\x78\x5d\x70\xd8\x7f\x41\xfd\x5f\x35\xba\x98\xe2\x01\xa8\x76'
136 b'\x45\x59\xde\x71\x02\x81\x81\x00\xec\x7c\x74\xa3\x47\x58\x1d'
137 b'\xf9\x21\xf0\xff\x60\x3d\x49\xa5\xd2\xd6\x4f\x4b\x79\x72\xed'
138 b'\xf9\x46\xc3\x41\xd6\xe3\x60\xeb\x21\xe4\xba\x13\xf8\x43\x7f'
139 b'\xba\xd3\xbb\xd1\x1c\x83\x62\xa8\xe5\x87\x3a\x89\xcd\xc8\x8a'
140 b'\x4e\xe0\x16\xe5\x25\x4f\x0b\xa8\x10\xb8\x2a\x69\x03\x6f\x4a'
141 b'\x9e\xda\xbb\xc7\x5f\x8b\xc3\xfe\x30\x1b\xde\x3b\xa6\x85\xdb'
142 b'\xeb\x4b\x4b\x76\x0d\xc1\x2b\x99\x81\x15\x33\x91\x93\x90\x13'
143 b'\xa8\x0c\x15\xab\xbb\x7e\xd8\xdb\x52\xe5\x2f\xc9\xba\x7c\xec'
144 b'\xe7\x1a\xd1\xa2\x50\xc5\x9d\x25\xf8\x2a\x7b\xd5\x97\xa2\x63'
145 b'\xdd\x02\x81\x81\x00\xc2\x39\x76\x53\x55\x74\x4f\x10\x58\x67'
146 b'\xaa\x7a\x8b\x12\xb6\x5e\xe8\x42\x64\xc9\x2c\x06\xf3\x08\x2d'
147 b'\x39\xd0\xa6\xaf\xae\xb4\x6e\x87\x18\xd6\x2f\x6f\x57\xe4\x5a'
148 b'\x33\x58\x80\x44\x75\xfa\xbb\xfb\x2e\x32\x19\x33\xfb\x72\x91'
149 b'\x8a\x7c\xf1\x20\x6e\x60\x42\xcc\xa2\x5a\x64\xe9\x15\x5d\xbd'
150 b'\xf1\x6f\x6f\x91\x1b\x66\xb0\x24\x03\x9f\x69\xb2\xf7\x4c\xaf'
151 b'\xe1\xee\xac\x2c\x8d\x27\x83\xb9\x7f\x37\x7a\xfb\x0b\x02\xcb'
152 b'\x34\x85\x7f\x0a\xa7\xb2\x68\xde\x34\xb2\xec\xc4\xf0\x08\xe0'
153 b'\x12\x06\xb9\x8d\x3b\x9a\xe9\xb3\xf9\x9b\xec\x7c\x7b\x02\x81'
154 b'\x81\x00\x9e\xb9\x6d\xc3\xc5\x77\xe4\x2e\x39\xd4\xba\x63\x0a'
155 b'\xdf\xaa\x97\xd7\x55\xc3\x6f\x91\x6f\x1e\x37\x9b\x88\x4e\x45'
156 b'\xb0\xe0\x40\x90\x77\x40\x3e\x0a\x77\xe9\x9a\x81\x5d\xfa\x08'
157 b'\x49\x28\xd9\x5d\xa9\x31\xa2\xd7\xed\xd4\xc0\xdd\x3d\x11\x8c'
158 b'\x7b\x63\x63\x4d\x68\xd1\xb1\x07\x7a\x8b\x22\x7e\x94\x73\x91'
159 b'\xa8\x8b\xac\x18\x98\x51\x6b\x14\x3f\x26\x2f\x14\x47\xf9\x35'
160 b'\x65\x21\x13\x9d\x7a\x4e\x44\x3f\x98\xa1\xda\xf2\x94\xa0\x34'
161 b'\xa4\x32\x98\xf1\xd0\xe0\x51\xf5\xd5\x3f\xcc\x25\x56\x0f\x66'
162 b'\x83\x72\x5f\x9d\x8c\x1e\x31\x37\x42\x55\x02\x81\x81\x00\xb1'
163 b'\xd7\x7d\xe2\x36\x68\x26\x91\x37\xf1\xcc\x67\x22\xfb\x02\x64'
164 b'\x8a\xd5\x68\x85\xd0\x3b\x98\xc3\x8e\xed\xd6\x81\x1a\x72\xa5'
165 b'\x22\x63\xaf\xb9\x47\x7b\xf3\x85\xd3\x96\x1a\x5e\x70\xd1\x7a'
166 b'\xc2\x2f\xf0\x0f\xcd\x86\x0c\xa2\xce\x63\x79\x9e\x2c\xed\x04'
167 b'\x55\x86\x1c\xcf\x1a\x81\x56\xa0\x1c\x71\x7b\x71\x33\xf4\x5c'
168 b'\x25\xc3\x04\x52\x2e\xad\xc1\xc5\xc5\x72\xe2\x61\x62\xf5\xe9'
169 b'\x0d\xb3\x87\xaa\x5c\x80\x8c\x87\x85\x5b\xd5\x35\x0b\xa3\x9c'
170 b'\x38\x6b\xe6\xe3\x42\xeb\xdd\x42\xb3\x31\xae\x58\xae\xda\xba'
171 b'\x31\x6e\x2b\x8b\xbb\x92\x0b\x02\x81\x81\x00\xdf\x76\xa5\x63'
172 b'\x4f\x8b\x97\x98\x6c\x0e\x87\x5c\xf8\x3f\x3b\xfa\x18\x2a\x1c'
173 b'\xfb\xa1\xa8\x6d\x78\x38\x0e\xfb\xc2\x52\x33\xfd\x31\x1f\xb6'
174 b'\xfb\x9b\x17\xd0\x06\x3f\x7f\xe6\x95\x08\x3d\x39\xfc\xd8\xf4'
175 b'\x46\xaa\x40\xc1\x47\x34\xdf\x36\x54\xe5\x9b\x4b\xda\xe3\x5e'
176 b'\xe9\x70\xe3\x12\xe8\x1f\x16\xd9\x73\x79\xae\xbe\xad\xb0\xfa'
177 b'\x2a\x91\x52\xfa\x7c\x4f\x24\x0f\x18\xc9\x66\x11\xa4\xd8\x69'
178 b'\x45\x61\x96\x41\xa9\x07\x79\xda\xf7\x06\xd3\x2d\x1a\xcd\x21'
179 b'\xa4\xa3\x40\x40\x6e\xf6\x1c\xa5\xad\x49\xf2\x50\x31\x7b\xe7'
180 b'\xd9\x19\x62\x70')
181 return key_der
182
183
184 def get_public_key_der():
185 """Returns a public key in DER format
186
187 This key was created by issuing the following openssl commands:
188 openssl genrsa -out private.pem 2048
189 openssl rsa -in private.pem -pubout > public.pem
190 The byte string returned by this function is the contents
191 of the public.der file.
192 """
193 key_der = (
194 b'\x30\x82\x01\x22\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01'
195 b'\x01\x01\x05\x00\x03\x82\x01\x0f\x00\x30\x82\x01\x0a\x02\x82'
196 b'\x01\x01\x00\xb3\x6b\x65\x68\x0d\x79\x81\x50\xc9\xb0\x8c\x5b'
197 b'\xbd\x17\xa3\x0c\xe6\xaf\xc0\x67\x55\xa3\x9d\x60\x36\x60\xd7'
198 b'\x4d\xcb\x6d\xfb\x4e\xb1\x8d\xfe\x7a\x1b\x0c\x3b\xfc\x14\x10'
199 b'\x69\x50\xf9\x87\x35\x9d\x38\x1f\x52\xf2\xc4\x57\x0f\xf1\x17'
200 b'\x85\xad\xc2\x17\xa6\x27\xec\x45\xeb\xb6\x94\x05\x9a\xa9\x13'
201 b'\xf1\xa2\xfb\xb9\x0a\xe0\x21\x7d\xe7\x0a\xbf\xe4\x61\x8c\xb5'
202 b'\x4b\x27\x42\x3e\x31\x92\x1b\xef\x64\x4e\x2a\x97\xd9\x4e\x66'
203 b'\xfb\x76\x19\x45\x80\x60\xf7\xbe\x40\xb9\xd4\x10\x9f\x84\x65'
204 b'\x56\xdf\x9c\x39\xd8\xe6\x3f\xdb\x7c\x79\x31\xe3\xb8\xca\xfc'
205 b'\x79\x9b\x23\xdc\x72\x7c\x4c\x55\x0e\x36\x2a\xe0\xeb\xcc\xaa'
206 b'\xa3\x06\x54\xa3\x98\x19\xdc\xa4\x66\x31\xd0\x98\x02\x4f\xeb'
207 b'\x32\x16\x61\xec\x97\xca\xce\x92\xa0\x8f\x3c\x52\xe8\xdb\x86'
208 b'\x10\x9f\xee\x3f\xa6\xbd\x40\x63\x06\x99\x01\xb3\x13\x97\xdc'
209 b'\xe8\x2e\xd1\x10\x8f\xab\x31\x49\xcb\x87\x71\x2f\x5e\xf2\x78'
210 b'\xa9\xb4\x3c\x65\xb1\xb2\xd0\x82\xa1\x95\x68\x67\x44\xd7\x5e'
211 b'\xec\xb4\x2f\x79\x40\x7e\xd4\xbc\x84\xdb\xb9\x8c\xdd\x8d\x9c'
212 b'\x01\x15\xcd\x52\x83\x3f\x06\x67\xfd\xa1\x2d\x2b\x07\xba\x32'
213 b'\x62\x21\x07\x2f\x02\x03\x01\x00\x01')
214 return key_der