-
Notifications
You must be signed in to change notification settings - Fork 11
/
generator.cpp
193 lines (174 loc) · 8.93 KB
/
generator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include "generator.hpp"
#include <fstream>
///////////////////////////////////////////////////////////////////////////////
namespace mbedcrypto {
namespace test {
namespace {
///////////////////////////////////////////////////////////////////////////////
const unsigned char BinaryShort[] = {
0x68, 0x40, 0x4c, 0x76, 0x37, 0x71, 0x88, 0x14, 0x3a, 0xe9, 0x67, 0x3f,
0x94, 0x13, 0xda, 0xdd, 0x03, 0x80, 0x9d, 0x31, 0x00, 0xff, 0xd7, 0x78,
0xba, 0xac, 0x90, 0xf0, 0xa3, 0x0e, 0xc0, 0xca, 0x71, 0x4f, 0xe4, 0x23,
0x48, 0xf2, 0x3e, 0x5d, 0x85, 0x63, 0xfb, 0x62, 0x67, 0x08, 0xf5, 0x77,
0x00, 0x25, 0xf6, 0x2c, 0x74, 0x10, 0x77, 0x59, 0xdf, 0xb2, 0x18};
// with many possible null bytes in the middle
const unsigned char BinaryLong[] = {
0xf3, 0x1b, 0x00, 0xa1, 0x98, 0xbf, 0xd0, 0xe9, 0xf6, 0x2a, 0xea, 0x28,
0xe0, 0x53, 0xc7, 0x69, 0xee, 0xdf, 0x81, 0x00, 0x00, 0xb0, 0x67, 0x00,
0x67, 0xf5, 0xf1, 0xec, 0xff, 0x8e, 0x8d, 0xfe, 0xe3, 0x5a, 0xc8, 0xb2,
0xd3, 0xdc, 0xe6, 0x9d, 0xa2, 0x1f, 0x4e, 0xa6, 0x9b, 0xb2, 0xf0, 0xb8,
0x89, 0xa6, 0x4d, 0xb8, 0xe5, 0x88, 0x22, 0xa4, 0xc9, 0xec, 0x69, 0xc7,
0x8e, 0x2c, 0x24, 0x04, 0x29, 0x07, 0xb9, 0x00, 0x32, 0x21, 0x12, 0xab,
0x18, 0x9a, 0xaf, 0xdb, 0xdb, 0x75, 0x77, 0xd0, 0x23, 0x37, 0xa3, 0xa9,
0xe6, 0xd0, 0xe3, 0x35, 0x13, 0x2b, 0x24, 0xf5, 0xe6, 0xe9, 0x74, 0x5f,
0xb7, 0x08, 0x33, 0x97, 0xb1, 0x75, 0xf9, 0x1c, 0xea, 0x3a, 0xcb, 0xdf,
0x58, 0x73, 0x35, 0x9a, 0x6a, 0x12, 0xc1, 0x07, 0x0a, 0x59, 0x40, 0xfa,
0xb4, 0xb7, 0xc8, 0x6d, 0xab, 0x63, 0x00, 0x8b,
};
// signature of long_text with the private key and sha1
const unsigned char SignatureSha1[] = {
0xb9, 0x33, 0x2d, 0xd3, 0xea, 0xd2, 0xbf, 0x6d, 0x98, 0x31, 0xe0, 0x16,
0xf3, 0xf1, 0x4a, 0x47, 0x37, 0x56, 0x85, 0x74, 0x7d, 0x08, 0x03, 0x88,
0x21, 0x97, 0xb4, 0x1c, 0x30, 0xc7, 0x68, 0x1c, 0x23, 0x67, 0xf4, 0x90,
0x9b, 0x2d, 0xb6, 0x8b, 0xcd, 0x4b, 0xb3, 0x29, 0x66, 0xcd, 0x5b, 0xc6,
0xce, 0x6d, 0xcc, 0x0d, 0xe7, 0xc8, 0x08, 0x3e, 0x31, 0x0f, 0xb4, 0x48,
0x43, 0x6d, 0x70, 0x93, 0xc1, 0x53, 0xed, 0x20, 0x90, 0xfc, 0x2d, 0x90,
0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////////////////////////////////////////////////////////////////////////
} // namespace anon
///////////////////////////////////////////////////////////////////////////////
void
dump_to_file(const buffer_t& data, const char* filename) {
std::fstream f(filename, std::fstream::out | std::fstream::binary);
f << data;
}
const char*
short_text() {
return "mbedtls cryptography";
}
const char*
long_text() {
return "Lorem ipsum dolor sit amet, consectetur adipiscing elit,"
" sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
" Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris"
" nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in"
" reprehenderit in voluptate velit esse cillum dolore eu fugiat "
"nulla pariatur."
" Excepteur sint occaecat cupidatat non proident,"
" sunt in culpa qui officia deserunt mollit anim id est laborum.";
}
buffer_t
short_binary() {
constexpr size_t length = sizeof(BinaryShort);
return buffer_t(reinterpret_cast<const char*>(BinaryShort), length);
}
buffer_t
long_binary() {
constexpr size_t length = sizeof(BinaryLong);
return buffer_t(reinterpret_cast<const char*>(BinaryLong), length);
}
buffer_t
rsa_private_key() {
buffer_t k(R"xx(-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEA4EjipWXxJPtz0KYDz5+fYWkGly7ieRJ2Zql9BkaIOjz3By/K
L+jkYbUIwOQ+jM+FComsII9Y6309Db74sfwtykJoyUGTvMfHsZ/0VmgWOwPcUZ6v
nw45D6YuOzoTRLSErR/Vd2EIjNlhYlHg8cy6j/M7IqlCrBfz5xdTVYkqU+c0dZ/z
7FbbTgCA/9VjCPH3NjtJ34OWYY4HIok+ml8ervlZkiBEIRW/rKiOUMBKy4fgGeWZ
ZBsMaf4wkO8O8fBvfT1CZvxsQnAzN/boRm8t00GT5VmyHsgEHU3rKIf31yA834x5
WqgOl7WV6GvGnrG9sWOH3/rJClxTadG3HiIarQIDAQABAoIBAHHF51sZzGsDN2vn
W1WOVo5WdaZpfS8Ho5JOdgKh8ucAGBvILVuCW6AI8qjO38AUYRvIXM2jierje/4m
GwhGsX/BkmBNaMFB4tYDGzJd2LEVM0UgJ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/KVreVvagVNR7TJHO6ybG/rc2ssfVIAXmKHtOI=
-----END RSA PRIVATE KEY-----)xx");
k.push_back('\0');
return k;
}
buffer_t
rsa_private_key_password() {
buffer_t k(R"xx(-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,142902F647920CE4B7AE3C2913FDFA10
nagu3l0U8ExoFvhCb8Te4nzsMGnBjdLUmfOm3abYhZLF7nTUv7EHmRGvJJnyHXjp
roBGiX4iii4FuUyAea1pIJNAi64f6V5XwSN5N+uEjcoHX55gl/o+kaGovXkDWq3A
xx4WqTeW0Jlr8Z1sx35NUrKf87h3JNRGqMK1cX+E7tmnhUx6orHBL+1ovTIPZ7LW
0fZHNHUl3tC87TCeHUgUvIZGWPSR3e9tbzfIzV6t68oXe8atvm2MAnRPZnYi8/7c
dSe77fTo/9rGVjhtg+wLmCqC9mOYOFIVORERcVMK/V2BZe1hsWcjmjFeg+DnaE6s
eCAV60S/QNkvQlWi/AdF5PRz9hHq8mQbhrPbKppabBQyrVOPytEFy76a7966t62Q
qtCGAC7aTVw0GKa9KmiD0CYA6aixVtw0+lP4jHquotGNZtletBwme2k/MsckmPK0
bsf6033SaUKD8uiW0JHQj26JgEgKZx7ZAIhKqEsRtLp0/YEw3kQQBEewBxEvmCE/
fFpGrE2joB+MvLoVaUv+4Vy2Er4A+C0KBCna8hwEV9yhrE5D4Ny5yp6yIvy9SsN4
7Nvdg25h7l6o6d0npW6W/w272skb2BlID/EEtwSCmUZLDCRN0chH99t+5OgDcA1N
qKXjnJpU5uqDzWuVi790Va5dfUE2oh/YSJShlstne4/xFlhHtCPlFPYcnFoJwrjg
KqahkEAj55qz9W7RU1uTEDt8CGTuPsWMIBsN+n5BDoeM0ZsF3ZcJ1zSXsyVuiYVs
NzxFlXFg7ZICeLkUFM8QnfkDXo6JLkqUX/mDpG2xZfi41CpgX/k9xW+dTRnHRY2x
vY0buJijF3GYgzdYHbicT/vdXud0HknN/31kf9M/pesC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J34OWYY4HIok+ml8e
rvlZkiBEIRW/rKiOUMBKy4fgGeWZZBsMaf4wkO8O8fBvfT1CZvxsQnAzN/boRm8t
00GT5VmyHsgEHU3rKIf31yA834x5WqgOl7WV6GvGnrG9sWOH3/rJClxTadG3HiIa
rQIDAQAB
-----END PUBLIC KEY-----)xx");
k.push_back('\0');
return k;
}
buffer_t
long_text_signature() {
constexpr size_t length = sizeof(SignatureSha1);
return buffer_t(reinterpret_cast<const char*>(SignatureSha1), length);
}
///////////////////////////////////////////////////////////////////////////////
} // namespace test
} // namespace mbedcrypto
///////////////////////////////////////////////////////////////////////////////