156 uint8_t h1_solution[12] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
160 uint8_t h2_solution[12] = {0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
164 uint8_t h3_solution[12] = {0x01, 0x00, 0x08, 0x04, 0x02, 0x01,
165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
168 uint8_t h4_solution[12] = {0x08, 0x07, 0x06, 0x05, 0x04, 0x03,
169 0x02, 0x01, 0x00, 0x00, 0x00, 0x00};
172 uint8_t h5_solution[12] = {0x08, 0x07, 0x06, 0x05, 0x04, 0x03,
173 0x02, 0x01, 0x08, 0x04, 0x02, 0x01};
175 BOOST_CHECK( std::equal(h1_solution,h1_solution+12,h1.
bytes) );
176 BOOST_CHECK( std::equal(h2_solution,h2_solution+12,h2.
bytes) );
177 BOOST_CHECK( std::equal(h3_solution,h3_solution+12,h3.
bytes) );
178 BOOST_CHECK( std::equal(h4_solution,h4_solution+12,h4.
bytes) );
179 BOOST_CHECK( std::equal(h5_solution,h5_solution+12,h5.
bytes) );
185 BOOST_CHECK( get_extended_size(e1) == 255 );
186 BOOST_CHECK( get_payload_size(h1,e1) == 255 );
187 BOOST_CHECK( get_masking_key_offset(h1) == 2 );
188 BOOST_CHECK( get_masking_key(h1,e1).i == 0 );
192 BOOST_CHECK( get_jumbo_size(e2) == 0x0807060504030201LL );
193 BOOST_CHECK( get_payload_size(h2,e2) == 0x0807060504030201LL );
194 BOOST_CHECK( get_masking_key_offset(h2) == 8 );
195 BOOST_CHECK( get_masking_key(h2,e2).i == 0 );
199 BOOST_CHECK( get_extended_size(e3) == 255 );
200 BOOST_CHECK( get_payload_size(h3,e3) == 255 );
201 BOOST_CHECK( get_masking_key_offset(h3) == 2 );
202 BOOST_CHECK( get_masking_key(h3,e3).i == 0x08040201 );
206 BOOST_CHECK( get_jumbo_size(e4) == 0x0807060504030201LL );
207 BOOST_CHECK( get_payload_size(h4,e4) == 0x0807060504030201LL );
208 BOOST_CHECK( get_masking_key_offset(h4) == 8 );
209 BOOST_CHECK( get_masking_key(h4,e4).i == 0x08040201 );
213 BOOST_CHECK( get_payload_size(h5,e5) == 125 );
219 std::string p1 = prepare_header(h1, e1);
221 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF,
222 0xD5, 0xFB, 0x70, 0xEE};
224 BOOST_CHECK( p1.size() == 14);
225 BOOST_CHECK( std::equal(p1.begin(),p1.end(),
reinterpret_cast<char*
>(s1)) );
229 std::string p2 = prepare_header(h2, e2);
230 uint8_t s2[4] = {0x81, 0x7E, 0x00, 0xFF};
232 BOOST_CHECK( p2.size() == 4);
233 BOOST_CHECK( std::equal(p2.begin(),p2.end(),
reinterpret_cast<char*
>(s2)) );
285 uint8_t input[15] = {0x00, 0x00, 0x00, 0x00,
286 0x00, 0x00, 0x00, 0x00,
287 0x00, 0x00, 0x00, 0x00,
292 uint8_t masked[15] = {0x00, 0x01, 0x02, 0x03,
293 0x00, 0x01, 0x02, 0x03,
294 0x00, 0x01, 0x02, 0x03,
303 byte_mask(input,input+15,output,key);
305 BOOST_CHECK( std::equal(output,output+15,masked) );
309 uint8_t buffer[15] = {0x00, 0x00, 0x00, 0x00,
310 0x00, 0x00, 0x00, 0x00,
311 0x00, 0x00, 0x00, 0x00,
314 uint8_t masked[15] = {0x00, 0x01, 0x02, 0x03,
315 0x00, 0x01, 0x02, 0x03,
316 0x00, 0x01, 0x02, 0x03,
325 byte_mask(buffer,buffer+15,key);
327 BOOST_CHECK( std::equal(buffer,buffer+15,masked) );
331 uint8_t input[15] = {0x00, 0x00, 0x00, 0x00,
332 0x00, 0x00, 0x00, 0x00,
333 0x00, 0x00, 0x00, 0x00,
338 uint8_t masked[15] = {0x00, 0x01, 0x02, 0x03,
339 0x00, 0x01, 0x02, 0x03,
340 0x00, 0x01, 0x02, 0x03,
349 word_mask_exact(input,output,15,key);
351 BOOST_CHECK( std::equal(output,output+15,masked) );
355 uint8_t buffer[15] = {0x00, 0x00, 0x00, 0x00,
356 0x00, 0x00, 0x00, 0x00,
357 0x00, 0x00, 0x00, 0x00,
360 uint8_t masked[15] = {0x00, 0x01, 0x02, 0x03,
361 0x00, 0x01, 0x02, 0x03,
362 0x00, 0x01, 0x02, 0x03,
371 word_mask_exact(buffer,15,key);
373 BOOST_CHECK( std::equal(buffer,buffer+15,masked) );
380 uint8_t masked[16] = {0x00, 0x01, 0x02, 0x03,
381 0x00, 0x01, 0x02, 0x03,
382 0x00, 0x01, 0x02, 0x03,
383 0x00, 0x01, 0x02, 0x00};
392 size_t pkey,pkey_temp;
394 std::fill_n(input,16,0x00);
395 std::fill_n(output,16,0x00);
397 BOOST_CHECK( std::equal(output,output+16,masked) );
401 std::fill_n(input,16,0x00);
402 std::fill_n(output,16,0x00);
405 BOOST_CHECK( std::equal(output,output+7,masked) );
409 BOOST_CHECK( std::equal(output,output+16,masked) );
417 uint8_t masked[16] = {0x00, 0x01, 0x02, 0x03,
418 0x00, 0x01, 0x02, 0x03,
419 0x00, 0x01, 0x02, 0x03,
420 0x00, 0x01, 0x02, 0x00};
429 size_t pkey,pkey_temp;
431 std::fill_n(input,16,0x00);
432 std::fill_n(output,16,0x00);
434 BOOST_CHECK( std::equal(output,output+16,masked) );
438 std::fill_n(input,16,0x00);
439 std::fill_n(output,16,0x00);
442 BOOST_CHECK( std::equal(output,output+7,masked) );
446 BOOST_CHECK( std::equal(output,output+16,masked) );
453 uint8_t masked[16] = {0x00, 0x01, 0x02, 0x03,
454 0x00, 0x01, 0x02, 0x03,
455 0x00, 0x01, 0x02, 0x03,
456 0x00, 0x01, 0x02, 0x00};
465 size_t pkey,pkey_temp;
467 std::fill_n(buffer,16,0x00);
469 BOOST_CHECK( std::equal(buffer,buffer+16,masked) );
473 std::fill_n(buffer,16,0x00);
476 BOOST_CHECK( std::equal(buffer,buffer+7,masked) );
480 BOOST_CHECK( std::equal(buffer,buffer+16,masked) );
487 uint8_t masked[16] = {0x00, 0x01, 0x02, 0x03,
488 0x00, 0x01, 0x02, 0x03,
489 0x00, 0x01, 0x02, 0x03,
490 0x00, 0x01, 0x02, 0x00};
499 size_t pkey,pkey_temp;
501 std::fill_n(buffer,16,0x00);
503 BOOST_CHECK( std::equal(buffer,buffer+16,masked) );
507 std::fill_n(buffer,16,0x00);
510 BOOST_CHECK( std::equal(buffer,buffer+7,masked) );
514 BOOST_CHECK( std::equal(buffer,buffer+16,masked) );
519 uint8_t buffer[12] = {0xA6, 0x15, 0x97, 0xB9,
520 0x81, 0x50, 0xAC, 0xBA,
521 0x9C, 0x1C, 0x9F, 0xF4};
523 uint8_t unmasked[12] = {0x48, 0x65, 0x6C, 0x6C,
524 0x6F, 0x20, 0x57, 0x6F,
525 0x72, 0x6C, 0x64, 0x21};
537 BOOST_CHECK( std::equal(buffer,buffer+12,unmasked) );