diff --git a/test/mocks/SHA256.h b/test/mocks/SHA256.h index b6e551a07..56d214b19 100644 --- a/test/mocks/SHA256.h +++ b/test/mocks/SHA256.h @@ -2,13 +2,102 @@ #include #include +#include -// Mock SHA256 class for testing -// Provides minimal interface to allow Utils.cpp to compile +// Real SHA-256 for native/host tests. Mirrors the rweather/Crypto streaming API used by +// src/Utils.cpp (update / finalize-with-truncation, plus resetHMAC / finalizeHMAC), so that +// Utils::sha256(...) produces correct digests on the host and OTA merkle tests are meaningful. +// (On-device the real rweather is used instead of this mock.) class SHA256 { + uint32_t h[8]; + uint8_t buf[64]; + uint32_t buf_len; + uint64_t total_len; + uint8_t hmac_key[64]; + + static uint32_t ror(uint32_t x, uint32_t n) { return (x >> n) | (x << (32 - n)); } + + void process(const uint8_t* p) { + static const uint32_t K[64] = { + 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5, + 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174, + 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da, + 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967, + 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85, + 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070, + 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3, + 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2}; + uint32_t w[64]; + for (int i = 0; i < 16; i++) + w[i] = ((uint32_t)p[i*4] << 24) | ((uint32_t)p[i*4+1] << 16) | ((uint32_t)p[i*4+2] << 8) | p[i*4+3]; + for (int i = 16; i < 64; i++) { + uint32_t s0 = ror(w[i-15],7) ^ ror(w[i-15],18) ^ (w[i-15] >> 3); + uint32_t s1 = ror(w[i-2],17) ^ ror(w[i-2],19) ^ (w[i-2] >> 10); + w[i] = w[i-16] + s0 + w[i-7] + s1; + } + uint32_t a=h[0],b=h[1],c=h[2],d=h[3],e=h[4],f=h[5],g=h[6],hh=h[7]; + for (int i = 0; i < 64; i++) { + uint32_t S1 = ror(e,6) ^ ror(e,11) ^ ror(e,25); + uint32_t ch = (e & f) ^ ((~e) & g); + uint32_t t1 = hh + S1 + ch + K[i] + w[i]; + uint32_t S0 = ror(a,2) ^ ror(a,13) ^ ror(a,22); + uint32_t maj = (a & b) ^ (a & c) ^ (b & c); + uint32_t t2 = S0 + maj; + hh=g; g=f; f=e; e=d+t1; d=c; c=b; b=a; a=t1+t2; + } + h[0]+=a; h[1]+=b; h[2]+=c; h[3]+=d; h[4]+=e; h[5]+=f; h[6]+=g; h[7]+=hh; + } + public: - void update(const uint8_t* data, size_t len) {} - void finalize(uint8_t* hash, size_t hashLen) {} - void resetHMAC(const uint8_t* key, size_t keyLen) {} - void finalizeHMAC(const uint8_t* key, size_t keyLen, uint8_t* hash, size_t hashLen) {} + SHA256() { reset(); } + + void reset() { + h[0]=0x6a09e667; h[1]=0xbb67ae85; h[2]=0x3c6ef372; h[3]=0xa54ff53a; + h[4]=0x510e527f; h[5]=0x9b05688c; h[6]=0x1f83d9ab; h[7]=0x5be0cd19; + buf_len = 0; total_len = 0; + } + + void update(const uint8_t* data, size_t n) { + total_len += n; + while (n) { + size_t take = 64 - buf_len; if (take > n) take = n; + memcpy(buf + buf_len, data, take); buf_len += (uint32_t)take; data += take; n -= take; + if (buf_len == 64) { process(buf); buf_len = 0; } + } + } + + void finalize(uint8_t* out, size_t out_len) { + uint64_t bits = total_len * 8; + buf[buf_len++] = 0x80; + if (buf_len > 56) { while (buf_len < 64) buf[buf_len++] = 0; process(buf); buf_len = 0; } + while (buf_len < 56) buf[buf_len++] = 0; + for (int i = 0; i < 8; i++) buf[56 + i] = (uint8_t)(bits >> (56 - 8*i)); + process(buf); buf_len = 0; + uint8_t full[32]; + for (int i = 0; i < 8; i++) { + full[i*4] = (uint8_t)(h[i] >> 24); full[i*4+1] = (uint8_t)(h[i] >> 16); + full[i*4+2] = (uint8_t)(h[i] >> 8); full[i*4+3] = (uint8_t)(h[i]); + } + if (out_len > 32) out_len = 32; + memcpy(out, full, out_len); + } + + // Standard HMAC-SHA256 (kept correct for API parity; OTA tests don't exercise it). + void resetHMAC(const uint8_t* key, size_t keyLen) { + memset(hmac_key, 0, 64); + if (keyLen > 64) { SHA256 t; t.update(key, keyLen); t.finalize(hmac_key, 32); } + else memcpy(hmac_key, key, keyLen); + reset(); + uint8_t ipad[64]; + for (int i = 0; i < 64; i++) ipad[i] = hmac_key[i] ^ 0x36; + update(ipad, 64); + } + + void finalizeHMAC(const uint8_t* key, size_t keyLen, uint8_t* out, size_t out_len) { + (void)key; (void)keyLen; + uint8_t inner[32]; finalize(inner, 32); + uint8_t opad[64]; + for (int i = 0; i < 64; i++) opad[i] = hmac_key[i] ^ 0x5c; + reset(); update(opad, 64); update(inner, 32); finalize(out, out_len); + } }; diff --git a/test/test_ota/mota_vectors.h b/test/test_ota/mota_vectors.h new file mode 100644 index 000000000..48a1e205d --- /dev/null +++ b/test/test_ota/mota_vectors.h @@ -0,0 +1,122 @@ +// AUTO-GENERATED by tools/mota/gen_vectors.py — do not edit by hand. +// Cross-check vectors: a real .mota from the reference packager (motalib.py). +#pragma once +#include + +static const uint8_t MOTA_VEC[5547] = {109,79,84,65,171,21,0,0,2,1,18,68,51,34,17,0,0,16,1,193,20,0,0,193,20,0,0,10,242,21,180,56,232,121,143,217,6,12,12,64,164,54,242,61,17,64,7,235,26,78,104,183,219,50,235,76,151,230,187,56,8,129,160,136,0,84,69,83,84,72,87,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,136,178,44,23,110,140,98,143,139,154,17,11,47,111,103,108,222,151,146,129,106,86,0,67,163,28,6,189,70,62,57,35,188,26,173,189,228,139,22,151,108,8,7,23,55,59,129,154,6,143,50,183,166,179,139,107,56,114,150,71,207,222,1,194,206,40,178,108,87,71,39,55,245,195,86,26,23,97,24,91,216,88,154,67,206,11,186,117,137,31,249,236,96,20,141,75,212,160,158,226,220,92,147,49,180,17,11,169,58,197,74,252,20,218,59,221,25,97,71,116,162,213,93,41,94,90,53,171,68,179,239,174,165,18,155,162,43,136,186,62,41,118,97,69,253,236,163,176,142,56,175,83,215,196,198,14,58,210,8,206,80,102,68,16,54,233,241,145,224,183,80,54,167,127,101,226,234,164,117,36,67,35,63,190,143,137,67,191,149,109,229,149,102,92,56,255,255,35,130,126,23,193,12,220,28,39,160,40,202,174,108,152,16,98,97,152,255,119,135,64,248,141,220,241,2,174,184,29,174,226,137,192,68,196,164,87,28,75,111,40,116,0,244,184,224,184,67,248,128,195,45,129,233,27,222,160,76,215,163,129,155,50,39,95,195,41,138,244,199,236,135,235,0,153,82,125,4,28,237,92,224,252,212,206,78,61,14,61,224,145,242,20,21,187,124,208,17,250,194,136,196,32,32,168,121,242,140,42,67,135,223,155,108,246,54,237,138,193,186,176,51,182,79,102,254,171,166,95,112,230,132,115,30,63,57,16,86,5,150,141,58,150,56,1,18,181,161,15,58,17,231,8,220,84,18,131,60,71,171,124,54,138,33,185,239,225,146,147,121,62,200,121,206,104,48,24,24,168,110,90,108,105,119,221,186,13,172,167,251,165,25,15,103,186,86,204,220,27,63,49,48,137,114,35,108,46,71,118,63,223,236,19,113,206,220,219,140,25,12,166,255,138,214,3,248,23,237,192,217,60,42,104,124,123,54,221,102,231,15,42,97,0,252,99,67,237,200,200,116,73,108,178,245,187,254,200,142,169,183,124,39,48,75,55,247,14,148,188,138,15,191,80,14,12,149,122,128,235,218,135,40,14,245,130,20,217,47,17,152,17,172,220,60,103,30,241,227,145,63,148,152,10,158,20,107,168,149,144,133,80,239,66,52,171,183,80,61,67,101,33,171,165,76,117,80,237,192,239,18,2,117,159,255,144,255,25,18,137,54,129,67,33,238,89,225,17,225,62,94,72,40,112,213,139,180,77,156,251,252,206,167,135,2,170,209,141,76,238,169,26,240,224,34,67,29,227,27,190,141,39,69,72,154,53,183,87,52,175,162,218,67,129,125,64,231,232,216,13,23,162,108,212,70,11,0,85,197,33,163,250,67,41,189,113,141,180,109,143,2,28,19,241,226,176,231,38,139,9,213,94,149,141,37,110,32,10,78,93,230,238,203,248,220,10,230,91,53,174,63,170,26,90,199,143,226,223,104,249,158,191,39,236,238,60,221,41,249,204,207,45,225,105,6,45,188,236,85,200,238,105,205,171,221,188,207,63,68,40,201,179,27,97,223,9,219,120,56,51,209,235,117,89,78,210,203,223,58,57,6,168,49,102,84,71,221,17,247,197,71,89,164,130,102,173,251,215,137,84,240,7,29,224,248,66,45,148,246,251,67,9,27,152,111,88,186,201,80,111,155,251,130,29,98,230,147,48,65,11,181,111,0,133,236,206,137,175,184,240,189,188,171,50,93,110,17,242,170,235,84,159,80,169,217,31,184,230,76,129,79,170,104,83,103,178,75,141,32,49,107,170,240,97,173,191,231,44,157,145,77,103,140,213,0,77,73,53,110,201,148,155,167,82,119,113,113,172,54,130,121,203,230,245,203,188,43,168,21,72,131,169,162,158,85,23,209,243,192,60,172,79,57,206,50,37,6,11,62,251,121,156,217,196,18,116,106,226,161,147,49,183,178,98,126,102,62,37,167,176,1,228,192,220,197,226,27,199,108,56,45,205,245,178,132,118,12,142,63,234,217,31,116,34,205,118,170,135,252,143,152,81,243,193,228,113,156,208,184,228,129,109,212,232,140,114,229,40,190,220,121,115,66,192,63,215,163,70,196,199,133,124,160,61,70,112,19,182,73,60,69,85,81,228,138,20,35,38,59,98,177,39,180,54,16,106,104,84,138,119,106,15,52,213,107,99,231,197,149,242,178,5,219,225,195,147,97,122,1,241,90,76,192,99,218,228,244,213,107,137,191,188,139,204,154,229,56,124,56,69,111,124,7,99,86,171,173,204,103,185,42,215,119,235,32,251,159,136,6,232,100,151,144,169,6,21,164,109,34,221,118,46,12,66,97,83,54,116,83,86,194,225,97,71,192,243,212,107,64,213,20,120,4,191,138,13,255,243,89,57,166,17,199,245,166,10,193,7,243,63,51,214,5,159,39,61,32,121,171,29,144,242,55,119,179,65,196,94,42,155,155,246,191,183,29,199,209,41,246,79,27,148,6,237,79,147,173,232,245,96,101,241,183,50,19,151,176,212,160,62,26,178,197,77,217,175,153,206,30,203,251,144,200,10,88,136,109,169,94,17,129,165,87,3,217,107,210,125,27,110,245,92,162,228,212,117,181,39,111,45,187,133,247,166,69,157,206,235,137,198,123,119,111,211,187,151,68,82,218,62,212,239,22,71,225,115,62,192,118,145,156,171,97,86,7,126,217,83,46,124,54,90,204,66,87,71,225,152,179,225,70,142,2,132,242,48,21,61,184,104,125,142,194,61,176,121,165,182,125,114,202,4,23,75,56,103,177,62,78,169,148,94,121,141,135,88,108,255,190,140,84,90,179,116,69,78,64,59,30,184,49,80,30,190,137,243,195,176,47,49,55,189,123,70,185,150,250,194,134,152,72,251,25,213,49,75,58,92,45,77,3,181,136,32,70,11,249,13,141,74,178,241,32,163,222,192,125,26,223,3,146,72,120,122,112,87,47,247,13,64,240,220,122,29,210,16,102,125,18,147,161,175,13,38,38,207,144,242,77,21,254,63,30,142,195,106,155,152,202,158,57,198,133,97,115,232,113,76,220,150,253,109,78,145,158,15,156,245,189,25,242,195,53,160,54,67,169,20,40,61,44,141,19,40,0,104,115,176,152,120,74,8,59,73,180,72,179,220,116,18,175,59,236,67,201,202,160,150,169,205,239,50,108,29,139,57,165,38,232,68,211,36,18,15,42,202,78,152,191,211,145,235,73,112,31,119,176,77,179,103,241,69,128,138,126,112,20,153,10,227,110,188,82,154,64,6,23,58,246,172,214,220,147,150,243,5,255,195,172,210,68,147,10,195,193,44,120,132,166,113,234,71,46,255,149,111,162,208,125,248,23,120,89,104,85,82,171,26,219,41,84,105,177,126,73,169,241,102,208,194,140,9,116,22,80,64,82,29,248,197,103,221,131,211,252,0,168,222,138,118,105,13,48,132,92,159,193,127,160,113,194,13,52,68,140,33,237,73,112,225,178,124,31,7,249,161,155,204,61,181,40,79,141,3,141,104,23,57,254,215,233,29,118,242,30,165,213,39,127,238,183,74,130,180,69,106,213,123,250,120,62,116,141,37,98,48,235,153,130,191,225,34,221,17,70,197,202,218,106,87,239,201,129,68,210,0,72,185,76,214,150,148,255,168,125,221,38,114,137,123,88,85,141,195,139,96,116,238,82,222,48,251,178,61,146,98,59,219,198,105,11,81,190,121,180,233,207,97,98,253,169,202,210,166,251,38,126,246,9,32,128,247,151,84,222,25,223,216,112,25,134,233,116,3,184,36,104,222,167,248,39,19,120,200,248,67,86,159,177,101,166,20,218,84,218,172,219,136,97,244,81,160,183,227,194,124,223,138,9,158,17,60,161,175,235,73,255,58,191,23,111,250,25,194,162,180,223,25,113,42,177,76,231,7,11,83,203,14,75,91,95,110,37,62,135,105,144,174,202,46,43,44,20,156,222,97,158,174,61,127,233,149,36,59,118,163,65,117,65,170,2,230,205,119,230,73,173,139,40,18,113,241,88,252,150,76,163,246,108,176,64,116,216,77,50,255,98,218,123,27,60,97,146,91,147,75,254,179,75,5,250,212,168,101,70,2,144,221,175,199,190,249,12,233,155,190,127,213,231,231,73,198,204,58,155,205,90,56,162,48,158,64,173,193,184,196,168,174,214,35,160,24,231,160,165,10,79,201,112,8,148,93,187,33,23,232,75,83,191,106,44,51,33,201,138,224,248,93,135,128,233,69,212,42,65,233,211,241,123,247,206,75,191,222,86,205,29,119,246,19,36,193,247,57,220,173,185,172,250,101,247,216,205,142,93,23,202,101,3,67,137,31,116,94,172,191,172,67,149,97,210,163,240,95,27,172,59,120,6,158,226,241,143,83,234,156,56,165,16,162,210,118,232,179,77,166,104,29,35,11,242,9,77,254,126,29,24,60,227,137,34,99,116,94,171,243,190,178,242,138,107,150,190,186,39,226,106,167,25,213,125,157,104,240,243,71,8,176,94,55,113,113,243,60,218,92,25,251,175,94,139,230,250,165,91,15,101,70,48,247,31,242,217,210,116,23,169,54,164,163,152,248,5,12,201,85,62,253,32,201,144,52,17,212,195,141,53,150,55,208,222,59,84,198,37,201,230,152,0,70,219,251,37,252,33,138,64,204,44,28,169,221,6,33,3,91,202,201,60,150,82,4,44,67,13,32,189,107,134,29,190,16,121,114,199,92,131,151,27,115,128,56,242,157,11,186,200,232,221,168,133,77,117,164,246,7,15,255,122,216,102,109,175,27,125,182,232,113,18,230,20,82,155,37,16,32,70,159,162,149,140,182,83,97,254,152,135,75,116,129,154,110,25,203,179,29,218,167,166,224,196,141,184,221,55,110,115,227,58,105,86,211,116,102,106,186,24,80,109,80,170,65,95,244,39,175,236,121,17,23,212,21,23,110,24,190,189,95,207,33,142,15,150,244,143,143,84,171,31,105,90,223,170,240,192,108,222,234,184,13,247,73,153,79,90,26,147,129,54,39,168,123,57,216,27,89,216,142,94,29,195,71,146,57,206,109,216,143,249,196,209,159,157,172,164,142,6,155,237,168,212,177,68,7,46,69,179,195,79,235,86,89,1,46,222,36,144,168,102,17,36,189,162,248,7,23,191,135,55,96,107,116,87,40,94,79,184,83,198,241,145,152,21,226,13,39,40,193,158,12,172,20,69,113,169,108,124,155,113,106,69,55,193,131,29,88,110,28,72,173,173,151,124,134,170,78,11,56,101,252,153,14,1,52,77,242,54,196,35,195,65,74,83,30,1,127,191,110,44,33,97,136,180,58,128,143,213,171,206,90,18,101,220,189,10,111,4,117,235,19,220,80,147,109,146,103,181,163,106,74,29,103,5,247,83,43,205,242,158,117,212,176,235,92,22,111,216,27,62,111,150,102,134,20,101,222,79,190,86,56,85,199,43,19,130,162,29,135,130,49,231,198,89,89,186,245,209,165,208,37,60,26,37,65,50,44,154,39,194,194,167,19,45,243,197,160,126,118,193,144,194,148,114,174,236,225,144,164,162,252,159,82,221,248,160,80,38,112,17,120,113,161,77,203,70,151,14,90,129,18,79,118,115,9,14,94,212,73,19,165,221,250,218,23,157,152,129,98,118,148,141,244,202,189,229,10,115,232,207,146,166,48,82,154,121,128,38,245,15,115,26,207,230,214,87,251,182,21,129,165,44,10,63,181,112,253,112,134,133,156,40,93,95,234,72,99,104,198,86,173,153,13,202,161,165,85,16,84,24,142,173,98,72,64,185,218,168,246,232,154,223,38,85,20,149,169,36,234,89,79,247,167,178,169,100,33,152,181,240,21,79,143,96,164,202,84,208,32,171,179,212,242,189,255,175,233,134,23,165,171,108,130,92,4,92,79,46,243,54,87,242,196,124,49,57,255,35,39,19,75,216,201,25,129,197,138,213,189,226,134,9,169,86,224,196,158,33,152,96,39,41,46,212,177,197,159,207,231,42,184,112,11,105,93,173,184,60,248,113,156,72,192,191,200,114,59,136,61,79,247,207,200,120,231,213,49,94,173,242,146,252,112,118,196,72,199,97,128,135,107,247,41,209,51,205,154,35,223,64,13,164,123,223,95,141,239,26,182,216,132,217,31,72,21,195,41,69,115,231,131,37,212,111,23,242,233,56,209,115,226,89,238,6,106,13,101,128,95,60,98,254,20,95,57,7,81,238,25,214,182,166,85,202,37,35,9,73,234,212,120,178,212,35,194,180,120,114,157,1,231,20,4,65,55,213,38,140,240,186,155,135,108,28,198,73,60,77,31,12,61,107,163,203,159,117,16,28,214,231,127,152,137,4,161,131,147,61,183,36,74,109,0,157,90,61,146,106,47,170,171,21,134,249,92,17,244,134,139,129,201,253,129,141,5,99,223,120,11,162,99,251,95,64,191,4,91,201,17,88,61,187,168,160,26,197,148,188,193,85,34,11,90,139,86,208,164,44,212,199,175,118,251,178,122,161,46,207,34,16,183,198,241,117,9,75,51,11,202,51,226,10,80,238,79,131,101,253,208,139,121,64,9,192,165,48,73,91,220,199,12,221,167,84,69,31,204,94,111,227,102,190,112,229,244,98,86,249,47,127,177,127,94,236,204,132,68,205,21,186,108,20,110,154,254,210,46,139,75,82,26,20,83,169,75,78,114,154,183,109,42,176,113,89,114,10,186,222,233,90,157,255,111,70,163,250,202,242,14,19,171,163,103,93,131,205,191,173,40,243,7,36,217,155,173,200,112,8,32,17,60,199,165,93,92,98,243,145,8,154,39,173,115,242,94,95,113,195,19,146,35,135,93,101,80,166,71,63,245,29,6,188,47,127,132,99,233,143,30,67,198,66,180,114,54,255,156,73,177,234,255,125,51,31,34,218,18,115,44,230,182,113,255,22,207,174,247,216,252,81,170,88,181,16,140,138,74,228,76,217,40,182,181,237,179,163,44,203,92,130,57,31,252,51,202,35,60,202,126,6,92,141,146,94,119,205,251,141,33,156,226,22,16,79,101,255,183,184,122,134,105,196,104,210,147,18,32,248,81,164,18,115,119,174,132,88,32,224,212,199,141,163,150,46,196,247,33,110,128,233,222,14,212,31,132,39,77,42,41,82,239,181,57,88,242,240,132,229,72,216,20,64,50,162,244,141,70,32,160,77,157,136,23,128,164,43,151,241,148,39,43,168,159,184,230,154,86,215,236,144,10,211,221,7,20,11,242,164,197,147,67,166,53,196,146,106,158,163,7,127,227,160,139,74,164,244,77,123,62,206,206,175,103,76,116,18,176,15,40,112,106,123,118,52,87,155,36,80,220,183,81,187,252,220,88,249,102,33,194,94,131,143,27,81,61,119,31,68,115,63,36,24,12,74,242,98,221,157,107,63,246,221,230,40,208,83,239,147,184,80,48,195,40,127,254,131,119,127,225,78,127,5,23,241,100,129,117,247,61,55,149,90,12,12,72,126,152,225,215,167,172,120,73,137,2,216,27,110,34,225,67,186,93,195,103,93,11,102,13,145,143,49,92,141,73,18,98,129,115,195,140,71,211,253,159,174,156,30,32,249,24,100,95,203,252,86,142,240,93,193,36,50,154,130,102,128,10,11,9,35,182,85,205,121,132,116,38,155,228,131,35,83,238,156,81,41,100,253,157,189,215,76,151,86,129,212,130,136,125,181,144,76,121,208,4,94,84,172,28,250,106,149,78,203,230,185,223,176,161,6,152,121,67,247,167,200,248,198,148,147,58,184,13,149,122,43,134,161,184,158,198,215,97,37,210,174,62,8,146,242,179,28,48,4,112,80,107,38,105,176,52,105,128,198,156,235,120,223,217,188,186,15,180,35,132,53,143,83,255,169,122,134,96,80,244,44,117,233,136,87,139,90,173,197,222,184,174,164,205,177,67,156,123,49,245,63,71,142,76,57,241,249,251,76,197,73,180,53,176,180,125,81,122,89,143,239,239,203,184,70,73,31,146,173,139,97,229,250,101,209,88,244,197,205,37,74,10,73,244,182,20,88,236,113,167,65,191,122,54,51,211,137,69,238,143,178,69,35,27,157,189,150,61,62,12,171,231,135,57,163,59,13,25,105,84,183,120,25,174,197,35,1,246,140,250,237,40,104,167,239,225,224,121,122,166,51,193,246,73,82,73,165,15,232,196,22,166,146,59,136,189,185,217,239,9,233,235,44,106,225,214,45,239,235,9,255,214,101,201,126,47,239,191,246,223,237,74,224,9,2,76,145,154,27,237,251,85,72,116,253,164,139,134,126,227,240,34,217,129,119,69,49,207,28,84,41,187,117,165,65,183,47,3,188,86,202,75,145,172,193,49,44,156,219,163,229,103,211,109,131,83,22,102,171,24,47,251,35,122,82,239,63,1,66,98,60,114,192,68,244,84,77,149,185,146,2,66,167,92,177,60,15,170,30,119,78,40,103,175,128,236,229,227,180,197,79,176,30,163,234,240,75,94,157,56,56,245,34,122,39,116,191,253,155,95,106,179,140,233,120,193,137,205,170,211,55,195,63,174,193,152,223,201,20,134,114,135,180,92,19,234,144,28,15,212,140,231,129,51,146,137,38,42,83,218,133,113,29,174,52,183,149,125,23,230,130,114,207,14,116,33,131,106,116,144,14,143,118,172,206,78,185,5,101,65,209,0,190,55,148,18,11,108,88,179,16,138,254,15,239,228,17,252,239,120,8,73,104,46,196,34,196,164,250,186,165,246,107,95,254,228,97,114,222,234,232,96,96,20,174,246,169,223,138,34,167,220,89,30,45,254,137,100,135,32,186,250,57,213,0,193,5,250,76,118,172,184,139,108,136,97,210,58,63,117,88,39,70,48,239,224,185,195,28,8,207,169,107,157,196,239,226,227,4,61,52,17,25,152,8,114,153,172,180,223,12,62,189,11,102,112,59,138,55,193,221,198,14,35,128,254,74,59,208,234,187,147,81,147,153,197,172,209,82,60,77,224,36,252,169,133,56,105,76,70,15,142,242,151,225,188,233,44,160,173,109,142,126,12,248,88,241,164,171,97,201,134,81,178,106,104,38,76,96,47,193,137,121,61,217,57,76,219,181,36,206,118,234,14,143,105,247,106,142,135,34,99,62,65,52,84,165,20,236,115,216,94,23,137,185,212,48,13,68,96,172,154,154,10,223,18,48,205,194,150,185,171,143,55,122,53,222,232,85,77,244,232,3,54,239,48,246,189,30,191,255,193,122,234,62,178,154,180,52,101,234,61,141,82,198,72,97,119,136,166,91,78,66,92,131,225,127,119,25,205,251,184,120,194,214,81,234,52,94,80,105,11,144,221,56,189,37,4,66,141,239,149,148,184,106,75,39,50,84,58,97,145,213,62,127,140,167,241,175,86,65,195,210,125,247,185,164,189,125,117,43,187,203,90,43,35,184,139,125,47,234,227,138,253,164,245,15,134,8,214,216,19,241,209,171,12,195,1,105,35,215,161,59,17,181,38,2,55,129,116,95,15,158,163,170,239,157,233,123,168,124,4,1,136,141,105,3,4,135,184,70,137,250,73,4,128,208,178,172,110,206,240,232,45,27,235,24,134,38,61,49,158,134,64,208,90,68,203,101,20,95,245,103,117,144,62,253,178,57,76,175,211,217,20,167,253,219,166,194,8,23,103,97,96,141,121,14,163,2,179,43,21,127,216,111,165,200,84,144,250,219,249,24,229,135,235,10,58,54,230,222,177,227,145,121,69,11,236,19,175,236,71,230,139,144,168,8,45,237,217,80,4,246,53,150,36,192,210,182,210,101,237,19,76,41,144,61,145,213,217,99,173,229,138,84,98,193,189,35,202,253,176,185,20,128,190,249,88,13,25,111,59,214,19,87,154,196,157,244,152,101,248,198,83,7,162,69,200,254,115,125,58,91,141,240,96,110,47,174,149,169,97,21,197,158,75,204,63,182,18,21,68,39,97,182,200,162,39,189,99,81,92,27,23,1,241,78,113,92,194,69,26,33,22,47,110,114,142,142,131,104,26,6,22,90,141,23,152,153,200,83,221,98,3,74,105,99,199,21,185,230,143,231,254,250,62,146,133,43,175,97,43,35,68,77,68,126,37,16,42,111,70,107,76,123,200,19,92,64,241,63,184,160,126,152,157,50,117,27,34,77,1,242,101,85,215,158,97,205,220,84,112,85,110,208,210,220,166,249,152,34,76,82,154,242,177,51,122,80,45,246,101,247,81,74,188,177,162,125,247,147,200,62,83,96,71,209,201,100,93,29,238,144,51,151,255,139,46,174,196,140,6,243,186,118,241,181,53,112,204,74,212,177,17,209,217,203,203,104,172,127,35,162,77,61,64,168,39,183,108,202,96,18,114,253,153,122,149,102,136,129,236,235,222,177,107,139,9,202,247,92,179,229,207,137,152,163,234,21,27,196,63,168,170,90,42,165,156,11,144,251,165,173,165,102,247,192,84,247,203,110,27,2,25,66,56,130,191,132,142,148,176,147,56,114,95,100,118,197,173,150,176,128,38,88,255,6,123,26,75,106,235,246,21,29,212,240,186,36,89,79,87,116,200,52,133,123,89,121,24,112,184,178,115,81,17,76,11,207,181,29,5,217,87,165,27,173,204,42,238,251,189,62,132,44,141,40,84,143,109,245,118,59,204,103,161,47,47,163,168,110,101,7,188,157,226,50,115,151,109,99,1,180,54,52,71,192,180,207,203,16,147,26,204,223,137,47,93,83,50,117,29,67,171,220,125,135,247,163,80,152,99,156,100,150,29,89,90,216,117,158,44,208,172,180,204,76,235,157,151,21,172,34,80,30,61,78,29,46,95,177,36,130,99,107,152,35,147,98,108,47,124,162,137,177,235,165,238,255,44,142,42,125,73,35,47,80,215,115,158,13,221,91,243,2,124,34,49,208,98,246,143,129,167,126,104,175,125,106,181,215,113,125,42,21,144,7,203,194,56,74,8,70,57,137,73,43,199,117,144,190,197,196,126,140,130,28,146,29,68,198,139,210,253,93,138,210,193,10,194,184,112,139,55,253,108,26,188,212,167,192,63,76,223,255,8,115,67,89,220,209,22,112,221,254,30,198,207,60,53,207,188,150,176,89,220,181,156,161,109,42,157,35,200,52,208,52,206,15,145,89,136,71,152,137,43,82,250,180,74,74,146,68,243,219,131,252,230,173,208,24,34,246,192,201,105,235,15,254,70,221,167,32,179,221,33,63,37,182,82,212,63,194,215,173,100,125,36,147,161,68,160,106,96,115,19,162,203,225,196,23,103,131,191,71,177,239,224,94,116,243,124,83,148,0,222,198,216,187,23,187,248,117,162,170,178,91,217,16,203,136,101,55,247,109,211,54,126,68,82,212,72,86,140,147,33,144,218,124,201,87,228,174,195,12,11,25,160,200,214,117,4,31,237,219,40,112,116,0,253,245,109,51,254,176,232,33,225,166,77,40,223,238,224,70,23,167,92,64,21,95,170,231,166,42,13,101,160,78,185,179,193,59,109,167,23,180,24,0,54,122,19,33,151,57,132,174,113,2,2,178,87,209,30,252,220,108,177,33,122,18,58,98,22,187,206,26,26,80,94,225,76,35,97,198,208,192,223,34,164,254,173,36,17,135,144,2,156,166,42,112,89,184,54,160,191,38,235,105,157,175,113,220,55,22,229,25,35,192,31,150,186,98,89,246,109,80,202,35,63,70,165,21,63,141,153,153,184,155,72,199,240,176,6,217,216,168,224,77,52,132,155,130,48,191,100,75,165,13,200,229,203,244,61,126,98,28,61,127,163,152,18,135,227,250,3,252,92,239,69,110,100,70,137,20,0,0,122,7,213,179,185,90,134,189,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,118,107,52,57,54}; + +static const uint32_t MOTA_VEC_LEN = 5547; +static const uint32_t EXP_TARGET_ID = 0x11223344u; +static const uint32_t EXP_FW_VERSION = 0x01100000u; +static const uint32_t EXP_IMAGE_SIZE = 5313u; +static const uint32_t EXP_PAYLOAD_SIZE = 5313u; +static const uint32_t EXP_BLOCK_COUNT = 6u; +static const uint8_t EXP_BLOCK_SIZE_LOG2 = 10; +static const uint8_t EXP_CODEC_ID = 0; +static const uint8_t EXP_MERKLE_ROOT[4] = {242,21,180,56}; + +static const uint8_t EXP_IMAGE_HASH[32] = {232,121,143,217,6,12,12,64,164,54,242,61,17,64,7,235,26,78,104,183,219,50,235,76,151,230,187,56,8,129,160,136}; + +static const uint8_t EXP_HW_ID[32] = {84,69,83,84,72,87,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +static const uint32_t PROOF_INDEX = 2u; +static const uint8_t PROOF_NSIB = 3; +static const uint8_t PROOF_SIBLINGS[12] = {47,111,103,108,64,78,181,132,54,247,159,221}; + +static const uint32_t T0_COUNT = 5u; +static const uint8_t T0_LEAVES[20] = {123,202,230,102,137,105,224,241,146,163,254,76,91,140,169,45,125,31,146,228}; + +static const uint8_t T0_ROOT[4] = {37,197,150,102}; + +static const uint16_t T0_POFF[5] = {0,12,24,36,48}; +static const uint8_t T0_PNSIB[5] = {3,3,3,3,1}; +static const uint8_t T0_PBLOB[52] = {137,105,224,241,76,132,127,136,125,31,146,228,123,202,230,102,76,132,127,136,125,31,146,228,91,140,169,45,113,104,86,244,125,31,146,228,146,163,254,76,113,104,86,244,125,31,146,228,32,57,180,151}; + +static const uint32_t T1_COUNT = 7u; +static const uint8_t T1_LEAVES[28] = {219,8,204,214,152,44,227,79,189,183,207,45,57,133,249,14,162,50,142,13,114,148,72,187,230,159,8,8}; + +static const uint8_t T1_ROOT[4] = {124,128,11,251}; + +static const uint16_t T1_POFF[7] = {0,12,24,36,48,60,72}; +static const uint8_t T1_PNSIB[7] = {3,3,3,3,3,3,2}; +static const uint8_t T1_PBLOB[80] = {152,44,227,79,6,192,47,1,91,61,26,208,219,8,204,214,6,192,47,1,91,61,26,208,57,133,249,14,208,126,61,254,91,61,26,208,189,183,207,45,208,126,61,254,91,61,26,208,114,148,72,187,230,159,8,8,21,58,53,95,162,50,142,13,230,159,8,8,21,58,53,95,50,200,22,34,21,58,53,95}; + +static const uint32_t T2_COUNT = 8u; +static const uint8_t T2_LEAVES[32] = {133,246,245,113,87,20,181,196,236,26,12,243,169,182,211,36,223,172,151,252,28,151,88,171,2,138,202,222,83,66,56,124}; + +static const uint8_t T2_ROOT[4] = {230,153,143,58}; + +static const uint16_t T2_POFF[8] = {0,12,24,36,48,60,72,84}; +static const uint8_t T2_PNSIB[8] = {3,3,3,3,3,3,3,3}; +static const uint8_t T2_PBLOB[96] = {87,20,181,196,185,61,131,58,188,95,217,235,133,246,245,113,185,61,131,58,188,95,217,235,169,182,211,36,9,144,114,130,188,95,217,235,236,26,12,243,9,144,114,130,188,95,217,235,28,151,88,171,182,122,229,190,175,255,207,112,223,172,151,252,182,122,229,190,175,255,207,112,83,66,56,124,132,32,7,1,175,255,207,112,2,138,202,222,132,32,7,1,175,255,207,112}; + +static const uint32_t T3_COUNT = 65u; +static const uint8_t T3_LEAVES[260] = {228,177,31,222,213,237,94,231,50,158,16,45,240,127,150,228,208,46,120,34,47,80,173,66,32,115,193,214,60,40,73,37,201,143,198,211,67,231,14,145,23,231,206,70,151,82,247,207,115,74,95,131,213,33,121,147,248,20,31,29,209,72,70,23,241,87,234,199,6,202,12,131,134,233,213,230,82,81,214,46,254,186,73,15,59,134,85,179,59,184,245,117,217,237,95,37,157,89,225,249,112,43,154,184,72,149,130,37,183,19,100,29,203,32,180,97,196,69,203,119,144,197,108,45,1,133,113,168,36,18,78,210,75,94,150,40,116,19,98,94,169,42,12,32,192,70,6,142,125,129,126,57,25,67,158,181,8,30,134,82,88,158,230,175,192,176,37,16,195,177,239,43,191,233,217,203,1,13,34,120,83,7,204,235,200,216,114,244,220,22,118,100,210,158,109,213,107,142,73,151,244,88,103,219,166,50,243,79,183,246,47,87,18,1,5,200,72,44,140,231,168,129,59,227,6,227,103,55,54,204,4,229,59,253,227,61,20,147,26,54,186,174,38,57,191,247,231,13,192,44,230,40,192,252,173,250,93,54,156,198}; + +static const uint8_t T3_ROOT[4] = {143,88,46,110}; + +static const uint16_t T3_POFF[65] = {0,28,56,84,112,140,168,196,224,252,280,308,336,364,392,420,448,476,504,532,560,588,616,644,672,700,728,756,784,812,840,868,896,924,952,980,1008,1036,1064,1092,1120,1148,1176,1204,1232,1260,1288,1316,1344,1372,1400,1428,1456,1484,1512,1540,1568,1596,1624,1652,1680,1708,1736,1764,1792}; +static const uint8_t T3_PNSIB[65] = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,1}; +static const uint8_t T3_PBLOB[1796] = {213,237,94,231,226,151,15,25,186,191,115,46,87,73,67,144,23,152,173,217,71,3,57,148,93,54,156,198,228,177,31,222,226,151,15,25,186,191,115,46,87,73,67,144,23,152,173,217,71,3,57,148,93,54,156,198,240,127,150,228,171,21,9,181,186,191,115,46,87,73,67,144,23,152,173,217,71,3,57,148,93,54,156,198,50,158,16,45,171,21,9,181,186,191,115,46,87,73,67,144,23,152,173,217,71,3,57,148,93,54,156,198,47,80,173,66,142,196,71,64,14,98,188,211,87,73,67,144,23,152,173,217,71,3,57,148,93,54,156,198,208,46,120,34,142,196,71,64,14,98,188,211,87,73,67,144,23,152,173,217,71,3,57,148,93,54,156,198,60,40,73,37,50,228,24,222,14,98,188,211,87,73,67,144,23,152,173,217,71,3,57,148,93,54,156,198,32,115,193,214,50,228,24,222,14,98,188,211,87,73,67,144,23,152,173,217,71,3,57,148,93,54,156,198,67,231,14,145,71,231,4,206,205,182,67,188,47,60,59,137,23,152,173,217,71,3,57,148,93,54,156,198,201,143,198,211,71,231,4,206,205,182,67,188,47,60,59,137,23,152,173,217,71,3,57,148,93,54,156,198,151,82,247,207,124,211,70,56,205,182,67,188,47,60,59,137,23,152,173,217,71,3,57,148,93,54,156,198,23,231,206,70,124,211,70,56,205,182,67,188,47,60,59,137,23,152,173,217,71,3,57,148,93,54,156,198,213,33,121,147,47,185,242,240,12,185,30,58,47,60,59,137,23,152,173,217,71,3,57,148,93,54,156,198,115,74,95,131,47,185,242,240,12,185,30,58,47,60,59,137,23,152,173,217,71,3,57,148,93,54,156,198,209,72,70,23,198,222,217,47,12,185,30,58,47,60,59,137,23,152,173,217,71,3,57,148,93,54,156,198,248,20,31,29,198,222,217,47,12,185,30,58,47,60,59,137,23,152,173,217,71,3,57,148,93,54,156,198,6,202,12,131,37,124,190,231,133,59,19,106,100,204,178,18,126,106,252,248,71,3,57,148,93,54,156,198,241,87,234,199,37,124,190,231,133,59,19,106,100,204,178,18,126,106,252,248,71,3,57,148,93,54,156,198,82,81,214,46,25,35,102,192,133,59,19,106,100,204,178,18,126,106,252,248,71,3,57,148,93,54,156,198,134,233,213,230,25,35,102,192,133,59,19,106,100,204,178,18,126,106,252,248,71,3,57,148,93,54,156,198,59,134,85,179,180,250,218,148,37,137,24,30,100,204,178,18,126,106,252,248,71,3,57,148,93,54,156,198,254,186,73,15,180,250,218,148,37,137,24,30,100,204,178,18,126,106,252,248,71,3,57,148,93,54,156,198,217,237,95,37,163,134,12,115,37,137,24,30,100,204,178,18,126,106,252,248,71,3,57,148,93,54,156,198,59,184,245,117,163,134,12,115,37,137,24,30,100,204,178,18,126,106,252,248,71,3,57,148,93,54,156,198,112,43,154,184,171,186,157,117,95,173,243,202,15,216,163,10,126,106,252,248,71,3,57,148,93,54,156,198,157,89,225,249,171,186,157,117,95,173,243,202,15,216,163,10,126,106,252,248,71,3,57,148,93,54,156,198,183,19,100,29,117,33,228,235,95,173,243,202,15,216,163,10,126,106,252,248,71,3,57,148,93,54,156,198,72,149,130,37,117,33,228,235,95,173,243,202,15,216,163,10,126,106,252,248,71,3,57,148,93,54,156,198,196,69,203,119,109,168,123,61,165,127,162,224,15,216,163,10,126,106,252,248,71,3,57,148,93,54,156,198,203,32,180,97,109,168,123,61,165,127,162,224,15,216,163,10,126,106,252,248,71,3,57,148,93,54,156,198,1,133,113,168,19,170,184,98,165,127,162,224,15,216,163,10,126,106,252,248,71,3,57,148,93,54,156,198,144,197,108,45,19,170,184,98,165,127,162,224,15,216,163,10,126,106,252,248,71,3,57,148,93,54,156,198,75,94,150,40,133,173,206,145,50,201,231,4,30,94,224,127,107,72,112,56,161,178,183,96,93,54,156,198,36,18,78,210,133,173,206,145,50,201,231,4,30,94,224,127,107,72,112,56,161,178,183,96,93,54,156,198,169,42,12,32,206,234,112,47,50,201,231,4,30,94,224,127,107,72,112,56,161,178,183,96,93,54,156,198,116,19,98,94,206,234,112,47,50,201,231,4,30,94,224,127,107,72,112,56,161,178,183,96,93,54,156,198,125,129,126,57,170,111,85,90,106,61,62,225,30,94,224,127,107,72,112,56,161,178,183,96,93,54,156,198,192,70,6,142,170,111,85,90,106,61,62,225,30,94,224,127,107,72,112,56,161,178,183,96,93,54,156,198,8,30,134,82,84,11,55,210,106,61,62,225,30,94,224,127,107,72,112,56,161,178,183,96,93,54,156,198,25,67,158,181,84,11,55,210,106,61,62,225,30,94,224,127,107,72,112,56,161,178,183,96,93,54,156,198,192,176,37,16,73,215,44,124,75,85,11,61,81,85,123,40,107,72,112,56,161,178,183,96,93,54,156,198,88,158,230,175,73,215,44,124,75,85,11,61,81,85,123,40,107,72,112,56,161,178,183,96,93,54,156,198,191,233,217,203,104,27,130,168,75,85,11,61,81,85,123,40,107,72,112,56,161,178,183,96,93,54,156,198,195,177,239,43,104,27,130,168,75,85,11,61,81,85,123,40,107,72,112,56,161,178,183,96,93,54,156,198,83,7,204,235,77,162,227,126,184,101,244,22,81,85,123,40,107,72,112,56,161,178,183,96,93,54,156,198,1,13,34,120,77,162,227,126,184,101,244,22,81,85,123,40,107,72,112,56,161,178,183,96,93,54,156,198,220,22,118,100,132,206,108,94,184,101,244,22,81,85,123,40,107,72,112,56,161,178,183,96,93,54,156,198,200,216,114,244,132,206,108,94,184,101,244,22,81,85,123,40,107,72,112,56,161,178,183,96,93,54,156,198,107,142,73,151,74,78,179,108,244,44,244,141,152,179,15,151,5,193,169,14,161,178,183,96,93,54,156,198,210,158,109,213,74,78,179,108,244,44,244,141,152,179,15,151,5,193,169,14,161,178,183,96,93,54,156,198,166,50,243,79,186,100,96,255,244,44,244,141,152,179,15,151,5,193,169,14,161,178,183,96,93,54,156,198,244,88,103,219,186,100,96,255,244,44,244,141,152,179,15,151,5,193,169,14,161,178,183,96,93,54,156,198,18,1,5,200,112,90,214,108,23,138,61,93,152,179,15,151,5,193,169,14,161,178,183,96,93,54,156,198,183,246,47,87,112,90,214,108,23,138,61,93,152,179,15,151,5,193,169,14,161,178,183,96,93,54,156,198,168,129,59,227,68,36,234,87,23,138,61,93,152,179,15,151,5,193,169,14,161,178,183,96,93,54,156,198,72,44,140,231,68,36,234,87,23,138,61,93,152,179,15,151,5,193,169,14,161,178,183,96,93,54,156,198,54,204,4,229,190,153,32,138,33,227,4,234,139,152,195,249,5,193,169,14,161,178,183,96,93,54,156,198,6,227,103,55,190,153,32,138,33,227,4,234,139,152,195,249,5,193,169,14,161,178,183,96,93,54,156,198,20,147,26,54,96,205,181,224,33,227,4,234,139,152,195,249,5,193,169,14,161,178,183,96,93,54,156,198,59,253,227,61,96,205,181,224,33,227,4,234,139,152,195,249,5,193,169,14,161,178,183,96,93,54,156,198,191,247,231,13,229,50,248,97,89,252,12,65,139,152,195,249,5,193,169,14,161,178,183,96,93,54,156,198,186,174,38,57,229,50,248,97,89,252,12,65,139,152,195,249,5,193,169,14,161,178,183,96,93,54,156,198,192,252,173,250,142,15,70,253,89,252,12,65,139,152,195,249,5,193,169,14,161,178,183,96,93,54,156,198,192,44,230,40,142,15,70,253,89,252,12,65,139,152,195,249,5,193,169,14,161,178,183,96,93,54,156,198,149,210,13,187}; + +static const uint32_t T4_COUNT = 100u; +static const uint8_t T4_LEAVES[400] = {250,6,181,225,56,207,131,195,200,254,34,10,238,105,33,132,48,50,156,13,143,158,201,222,178,194,103,10,124,149,60,141,9,94,243,101,75,219,122,125,213,33,64,40,32,228,121,213,226,253,231,144,75,135,234,131,152,214,212,106,51,145,3,183,128,183,173,26,69,67,252,15,42,219,249,19,124,72,186,210,66,55,64,53,27,111,249,47,219,212,89,93,243,63,146,136,20,157,216,177,50,200,32,211,137,241,63,21,222,236,109,140,89,124,160,1,24,252,27,231,105,182,145,139,59,254,133,183,194,117,230,133,86,39,227,203,37,170,103,5,12,76,12,151,82,192,112,121,156,72,138,44,13,141,142,83,126,173,15,67,193,11,13,252,218,226,147,150,252,127,155,49,168,56,120,149,138,173,127,54,5,91,4,203,100,103,34,42,224,120,111,134,236,40,86,53,123,141,164,71,178,229,86,75,83,180,208,56,78,46,180,59,154,244,17,9,205,174,70,75,97,138,191,59,188,95,40,182,254,210,175,49,38,68,197,58,155,82,244,130,58,135,66,250,162,37,231,120,15,232,85,246,64,60,232,16,250,85,139,178,226,21,172,135,128,162,227,198,90,175,208,53,161,165,158,250,207,38,249,195,125,26,112,252,188,142,55,227,7,88,106,227,22,155,231,103,250,222,43,181,121,239,180,119,204,205,9,203,29,142,3,40,113,191,12,53,22,240,105,201,205,146,175,25,133,29,26,65,72,143,138,248,90,133,22,232,188,178,200,127,202,39,235,197,94,167,110,82,62,235,228,215,17,17,117,54,102,46,37,22,164,40,183,159,25,55,80,182,241,239,12,185,12,200,147,241,76,90,125,48,23,173,235,75,97,85,135,96,255,21,97,103,85,13,180,129,176,168,148,246}; + +static const uint8_t T4_ROOT[4] = {169,167,185,243}; + +static const uint16_t T4_POFF[100] = {0,28,56,84,112,140,168,196,224,252,280,308,336,364,392,420,448,476,504,532,560,588,616,644,672,700,728,756,784,812,840,868,896,924,952,980,1008,1036,1064,1092,1120,1148,1176,1204,1232,1260,1288,1316,1344,1372,1400,1428,1456,1484,1512,1540,1568,1596,1624,1652,1680,1708,1736,1764,1792,1820,1848,1876,1904,1932,1960,1988,2016,2044,2072,2100,2128,2156,2184,2212,2240,2268,2296,2324,2352,2380,2408,2436,2464,2492,2520,2548,2576,2604,2632,2660,2688,2704,2720,2736}; +static const uint8_t T4_PNSIB[100] = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,4,4,4,4}; +static const uint8_t T4_PBLOB[2752] = {56,207,131,195,144,4,34,70,211,98,27,29,229,111,37,122,45,29,32,241,1,82,253,243,18,149,46,121,250,6,181,225,144,4,34,70,211,98,27,29,229,111,37,122,45,29,32,241,1,82,253,243,18,149,46,121,238,105,33,132,21,3,59,222,211,98,27,29,229,111,37,122,45,29,32,241,1,82,253,243,18,149,46,121,200,254,34,10,21,3,59,222,211,98,27,29,229,111,37,122,45,29,32,241,1,82,253,243,18,149,46,121,143,158,201,222,96,188,135,52,159,141,76,84,229,111,37,122,45,29,32,241,1,82,253,243,18,149,46,121,48,50,156,13,96,188,135,52,159,141,76,84,229,111,37,122,45,29,32,241,1,82,253,243,18,149,46,121,124,149,60,141,98,199,71,87,159,141,76,84,229,111,37,122,45,29,32,241,1,82,253,243,18,149,46,121,178,194,103,10,98,199,71,87,159,141,76,84,229,111,37,122,45,29,32,241,1,82,253,243,18,149,46,121,75,219,122,125,169,14,251,128,243,113,185,185,54,115,204,16,45,29,32,241,1,82,253,243,18,149,46,121,9,94,243,101,169,14,251,128,243,113,185,185,54,115,204,16,45,29,32,241,1,82,253,243,18,149,46,121,32,228,121,213,35,96,203,98,243,113,185,185,54,115,204,16,45,29,32,241,1,82,253,243,18,149,46,121,213,33,64,40,35,96,203,98,243,113,185,185,54,115,204,16,45,29,32,241,1,82,253,243,18,149,46,121,75,135,234,131,212,196,76,34,41,226,170,218,54,115,204,16,45,29,32,241,1,82,253,243,18,149,46,121,226,253,231,144,212,196,76,34,41,226,170,218,54,115,204,16,45,29,32,241,1,82,253,243,18,149,46,121,51,145,3,183,204,217,111,117,41,226,170,218,54,115,204,16,45,29,32,241,1,82,253,243,18,149,46,121,152,214,212,106,204,217,111,117,41,226,170,218,54,115,204,16,45,29,32,241,1,82,253,243,18,149,46,121,69,67,252,15,57,132,159,140,174,142,2,180,177,111,134,244,146,34,242,217,1,82,253,243,18,149,46,121,128,183,173,26,57,132,159,140,174,142,2,180,177,111,134,244,146,34,242,217,1,82,253,243,18,149,46,121,124,72,186,210,8,162,138,25,174,142,2,180,177,111,134,244,146,34,242,217,1,82,253,243,18,149,46,121,42,219,249,19,8,162,138,25,174,142,2,180,177,111,134,244,146,34,242,217,1,82,253,243,18,149,46,121,27,111,249,47,19,49,135,113,74,129,59,240,177,111,134,244,146,34,242,217,1,82,253,243,18,149,46,121,66,55,64,53,19,49,135,113,74,129,59,240,177,111,134,244,146,34,242,217,1,82,253,243,18,149,46,121,243,63,146,136,75,253,36,162,74,129,59,240,177,111,134,244,146,34,242,217,1,82,253,243,18,149,46,121,219,212,89,93,75,253,36,162,74,129,59,240,177,111,134,244,146,34,242,217,1,82,253,243,18,149,46,121,50,200,32,211,196,6,205,75,139,127,232,79,21,35,67,161,146,34,242,217,1,82,253,243,18,149,46,121,20,157,216,177,196,6,205,75,139,127,232,79,21,35,67,161,146,34,242,217,1,82,253,243,18,149,46,121,222,236,109,140,155,133,32,81,139,127,232,79,21,35,67,161,146,34,242,217,1,82,253,243,18,149,46,121,137,241,63,21,155,133,32,81,139,127,232,79,21,35,67,161,146,34,242,217,1,82,253,243,18,149,46,121,24,252,27,231,16,192,89,45,184,230,20,55,21,35,67,161,146,34,242,217,1,82,253,243,18,149,46,121,89,124,160,1,16,192,89,45,184,230,20,55,21,35,67,161,146,34,242,217,1,82,253,243,18,149,46,121,59,254,133,183,58,26,222,255,184,230,20,55,21,35,67,161,146,34,242,217,1,82,253,243,18,149,46,121,105,182,145,139,58,26,222,255,184,230,20,55,21,35,67,161,146,34,242,217,1,82,253,243,18,149,46,121,86,39,227,203,37,93,129,116,201,76,71,155,177,116,125,30,199,197,197,5,236,20,11,118,18,149,46,121,194,117,230,133,37,93,129,116,201,76,71,155,177,116,125,30,199,197,197,5,236,20,11,118,18,149,46,121,12,76,12,151,171,23,55,158,201,76,71,155,177,116,125,30,199,197,197,5,236,20,11,118,18,149,46,121,37,170,103,5,171,23,55,158,201,76,71,155,177,116,125,30,199,197,197,5,236,20,11,118,18,149,46,121,156,72,138,44,178,196,184,248,236,104,3,167,177,116,125,30,199,197,197,5,236,20,11,118,18,149,46,121,82,192,112,121,178,196,184,248,236,104,3,167,177,116,125,30,199,197,197,5,236,20,11,118,18,149,46,121,126,173,15,67,148,162,128,54,236,104,3,167,177,116,125,30,199,197,197,5,236,20,11,118,18,149,46,121,13,141,142,83,148,162,128,54,236,104,3,167,177,116,125,30,199,197,197,5,236,20,11,118,18,149,46,121,218,226,147,150,0,21,170,193,76,191,87,153,39,66,60,32,199,197,197,5,236,20,11,118,18,149,46,121,193,11,13,252,0,21,170,193,76,191,87,153,39,66,60,32,199,197,197,5,236,20,11,118,18,149,46,121,168,56,120,149,17,155,65,75,76,191,87,153,39,66,60,32,199,197,197,5,236,20,11,118,18,149,46,121,252,127,155,49,17,155,65,75,76,191,87,153,39,66,60,32,199,197,197,5,236,20,11,118,18,149,46,121,5,91,4,203,81,193,61,17,63,43,120,95,39,66,60,32,199,197,197,5,236,20,11,118,18,149,46,121,138,173,127,54,81,193,61,17,63,43,120,95,39,66,60,32,199,197,197,5,236,20,11,118,18,149,46,121,224,120,111,134,197,230,31,135,63,43,120,95,39,66,60,32,199,197,197,5,236,20,11,118,18,149,46,121,100,103,34,42,197,230,31,135,63,43,120,95,39,66,60,32,199,197,197,5,236,20,11,118,18,149,46,121,123,141,164,71,92,60,129,206,78,17,61,245,190,40,237,164,62,10,40,12,236,20,11,118,18,149,46,121,236,40,86,53,92,60,129,206,78,17,61,245,190,40,237,164,62,10,40,12,236,20,11,118,18,149,46,121,83,180,208,56,113,215,5,130,78,17,61,245,190,40,237,164,62,10,40,12,236,20,11,118,18,149,46,121,178,229,86,75,113,215,5,130,78,17,61,245,190,40,237,164,62,10,40,12,236,20,11,118,18,149,46,121,154,244,17,9,241,185,75,36,120,5,10,203,190,40,237,164,62,10,40,12,236,20,11,118,18,149,46,121,78,46,180,59,241,185,75,36,120,5,10,203,190,40,237,164,62,10,40,12,236,20,11,118,18,149,46,121,97,138,191,59,36,148,140,82,120,5,10,203,190,40,237,164,62,10,40,12,236,20,11,118,18,149,46,121,205,174,70,75,36,148,140,82,120,5,10,203,190,40,237,164,62,10,40,12,236,20,11,118,18,149,46,121,254,210,175,49,58,244,150,107,254,225,141,150,117,212,105,39,62,10,40,12,236,20,11,118,18,149,46,121,188,95,40,182,58,244,150,107,254,225,141,150,117,212,105,39,62,10,40,12,236,20,11,118,18,149,46,121,155,82,244,130,3,23,222,243,254,225,141,150,117,212,105,39,62,10,40,12,236,20,11,118,18,149,46,121,38,68,197,58,3,23,222,243,254,225,141,150,117,212,105,39,62,10,40,12,236,20,11,118,18,149,46,121,162,37,231,120,111,3,141,159,193,86,116,188,117,212,105,39,62,10,40,12,236,20,11,118,18,149,46,121,58,135,66,250,111,3,141,159,193,86,116,188,117,212,105,39,62,10,40,12,236,20,11,118,18,149,46,121,64,60,232,16,135,211,9,178,193,86,116,188,117,212,105,39,62,10,40,12,236,20,11,118,18,149,46,121,15,232,85,246,135,211,9,178,193,86,116,188,117,212,105,39,62,10,40,12,236,20,11,118,18,149,46,121,226,21,172,135,111,71,248,116,217,80,60,219,188,142,11,51,245,200,136,13,137,103,31,19,18,72,110,254,250,85,139,178,111,71,248,116,217,80,60,219,188,142,11,51,245,200,136,13,137,103,31,19,18,72,110,254,90,175,208,53,118,128,133,179,217,80,60,219,188,142,11,51,245,200,136,13,137,103,31,19,18,72,110,254,128,162,227,198,118,128,133,179,217,80,60,219,188,142,11,51,245,200,136,13,137,103,31,19,18,72,110,254,207,38,249,195,37,131,44,47,77,82,94,73,188,142,11,51,245,200,136,13,137,103,31,19,18,72,110,254,161,165,158,250,37,131,44,47,77,82,94,73,188,142,11,51,245,200,136,13,137,103,31,19,18,72,110,254,188,142,55,227,180,0,66,204,77,82,94,73,188,142,11,51,245,200,136,13,137,103,31,19,18,72,110,254,125,26,112,252,180,0,66,204,77,82,94,73,188,142,11,51,245,200,136,13,137,103,31,19,18,72,110,254,22,155,231,103,9,180,25,20,71,242,120,146,238,91,144,22,245,200,136,13,137,103,31,19,18,72,110,254,7,88,106,227,9,180,25,20,71,242,120,146,238,91,144,22,245,200,136,13,137,103,31,19,18,72,110,254,121,239,180,119,106,219,202,18,71,242,120,146,238,91,144,22,245,200,136,13,137,103,31,19,18,72,110,254,250,222,43,181,106,219,202,18,71,242,120,146,238,91,144,22,245,200,136,13,137,103,31,19,18,72,110,254,29,142,3,40,29,164,246,98,55,204,76,233,238,91,144,22,245,200,136,13,137,103,31,19,18,72,110,254,204,205,9,203,29,164,246,98,55,204,76,233,238,91,144,22,245,200,136,13,137,103,31,19,18,72,110,254,22,240,105,201,197,130,110,101,55,204,76,233,238,91,144,22,245,200,136,13,137,103,31,19,18,72,110,254,113,191,12,53,197,130,110,101,55,204,76,233,238,91,144,22,245,200,136,13,137,103,31,19,18,72,110,254,133,29,26,65,5,22,180,187,234,247,123,20,249,90,67,149,254,114,155,109,137,103,31,19,18,72,110,254,205,146,175,25,5,22,180,187,234,247,123,20,249,90,67,149,254,114,155,109,137,103,31,19,18,72,110,254,90,133,22,232,144,41,193,104,234,247,123,20,249,90,67,149,254,114,155,109,137,103,31,19,18,72,110,254,72,143,138,248,144,41,193,104,234,247,123,20,249,90,67,149,254,114,155,109,137,103,31,19,18,72,110,254,202,39,235,197,208,130,10,34,23,254,125,179,249,90,67,149,254,114,155,109,137,103,31,19,18,72,110,254,188,178,200,127,208,130,10,34,23,254,125,179,249,90,67,149,254,114,155,109,137,103,31,19,18,72,110,254,62,235,228,215,5,218,223,93,23,254,125,179,249,90,67,149,254,114,155,109,137,103,31,19,18,72,110,254,94,167,110,82,5,218,223,93,23,254,125,179,249,90,67,149,254,114,155,109,137,103,31,19,18,72,110,254,102,46,37,22,127,3,61,253,120,198,248,114,124,220,117,120,254,114,155,109,137,103,31,19,18,72,110,254,17,17,117,54,127,3,61,253,120,198,248,114,124,220,117,120,254,114,155,109,137,103,31,19,18,72,110,254,25,55,80,182,112,68,206,98,120,198,248,114,124,220,117,120,254,114,155,109,137,103,31,19,18,72,110,254,164,40,183,159,112,68,206,98,120,198,248,114,124,220,117,120,254,114,155,109,137,103,31,19,18,72,110,254,12,200,147,241,240,129,157,149,214,175,107,55,124,220,117,120,254,114,155,109,137,103,31,19,18,72,110,254,241,239,12,185,240,129,157,149,214,175,107,55,124,220,117,120,254,114,155,109,137,103,31,19,18,72,110,254,23,173,235,75,247,5,120,126,214,175,107,55,124,220,117,120,254,114,155,109,137,103,31,19,18,72,110,254,76,90,125,48,247,5,120,126,214,175,107,55,124,220,117,120,254,114,155,109,137,103,31,19,18,72,110,254,255,21,97,103,4,191,4,227,166,66,253,139,18,72,110,254,97,85,135,96,4,191,4,227,166,66,253,139,18,72,110,254,176,168,148,246,118,100,253,16,166,66,253,139,18,72,110,254,85,13,180,129,118,100,253,16,166,66,253,139,18,72,110,254}; + +static const uint32_t T5_COUNT = 255u; +static const uint8_t T5_LEAVES[1020] = {99,92,33,97,215,30,198,101,110,35,237,220,30,114,79,78,74,29,101,121,222,43,226,84,17,236,91,25,47,133,95,23,43,24,222,170,190,97,229,65,76,57,46,5,125,175,81,95,129,156,155,63,139,113,160,112,9,231,52,203,252,7,66,123,48,252,216,98,69,222,198,113,178,127,158,162,81,195,118,245,12,104,14,245,195,109,80,118,156,90,70,58,116,110,104,111,98,218,154,9,0,246,201,54,21,252,233,206,122,167,217,33,27,229,83,158,113,117,40,232,181,76,250,165,202,26,5,178,24,172,180,91,248,103,94,4,159,132,24,153,192,212,194,197,91,144,28,217,220,138,69,32,88,62,37,53,222,242,192,136,108,15,206,62,175,37,53,189,122,8,1,151,251,79,38,134,218,146,209,8,209,69,107,224,101,240,227,215,64,22,211,222,200,168,86,206,166,14,152,208,136,237,24,102,21,75,241,208,229,172,0,114,82,123,56,244,139,243,123,44,152,92,225,42,18,138,48,214,248,103,199,37,85,246,102,71,235,63,48,78,118,250,138,255,183,97,23,93,190,117,84,232,123,112,151,77,179,219,237,53,190,42,18,93,107,191,176,137,124,122,74,20,142,110,105,47,54,175,181,107,222,49,152,50,17,253,130,64,26,56,103,115,55,250,154,108,68,73,225,98,107,219,25,215,125,6,206,178,170,145,250,144,206,100,175,127,158,19,247,69,153,200,212,164,188,45,2,3,199,126,46,239,154,24,194,145,219,53,73,113,240,97,62,59,45,184,154,234,46,208,65,46,153,97,185,189,80,96,1,217,222,177,59,129,129,235,150,104,135,177,190,75,226,233,82,45,254,83,235,151,179,166,244,74,106,234,100,179,159,56,71,63,37,219,60,174,72,210,203,202,117,29,49,129,193,83,137,16,54,223,126,253,200,222,108,14,42,75,153,9,237,246,91,48,20,82,162,31,204,182,70,123,170,142,148,194,92,104,120,163,114,162,123,143,133,175,134,57,34,19,231,207,204,211,133,58,121,174,231,52,136,250,88,177,238,169,212,146,91,241,161,135,170,251,202,84,228,237,231,18,165,178,89,96,218,135,59,199,248,202,177,222,234,229,141,108,120,41,139,215,36,65,173,224,128,97,225,251,106,100,234,202,236,222,20,34,145,135,162,162,186,253,245,44,87,151,161,224,84,113,162,206,100,154,175,183,109,12,155,201,93,121,19,131,120,4,60,73,19,222,160,237,167,13,195,180,108,243,228,36,28,72,216,0,231,211,112,6,34,247,115,50,7,25,79,120,224,173,218,66,44,6,104,153,101,176,42,94,72,63,198,240,243,34,3,7,51,230,53,223,243,118,3,198,52,105,9,172,174,40,34,202,177,224,62,9,73,147,168,22,37,254,205,200,135,62,227,125,114,160,12,107,0,103,126,218,5,89,61,218,9,212,71,125,200,61,131,83,235,30,236,207,185,131,237,198,225,61,208,112,102,57,123,99,71,28,42,28,25,186,35,229,158,90,56,92,133,16,82,153,52,230,163,184,45,20,64,214,172,131,94,26,249,52,201,130,242,21,132,147,240,84,64,243,51,52,187,146,246,205,26,211,105,175,61,221,209,21,230,137,88,0,176,105,144,150,137,124,228,223,2,180,169,190,150,90,170,98,205,172,40,91,71,138,242,213,140,102,41,178,241,149,113,112,82,60,194,159,187,87,136,172,169,188,177,199,28,202,9,199,205,7,162,249,44,225,132,229,226,98,158,22,105,45,129,185,103,208,200,45,189,25,202,91,179,42,213,54,2,126,142,224,63,170,137,186,245,105,74,26,77,175,88,126,216,140,18,235,136,40,156,192,38,255,28,233,255,161,39,109,33,227,82,143,178,188,149,99,100,231,41,39,133,234,183,230,240,243,133,198,56,49,198,172,6,104,36,29,157,93,82,16,201,114,111,225,187,176,227,62,90,123,100,22,147,98,176,102,96,95,228,116,217,35,147,129,183,208,131,237,195,100,89,243,185,43,17,209,44,159,179,151,84,159,167,187,80,191,118,89,121,54,37,82,106,170,109,95,140,81,224,108,165,161,252,226,92,204,207,129,169,31,4,27,80,174,208,127,241,68,233,224,38,93,233,162,74,54,164,245,145,211,22,15,219,10,211,93,159,62,71,14,45,19,225,239,69,93,176,167,66,95,75,158,79,2,221,52,115,89,137,108,87,155,209,12,100,54,71,201,170,17,132,15,135,37,31,139,240,132,99,151,51,84,187,224,195,234,66,91,87,129,171,22,20,242,205,129,26,178}; + +static const uint8_t T5_ROOT[4] = {125,131,30,129}; + +static const uint16_t T5_POFF[255] = {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,480,512,544,576,608,640,672,704,736,768,800,832,864,896,928,960,992,1024,1056,1088,1120,1152,1184,1216,1248,1280,1312,1344,1376,1408,1440,1472,1504,1536,1568,1600,1632,1664,1696,1728,1760,1792,1824,1856,1888,1920,1952,1984,2016,2048,2080,2112,2144,2176,2208,2240,2272,2304,2336,2368,2400,2432,2464,2496,2528,2560,2592,2624,2656,2688,2720,2752,2784,2816,2848,2880,2912,2944,2976,3008,3040,3072,3104,3136,3168,3200,3232,3264,3296,3328,3360,3392,3424,3456,3488,3520,3552,3584,3616,3648,3680,3712,3744,3776,3808,3840,3872,3904,3936,3968,4000,4032,4064,4096,4128,4160,4192,4224,4256,4288,4320,4352,4384,4416,4448,4480,4512,4544,4576,4608,4640,4672,4704,4736,4768,4800,4832,4864,4896,4928,4960,4992,5024,5056,5088,5120,5152,5184,5216,5248,5280,5312,5344,5376,5408,5440,5472,5504,5536,5568,5600,5632,5664,5696,5728,5760,5792,5824,5856,5888,5920,5952,5984,6016,6048,6080,6112,6144,6176,6208,6240,6272,6304,6336,6368,6400,6432,6464,6496,6528,6560,6592,6624,6656,6688,6720,6752,6784,6816,6848,6880,6912,6944,6976,7008,7040,7072,7104,7136,7168,7200,7232,7264,7296,7328,7360,7392,7424,7456,7488,7520,7552,7584,7616,7648,7680,7712,7744,7776,7808,7840,7872,7904,7936,7968,8000,8032,8064,8096,8128}; +static const uint8_t T5_PNSIB[255] = {8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7}; +static const uint8_t T5_PBLOB[8156] = {215,30,198,101,190,120,224,191,253,188,254,181,170,224,185,20,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,99,92,33,97,190,120,224,191,253,188,254,181,170,224,185,20,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,30,114,79,78,121,1,165,22,253,188,254,181,170,224,185,20,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,110,35,237,220,121,1,165,22,253,188,254,181,170,224,185,20,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,222,43,226,84,141,8,229,42,34,203,204,102,170,224,185,20,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,74,29,101,121,141,8,229,42,34,203,204,102,170,224,185,20,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,47,133,95,23,206,109,234,200,34,203,204,102,170,224,185,20,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,17,236,91,25,206,109,234,200,34,203,204,102,170,224,185,20,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,190,97,229,65,204,162,212,253,158,221,103,119,94,138,252,177,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,43,24,222,170,204,162,212,253,158,221,103,119,94,138,252,177,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,125,175,81,95,207,138,11,26,158,221,103,119,94,138,252,177,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,76,57,46,5,207,138,11,26,158,221,103,119,94,138,252,177,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,139,113,160,112,70,90,148,231,170,148,193,238,94,138,252,177,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,129,156,155,63,70,90,148,231,170,148,193,238,94,138,252,177,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,252,7,66,123,221,141,84,219,170,148,193,238,94,138,252,177,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,9,231,52,203,221,141,84,219,170,148,193,238,94,138,252,177,232,113,80,94,246,33,129,111,238,68,253,253,233,186,40,163,69,222,198,113,5,81,192,127,46,0,223,26,254,26,86,132,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,48,252,216,98,5,81,192,127,46,0,223,26,254,26,86,132,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,81,195,118,245,162,175,255,73,46,0,223,26,254,26,86,132,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,178,127,158,162,162,175,255,73,46,0,223,26,254,26,86,132,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,195,109,80,118,127,36,23,8,63,65,173,128,254,26,86,132,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,12,104,14,245,127,36,23,8,63,65,173,128,254,26,86,132,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,116,110,104,111,201,228,150,142,63,65,173,128,254,26,86,132,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,156,90,70,58,201,228,150,142,63,65,173,128,254,26,86,132,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,0,246,201,54,128,178,99,183,233,161,204,65,5,250,190,144,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,98,218,154,9,128,178,99,183,233,161,204,65,5,250,190,144,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,122,167,217,33,47,15,253,93,233,161,204,65,5,250,190,144,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,21,252,233,206,47,15,253,93,233,161,204,65,5,250,190,144,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,113,117,40,232,216,234,112,92,191,252,51,40,5,250,190,144,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,27,229,83,158,216,234,112,92,191,252,51,40,5,250,190,144,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,202,26,5,178,170,64,23,82,191,252,51,40,5,250,190,144,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,181,76,250,165,170,64,23,82,191,252,51,40,5,250,190,144,76,178,240,104,246,33,129,111,238,68,253,253,233,186,40,163,248,103,94,4,94,81,198,48,105,236,187,128,230,97,25,120,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,24,172,180,91,94,81,198,48,105,236,187,128,230,97,25,120,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,192,212,194,197,113,91,163,95,105,236,187,128,230,97,25,120,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,159,132,24,153,113,91,163,95,105,236,187,128,230,97,25,120,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,220,138,69,32,74,123,206,252,86,172,110,251,230,97,25,120,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,91,144,28,217,74,123,206,252,86,172,110,251,230,97,25,120,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,222,242,192,136,14,210,218,85,86,172,110,251,230,97,25,120,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,88,62,37,53,14,210,218,85,86,172,110,251,230,97,25,120,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,175,37,53,189,128,163,232,24,76,245,254,84,247,196,73,244,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,108,15,206,62,128,163,232,24,76,245,254,84,247,196,73,244,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,251,79,38,134,1,113,206,77,76,245,254,84,247,196,73,244,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,122,8,1,151,1,113,206,77,76,245,254,84,247,196,73,244,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,209,69,107,224,183,59,60,223,198,229,132,188,247,196,73,244,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,218,146,209,8,183,59,60,223,198,229,132,188,247,196,73,244,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,64,22,211,222,205,108,8,132,198,229,132,188,247,196,73,244,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,101,240,227,215,205,108,8,132,198,229,132,188,247,196,73,244,232,125,159,24,124,247,176,24,238,68,253,253,233,186,40,163,166,14,152,208,48,91,11,92,204,141,206,246,20,174,189,54,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,200,168,86,206,48,91,11,92,204,141,206,246,20,174,189,54,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,21,75,241,208,63,55,43,68,204,141,206,246,20,174,189,54,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,136,237,24,102,63,55,43,68,204,141,206,246,20,174,189,54,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,82,123,56,244,254,79,71,92,116,172,104,147,20,174,189,54,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,229,172,0,114,254,79,71,92,116,172,104,147,20,174,189,54,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,152,92,225,42,240,171,219,118,116,172,104,147,20,174,189,54,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,139,243,123,44,240,171,219,118,116,172,104,147,20,174,189,54,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,248,103,199,37,16,8,159,27,191,1,63,178,89,185,204,8,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,18,138,48,214,16,8,159,27,191,1,63,178,89,185,204,8,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,235,63,48,78,217,233,2,26,191,1,63,178,89,185,204,8,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,85,246,102,71,217,233,2,26,191,1,63,178,89,185,204,8,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,183,97,23,93,130,244,157,66,116,89,239,252,89,185,204,8,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,118,250,138,255,130,244,157,66,116,89,239,252,89,185,204,8,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,123,112,151,77,120,114,184,129,116,89,239,252,89,185,204,8,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,190,117,84,232,120,114,184,129,116,89,239,252,89,185,204,8,137,23,246,178,124,247,176,24,238,68,253,253,233,186,40,163,190,42,18,93,115,230,103,83,250,214,185,120,6,177,124,63,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,179,219,237,53,115,230,103,83,250,214,185,120,6,177,124,63,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,124,122,74,20,97,4,88,76,250,214,185,120,6,177,124,63,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,107,191,176,137,97,4,88,76,250,214,185,120,6,177,124,63,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,54,175,181,107,59,91,192,30,154,31,201,64,6,177,124,63,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,142,110,105,47,59,91,192,30,154,31,201,64,6,177,124,63,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,17,253,130,64,228,124,158,215,154,31,201,64,6,177,124,63,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,222,49,152,50,228,124,158,215,154,31,201,64,6,177,124,63,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,55,250,154,108,155,128,129,53,134,36,253,166,16,136,239,89,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,26,56,103,115,155,128,129,53,134,36,253,166,16,136,239,89,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,107,219,25,215,247,173,148,218,134,36,253,166,16,136,239,89,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,68,73,225,98,247,173,148,218,134,36,253,166,16,136,239,89,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,170,145,250,144,247,90,52,20,72,129,76,253,16,136,239,89,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,125,6,206,178,247,90,52,20,72,129,76,253,16,136,239,89,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,158,19,247,69,247,95,164,102,72,129,76,253,16,136,239,89,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,206,100,175,127,247,95,164,102,72,129,76,253,16,136,239,89,141,126,172,97,186,114,88,100,190,95,10,234,233,186,40,163,188,45,2,3,212,87,54,4,182,96,47,198,19,88,25,99,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,153,200,212,164,212,87,54,4,182,96,47,198,19,88,25,99,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,154,24,194,145,102,246,218,123,182,96,47,198,19,88,25,99,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,199,126,46,239,102,246,218,123,182,96,47,198,19,88,25,99,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,240,97,62,59,132,77,109,128,30,168,105,2,19,88,25,99,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,219,53,73,113,132,77,109,128,30,168,105,2,19,88,25,99,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,46,208,65,46,219,116,26,133,30,168,105,2,19,88,25,99,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,45,184,154,234,219,116,26,133,30,168,105,2,19,88,25,99,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,80,96,1,217,107,212,205,186,49,177,100,105,12,28,250,33,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,153,97,185,189,107,212,205,186,49,177,100,105,12,28,250,33,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,129,235,150,104,41,140,2,32,49,177,100,105,12,28,250,33,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,222,177,59,129,41,140,2,32,49,177,100,105,12,28,250,33,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,226,233,82,45,227,209,206,178,239,122,214,94,12,28,250,33,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,135,177,190,75,227,209,206,178,239,122,214,94,12,28,250,33,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,179,166,244,74,27,220,156,60,239,122,214,94,12,28,250,33,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,254,83,235,151,27,220,156,60,239,122,214,94,12,28,250,33,179,154,15,154,186,114,88,100,190,95,10,234,233,186,40,163,159,56,71,63,104,144,222,36,82,146,142,92,101,134,175,232,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,106,234,100,179,104,144,222,36,82,146,142,92,101,134,175,232,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,72,210,203,202,139,83,253,41,82,146,142,92,101,134,175,232,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,37,219,60,174,139,83,253,41,82,146,142,92,101,134,175,232,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,193,83,137,16,92,24,45,75,67,119,114,64,101,134,175,232,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,117,29,49,129,92,24,45,75,67,119,114,64,101,134,175,232,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,200,222,108,14,198,219,28,222,67,119,114,64,101,134,175,232,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,54,223,126,253,198,219,28,222,67,119,114,64,101,134,175,232,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,237,246,91,48,198,140,193,108,237,129,4,58,185,251,175,87,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,42,75,153,9,198,140,193,108,237,129,4,58,185,251,175,87,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,204,182,70,123,33,124,19,168,237,129,4,58,185,251,175,87,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,20,82,162,31,33,124,19,168,237,129,4,58,185,251,175,87,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,92,104,120,163,233,43,141,148,84,198,210,114,185,251,175,87,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,170,142,148,194,233,43,141,148,84,198,210,114,185,251,175,87,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,133,175,134,57,188,213,87,64,84,198,210,114,185,251,175,87,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,114,162,123,143,188,213,87,64,84,198,210,114,185,251,175,87,4,224,138,85,173,101,8,17,190,95,10,234,233,186,40,163,204,211,133,58,172,141,153,40,4,89,108,160,216,249,136,47,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,34,19,231,207,172,141,153,40,4,89,108,160,216,249,136,47,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,136,250,88,177,28,20,32,234,4,89,108,160,216,249,136,47,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,121,174,231,52,28,20,32,234,4,89,108,160,216,249,136,47,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,91,241,161,135,1,39,136,34,213,47,116,54,216,249,136,47,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,238,169,212,146,1,39,136,34,213,47,116,54,216,249,136,47,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,228,237,231,18,80,230,21,186,213,47,116,54,216,249,136,47,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,170,251,202,84,80,230,21,186,213,47,116,54,216,249,136,47,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,218,135,59,199,10,168,54,220,255,52,36,199,124,230,161,37,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,165,178,89,96,10,168,54,220,255,52,36,199,124,230,161,37,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,234,229,141,108,8,71,93,60,255,52,36,199,124,230,161,37,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,248,202,177,222,8,71,93,60,255,52,36,199,124,230,161,37,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,36,65,173,224,188,66,117,38,117,207,98,22,124,230,161,37,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,120,41,139,215,188,66,117,38,117,207,98,22,124,230,161,37,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,106,100,234,202,132,221,207,206,117,207,98,22,124,230,161,37,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,128,97,225,251,132,221,207,206,117,207,98,22,124,230,161,37,136,111,137,202,173,101,8,17,190,95,10,234,233,186,40,163,145,135,162,162,128,226,107,222,27,245,169,183,60,125,13,147,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,236,222,20,34,128,226,107,222,27,245,169,183,60,125,13,147,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,87,151,161,224,245,250,197,106,27,245,169,183,60,125,13,147,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,186,253,245,44,245,250,197,106,27,245,169,183,60,125,13,147,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,100,154,175,183,44,49,136,235,120,234,96,37,60,125,13,147,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,84,113,162,206,44,49,136,235,120,234,96,37,60,125,13,147,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,93,121,19,131,91,181,125,107,120,234,96,37,60,125,13,147,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,109,12,155,201,91,181,125,107,120,234,96,37,60,125,13,147,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,19,222,160,237,67,77,22,132,180,72,145,62,24,52,46,163,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,120,4,60,73,67,77,22,132,180,72,145,62,24,52,46,163,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,108,243,228,36,222,239,160,173,180,72,145,62,24,52,46,163,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,167,13,195,180,222,239,160,173,180,72,145,62,24,52,46,163,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,231,211,112,6,114,90,52,194,139,74,217,121,24,52,46,163,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,28,72,216,0,114,90,52,194,139,74,217,121,24,52,46,163,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,7,25,79,120,146,163,201,62,139,74,217,121,24,52,46,163,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,34,247,115,50,146,163,201,62,139,74,217,121,24,52,46,163,237,58,98,217,159,169,75,34,212,98,161,137,210,194,150,8,44,6,104,153,56,87,29,135,154,198,105,207,151,164,231,88,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,224,173,218,66,56,87,29,135,154,198,105,207,151,164,231,88,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,72,63,198,240,65,166,63,192,154,198,105,207,151,164,231,88,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,101,176,42,94,65,166,63,192,154,198,105,207,151,164,231,88,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,51,230,53,223,28,211,208,130,48,96,188,16,151,164,231,88,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,243,34,3,7,28,211,208,130,48,96,188,16,151,164,231,88,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,52,105,9,172,54,211,161,218,48,96,188,16,151,164,231,88,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,243,118,3,198,54,211,161,218,48,96,188,16,151,164,231,88,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,177,224,62,9,59,205,5,114,107,174,125,168,56,155,1,160,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,174,40,34,202,59,205,5,114,107,174,125,168,56,155,1,160,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,37,254,205,200,44,209,46,252,107,174,125,168,56,155,1,160,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,73,147,168,22,44,209,46,252,107,174,125,168,56,155,1,160,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,114,160,12,107,235,25,189,36,233,112,219,6,56,155,1,160,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,135,62,227,125,235,25,189,36,233,112,219,6,56,155,1,160,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,5,89,61,218,90,114,53,227,233,112,219,6,56,155,1,160,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,0,103,126,218,90,114,53,227,233,112,219,6,56,155,1,160,37,0,202,214,159,169,75,34,212,98,161,137,210,194,150,8,200,61,131,83,40,49,219,14,254,162,186,146,250,26,34,183,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,9,212,71,125,40,49,219,14,254,162,186,146,250,26,34,183,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,185,131,237,198,15,92,26,171,254,162,186,146,250,26,34,183,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,235,30,236,207,15,92,26,171,254,162,186,146,250,26,34,183,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,102,57,123,99,144,130,249,100,143,201,181,210,250,26,34,183,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,225,61,208,112,144,130,249,100,143,201,181,210,250,26,34,183,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,25,186,35,229,160,164,55,211,143,201,181,210,250,26,34,183,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,71,28,42,28,160,164,55,211,143,201,181,210,250,26,34,183,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,133,16,82,153,87,90,43,2,165,219,251,178,104,250,180,234,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,158,90,56,92,87,90,43,2,165,219,251,178,104,250,180,234,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,45,20,64,214,230,188,131,193,165,219,251,178,104,250,180,234,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,52,230,163,184,230,188,131,193,165,219,251,178,104,250,180,234,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,249,52,201,130,77,104,95,217,211,245,148,89,104,250,180,234,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,172,131,94,26,77,104,95,217,211,245,148,89,104,250,180,234,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,240,84,64,243,170,132,164,23,211,245,148,89,104,250,180,234,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,242,21,132,147,170,132,164,23,211,245,148,89,104,250,180,234,72,63,60,250,171,254,193,32,212,98,161,137,210,194,150,8,246,205,26,211,15,174,31,185,55,209,133,81,85,74,56,148,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,51,52,187,146,15,174,31,185,55,209,133,81,85,74,56,148,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,209,21,230,137,138,228,144,223,55,209,133,81,85,74,56,148,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,105,175,61,221,138,228,144,223,55,209,133,81,85,74,56,148,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,144,150,137,124,174,229,97,187,146,63,122,179,85,74,56,148,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,88,0,176,105,174,229,97,187,146,63,122,179,85,74,56,148,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,169,190,150,90,126,224,170,11,146,63,122,179,85,74,56,148,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,228,223,2,180,126,224,170,11,146,63,122,179,85,74,56,148,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,40,91,71,138,119,136,244,54,130,225,71,203,216,9,61,7,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,170,98,205,172,119,136,244,54,130,225,71,203,216,9,61,7,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,41,178,241,149,28,208,76,222,130,225,71,203,216,9,61,7,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,242,213,140,102,28,208,76,222,130,225,71,203,216,9,61,7,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,194,159,187,87,57,72,39,59,255,196,49,66,216,9,61,7,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,113,112,82,60,57,72,39,59,255,196,49,66,216,9,61,7,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,177,199,28,202,169,232,218,239,255,196,49,66,216,9,61,7,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,136,172,169,188,169,232,218,239,255,196,49,66,216,9,61,7,53,81,124,127,171,254,193,32,212,98,161,137,210,194,150,8,162,249,44,225,249,165,132,202,234,33,63,146,60,224,153,145,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,9,199,205,7,249,165,132,202,234,33,63,146,60,224,153,145,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,158,22,105,45,34,213,230,145,234,33,63,146,60,224,153,145,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,132,229,226,98,34,213,230,145,234,33,63,146,60,224,153,145,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,200,45,189,25,171,54,42,114,248,169,247,187,60,224,153,145,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,129,185,103,208,171,54,42,114,248,169,247,187,60,224,153,145,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,213,54,2,126,251,67,226,96,248,169,247,187,60,224,153,145,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,202,91,179,42,251,67,226,96,248,169,247,187,60,224,153,145,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,137,186,245,105,144,131,210,251,112,70,110,179,241,127,216,216,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,142,224,63,170,144,131,210,251,112,70,110,179,241,127,216,216,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,88,126,216,140,30,32,172,94,112,70,110,179,241,127,216,216,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,74,26,77,175,30,32,172,94,112,70,110,179,241,127,216,216,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,156,192,38,255,33,149,144,107,38,82,1,94,241,127,216,216,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,18,235,136,40,33,149,144,107,38,82,1,94,241,127,216,216,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,39,109,33,227,5,87,237,247,38,82,1,94,241,127,216,216,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,28,233,255,161,5,87,237,247,38,82,1,94,241,127,216,216,218,21,199,202,42,98,34,4,214,10,216,155,210,194,150,8,149,99,100,231,97,200,185,0,114,180,59,25,239,193,60,24,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,82,143,178,188,97,200,185,0,114,180,59,25,239,193,60,24,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,183,230,240,243,50,21,131,25,114,180,59,25,239,193,60,24,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,41,39,133,234,50,21,131,25,114,180,59,25,239,193,60,24,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,198,172,6,104,123,204,219,26,132,238,138,31,239,193,60,24,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,133,198,56,49,123,204,219,26,132,238,138,31,239,193,60,24,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,82,16,201,114,49,236,17,124,132,238,138,31,239,193,60,24,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,36,29,157,93,49,236,17,124,132,238,138,31,239,193,60,24,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,227,62,90,123,221,253,182,84,222,147,38,189,212,95,114,28,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,111,225,187,176,221,253,182,84,222,147,38,189,212,95,114,28,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,176,102,96,95,99,160,74,245,222,147,38,189,212,95,114,28,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,100,22,147,98,99,160,74,245,222,147,38,189,212,95,114,28,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,147,129,183,208,5,201,11,116,231,37,94,179,212,95,114,28,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,228,116,217,35,5,201,11,116,231,37,94,179,212,95,114,28,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,89,243,185,43,160,179,19,124,231,37,94,179,212,95,114,28,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,131,237,195,100,160,179,19,124,231,37,94,179,212,95,114,28,220,94,32,174,42,98,34,4,214,10,216,155,210,194,150,8,179,151,84,159,236,194,218,247,95,184,14,182,203,139,195,106,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,17,209,44,159,236,194,218,247,95,184,14,182,203,139,195,106,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,118,89,121,54,244,73,190,177,95,184,14,182,203,139,195,106,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,167,187,80,191,244,73,190,177,95,184,14,182,203,139,195,106,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,109,95,140,81,42,92,129,234,198,169,156,133,203,139,195,106,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,37,82,106,170,42,92,129,234,198,169,156,133,203,139,195,106,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,252,226,92,204,108,153,157,227,198,169,156,133,203,139,195,106,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,224,108,165,161,108,153,157,227,198,169,156,133,203,139,195,106,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,4,27,80,174,163,50,171,76,217,92,112,26,68,158,170,93,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,207,129,169,31,163,50,171,76,217,92,112,26,68,158,170,93,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,233,224,38,93,241,7,162,27,217,92,112,26,68,158,170,93,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,208,127,241,68,241,7,162,27,217,92,112,26,68,158,170,93,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,164,245,145,211,206,131,153,180,248,164,93,124,68,158,170,93,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,233,162,74,54,206,131,153,180,248,164,93,124,68,158,170,93,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,211,93,159,62,43,141,136,237,248,164,93,124,68,158,170,93,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,22,15,219,10,43,141,136,237,248,164,93,124,68,158,170,93,178,241,150,166,105,50,201,221,214,10,216,155,210,194,150,8,225,239,69,93,58,174,252,226,253,62,176,21,120,148,23,214,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,71,14,45,19,58,174,252,226,253,62,176,21,120,148,23,214,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,75,158,79,2,212,250,126,95,253,62,176,21,120,148,23,214,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,176,167,66,95,212,250,126,95,253,62,176,21,120,148,23,214,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,137,108,87,155,235,72,9,223,219,78,116,24,120,148,23,214,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,221,52,115,89,235,72,9,223,219,78,116,24,120,148,23,214,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,71,201,170,17,200,40,165,177,219,78,116,24,120,148,23,214,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,209,12,100,54,200,40,165,177,219,78,116,24,120,148,23,214,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,31,139,240,132,128,92,178,133,95,12,184,178,84,135,163,76,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,132,15,135,37,128,92,178,133,95,12,184,178,84,135,163,76,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,187,224,195,234,23,150,210,86,95,12,184,178,84,135,163,76,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,99,151,51,84,23,150,210,86,95,12,184,178,84,135,163,76,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,171,22,20,242,205,129,26,178,175,20,10,249,84,135,163,76,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,66,91,87,129,205,129,26,178,175,20,10,249,84,135,163,76,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8,58,200,104,48,175,20,10,249,84,135,163,76,214,159,130,226,105,50,201,221,214,10,216,155,210,194,150,8}; + +static const uint32_t T6_COUNT = 256u; +static const uint8_t T6_LEAVES[1024] = {140,30,28,139,112,181,234,109,189,248,70,203,91,147,16,79,160,214,180,247,227,25,226,179,212,216,74,183,29,218,24,245,174,86,29,161,246,98,88,70,57,109,6,63,2,118,183,123,179,170,29,164,240,42,222,210,44,221,150,34,140,58,40,230,34,40,243,221,70,200,235,154,222,245,150,142,26,73,239,10,149,160,70,187,237,164,108,108,255,97,11,186,38,207,198,61,150,120,191,174,140,118,171,135,98,134,144,226,134,125,154,211,144,180,156,190,239,161,238,1,12,58,108,180,205,156,159,243,234,143,100,122,48,2,67,107,16,94,165,53,11,230,64,17,156,108,188,173,215,106,87,57,40,134,87,49,84,165,105,235,101,114,152,214,254,223,71,12,185,117,113,106,204,140,153,139,17,99,242,43,219,162,40,74,235,167,12,139,193,244,177,243,168,241,35,162,3,244,187,19,8,31,0,50,125,10,54,219,128,111,71,120,98,85,123,253,109,114,78,90,28,74,181,193,78,119,202,25,52,9,11,168,104,102,167,195,163,38,76,46,244,20,10,239,73,42,118,156,35,123,44,47,169,77,215,85,5,158,206,234,117,78,236,245,199,90,190,233,27,94,66,124,125,216,144,206,176,49,232,25,240,96,71,166,1,188,162,37,52,170,95,214,202,140,244,166,202,197,31,175,200,200,184,216,89,16,76,83,0,214,101,183,191,58,24,205,152,185,199,196,158,173,204,151,167,47,174,166,166,219,25,142,153,242,69,204,213,20,122,92,72,139,123,35,174,151,61,167,16,59,48,232,207,11,215,131,29,237,20,185,230,248,162,116,73,249,8,193,17,122,162,2,30,200,86,10,211,163,22,176,91,129,245,134,24,251,148,174,99,121,51,181,210,28,91,5,71,206,178,16,152,119,134,224,1,52,173,144,205,28,218,5,29,48,99,59,245,188,174,66,8,246,1,98,79,31,195,126,195,166,105,161,123,146,111,78,186,171,239,170,88,104,171,67,123,130,25,202,36,167,154,238,225,39,215,152,97,177,82,216,38,134,48,83,21,132,181,183,97,164,142,64,211,142,129,160,76,126,37,4,25,250,177,60,206,78,107,67,60,48,109,132,22,42,14,35,31,107,190,9,174,168,77,194,252,126,158,68,230,216,74,121,1,20,130,34,13,230,124,118,63,95,167,113,32,221,48,116,23,12,240,245,169,207,209,44,166,94,127,63,210,175,232,112,46,53,192,226,14,93,152,208,26,123,5,72,249,48,209,230,232,165,48,43,179,126,101,6,6,32,139,240,34,165,130,235,221,88,169,2,237,233,7,132,223,53,21,123,154,157,80,249,223,99,236,125,24,201,152,48,250,227,240,143,9,96,140,175,122,0,252,131,89,231,69,134,174,100,160,121,169,149,133,58,128,154,161,213,253,115,9,78,17,162,36,204,144,39,254,0,202,10,231,163,145,210,170,33,99,34,51,113,149,65,26,52,97,21,41,130,29,16,14,2,224,227,56,163,187,59,211,67,23,244,16,132,64,72,173,170,144,118,245,143,49,245,173,189,32,108,165,42,182,244,204,65,246,192,37,126,173,189,141,102,42,108,224,229,243,79,2,122,50,173,7,109,74,193,250,241,62,119,175,121,191,252,45,227,1,178,83,242,47,51,38,223,124,72,20,198,43,190,11,27,198,20,180,133,14,88,191,54,150,173,116,181,86,153,4,30,100,151,106,29,221,6,67,158,161,230,124,15,88,83,106,181,58,198,103,66,16,18,120,121,81,131,20,21,57,196,42,236,254,91,123,120,206,207,152,201,32,88,58,158,182,125,143,86,40,251,141,75,187,57,85,90,76,77,62,226,116,232,18,4,109,141,210,161,216,65,104,210,138,24,186,238,238,226,2,92,49,35,250,235,8,158,91,229,28,150,74,93,54,112,81,75,223,55,136,55,155,189,6,233,116,184,247,71,111,154,180,28,143,63,60,255,75,249,199,13,97,69,87,36,175,246,44,216,61,168,118,195,204,131,86,83,83,32,90,221,132,118,242,32,60,215,255,231,227,69,26,211,0,238,219,13,201,242,27,183,76,251,117,59,5,13,224,73,11,245,144,125,225,219,27,34,56,188,153,118,49,119,131,237,26,122,26,117,25,247,250,36,237,13,251,160,154,108,50,14,128,55,252,79,241,90,51,108,77,162,87,54,209,217,193,197,84,169,7,120,34,68,123,53,198,185,26,150,54,8,118,114,189,199,0,181,43,2,251,13,79,53,110,102,8,8,189,31,22,138,15,158,160,16,43,19,128,242,89,33,244,11,70,181}; + +static const uint8_t T6_ROOT[4] = {10,218,78,212}; + +static const uint16_t T6_POFF[256] = {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,480,512,544,576,608,640,672,704,736,768,800,832,864,896,928,960,992,1024,1056,1088,1120,1152,1184,1216,1248,1280,1312,1344,1376,1408,1440,1472,1504,1536,1568,1600,1632,1664,1696,1728,1760,1792,1824,1856,1888,1920,1952,1984,2016,2048,2080,2112,2144,2176,2208,2240,2272,2304,2336,2368,2400,2432,2464,2496,2528,2560,2592,2624,2656,2688,2720,2752,2784,2816,2848,2880,2912,2944,2976,3008,3040,3072,3104,3136,3168,3200,3232,3264,3296,3328,3360,3392,3424,3456,3488,3520,3552,3584,3616,3648,3680,3712,3744,3776,3808,3840,3872,3904,3936,3968,4000,4032,4064,4096,4128,4160,4192,4224,4256,4288,4320,4352,4384,4416,4448,4480,4512,4544,4576,4608,4640,4672,4704,4736,4768,4800,4832,4864,4896,4928,4960,4992,5024,5056,5088,5120,5152,5184,5216,5248,5280,5312,5344,5376,5408,5440,5472,5504,5536,5568,5600,5632,5664,5696,5728,5760,5792,5824,5856,5888,5920,5952,5984,6016,6048,6080,6112,6144,6176,6208,6240,6272,6304,6336,6368,6400,6432,6464,6496,6528,6560,6592,6624,6656,6688,6720,6752,6784,6816,6848,6880,6912,6944,6976,7008,7040,7072,7104,7136,7168,7200,7232,7264,7296,7328,7360,7392,7424,7456,7488,7520,7552,7584,7616,7648,7680,7712,7744,7776,7808,7840,7872,7904,7936,7968,8000,8032,8064,8096,8128,8160}; +static const uint8_t T6_PNSIB[256] = {8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8}; +static const uint8_t T6_PBLOB[8192] = {112,181,234,109,61,1,12,254,33,187,164,242,39,169,252,55,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,140,30,28,139,61,1,12,254,33,187,164,242,39,169,252,55,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,91,147,16,79,201,152,239,203,33,187,164,242,39,169,252,55,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,189,248,70,203,201,152,239,203,33,187,164,242,39,169,252,55,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,227,25,226,179,173,126,189,138,120,56,19,180,39,169,252,55,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,160,214,180,247,173,126,189,138,120,56,19,180,39,169,252,55,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,29,218,24,245,135,255,44,188,120,56,19,180,39,169,252,55,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,212,216,74,183,135,255,44,188,120,56,19,180,39,169,252,55,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,246,98,88,70,236,139,173,115,56,194,247,25,44,119,165,187,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,174,86,29,161,236,139,173,115,56,194,247,25,44,119,165,187,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,2,118,183,123,101,83,76,9,56,194,247,25,44,119,165,187,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,57,109,6,63,101,83,76,9,56,194,247,25,44,119,165,187,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,240,42,222,210,128,122,161,242,120,133,88,237,44,119,165,187,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,179,170,29,164,128,122,161,242,120,133,88,237,44,119,165,187,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,140,58,40,230,12,204,61,48,120,133,88,237,44,119,165,187,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,44,221,150,34,12,204,61,48,120,133,88,237,44,119,165,187,151,142,28,255,20,91,128,192,110,91,64,66,11,50,110,46,70,200,235,154,155,192,177,60,14,228,38,70,8,205,156,178,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,34,40,243,221,155,192,177,60,14,228,38,70,8,205,156,178,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,26,73,239,10,164,82,17,53,14,228,38,70,8,205,156,178,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,222,245,150,142,164,82,17,53,14,228,38,70,8,205,156,178,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,237,164,108,108,158,68,74,89,73,205,248,16,8,205,156,178,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,149,160,70,187,158,68,74,89,73,205,248,16,8,205,156,178,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,38,207,198,61,89,73,17,146,73,205,248,16,8,205,156,178,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,255,97,11,186,89,73,17,146,73,205,248,16,8,205,156,178,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,140,118,171,135,145,169,118,133,95,35,5,66,212,234,181,1,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,150,120,191,174,145,169,118,133,95,35,5,66,212,234,181,1,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,134,125,154,211,163,128,131,192,95,35,5,66,212,234,181,1,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,98,134,144,226,163,128,131,192,95,35,5,66,212,234,181,1,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,239,161,238,1,158,10,68,7,182,80,56,25,212,234,181,1,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,144,180,156,190,158,10,68,7,182,80,56,25,212,234,181,1,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,205,156,159,243,136,66,47,18,182,80,56,25,212,234,181,1,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,12,58,108,180,136,66,47,18,182,80,56,25,212,234,181,1,175,42,80,15,20,91,128,192,110,91,64,66,11,50,110,46,48,2,67,107,248,10,239,42,204,110,154,236,208,111,42,78,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,234,143,100,122,248,10,239,42,204,110,154,236,208,111,42,78,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,11,230,64,17,246,211,40,32,204,110,154,236,208,111,42,78,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,16,94,165,53,246,211,40,32,204,110,154,236,208,111,42,78,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,215,106,87,57,152,82,220,235,137,94,251,72,208,111,42,78,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,156,108,188,173,152,82,220,235,137,94,251,72,208,111,42,78,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,84,165,105,235,140,26,155,3,137,94,251,72,208,111,42,78,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,40,134,87,49,140,26,155,3,137,94,251,72,208,111,42,78,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,254,223,71,12,132,90,115,110,234,251,207,116,249,181,216,28,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,101,114,152,214,132,90,115,110,234,251,207,116,249,181,216,28,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,204,140,153,139,137,178,153,49,234,251,207,116,249,181,216,28,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,185,117,113,106,137,178,153,49,234,251,207,116,249,181,216,28,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,219,162,40,74,69,228,101,168,223,175,27,248,249,181,216,28,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,17,99,242,43,69,228,101,168,223,175,27,248,249,181,216,28,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,193,244,177,243,125,249,212,200,223,175,27,248,249,181,216,28,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,235,167,12,139,125,249,212,200,223,175,27,248,249,181,216,28,192,126,161,111,46,33,156,185,110,91,64,66,11,50,110,46,3,244,187,19,94,151,244,19,107,129,211,179,113,136,247,118,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,168,241,35,162,94,151,244,19,107,129,211,179,113,136,247,118,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,125,10,54,219,202,36,212,89,107,129,211,179,113,136,247,118,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,8,31,0,50,202,36,212,89,107,129,211,179,113,136,247,118,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,98,85,123,253,26,197,238,204,90,36,254,87,113,136,247,118,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,128,111,71,120,26,197,238,204,90,36,254,87,113,136,247,118,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,28,74,181,193,127,14,113,74,90,36,254,87,113,136,247,118,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,109,114,78,90,127,14,113,74,90,36,254,87,113,136,247,118,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,52,9,11,168,169,44,254,214,66,244,207,42,59,29,246,54,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,78,119,202,25,169,44,254,214,66,244,207,42,59,29,246,54,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,163,38,76,46,97,244,180,89,66,244,207,42,59,29,246,54,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,104,102,167,195,97,244,180,89,66,244,207,42,59,29,246,54,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,73,42,118,156,79,101,8,131,93,71,48,66,59,29,246,54,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,244,20,10,239,79,101,8,131,93,71,48,66,59,29,246,54,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,169,77,215,85,169,129,185,199,93,71,48,66,59,29,246,54,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,35,123,44,47,169,129,185,199,93,71,48,66,59,29,246,54,185,81,249,212,46,33,156,185,110,91,64,66,11,50,110,46,117,78,236,245,235,154,192,111,240,18,230,218,49,34,73,109,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,5,158,206,234,235,154,192,111,240,18,230,218,49,34,73,109,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,27,94,66,124,233,56,213,248,240,18,230,218,49,34,73,109,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,199,90,190,233,233,56,213,248,240,18,230,218,49,34,73,109,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,176,49,232,25,220,128,15,34,230,236,117,104,49,34,73,109,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,125,216,144,206,220,128,15,34,230,236,117,104,49,34,73,109,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,1,188,162,37,203,208,234,75,230,236,117,104,49,34,73,109,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,240,96,71,166,203,208,234,75,230,236,117,104,49,34,73,109,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,202,140,244,166,94,202,124,71,119,27,207,13,109,180,97,35,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,52,170,95,214,94,202,124,71,119,27,207,13,109,180,97,35,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,200,200,184,216,10,151,94,242,119,27,207,13,109,180,97,35,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,202,197,31,175,10,151,94,242,119,27,207,13,109,180,97,35,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,0,214,101,183,3,71,78,156,125,228,213,164,109,180,97,35,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,89,16,76,83,3,71,78,156,125,228,213,164,109,180,97,35,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,152,185,199,196,153,28,104,1,125,228,213,164,109,180,97,35,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,191,58,24,205,153,28,104,1,125,228,213,164,109,180,97,35,181,47,173,43,69,90,182,188,13,119,131,192,11,50,110,46,167,47,174,166,133,151,46,226,42,176,96,146,69,205,119,196,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,158,173,204,151,133,151,46,226,42,176,96,146,69,205,119,196,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,153,242,69,204,33,228,244,127,42,176,96,146,69,205,119,196,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,166,219,25,142,33,228,244,127,42,176,96,146,69,205,119,196,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,72,139,123,35,150,96,253,48,201,147,77,187,69,205,119,196,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,213,20,122,92,150,96,253,48,201,147,77,187,69,205,119,196,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,16,59,48,232,68,185,0,27,201,147,77,187,69,205,119,196,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,174,151,61,167,68,185,0,27,201,147,77,187,69,205,119,196,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,29,237,20,185,229,214,255,73,23,131,74,221,194,223,146,194,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,207,11,215,131,229,214,255,73,23,131,74,221,194,223,146,194,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,73,249,8,193,142,154,168,78,23,131,74,221,194,223,146,194,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,230,248,162,116,142,154,168,78,23,131,74,221,194,223,146,194,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,30,200,86,10,109,134,40,163,227,231,120,235,194,223,146,194,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,17,122,162,2,109,134,40,163,227,231,120,235,194,223,146,194,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,91,129,245,134,86,43,234,76,227,231,120,235,194,223,146,194,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,211,163,22,176,86,43,234,76,227,231,120,235,194,223,146,194,160,113,89,231,69,90,182,188,13,119,131,192,11,50,110,46,99,121,51,181,87,196,85,145,88,254,58,219,68,225,163,175,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,24,251,148,174,87,196,85,145,88,254,58,219,68,225,163,175,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,71,206,178,16,95,6,2,213,88,254,58,219,68,225,163,175,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,210,28,91,5,95,6,2,213,88,254,58,219,68,225,163,175,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,1,52,173,144,237,118,80,254,72,165,67,184,68,225,163,175,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,152,119,134,224,237,118,80,254,72,165,67,184,68,225,163,175,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,29,48,99,59,197,94,52,174,72,165,67,184,68,225,163,175,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,205,28,218,5,197,94,52,174,72,165,67,184,68,225,163,175,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,8,246,1,98,170,186,235,80,84,146,181,196,215,183,224,153,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,245,188,174,66,170,186,235,80,84,146,181,196,215,183,224,153,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,195,166,105,161,202,194,96,248,84,146,181,196,215,183,224,153,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,79,31,195,126,202,194,96,248,84,146,181,196,215,183,224,153,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,186,171,239,170,244,54,50,8,202,28,238,117,215,183,224,153,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,123,146,111,78,244,54,50,8,202,28,238,117,215,183,224,153,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,123,130,25,202,234,2,144,51,202,28,238,117,215,183,224,153,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,88,104,171,67,234,2,144,51,202,28,238,117,215,183,224,153,55,106,44,53,36,70,252,155,13,119,131,192,11,50,110,46,225,39,215,152,207,242,127,202,42,74,199,130,90,255,186,65,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,36,167,154,238,207,242,127,202,42,74,199,130,90,255,186,65,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,38,134,48,83,104,123,243,232,42,74,199,130,90,255,186,65,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,97,177,82,216,104,123,243,232,42,74,199,130,90,255,186,65,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,97,164,142,64,126,233,6,137,167,204,43,160,90,255,186,65,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,21,132,181,183,126,233,6,137,167,204,43,160,90,255,186,65,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,76,126,37,4,200,38,101,97,167,204,43,160,90,255,186,65,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,211,142,129,160,200,38,101,97,167,204,43,160,90,255,186,65,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,206,78,107,67,79,168,90,42,1,107,110,249,76,250,12,7,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,25,250,177,60,79,168,90,42,1,107,110,249,76,250,12,7,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,22,42,14,35,225,182,62,86,1,107,110,249,76,250,12,7,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,60,48,109,132,225,182,62,86,1,107,110,249,76,250,12,7,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,174,168,77,194,114,252,130,194,92,96,157,227,76,250,12,7,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,31,107,190,9,114,252,130,194,92,96,157,227,76,250,12,7,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,230,216,74,121,36,64,151,125,92,96,157,227,76,250,12,7,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,252,126,158,68,36,64,151,125,92,96,157,227,76,250,12,7,253,241,16,85,36,70,252,155,13,119,131,192,11,50,110,46,13,230,124,118,17,156,215,202,183,49,105,235,215,51,80,145,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,1,20,130,34,17,156,215,202,183,49,105,235,215,51,80,145,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,32,221,48,116,36,250,74,15,183,49,105,235,215,51,80,145,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,63,95,167,113,36,250,74,15,183,49,105,235,215,51,80,145,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,169,207,209,44,18,101,254,55,135,197,25,81,215,51,80,145,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,23,12,240,245,18,101,254,55,135,197,25,81,215,51,80,145,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,210,175,232,112,231,137,163,84,135,197,25,81,215,51,80,145,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,166,94,127,63,231,137,163,84,135,197,25,81,215,51,80,145,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,14,93,152,208,42,201,125,57,85,173,43,21,129,232,137,147,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,46,53,192,226,42,201,125,57,85,173,43,21,129,232,137,147,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,249,48,209,230,27,246,163,220,85,173,43,21,129,232,137,147,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,26,123,5,72,27,246,163,220,85,173,43,21,129,232,137,147,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,179,126,101,6,84,20,12,42,18,232,75,10,129,232,137,147,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,232,165,48,43,84,20,12,42,18,232,75,10,129,232,137,147,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,34,165,130,235,198,44,224,37,18,232,75,10,129,232,137,147,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,6,32,139,240,198,44,224,37,18,232,75,10,129,232,137,147,139,170,98,148,168,231,5,161,169,49,25,41,205,145,153,193,237,233,7,132,34,148,45,218,205,140,108,59,178,172,196,88,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,221,88,169,2,34,148,45,218,205,140,108,59,178,172,196,88,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,154,157,80,249,138,243,53,229,205,140,108,59,178,172,196,88,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,223,53,21,123,138,243,53,229,205,140,108,59,178,172,196,88,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,24,201,152,48,77,11,238,45,47,105,248,72,178,172,196,88,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,223,99,236,125,77,11,238,45,47,105,248,72,178,172,196,88,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,9,96,140,175,11,32,118,46,47,105,248,72,178,172,196,88,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,250,227,240,143,11,32,118,46,47,105,248,72,178,172,196,88,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,89,231,69,134,170,55,205,13,225,0,77,244,145,124,231,103,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,122,0,252,131,170,55,205,13,225,0,77,244,145,124,231,103,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,169,149,133,58,8,52,141,54,225,0,77,244,145,124,231,103,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,174,100,160,121,8,52,141,54,225,0,77,244,145,124,231,103,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,253,115,9,78,253,6,237,133,242,199,92,176,145,124,231,103,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,128,154,161,213,253,6,237,133,242,199,92,176,145,124,231,103,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,144,39,254,0,138,111,241,58,242,199,92,176,145,124,231,103,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,17,162,36,204,138,111,241,58,242,199,92,176,145,124,231,103,124,98,133,186,168,231,5,161,169,49,25,41,205,145,153,193,145,210,170,33,178,23,38,4,249,81,224,211,160,149,210,156,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,202,10,231,163,178,23,38,4,249,81,224,211,160,149,210,156,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,149,65,26,52,53,143,130,185,249,81,224,211,160,149,210,156,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,99,34,51,113,53,143,130,185,249,81,224,211,160,149,210,156,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,29,16,14,2,184,254,73,5,136,27,21,135,160,149,210,156,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,97,21,41,130,184,254,73,5,136,27,21,135,160,149,210,156,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,187,59,211,67,136,22,241,209,136,27,21,135,160,149,210,156,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,224,227,56,163,136,22,241,209,136,27,21,135,160,149,210,156,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,64,72,173,170,66,192,129,16,61,45,220,54,214,237,112,183,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,23,244,16,132,66,192,129,16,61,45,220,54,214,237,112,183,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,49,245,173,189,156,87,248,186,61,45,220,54,214,237,112,183,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,144,118,245,143,156,87,248,186,61,45,220,54,214,237,112,183,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,182,244,204,65,238,158,136,206,182,187,182,151,214,237,112,183,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,32,108,165,42,238,158,136,206,182,187,182,151,214,237,112,183,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,173,189,141,102,147,196,149,176,182,187,182,151,214,237,112,183,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,246,192,37,126,147,196,149,176,182,187,182,151,214,237,112,183,151,119,3,93,184,170,201,21,169,49,25,41,205,145,153,193,243,79,2,122,92,204,93,90,204,88,124,201,60,130,205,15,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,42,108,224,229,92,204,93,90,204,88,124,201,60,130,205,15,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,74,193,250,241,54,84,165,173,204,88,124,201,60,130,205,15,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,50,173,7,109,54,84,165,173,204,88,124,201,60,130,205,15,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,191,252,45,227,225,175,9,37,8,140,232,231,60,130,205,15,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,62,119,175,121,225,175,9,37,8,140,232,231,60,130,205,15,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,47,51,38,223,133,178,119,244,8,140,232,231,60,130,205,15,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,1,178,83,242,133,178,119,244,8,140,232,231,60,130,205,15,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,43,190,11,27,44,226,61,236,100,101,157,254,86,254,208,218,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,124,72,20,198,44,226,61,236,100,101,157,254,86,254,208,218,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,14,88,191,54,173,170,78,64,100,101,157,254,86,254,208,218,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,198,20,180,133,173,170,78,64,100,101,157,254,86,254,208,218,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,86,153,4,30,192,111,140,96,80,35,205,94,86,254,208,218,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,150,173,116,181,192,111,140,96,80,35,205,94,86,254,208,218,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,221,6,67,158,137,248,10,193,80,35,205,94,86,254,208,218,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,100,151,106,29,137,248,10,193,80,35,205,94,86,254,208,218,127,121,251,11,184,170,201,21,169,49,25,41,205,145,153,193,88,83,106,181,176,46,58,108,158,69,241,23,131,185,71,239,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,161,230,124,15,176,46,58,108,158,69,241,23,131,185,71,239,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,16,18,120,121,20,157,197,130,158,69,241,23,131,185,71,239,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,58,198,103,66,20,157,197,130,158,69,241,23,131,185,71,239,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,57,196,42,236,188,201,76,45,180,210,216,181,131,185,71,239,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,81,131,20,21,188,201,76,45,180,210,216,181,131,185,71,239,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,206,207,152,201,155,240,76,139,180,210,216,181,131,185,71,239,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,254,91,123,120,155,240,76,139,180,210,216,181,131,185,71,239,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,182,125,143,86,188,11,230,127,58,74,252,219,243,220,247,115,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,32,88,58,158,188,11,230,127,58,74,252,219,243,220,247,115,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,187,57,85,90,11,131,61,239,58,74,252,219,243,220,247,115,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,40,251,141,75,11,131,61,239,58,74,252,219,243,220,247,115,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,116,232,18,4,37,43,67,225,144,156,101,124,243,220,247,115,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,76,77,62,226,37,43,67,225,144,156,101,124,243,220,247,115,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,216,65,104,210,141,5,173,175,144,156,101,124,243,220,247,115,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,109,141,210,161,141,5,173,175,144,156,101,124,243,220,247,115,249,90,208,219,50,56,128,16,39,36,114,140,205,145,153,193,238,226,2,92,42,239,5,81,77,101,160,124,120,171,179,254,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,138,24,186,238,42,239,5,81,77,101,160,124,120,171,179,254,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,8,158,91,229,207,11,159,198,77,101,160,124,120,171,179,254,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,49,35,250,235,207,11,159,198,77,101,160,124,120,171,179,254,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,54,112,81,75,32,156,170,201,175,73,239,231,120,171,179,254,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,28,150,74,93,32,156,170,201,175,73,239,231,120,171,179,254,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,155,189,6,233,10,239,214,233,175,73,239,231,120,171,179,254,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,223,55,136,55,10,239,214,233,175,73,239,231,120,171,179,254,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,111,154,180,28,25,229,39,173,135,72,150,61,147,214,199,152,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,116,184,247,71,25,229,39,173,135,72,150,61,147,214,199,152,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,75,249,199,13,48,182,150,175,135,72,150,61,147,214,199,152,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,143,63,60,255,48,182,150,175,135,72,150,61,147,214,199,152,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,175,246,44,216,102,52,237,10,146,220,104,237,147,214,199,152,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,97,69,87,36,102,52,237,10,146,220,104,237,147,214,199,152,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,204,131,86,83,35,22,177,96,146,220,104,237,147,214,199,152,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,61,168,118,195,35,22,177,96,146,220,104,237,147,214,199,152,113,48,110,147,50,56,128,16,39,36,114,140,205,145,153,193,132,118,242,32,140,185,38,31,244,28,217,183,43,201,19,159,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,83,32,90,221,140,185,38,31,244,28,217,183,43,201,19,159,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,227,69,26,211,68,62,78,226,244,28,217,183,43,201,19,159,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,60,215,255,231,68,62,78,226,244,28,217,183,43,201,19,159,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,201,242,27,183,96,251,95,202,200,19,188,50,43,201,19,159,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,0,238,219,13,96,251,95,202,200,19,188,50,43,201,19,159,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,5,13,224,73,145,158,120,63,200,19,188,50,43,201,19,159,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,76,251,117,59,145,158,120,63,200,19,188,50,43,201,19,159,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,225,219,27,34,167,21,105,44,50,101,172,28,137,231,135,203,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,11,245,144,125,167,21,105,44,50,101,172,28,137,231,135,203,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,49,119,131,237,24,221,50,135,50,101,172,28,137,231,135,203,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,56,188,153,118,24,221,50,135,50,101,172,28,137,231,135,203,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,25,247,250,36,202,15,38,98,231,5,85,193,137,231,135,203,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,26,122,26,117,202,15,38,98,231,5,85,193,137,231,135,203,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,154,108,50,14,83,247,163,3,231,5,85,193,137,231,135,203,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,237,13,251,160,83,247,163,3,231,5,85,193,137,231,135,203,142,40,224,45,187,74,156,253,39,36,114,140,205,145,153,193,241,90,51,108,160,86,8,3,35,42,57,2,24,12,220,46,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,128,55,252,79,160,86,8,3,35,42,57,2,24,12,220,46,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,209,217,193,197,18,124,187,233,35,42,57,2,24,12,220,46,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,77,162,87,54,18,124,187,233,35,42,57,2,24,12,220,46,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,34,68,123,53,182,252,59,195,146,136,61,177,24,12,220,46,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,84,169,7,120,182,252,59,195,146,136,61,177,24,12,220,46,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,54,8,118,114,58,164,90,159,146,136,61,177,24,12,220,46,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,198,185,26,150,58,164,90,159,146,136,61,177,24,12,220,46,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,43,2,251,13,99,37,63,226,66,59,122,13,69,38,40,64,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,189,199,0,181,99,37,63,226,66,59,122,13,69,38,40,64,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,8,8,189,31,184,65,4,129,66,59,122,13,69,38,40,64,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,79,53,110,102,184,65,4,129,66,59,122,13,69,38,40,64,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,160,16,43,19,103,77,131,14,242,113,165,227,69,38,40,64,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,22,138,15,158,103,77,131,14,242,113,165,227,69,38,40,64,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,244,11,70,181,109,53,81,138,242,113,165,227,69,38,40,64,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193,128,242,89,33,109,53,81,138,242,113,165,227,69,38,40,64,6,151,150,245,187,74,156,253,39,36,114,140,205,145,153,193}; + +struct ProofCase { uint32_t count; const uint8_t* leaves; const uint8_t* root; const uint16_t* poff; const uint8_t* pnsib; const uint8_t* pblob; }; +static const ProofCase PROOF_CASES[] = {{T0_COUNT,T0_LEAVES,T0_ROOT,T0_POFF,T0_PNSIB,T0_PBLOB},{T1_COUNT,T1_LEAVES,T1_ROOT,T1_POFF,T1_PNSIB,T1_PBLOB},{T2_COUNT,T2_LEAVES,T2_ROOT,T2_POFF,T2_PNSIB,T2_PBLOB},{T3_COUNT,T3_LEAVES,T3_ROOT,T3_POFF,T3_PNSIB,T3_PBLOB},{T4_COUNT,T4_LEAVES,T4_ROOT,T4_POFF,T4_PNSIB,T4_PBLOB},{T5_COUNT,T5_LEAVES,T5_ROOT,T5_POFF,T5_PNSIB,T5_PBLOB},{T6_COUNT,T6_LEAVES,T6_ROOT,T6_POFF,T6_PNSIB,T6_PBLOB}}; +static const int N_PROOF_CASES = 7; +// small-block signed .mota for the OtaManager host transfer simulation +static const uint8_t SIM_MOTA[2334] = {109,79,84,65,30,9,0,0,2,3,18,190,186,254,202,0,0,0,3,8,8,0,0,8,8,0,0,7,97,190,149,151,182,60,80,58,200,234,98,44,193,140,71,76,243,130,97,209,39,43,50,65,54,148,88,72,127,67,165,233,114,102,17,129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,161,7,191,243,206,16,190,29,112,221,24,231,75,192,153,103,228,214,48,155,165,13,95,29,220,134,100,18,85,49,184,38,98,213,118,187,206,236,168,51,174,162,73,89,30,161,211,77,42,34,60,159,243,83,241,213,243,188,72,94,109,154,234,68,70,87,185,215,226,224,96,146,252,13,183,118,91,107,134,241,252,255,206,215,103,126,185,188,114,49,17,62,148,194,5,255,255,255,255,95,197,98,90,98,17,7,154,48,52,162,55,106,72,59,84,136,235,135,81,243,8,241,172,4,174,251,120,121,213,89,254,16,213,235,145,157,150,188,132,125,7,184,29,126,203,177,170,175,71,66,193,125,16,43,58,126,48,74,90,30,57,43,99,175,85,112,245,103,97,51,153,45,58,63,34,194,22,64,186,98,135,175,179,137,22,240,159,125,51,107,184,156,150,55,202,230,201,95,210,99,220,174,54,38,118,169,45,217,145,86,21,242,183,135,173,198,22,120,80,103,10,68,142,1,108,52,92,253,238,136,20,118,132,230,50,155,118,250,13,91,33,55,243,235,183,41,191,202,113,152,236,251,45,241,128,169,45,9,28,5,43,121,175,209,107,20,239,108,161,22,36,79,158,1,97,84,34,133,103,51,230,201,249,14,163,54,113,65,139,103,211,195,32,90,240,177,121,236,14,33,189,221,183,153,199,191,38,155,240,104,31,24,30,36,75,44,253,45,104,37,236,53,225,143,81,197,127,204,59,216,65,30,219,210,92,47,173,18,128,73,2,149,213,12,86,55,96,102,86,210,207,102,98,106,208,94,136,23,46,225,9,236,95,184,219,102,197,113,58,79,218,167,57,167,184,79,27,223,176,184,80,55,195,207,182,172,182,63,98,75,112,192,245,20,225,112,107,246,232,65,17,128,75,232,175,223,82,201,122,136,32,238,229,65,110,225,74,104,247,168,211,156,40,72,97,173,173,154,220,252,158,170,182,112,49,97,86,227,50,88,1,170,90,177,75,246,217,49,228,170,170,43,202,163,66,168,106,190,192,221,180,59,104,220,220,88,168,102,0,28,128,136,51,0,133,79,243,172,250,191,253,42,130,200,206,113,238,52,67,191,217,189,106,119,143,135,160,158,196,161,212,195,155,196,73,51,189,5,255,26,206,78,19,148,8,246,14,106,76,94,248,142,160,242,181,150,147,75,49,193,25,253,221,203,101,102,202,44,67,117,84,32,224,33,230,114,222,217,177,179,99,107,143,244,183,45,92,64,53,70,118,146,216,227,179,97,47,211,233,239,255,122,146,228,160,227,234,121,170,43,250,19,136,61,255,117,133,3,29,84,203,126,18,85,167,187,1,145,174,136,70,162,3,149,81,105,66,42,34,150,235,12,101,9,12,87,130,58,142,193,74,40,214,112,14,178,198,106,58,206,48,29,124,43,69,70,168,93,18,143,235,50,198,143,44,179,90,167,245,208,136,20,190,173,29,185,32,211,35,38,139,22,8,194,131,165,97,42,90,222,200,183,59,157,155,194,247,156,41,87,197,13,228,87,207,160,111,48,78,45,189,28,37,127,164,247,133,187,238,3,59,96,234,174,203,24,200,203,253,60,145,113,187,202,154,223,227,20,224,209,41,224,227,214,42,198,113,95,64,80,150,11,149,101,5,76,242,40,33,241,2,225,73,207,142,75,74,31,126,109,205,18,10,90,41,155,174,81,216,85,169,83,206,212,247,8,96,208,69,156,58,140,38,177,172,4,195,220,240,73,189,102,107,131,183,230,198,58,44,134,104,253,13,54,61,165,66,41,215,145,24,111,1,144,241,7,214,51,33,230,244,46,161,76,15,253,225,65,46,148,195,110,38,0,238,164,9,128,101,239,253,250,114,18,42,150,59,87,111,33,122,234,156,23,94,128,40,59,187,146,124,53,183,218,25,111,156,51,231,204,44,34,121,188,229,63,44,215,175,65,42,166,132,172,204,129,234,222,217,139,19,60,61,134,58,175,180,107,101,134,143,18,61,64,82,196,144,85,126,48,24,203,160,7,241,9,111,15,80,48,236,12,169,74,47,68,230,236,171,65,2,147,135,75,50,185,93,29,40,88,99,36,178,78,135,66,50,115,14,241,245,6,90,59,36,155,20,213,220,97,4,91,240,81,227,96,62,137,39,199,18,5,7,45,54,56,87,158,65,194,241,18,165,0,111,29,168,111,20,177,216,249,186,94,127,108,142,224,96,196,143,231,165,67,83,182,88,206,29,69,135,62,16,238,8,56,68,83,158,26,69,224,78,159,159,62,54,113,170,113,133,4,154,190,67,19,198,98,31,188,4,72,126,195,241,230,206,180,113,109,203,237,193,82,130,255,60,154,177,136,236,223,221,27,234,73,101,198,53,17,151,236,71,116,190,125,86,255,152,21,178,5,12,144,21,162,33,220,104,49,108,226,169,168,150,148,4,5,31,204,82,55,52,170,163,254,27,3,255,110,212,240,224,73,46,214,34,209,198,176,73,255,45,180,106,26,79,215,47,192,107,98,161,24,19,68,242,134,77,64,217,252,186,40,192,70,186,31,8,191,154,212,17,64,121,100,32,227,74,153,123,55,216,255,220,197,128,78,212,114,64,128,64,162,47,117,72,38,48,84,130,32,205,128,58,157,90,154,132,18,58,142,111,200,37,146,0,86,185,201,187,102,148,203,21,2,108,22,108,117,27,21,1,49,222,238,22,198,61,76,49,29,37,187,66,181,79,44,211,142,173,164,48,22,157,28,82,6,247,214,55,76,103,85,129,10,113,166,247,64,122,138,157,89,55,89,33,11,179,83,178,233,141,241,172,233,59,217,53,207,204,160,133,154,108,183,121,245,41,154,88,142,45,186,132,216,204,136,78,5,4,155,151,88,39,32,111,11,17,136,81,244,172,142,74,213,92,44,141,84,177,244,197,176,25,186,140,75,8,170,232,87,108,50,162,40,10,44,160,23,121,100,109,222,139,139,97,95,151,164,213,236,96,66,26,235,52,251,199,90,34,16,67,174,25,235,1,94,99,80,151,60,151,31,154,170,250,74,254,238,70,104,229,33,34,170,227,251,215,33,73,248,179,169,200,196,219,242,6,140,130,136,67,36,63,105,134,141,32,67,77,111,190,98,23,214,246,88,7,229,125,58,122,166,16,127,225,77,61,199,129,253,9,32,116,207,202,17,236,90,143,244,33,247,164,237,253,90,198,189,137,250,10,16,3,212,55,185,188,238,3,115,51,164,134,195,117,127,162,183,0,55,186,11,155,56,39,252,163,110,47,227,32,248,220,234,206,140,117,73,213,155,5,197,212,184,208,8,77,14,160,8,175,63,145,100,217,95,240,194,127,195,34,72,146,89,178,228,38,176,235,8,201,84,147,210,95,137,215,51,170,106,244,173,67,45,131,65,122,215,20,99,181,105,184,253,66,245,155,77,122,0,142,44,197,249,7,179,64,59,44,231,172,224,244,182,215,4,40,135,220,56,76,65,82,100,91,102,41,226,67,95,200,42,1,39,140,118,118,71,188,214,123,161,81,187,161,45,83,145,36,176,157,12,128,102,142,171,150,39,203,245,119,54,128,30,203,176,101,252,84,197,108,136,80,84,250,55,180,16,22,57,249,160,194,63,203,253,98,40,248,62,182,104,245,244,58,87,20,47,15,185,14,22,161,120,97,55,186,249,67,112,86,129,1,244,46,167,142,254,163,109,152,223,164,111,81,70,188,245,43,159,236,36,123,145,95,176,215,34,244,123,253,113,118,46,116,175,132,124,152,152,76,137,114,157,118,199,25,123,8,247,235,230,172,116,49,31,88,125,2,97,111,227,242,80,212,15,186,50,32,224,200,31,238,232,140,109,243,138,238,193,253,222,0,28,32,150,190,48,34,244,56,197,196,64,5,88,180,249,15,245,11,196,51,9,49,56,240,154,254,52,54,132,192,1,47,118,67,121,90,212,93,88,234,230,86,62,74,4,165,115,26,42,148,244,10,210,223,239,225,54,204,223,102,234,204,72,197,208,214,94,87,47,181,173,120,85,167,77,201,165,122,165,126,3,120,7,65,137,154,23,84,27,251,239,7,243,108,182,237,236,95,176,233,237,180,0,44,95,91,93,150,86,172,69,245,81,234,190,228,243,239,236,67,99,42,154,211,59,170,79,213,233,246,137,20,22,171,123,18,201,20,174,51,28,88,99,220,82,250,56,219,62,13,214,33,141,64,205,143,101,42,215,166,1,222,87,80,48,96,68,127,188,203,45,43,224,181,148,200,224,171,5,168,15,39,8,78,252,90,120,37,15,35,73,166,90,148,66,63,80,237,61,15,63,64,110,238,28,211,153,21,206,143,45,0,163,151,175,49,81,125,98,92,35,255,157,214,250,223,198,59,54,238,109,208,130,116,71,106,246,221,224,50,114,241,58,227,192,72,132,9,183,55,223,87,248,119,200,188,52,25,141,180,183,9,44,8,253,50,69,220,217,111,3,18,22,43,4,63,22,31,19,17,20,4,185,220,235,68,204,223,209,95,199,95,44,113,98,153,12,109,46,120,50,131,118,82,236,19,90,44,176,79,168,210,78,153,10,163,55,171,51,11,131,141,80,191,166,60,156,119,28,69,220,141,106,190,54,31,8,41,123,205,30,202,192,46,51,33,43,160,109,215,19,150,232,243,219,67,20,200,61,53,213,132,196,237,137,4,173,157,112,173,155,116,158,69,190,147,248,64,132,112,33,143,197,191,249,118,137,88,239,250,192,122,192,62,202,131,155,222,27,224,34,17,222,231,164,17,43,154,60,226,223,135,32,134,149,107,194,168,74,204,4,72,98,47,171,92,224,231,153,13,18,153,50,192,130,191,64,92,33,243,39,161,69,110,100,70,208,7,0,0,250,86,224,170,102,212,176,242,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,118,107,52,57,54}; + +static const uint32_t SIM_MOTA_LEN = 2334; +static const uint32_t SIM_TARGET_ID = 0xcafebabeu; +// 1 KB-block signed .mota (multi-fragment per block) for the reassembly transfer test +static const uint8_t SIM_MOTA_1K[2278] = {109,79,84,65,230,8,0,0,2,3,18,190,186,254,202,0,0,0,3,8,8,0,0,8,8,0,0,10,164,51,202,103,182,60,80,58,200,234,98,44,193,140,71,76,243,130,97,209,39,43,50,65,54,148,88,72,127,67,165,233,114,102,17,129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,161,7,191,243,206,16,190,29,112,221,24,231,75,192,153,103,228,214,48,155,165,13,95,29,220,134,100,18,85,49,184,171,129,180,182,69,0,212,122,174,47,219,250,34,204,198,63,40,244,119,210,21,11,30,188,119,170,189,46,247,90,166,169,6,102,11,226,54,97,112,202,185,10,171,131,170,250,246,20,84,173,222,226,146,215,83,51,164,107,48,67,2,52,40,1,255,255,255,255,226,102,124,83,43,137,26,96,175,85,112,245,103,97,51,153,45,58,63,34,194,22,64,186,98,135,175,179,137,22,240,159,125,51,107,184,156,150,55,202,230,201,95,210,99,220,174,54,38,118,169,45,217,145,86,21,242,183,135,173,198,22,120,80,103,10,68,142,1,108,52,92,253,238,136,20,118,132,230,50,155,118,250,13,91,33,55,243,235,183,41,191,202,113,152,236,251,45,241,128,169,45,9,28,5,43,121,175,209,107,20,239,108,161,22,36,79,158,1,97,84,34,133,103,51,230,201,249,14,163,54,113,65,139,103,211,195,32,90,240,177,121,236,14,33,189,221,183,153,199,191,38,155,240,104,31,24,30,36,75,44,253,45,104,37,236,53,225,143,81,197,127,204,59,216,65,30,219,210,92,47,173,18,128,73,2,149,213,12,86,55,96,102,86,210,207,102,98,106,208,94,136,23,46,225,9,236,95,184,219,102,197,113,58,79,218,167,57,167,184,79,27,223,176,184,80,55,195,207,182,172,182,63,98,75,112,192,245,20,225,112,107,246,232,65,17,128,75,232,175,223,82,201,122,136,32,238,229,65,110,225,74,104,247,168,211,156,40,72,97,173,173,154,220,252,158,170,182,112,49,97,86,227,50,88,1,170,90,177,75,246,217,49,228,170,170,43,202,163,66,168,106,190,192,221,180,59,104,220,220,88,168,102,0,28,128,136,51,0,133,79,243,172,250,191,253,42,130,200,206,113,238,52,67,191,217,189,106,119,143,135,160,158,196,161,212,195,155,196,73,51,189,5,255,26,206,78,19,148,8,246,14,106,76,94,248,142,160,242,181,150,147,75,49,193,25,253,221,203,101,102,202,44,67,117,84,32,224,33,230,114,222,217,177,179,99,107,143,244,183,45,92,64,53,70,118,146,216,227,179,97,47,211,233,239,255,122,146,228,160,227,234,121,170,43,250,19,136,61,255,117,133,3,29,84,203,126,18,85,167,187,1,145,174,136,70,162,3,149,81,105,66,42,34,150,235,12,101,9,12,87,130,58,142,193,74,40,214,112,14,178,198,106,58,206,48,29,124,43,69,70,168,93,18,143,235,50,198,143,44,179,90,167,245,208,136,20,190,173,29,185,32,211,35,38,139,22,8,194,131,165,97,42,90,222,200,183,59,157,155,194,247,156,41,87,197,13,228,87,207,160,111,48,78,45,189,28,37,127,164,247,133,187,238,3,59,96,234,174,203,24,200,203,253,60,145,113,187,202,154,223,227,20,224,209,41,224,227,214,42,198,113,95,64,80,150,11,149,101,5,76,242,40,33,241,2,225,73,207,142,75,74,31,126,109,205,18,10,90,41,155,174,81,216,85,169,83,206,212,247,8,96,208,69,156,58,140,38,177,172,4,195,220,240,73,189,102,107,131,183,230,198,58,44,134,104,253,13,54,61,165,66,41,215,145,24,111,1,144,241,7,214,51,33,230,244,46,161,76,15,253,225,65,46,148,195,110,38,0,238,164,9,128,101,239,253,250,114,18,42,150,59,87,111,33,122,234,156,23,94,128,40,59,187,146,124,53,183,218,25,111,156,51,231,204,44,34,121,188,229,63,44,215,175,65,42,166,132,172,204,129,234,222,217,139,19,60,61,134,58,175,180,107,101,134,143,18,61,64,82,196,144,85,126,48,24,203,160,7,241,9,111,15,80,48,236,12,169,74,47,68,230,236,171,65,2,147,135,75,50,185,93,29,40,88,99,36,178,78,135,66,50,115,14,241,245,6,90,59,36,155,20,213,220,97,4,91,240,81,227,96,62,137,39,199,18,5,7,45,54,56,87,158,65,194,241,18,165,0,111,29,168,111,20,177,216,249,186,94,127,108,142,224,96,196,143,231,165,67,83,182,88,206,29,69,135,62,16,238,8,56,68,83,158,26,69,224,78,159,159,62,54,113,170,113,133,4,154,190,67,19,198,98,31,188,4,72,126,195,241,230,206,180,113,109,203,237,193,82,130,255,60,154,177,136,236,223,221,27,234,73,101,198,53,17,151,236,71,116,190,125,86,255,152,21,178,5,12,144,21,162,33,220,104,49,108,226,169,168,150,148,4,5,31,204,82,55,52,170,163,254,27,3,255,110,212,240,224,73,46,214,34,209,198,176,73,255,45,180,106,26,79,215,47,192,107,98,161,24,19,68,242,134,77,64,217,252,186,40,192,70,186,31,8,191,154,212,17,64,121,100,32,227,74,153,123,55,216,255,220,197,128,78,212,114,64,128,64,162,47,117,72,38,48,84,130,32,205,128,58,157,90,154,132,18,58,142,111,200,37,146,0,86,185,201,187,102,148,203,21,2,108,22,108,117,27,21,1,49,222,238,22,198,61,76,49,29,37,187,66,181,79,44,211,142,173,164,48,22,157,28,82,6,247,214,55,76,103,85,129,10,113,166,247,64,122,138,157,89,55,89,33,11,179,83,178,233,141,241,172,233,59,217,53,207,204,160,133,154,108,183,121,245,41,154,88,142,45,186,132,216,204,136,78,5,4,155,151,88,39,32,111,11,17,136,81,244,172,142,74,213,92,44,141,84,177,244,197,176,25,186,140,75,8,170,232,87,108,50,162,40,10,44,160,23,121,100,109,222,139,139,97,95,151,164,213,236,96,66,26,235,52,251,199,90,34,16,67,174,25,235,1,94,99,80,151,60,151,31,154,170,250,74,254,238,70,104,229,33,34,170,227,251,215,33,73,248,179,169,200,196,219,242,6,140,130,136,67,36,63,105,134,141,32,67,77,111,190,98,23,214,246,88,7,229,125,58,122,166,16,127,225,77,61,199,129,253,9,32,116,207,202,17,236,90,143,244,33,247,164,237,253,90,198,189,137,250,10,16,3,212,55,185,188,238,3,115,51,164,134,195,117,127,162,183,0,55,186,11,155,56,39,252,163,110,47,227,32,248,220,234,206,140,117,73,213,155,5,197,212,184,208,8,77,14,160,8,175,63,145,100,217,95,240,194,127,195,34,72,146,89,178,228,38,176,235,8,201,84,147,210,95,137,215,51,170,106,244,173,67,45,131,65,122,215,20,99,181,105,184,253,66,245,155,77,122,0,142,44,197,249,7,179,64,59,44,231,172,224,244,182,215,4,40,135,220,56,76,65,82,100,91,102,41,226,67,95,200,42,1,39,140,118,118,71,188,214,123,161,81,187,161,45,83,145,36,176,157,12,128,102,142,171,150,39,203,245,119,54,128,30,203,176,101,252,84,197,108,136,80,84,250,55,180,16,22,57,249,160,194,63,203,253,98,40,248,62,182,104,245,244,58,87,20,47,15,185,14,22,161,120,97,55,186,249,67,112,86,129,1,244,46,167,142,254,163,109,152,223,164,111,81,70,188,245,43,159,236,36,123,145,95,176,215,34,244,123,253,113,118,46,116,175,132,124,152,152,76,137,114,157,118,199,25,123,8,247,235,230,172,116,49,31,88,125,2,97,111,227,242,80,212,15,186,50,32,224,200,31,238,232,140,109,243,138,238,193,253,222,0,28,32,150,190,48,34,244,56,197,196,64,5,88,180,249,15,245,11,196,51,9,49,56,240,154,254,52,54,132,192,1,47,118,67,121,90,212,93,88,234,230,86,62,74,4,165,115,26,42,148,244,10,210,223,239,225,54,204,223,102,234,204,72,197,208,214,94,87,47,181,173,120,85,167,77,201,165,122,165,126,3,120,7,65,137,154,23,84,27,251,239,7,243,108,182,237,236,95,176,233,237,180,0,44,95,91,93,150,86,172,69,245,81,234,190,228,243,239,236,67,99,42,154,211,59,170,79,213,233,246,137,20,22,171,123,18,201,20,174,51,28,88,99,220,82,250,56,219,62,13,214,33,141,64,205,143,101,42,215,166,1,222,87,80,48,96,68,127,188,203,45,43,224,181,148,200,224,171,5,168,15,39,8,78,252,90,120,37,15,35,73,166,90,148,66,63,80,237,61,15,63,64,110,238,28,211,153,21,206,143,45,0,163,151,175,49,81,125,98,92,35,255,157,214,250,223,198,59,54,238,109,208,130,116,71,106,246,221,224,50,114,241,58,227,192,72,132,9,183,55,223,87,248,119,200,188,52,25,141,180,183,9,44,8,253,50,69,220,217,111,3,18,22,43,4,63,22,31,19,17,20,4,185,220,235,68,204,223,209,95,199,95,44,113,98,153,12,109,46,120,50,131,118,82,236,19,90,44,176,79,168,210,78,153,10,163,55,171,51,11,131,141,80,191,166,60,156,119,28,69,220,141,106,190,54,31,8,41,123,205,30,202,192,46,51,33,43,160,109,215,19,150,232,243,219,67,20,200,61,53,213,132,196,237,137,4,173,157,112,173,155,116,158,69,190,147,248,64,132,112,33,143,197,191,249,118,137,88,239,250,192,122,192,62,202,131,155,222,27,224,34,17,222,231,164,17,43,154,60,226,223,135,32,134,149,107,194,168,74,204,4,72,98,47,171,92,224,231,153,13,18,153,50,192,130,191,64,92,33,243,39,161,69,110,100,70,208,7,0,0,250,86,224,170,102,212,176,242,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,118,107,52,57,54}; + +static const uint32_t SIM_MOTA_1K_LEN = 2278; +static const uint32_t SIM_MOTA_1K_BLOCKS = 3; +// detools sequential+crle delta: apply DT_PATCH to DT_BASE -> DT_TARGET +static const uint8_t DT_BASE[3056] = {120,46,186,148,77,51,227,185,104,193,183,194,67,136,62,162,208,188,127,90,106,134,186,157,246,55,79,139,180,84,132,19,187,198,255,221,52,176,192,186,119,236,181,212,223,167,37,136,54,222,105,250,14,197,89,160,106,119,31,185,190,35,195,83,99,84,88,203,51,83,109,106,81,145,54,231,222,104,58,52,10,191,57,195,4,248,221,66,216,129,81,197,245,145,205,180,107,157,28,84,217,167,155,199,59,60,254,118,93,34,51,94,126,152,214,160,36,67,99,159,86,85,240,181,255,182,119,220,43,175,178,196,220,33,84,236,52,148,175,16,25,240,215,44,1,230,38,112,180,60,89,58,20,50,205,72,61,177,118,154,67,123,134,225,111,169,248,106,51,215,18,77,77,71,34,144,169,187,64,134,25,126,55,228,50,200,99,45,131,217,57,81,90,192,179,228,204,11,148,230,238,173,139,96,239,189,184,243,162,18,30,58,14,132,32,241,212,53,232,162,157,236,22,242,129,44,60,124,149,204,187,42,41,22,32,158,26,207,241,152,143,207,254,154,161,7,152,27,143,46,139,178,80,0,31,71,7,46,15,26,162,219,159,172,158,187,53,148,53,165,48,118,47,121,80,69,187,116,162,112,213,183,206,210,55,102,150,221,114,221,107,152,179,34,225,53,41,79,101,50,192,45,91,116,175,3,30,85,172,0,197,57,192,129,107,168,249,9,54,155,118,141,127,140,206,12,110,85,2,130,87,141,249,230,240,224,65,170,187,40,57,154,248,27,211,203,216,110,17,245,225,34,44,6,220,86,78,242,234,64,126,41,92,213,119,237,111,241,125,157,83,40,9,197,31,30,93,108,162,244,46,129,180,24,13,168,111,228,6,207,233,227,240,69,59,30,81,139,222,145,35,54,145,149,27,110,26,241,153,180,178,68,111,143,40,195,59,240,0,131,31,50,96,137,146,104,114,146,201,44,212,165,236,63,141,235,195,74,230,208,70,151,91,115,163,28,103,101,194,72,81,128,133,58,60,210,199,206,91,58,107,201,119,146,79,73,245,172,175,236,49,119,165,138,13,64,97,211,166,53,67,105,132,34,167,80,72,176,137,206,241,34,195,23,129,56,118,155,71,75,63,165,132,99,189,72,244,47,246,228,233,247,122,206,93,247,7,152,165,96,177,16,193,185,231,34,25,108,156,82,48,255,196,244,244,19,194,148,65,8,206,163,198,66,171,217,133,48,241,218,204,111,42,49,182,120,211,68,17,118,31,25,151,68,33,191,98,200,250,150,212,165,25,57,193,149,60,42,75,166,229,35,209,177,238,206,98,175,27,249,33,86,105,84,161,179,85,140,210,192,60,5,154,71,97,35,145,68,43,129,204,230,65,55,225,230,140,33,179,109,189,138,48,32,208,33,172,177,59,64,6,163,157,173,28,251,108,135,107,8,121,39,70,182,92,118,88,74,123,227,173,148,114,232,141,165,8,174,233,72,47,98,166,229,126,163,92,128,124,93,240,40,16,129,188,248,249,141,68,50,46,112,119,83,159,1,36,188,29,108,12,72,193,168,191,20,181,224,21,171,122,118,241,53,134,128,172,191,216,59,171,163,169,80,167,131,162,77,124,75,148,14,173,54,172,186,138,121,182,62,79,166,255,80,64,84,10,35,159,137,202,138,66,88,88,38,13,89,3,158,80,192,80,50,47,239,72,206,116,135,12,251,40,25,201,123,163,67,100,13,105,51,174,34,34,93,3,115,92,192,106,231,63,31,87,218,156,115,83,1,188,172,152,212,206,133,105,183,160,198,113,51,32,213,29,130,254,173,239,245,104,126,255,101,127,115,186,56,236,11,217,178,248,114,215,168,163,134,209,19,244,68,229,206,194,29,94,160,221,137,217,92,17,83,227,202,123,155,151,121,220,191,199,202,241,205,234,70,164,104,185,211,96,128,163,65,230,28,4,63,219,134,230,237,183,181,229,109,41,192,38,48,3,205,3,69,15,27,85,41,249,58,60,229,132,70,199,19,39,247,213,215,10,64,234,230,209,250,91,21,134,94,143,43,27,92,64,200,3,206,207,147,130,194,137,110,114,158,192,62,200,9,173,197,36,195,222,90,68,139,0,117,232,231,62,93,112,14,37,53,86,17,150,199,31,117,20,200,185,21,58,0,193,20,229,210,41,161,119,53,225,179,50,59,120,212,104,243,159,148,20,197,167,106,194,135,192,98,133,68,210,210,227,227,161,183,180,36,62,92,189,50,39,122,5,177,246,255,185,32,70,105,173,233,213,61,174,111,102,212,174,40,98,96,113,237,146,163,30,186,69,139,67,157,37,83,30,161,170,92,20,88,126,31,148,49,32,133,35,206,117,26,155,154,102,119,184,196,144,146,104,188,112,247,229,124,82,237,146,81,215,157,134,60,215,44,249,56,157,202,243,236,105,6,130,117,190,131,93,11,78,190,251,41,176,233,229,147,70,59,56,145,165,174,147,111,242,160,241,201,203,118,88,132,232,178,22,117,168,133,225,76,86,240,4,246,158,51,191,121,245,52,164,72,112,109,131,246,21,37,123,166,143,107,76,69,128,184,87,200,23,39,48,21,138,248,161,140,8,151,174,127,172,55,217,205,164,191,41,40,21,65,102,38,231,245,193,137,82,79,200,219,185,83,168,181,87,125,247,47,112,61,195,99,115,20,131,186,193,11,9,106,72,43,175,52,216,11,212,247,27,151,35,162,53,237,20,208,201,47,218,30,26,86,4,185,26,142,255,250,59,219,212,222,152,155,131,117,49,122,51,2,78,187,225,215,90,99,196,255,71,7,19,218,205,190,132,213,178,193,114,94,81,104,244,138,51,254,116,38,23,73,190,214,169,31,220,41,172,172,205,57,159,93,237,199,135,219,63,101,42,222,90,192,55,33,98,171,182,18,47,63,214,206,6,76,251,28,178,150,174,154,63,127,87,170,172,107,230,55,12,253,165,15,70,55,191,80,114,158,203,222,55,160,212,2,147,59,21,136,61,126,64,193,123,132,221,255,44,162,133,94,13,143,204,9,115,165,105,81,111,100,16,20,44,80,204,209,171,181,144,67,195,225,253,33,209,171,193,155,183,25,142,150,232,170,231,94,127,241,58,4,97,162,46,174,96,95,35,15,98,225,46,228,222,216,179,230,92,153,238,220,253,247,20,57,60,168,242,236,186,70,34,78,184,1,123,95,111,107,91,156,13,3,71,10,125,232,250,215,249,13,223,48,132,48,156,61,129,121,46,148,222,129,228,3,189,217,19,25,6,29,125,180,13,205,152,222,79,198,73,205,97,155,156,229,15,195,235,128,254,9,137,30,63,146,187,223,104,18,14,16,87,252,21,24,8,109,65,199,160,20,169,27,205,213,146,211,166,109,129,203,224,196,235,198,154,251,215,11,228,122,121,254,118,28,97,98,132,36,48,194,97,45,127,162,252,193,144,38,51,235,54,12,75,128,236,76,100,184,5,223,113,92,189,7,229,144,154,126,214,210,14,217,255,3,240,73,227,232,82,220,33,93,55,112,7,32,76,178,247,134,245,50,157,101,68,55,237,191,114,53,220,235,56,124,190,163,8,192,216,1,26,101,153,181,14,174,1,213,255,111,61,46,65,109,153,124,203,111,65,13,206,176,115,10,245,43,152,144,152,119,211,90,150,27,127,253,111,51,198,47,247,9,224,245,233,188,100,81,18,83,249,180,142,84,249,109,215,178,75,102,203,163,250,154,185,204,231,27,239,194,79,230,120,16,249,205,89,189,108,124,23,74,196,171,118,88,103,14,22,9,250,115,195,156,95,122,201,54,2,16,21,23,8,89,182,241,168,220,85,132,206,169,166,61,26,8,208,0,235,19,187,18,27,197,95,7,147,13,48,151,71,243,218,70,3,189,109,122,228,228,24,168,225,138,111,120,81,184,200,93,61,118,227,105,174,242,24,113,22,201,161,12,120,202,28,112,5,43,46,172,168,46,226,229,44,48,20,91,10,59,228,230,236,190,97,0,217,185,27,113,192,7,100,14,89,93,107,66,95,179,55,124,165,105,168,237,38,3,204,188,169,189,35,154,233,228,249,76,132,68,255,95,118,181,182,132,234,105,157,178,176,132,195,183,64,62,170,40,20,135,99,6,238,75,241,135,101,245,19,28,239,79,117,251,11,161,103,148,230,156,97,82,245,248,36,29,77,232,24,61,115,206,10,85,185,234,141,140,183,158,86,215,114,111,36,207,92,252,210,111,241,157,99,97,115,199,170,90,232,213,30,185,191,109,54,216,177,170,225,232,90,48,170,58,215,86,94,202,54,39,191,150,47,189,120,234,161,59,91,219,95,38,160,190,181,2,118,54,254,2,89,50,63,108,80,84,9,115,125,140,243,178,117,100,5,38,237,219,200,62,254,182,2,127,93,146,47,79,13,150,88,221,178,75,232,71,43,46,81,92,163,53,180,207,202,243,40,229,120,166,221,150,6,20,155,26,22,24,92,163,85,117,214,210,191,112,30,227,92,77,38,111,245,111,152,252,10,35,129,158,153,153,20,150,170,209,86,177,142,81,169,6,55,32,170,218,25,23,47,109,30,135,107,196,169,200,79,178,229,12,27,72,239,20,61,227,166,234,174,86,177,184,197,72,161,19,162,9,20,149,29,178,171,11,75,218,23,33,14,131,126,156,122,48,129,25,221,92,199,2,61,248,38,79,17,27,76,70,170,222,166,233,192,96,154,178,148,64,21,136,4,86,222,208,52,174,19,163,74,215,130,27,118,18,129,120,192,188,202,75,171,253,246,36,163,136,10,247,100,10,119,218,67,158,103,253,48,145,245,89,110,244,154,197,9,238,221,133,47,78,160,159,204,225,4,169,209,223,136,127,179,234,176,178,32,244,109,158,123,117,143,142,122,200,37,130,29,87,226,67,209,10,52,142,29,49,199,189,107,161,95,142,101,182,230,0,3,181,31,212,100,211,194,68,88,239,122,38,199,231,62,143,195,76,198,217,49,152,198,98,169,6,111,161,208,229,37,157,26,175,58,235,194,12,130,208,47,58,96,40,177,162,78,24,167,121,80,70,17,255,86,54,223,60,120,243,107,155,52,51,131,168,140,230,94,207,167,67,162,146,199,15,19,23,147,144,161,222,118,19,234,109,214,155,142,65,191,43,26,239,28,102,167,172,222,237,26,148,36,49,105,211,242,73,60,84,80,26,221,208,83,138,48,87,250,120,37,33,218,171,246,97,171,6,247,86,59,64,65,8,160,226,204,127,68,59,77,12,12,224,140,114,52,166,11,25,44,233,41,5,3,182,252,41,105,251,215,25,153,44,189,144,150,73,1,142,202,175,232,240,68,218,90,200,93,130,163,19,144,168,137,22,244,71,172,30,111,151,230,127,28,105,156,154,140,249,220,201,203,136,93,28,117,47,165,141,138,122,248,160,217,119,113,167,209,245,182,1,252,150,25,54,36,62,194,197,136,4,190,12,126,29,230,234,246,252,254,36,99,6,237,175,42,95,94,164,0,220,157,137,123,47,38,152,42,140,245,31,54,38,211,14,178,164,2,211,234,250,121,117,69,98,190,78,20,238,181,194,96,144,209,138,137,232,226,205,225,115,24,57,129,221,89,191,35,96,149,25,151,73,139,213,145,7,162,175,53,142,12,248,115,235,28,27,222,249,253,184,233,157,176,24,138,48,219,6,132,62,41,213,69,73,110,37,72,178,91,57,202,151,2,180,18,216,169,25,181,105,47,144,143,2,187,101,193,163,107,54,42,18,254,14,108,234,166,29,33,219,251,212,119,76,247,204,242,159,49,224,204,189,75,30,135,183,182,147,252,14,187,185,86,6,228,160,111,45,122,79,195,199,30,106,201,237,247,201,72,29,186,226,152,54,181,133,122,118,173,45,197,146,66,247,83,25,176,166,117,207,96,149,25,198,175,41,154,59,109,225,184,107,236,150,25,34,202,13,43,92,96,249,85,73,54,22,172,123,6,174,149,76,59,19,63,195,115,254,12,143,253,116,104,204,9,75,118,200,248,23,178,80,193,61,48,128,232,47,156,18,18,158,148,238,118,11,167,70,41,112,70,48,178,1,174,82,110,22,16,245,110,154,81,216,72,211,37,132,72,185,141,157,102,134,78,205,218,30,109,59,236,102,25,38,221,165,122,246,131,120,66,137,225,50,184,190,74,195,26,32,155,162,132,142,156,141,32,2,209,213,139,198,59,168,211,168,199,46,189,74,203,219,127,108,221,43,124,185,228,187,250,239,195,8,221,31,84,161,24,80,133,244,168,50,199,166,173,233,92,225,38,1,54,145,7,160,122,105,0,32,234,2,89,146,61,78,132,101,85,31,164,226,151,123,53,197,167,56,212,124,226,220,252,7,161,98,26,46,140,40,136,42,158,224,188,172,96,245,228,231,224,19,99,127,123,162,38,111,213,4,169,9,38,253,178,208,83,237,62,224,131,82,90,104,235,13,88,191,215,199,182,210,225,25,64,216,125,102,252,136,181,125,116,52,11,149,169,37,139,183,73,178,160,210,184,143,164,202,70,104,52,141,189,138,2,105,15,214,66,15,180,136,205,72,233,248,103,141,34,179,176,190,125,226,194,107,143,147,164,226,90,12,17,135,137,31,15,146,15,78,151,177,88,61,19,157,195,159,16,1,144,109,100,25,169,117,64,189,36,176,62,18,199,120,137,164,82,192,209,137,235,200,110,117,175,96,198,31,20,251,69,110,100,70,184,11,0,0,206,99,32,159,72,64,138,233,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +static const uint32_t DT_BASE_LEN = 3056; +static const uint8_t DT_PATCH[256] = {2,184,50,0,3,0,183,46,1,137,1,0,0,3,58,70,58,1,208,10,0,0,1,90,1,218,11,0,0,219,1,129,4,161,65,21,222,118,227,83,116,130,47,46,29,77,101,152,18,250,150,181,146,187,69,168,41,231,203,39,100,60,10,171,117,166,25,196,223,139,175,135,160,165,105,80,177,67,238,254,178,160,71,28,52,19,182,119,243,6,138,208,97,27,67,219,113,216,204,202,205,248,201,87,118,153,109,114,73,143,254,2,242,154,38,46,102,225,149,144,52,199,233,250,158,219,149,126,61,148,56,5,192,133,20,207,187,123,188,13,103,205,254,252,168,177,233,227,201,226,244,110,112,157,146,184,209,213,57,222,245,174,112,135,212,136,219,201,165,19,83,42,252,113,219,24,136,72,17,243,212,100,222,153,200,61,81,236,19,226,122,18,18,186,90,31,101,103,96,250,243,52,123,4,252,143,86,100,29,235,253,116,35,103,161,211,45,146,97,128,89,98,232,29,89,4,210,177,153,51,113,37,130,194,69,110,100,70,128,12,0,0,252,28,232,94,154,58,84,206,1,40,0,0,1,56}; + +static const uint32_t DT_PATCH_LEN = 256; +static const uint8_t DT_TARGET[3256] = {120,46,186,148,77,51,227,185,104,193,183,194,67,136,62,162,208,188,127,90,106,134,186,157,246,55,79,139,180,84,132,19,187,198,255,221,52,176,192,186,119,236,181,212,223,167,37,136,54,222,105,250,14,197,89,160,106,119,31,185,190,35,195,83,99,84,88,203,51,83,109,106,81,145,54,231,222,104,58,52,10,191,57,195,4,248,221,66,216,129,81,197,245,145,205,180,107,157,28,84,217,167,155,199,59,60,254,118,93,34,51,94,126,152,214,160,36,67,99,159,86,85,240,181,255,182,119,220,43,175,178,196,220,33,84,236,52,206,245,74,25,240,215,44,1,230,38,112,180,60,89,58,20,50,205,72,61,177,118,154,67,123,134,225,111,169,248,106,51,215,18,77,77,71,34,144,169,187,64,134,25,126,55,228,50,200,99,45,131,217,57,81,90,192,179,228,204,11,148,230,238,173,139,96,239,189,184,243,162,18,30,58,14,132,32,241,212,53,232,162,157,236,22,242,129,44,60,124,149,204,187,42,41,22,32,158,26,207,241,152,143,207,254,154,161,7,152,27,143,46,139,178,80,0,31,71,7,46,15,26,162,219,159,172,158,187,53,148,53,165,48,118,47,121,80,69,187,116,162,112,213,183,206,210,55,102,150,221,114,221,107,152,179,34,225,53,41,79,101,50,192,45,91,116,175,3,30,85,172,0,197,57,192,129,107,168,249,9,54,155,118,141,127,140,206,12,110,85,2,130,87,141,249,230,240,224,65,170,187,40,57,154,248,27,211,203,216,110,17,245,225,34,44,6,220,86,78,242,234,64,126,41,92,213,119,237,111,241,125,157,83,40,9,197,31,30,93,108,162,244,46,129,180,24,13,168,111,228,6,207,233,227,240,69,59,30,81,139,222,145,35,54,145,149,27,110,26,241,153,180,178,68,111,143,40,195,59,240,0,131,31,50,96,137,146,104,114,146,201,44,212,165,236,63,141,235,195,74,230,208,70,151,91,115,163,28,103,101,194,72,81,128,133,58,60,210,199,206,91,58,107,201,119,146,79,73,245,172,175,236,49,119,165,138,13,64,97,211,166,53,67,105,132,34,167,80,72,176,137,206,241,34,195,23,129,56,118,155,71,75,63,165,132,99,189,72,244,47,246,228,233,247,122,206,93,247,7,152,165,96,177,16,193,185,231,34,25,108,156,82,48,255,196,244,244,19,194,148,65,8,206,163,198,66,171,217,133,48,241,218,204,111,42,49,182,120,211,68,17,118,31,25,151,68,33,191,98,200,250,150,212,165,25,57,193,149,60,42,75,166,229,35,209,177,238,206,98,175,27,249,33,86,105,84,161,179,85,140,210,192,60,5,154,71,97,35,145,68,43,129,204,230,65,55,225,230,140,33,179,109,189,138,48,32,208,33,172,177,59,64,6,163,157,173,28,251,108,135,107,8,121,39,70,182,92,118,88,74,123,227,173,148,114,232,141,165,8,174,233,72,47,98,166,229,126,163,92,128,124,93,240,40,16,129,188,248,249,141,68,50,46,112,119,83,159,1,36,188,29,108,12,72,193,168,191,20,181,224,21,171,122,118,241,53,134,128,172,191,216,59,171,163,169,80,167,131,162,77,124,75,148,14,173,54,172,186,138,121,182,62,79,166,255,80,64,84,10,35,159,137,202,138,66,88,88,38,13,89,3,158,80,192,80,50,47,239,72,206,116,135,12,251,40,25,201,123,163,67,100,13,105,51,174,34,34,93,3,115,92,192,106,231,63,31,87,218,156,115,83,1,188,172,152,212,206,133,105,183,160,198,113,51,32,213,29,130,254,173,239,245,104,126,255,101,127,115,186,56,236,11,217,178,248,114,215,168,163,134,209,19,244,68,229,206,194,29,94,160,221,137,217,92,17,83,227,202,123,155,151,121,220,191,199,202,241,205,234,70,164,104,185,211,96,128,163,65,230,28,4,63,219,134,230,237,183,181,229,109,41,192,38,48,3,205,3,69,15,27,85,41,249,58,60,229,132,70,199,19,39,247,213,215,10,64,234,230,209,250,91,21,134,94,143,43,27,92,64,200,3,206,207,147,130,194,137,110,114,158,192,62,200,9,173,197,36,195,222,90,68,139,0,117,232,231,62,93,112,14,37,53,86,17,150,199,31,117,20,200,185,21,58,0,193,20,229,210,41,161,119,53,225,179,50,59,120,212,104,243,159,148,20,197,167,106,194,135,192,98,133,68,210,210,227,227,161,183,180,36,62,92,189,50,39,122,5,177,246,255,185,32,70,105,173,233,213,61,174,111,102,212,174,40,98,96,113,237,146,163,30,186,69,139,67,157,37,83,30,161,170,92,20,88,126,31,148,49,32,133,35,206,117,26,155,154,102,119,184,196,144,146,104,188,112,247,229,124,82,237,146,81,215,157,134,60,215,44,249,56,157,202,243,236,105,6,130,117,190,131,93,11,78,190,251,41,176,233,229,147,70,59,56,145,165,174,147,111,242,160,241,201,203,118,88,132,232,178,22,117,168,133,225,76,86,240,4,246,158,51,191,121,245,52,164,72,112,109,131,246,21,37,123,166,143,107,76,69,128,184,87,200,23,39,48,21,138,248,161,140,8,151,174,127,172,55,217,205,164,191,41,40,21,65,102,38,231,245,193,137,82,79,200,219,185,83,168,181,87,125,247,47,112,61,195,99,115,20,131,186,193,11,9,106,72,43,175,52,216,11,212,247,27,151,35,162,53,237,20,208,201,47,218,30,26,86,4,185,26,142,255,250,59,219,212,222,152,155,131,117,49,122,51,2,78,187,225,215,90,99,196,255,71,7,19,218,205,190,132,213,178,193,114,94,81,104,244,138,51,254,116,38,23,73,190,214,169,31,220,41,172,172,205,57,159,93,237,199,135,219,63,101,42,222,90,192,55,33,98,171,182,18,47,63,214,206,6,76,251,28,178,150,174,154,63,127,87,170,172,107,230,55,12,253,165,15,70,55,191,80,114,158,203,222,55,160,212,2,147,59,21,136,61,126,64,193,123,132,221,255,44,162,133,94,13,143,204,9,115,165,105,81,111,100,16,20,44,80,204,209,171,181,144,67,195,225,253,33,209,171,193,155,183,25,142,150,232,170,231,94,127,241,58,4,97,162,46,174,96,95,35,15,98,225,46,228,222,216,179,230,92,153,238,220,253,247,20,57,60,168,242,236,186,70,34,78,184,1,123,95,111,107,91,156,13,3,71,10,125,232,250,215,249,13,223,48,132,48,156,61,129,121,46,148,222,129,228,3,189,217,19,25,6,29,125,180,13,205,152,222,79,198,73,205,97,155,156,229,15,195,235,128,254,9,137,30,63,146,187,223,104,18,14,16,87,252,21,24,8,109,65,199,250,20,169,27,205,213,146,211,166,109,129,203,224,196,235,198,154,251,215,11,228,122,121,254,118,28,97,98,132,36,48,194,97,45,127,162,252,193,144,38,51,235,54,12,75,128,236,76,100,184,5,223,113,92,189,7,229,144,154,126,214,210,14,217,255,3,240,73,227,232,82,220,33,93,55,112,7,32,76,178,247,134,245,50,157,101,68,55,237,191,114,53,220,235,56,124,190,163,8,192,216,1,26,101,153,181,14,174,1,213,255,111,61,46,65,109,153,124,203,111,65,13,206,176,115,10,245,43,152,144,152,119,211,90,150,27,127,253,111,51,198,47,247,9,224,245,233,188,100,81,18,83,249,180,142,84,249,109,215,178,75,102,203,163,250,154,185,204,231,27,239,194,79,230,120,16,249,205,89,189,108,124,23,74,196,171,118,88,103,14,22,9,250,115,195,156,95,122,201,54,2,16,21,23,8,89,182,241,168,220,85,132,206,169,166,61,26,8,208,0,235,19,187,18,27,197,95,7,147,13,48,151,71,243,218,70,3,189,109,122,228,228,24,168,225,138,111,120,81,184,200,93,61,118,227,105,174,242,24,113,22,201,161,12,120,202,28,112,5,43,46,172,168,46,226,229,44,48,20,91,10,59,228,230,236,190,97,0,217,185,27,113,192,7,100,14,89,93,107,66,95,179,55,124,165,105,168,237,38,3,204,188,169,189,35,154,233,228,249,76,132,68,255,95,118,181,182,132,234,105,157,178,176,132,195,183,64,62,170,40,20,135,99,6,238,75,241,135,101,245,19,28,239,79,117,251,11,161,103,148,230,156,97,82,245,248,36,29,77,232,24,61,115,206,10,85,185,234,141,140,183,158,86,215,114,111,36,207,92,252,210,111,241,157,99,97,115,199,170,90,232,213,30,185,191,109,54,216,177,170,225,232,90,48,170,58,215,86,94,202,54,39,191,150,47,189,120,234,161,59,91,219,95,38,160,190,181,2,118,54,254,2,89,50,63,108,80,84,9,115,125,140,243,178,117,100,5,38,237,219,200,62,254,182,2,127,93,146,47,79,13,150,88,221,178,75,232,71,43,46,81,92,163,53,180,207,202,243,40,229,120,166,221,150,6,20,155,26,22,24,92,163,85,117,214,210,191,112,30,227,92,77,38,111,245,111,152,252,10,35,129,158,153,153,20,150,170,209,86,177,142,81,169,6,55,32,170,218,25,23,47,109,30,135,107,196,169,200,79,178,229,12,27,72,239,20,61,227,166,234,174,86,177,184,197,72,161,19,162,9,20,149,29,178,171,11,75,218,23,33,14,131,126,156,122,48,129,25,221,92,199,2,61,248,38,79,17,27,76,70,170,222,166,233,192,96,154,178,148,64,21,136,4,86,222,208,52,174,19,163,74,215,130,27,118,18,129,120,192,188,202,75,171,253,246,36,163,136,10,247,100,10,119,218,67,158,103,253,48,145,245,89,110,244,154,197,9,238,221,133,47,78,160,159,204,225,4,169,209,223,136,127,179,234,176,178,32,244,109,158,123,117,143,142,122,200,37,130,29,87,226,67,209,10,52,142,29,49,199,189,107,161,95,142,101,182,230,0,3,181,31,212,100,211,194,68,88,239,122,38,199,231,62,143,195,76,198,217,49,152,198,98,169,6,111,161,208,229,37,157,26,175,58,235,194,12,130,208,47,58,96,40,177,162,78,24,167,121,80,70,17,255,86,54,223,60,120,243,107,155,52,51,131,168,140,230,94,207,167,67,162,146,199,15,19,23,147,144,161,222,118,19,234,109,214,155,142,65,191,43,26,239,28,102,167,172,222,237,26,148,36,49,105,211,242,73,60,84,80,26,221,208,83,138,48,87,250,120,37,33,218,171,246,97,171,6,247,86,59,64,65,8,160,226,204,127,68,59,77,12,12,224,140,114,52,166,11,25,44,233,41,5,3,182,252,41,105,251,215,25,153,44,189,144,150,73,1,142,202,175,232,240,68,218,90,200,93,130,163,19,144,168,137,22,244,71,172,30,111,151,230,127,28,105,156,154,140,249,220,201,203,136,93,28,117,47,165,141,138,122,248,160,217,119,113,167,209,245,182,1,252,150,25,54,36,62,194,197,136,4,190,12,126,29,230,234,246,252,254,36,99,6,237,175,42,95,94,164,0,220,157,137,123,47,38,152,42,140,245,31,54,38,211,14,178,164,2,211,234,250,121,117,69,98,190,78,20,238,181,194,96,144,209,138,137,232,226,205,225,115,24,57,129,221,89,191,35,96,149,25,151,73,139,213,145,7,162,175,53,142,12,248,115,235,28,27,222,249,253,184,233,157,176,24,138,48,219,6,132,62,41,213,69,73,110,37,72,178,91,57,202,151,2,180,18,216,169,25,181,105,47,144,143,2,187,101,193,163,107,54,42,18,254,14,108,234,166,29,33,219,251,212,119,76,247,204,242,159,49,224,204,189,75,30,135,183,182,147,252,14,187,185,86,6,228,160,111,45,122,79,195,199,30,106,201,237,247,201,72,29,186,226,152,54,181,133,122,118,173,45,197,146,66,247,83,25,176,166,117,207,96,149,25,198,175,41,154,59,109,225,184,107,236,150,25,34,202,13,43,92,96,249,85,73,54,22,172,123,6,174,149,76,59,19,63,195,115,254,12,143,253,116,104,204,9,75,118,200,248,23,178,80,193,61,48,128,232,47,156,18,18,158,148,238,118,11,167,70,41,112,70,48,178,1,174,82,110,22,16,245,110,154,81,216,72,211,37,132,72,185,141,157,102,134,78,205,218,30,109,59,236,102,25,38,221,165,122,246,131,120,66,137,225,50,184,190,74,195,26,32,155,162,132,142,156,141,32,2,209,213,139,198,59,168,211,168,199,46,189,74,203,219,127,108,221,43,124,185,228,187,250,239,195,8,221,31,84,161,24,80,133,244,168,50,199,166,173,233,92,225,38,1,54,145,7,160,122,105,0,32,234,2,89,146,61,78,132,101,85,31,164,226,151,123,53,197,167,56,212,124,226,220,252,7,161,98,26,46,140,40,136,42,158,224,188,172,96,245,228,231,224,19,99,127,123,162,38,111,213,4,169,9,38,253,178,208,83,237,62,224,131,82,90,104,235,13,88,191,215,199,182,210,225,25,64,216,125,102,252,136,181,125,116,52,11,149,169,37,139,183,73,178,160,210,184,143,164,202,70,104,52,141,189,138,2,105,15,214,66,15,180,136,205,72,233,248,103,141,34,179,176,190,125,226,194,107,143,147,164,226,90,12,17,135,137,31,15,146,15,78,151,177,88,61,19,157,195,159,16,1,144,109,100,25,169,117,64,189,36,176,62,18,199,120,137,164,82,192,209,137,235,200,110,117,175,96,198,31,20,161,65,21,222,118,227,83,116,130,47,46,29,77,101,152,18,250,150,181,146,187,69,168,41,231,203,39,100,60,10,171,117,166,25,196,223,139,175,135,160,165,105,80,177,67,238,254,178,160,71,28,52,19,182,119,243,6,138,208,97,27,67,219,113,216,204,202,205,248,201,87,118,153,109,114,73,143,254,2,242,154,38,46,102,225,149,144,52,199,233,250,158,219,149,126,61,148,56,5,192,133,20,207,187,123,188,13,103,205,254,252,168,177,233,227,201,226,244,110,112,157,146,184,209,213,57,222,245,174,112,135,212,136,219,201,165,19,83,42,252,113,219,24,136,72,17,243,212,100,222,153,200,61,81,236,19,226,122,18,18,186,90,31,101,103,96,250,243,52,123,4,252,143,86,100,29,235,253,116,35,103,161,211,45,146,97,128,89,98,232,29,89,4,210,177,153,51,113,37,130,194,69,110,100,70,128,12,0,0,252,28,232,94,154,58,84,206,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +static const uint32_t DT_TARGET_LEN = 3256; +// detools in-place+crle delta: apply DT_IP_PATCH over a DT_IP_MEM buffer holding DT_IP_BASE +static const uint8_t DT_IP_BASE[3056] = {120,46,186,148,77,51,227,185,104,193,183,194,67,136,62,162,208,188,127,90,106,134,186,157,246,55,79,139,180,84,132,19,187,198,255,221,52,176,192,186,119,236,181,212,223,167,37,136,54,222,105,250,14,197,89,160,106,119,31,185,190,35,195,83,99,84,88,203,51,83,109,106,81,145,54,231,222,104,58,52,10,191,57,195,4,248,221,66,216,129,81,197,245,145,205,180,107,157,28,84,217,167,155,199,59,60,254,118,93,34,51,94,126,152,214,160,36,67,99,159,86,85,240,181,255,182,119,220,43,175,178,196,220,33,84,236,52,148,175,16,25,240,215,44,1,230,38,112,180,60,89,58,20,50,205,72,61,177,118,154,67,123,134,225,111,169,248,106,51,215,18,77,77,71,34,144,169,187,64,134,25,126,55,228,50,200,99,45,131,217,57,81,90,192,179,228,204,11,148,230,238,173,139,96,239,189,184,243,162,18,30,58,14,132,32,241,212,53,232,162,157,236,22,242,129,44,60,124,149,204,187,42,41,22,32,158,26,207,241,152,143,207,254,154,161,7,152,27,143,46,139,178,80,0,31,71,7,46,15,26,162,219,159,172,158,187,53,148,53,165,48,118,47,121,80,69,187,116,162,112,213,183,206,210,55,102,150,221,114,221,107,152,179,34,225,53,41,79,101,50,192,45,91,116,175,3,30,85,172,0,197,57,192,129,107,168,249,9,54,155,118,141,127,140,206,12,110,85,2,130,87,141,249,230,240,224,65,170,187,40,57,154,248,27,211,203,216,110,17,245,225,34,44,6,220,86,78,242,234,64,126,41,92,213,119,237,111,241,125,157,83,40,9,197,31,30,93,108,162,244,46,129,180,24,13,168,111,228,6,207,233,227,240,69,59,30,81,139,222,145,35,54,145,149,27,110,26,241,153,180,178,68,111,143,40,195,59,240,0,131,31,50,96,137,146,104,114,146,201,44,212,165,236,63,141,235,195,74,230,208,70,151,91,115,163,28,103,101,194,72,81,128,133,58,60,210,199,206,91,58,107,201,119,146,79,73,245,172,175,236,49,119,165,138,13,64,97,211,166,53,67,105,132,34,167,80,72,176,137,206,241,34,195,23,129,56,118,155,71,75,63,165,132,99,189,72,244,47,246,228,233,247,122,206,93,247,7,152,165,96,177,16,193,185,231,34,25,108,156,82,48,255,196,244,244,19,194,148,65,8,206,163,198,66,171,217,133,48,241,218,204,111,42,49,182,120,211,68,17,118,31,25,151,68,33,191,98,200,250,150,212,165,25,57,193,149,60,42,75,166,229,35,209,177,238,206,98,175,27,249,33,86,105,84,161,179,85,140,210,192,60,5,154,71,97,35,145,68,43,129,204,230,65,55,225,230,140,33,179,109,189,138,48,32,208,33,172,177,59,64,6,163,157,173,28,251,108,135,107,8,121,39,70,182,92,118,88,74,123,227,173,148,114,232,141,165,8,174,233,72,47,98,166,229,126,163,92,128,124,93,240,40,16,129,188,248,249,141,68,50,46,112,119,83,159,1,36,188,29,108,12,72,193,168,191,20,181,224,21,171,122,118,241,53,134,128,172,191,216,59,171,163,169,80,167,131,162,77,124,75,148,14,173,54,172,186,138,121,182,62,79,166,255,80,64,84,10,35,159,137,202,138,66,88,88,38,13,89,3,158,80,192,80,50,47,239,72,206,116,135,12,251,40,25,201,123,163,67,100,13,105,51,174,34,34,93,3,115,92,192,106,231,63,31,87,218,156,115,83,1,188,172,152,212,206,133,105,183,160,198,113,51,32,213,29,130,254,173,239,245,104,126,255,101,127,115,186,56,236,11,217,178,248,114,215,168,163,134,209,19,244,68,229,206,194,29,94,160,221,137,217,92,17,83,227,202,123,155,151,121,220,191,199,202,241,205,234,70,164,104,185,211,96,128,163,65,230,28,4,63,219,134,230,237,183,181,229,109,41,192,38,48,3,205,3,69,15,27,85,41,249,58,60,229,132,70,199,19,39,247,213,215,10,64,234,230,209,250,91,21,134,94,143,43,27,92,64,200,3,206,207,147,130,194,137,110,114,158,192,62,200,9,173,197,36,195,222,90,68,139,0,117,232,231,62,93,112,14,37,53,86,17,150,199,31,117,20,200,185,21,58,0,193,20,229,210,41,161,119,53,225,179,50,59,120,212,104,243,159,148,20,197,167,106,194,135,192,98,133,68,210,210,227,227,161,183,180,36,62,92,189,50,39,122,5,177,246,255,185,32,70,105,173,233,213,61,174,111,102,212,174,40,98,96,113,237,146,163,30,186,69,139,67,157,37,83,30,161,170,92,20,88,126,31,148,49,32,133,35,206,117,26,155,154,102,119,184,196,144,146,104,188,112,247,229,124,82,237,146,81,215,157,134,60,215,44,249,56,157,202,243,236,105,6,130,117,190,131,93,11,78,190,251,41,176,233,229,147,70,59,56,145,165,174,147,111,242,160,241,201,203,118,88,132,232,178,22,117,168,133,225,76,86,240,4,246,158,51,191,121,245,52,164,72,112,109,131,246,21,37,123,166,143,107,76,69,128,184,87,200,23,39,48,21,138,248,161,140,8,151,174,127,172,55,217,205,164,191,41,40,21,65,102,38,231,245,193,137,82,79,200,219,185,83,168,181,87,125,247,47,112,61,195,99,115,20,131,186,193,11,9,106,72,43,175,52,216,11,212,247,27,151,35,162,53,237,20,208,201,47,218,30,26,86,4,185,26,142,255,250,59,219,212,222,152,155,131,117,49,122,51,2,78,187,225,215,90,99,196,255,71,7,19,218,205,190,132,213,178,193,114,94,81,104,244,138,51,254,116,38,23,73,190,214,169,31,220,41,172,172,205,57,159,93,237,199,135,219,63,101,42,222,90,192,55,33,98,171,182,18,47,63,214,206,6,76,251,28,178,150,174,154,63,127,87,170,172,107,230,55,12,253,165,15,70,55,191,80,114,158,203,222,55,160,212,2,147,59,21,136,61,126,64,193,123,132,221,255,44,162,133,94,13,143,204,9,115,165,105,81,111,100,16,20,44,80,204,209,171,181,144,67,195,225,253,33,209,171,193,155,183,25,142,150,232,170,231,94,127,241,58,4,97,162,46,174,96,95,35,15,98,225,46,228,222,216,179,230,92,153,238,220,253,247,20,57,60,168,242,236,186,70,34,78,184,1,123,95,111,107,91,156,13,3,71,10,125,232,250,215,249,13,223,48,132,48,156,61,129,121,46,148,222,129,228,3,189,217,19,25,6,29,125,180,13,205,152,222,79,198,73,205,97,155,156,229,15,195,235,128,254,9,137,30,63,146,187,223,104,18,14,16,87,252,21,24,8,109,65,199,160,20,169,27,205,213,146,211,166,109,129,203,224,196,235,198,154,251,215,11,228,122,121,254,118,28,97,98,132,36,48,194,97,45,127,162,252,193,144,38,51,235,54,12,75,128,236,76,100,184,5,223,113,92,189,7,229,144,154,126,214,210,14,217,255,3,240,73,227,232,82,220,33,93,55,112,7,32,76,178,247,134,245,50,157,101,68,55,237,191,114,53,220,235,56,124,190,163,8,192,216,1,26,101,153,181,14,174,1,213,255,111,61,46,65,109,153,124,203,111,65,13,206,176,115,10,245,43,152,144,152,119,211,90,150,27,127,253,111,51,198,47,247,9,224,245,233,188,100,81,18,83,249,180,142,84,249,109,215,178,75,102,203,163,250,154,185,204,231,27,239,194,79,230,120,16,249,205,89,189,108,124,23,74,196,171,118,88,103,14,22,9,250,115,195,156,95,122,201,54,2,16,21,23,8,89,182,241,168,220,85,132,206,169,166,61,26,8,208,0,235,19,187,18,27,197,95,7,147,13,48,151,71,243,218,70,3,189,109,122,228,228,24,168,225,138,111,120,81,184,200,93,61,118,227,105,174,242,24,113,22,201,161,12,120,202,28,112,5,43,46,172,168,46,226,229,44,48,20,91,10,59,228,230,236,190,97,0,217,185,27,113,192,7,100,14,89,93,107,66,95,179,55,124,165,105,168,237,38,3,204,188,169,189,35,154,233,228,249,76,132,68,255,95,118,181,182,132,234,105,157,178,176,132,195,183,64,62,170,40,20,135,99,6,238,75,241,135,101,245,19,28,239,79,117,251,11,161,103,148,230,156,97,82,245,248,36,29,77,232,24,61,115,206,10,85,185,234,141,140,183,158,86,215,114,111,36,207,92,252,210,111,241,157,99,97,115,199,170,90,232,213,30,185,191,109,54,216,177,170,225,232,90,48,170,58,215,86,94,202,54,39,191,150,47,189,120,234,161,59,91,219,95,38,160,190,181,2,118,54,254,2,89,50,63,108,80,84,9,115,125,140,243,178,117,100,5,38,237,219,200,62,254,182,2,127,93,146,47,79,13,150,88,221,178,75,232,71,43,46,81,92,163,53,180,207,202,243,40,229,120,166,221,150,6,20,155,26,22,24,92,163,85,117,214,210,191,112,30,227,92,77,38,111,245,111,152,252,10,35,129,158,153,153,20,150,170,209,86,177,142,81,169,6,55,32,170,218,25,23,47,109,30,135,107,196,169,200,79,178,229,12,27,72,239,20,61,227,166,234,174,86,177,184,197,72,161,19,162,9,20,149,29,178,171,11,75,218,23,33,14,131,126,156,122,48,129,25,221,92,199,2,61,248,38,79,17,27,76,70,170,222,166,233,192,96,154,178,148,64,21,136,4,86,222,208,52,174,19,163,74,215,130,27,118,18,129,120,192,188,202,75,171,253,246,36,163,136,10,247,100,10,119,218,67,158,103,253,48,145,245,89,110,244,154,197,9,238,221,133,47,78,160,159,204,225,4,169,209,223,136,127,179,234,176,178,32,244,109,158,123,117,143,142,122,200,37,130,29,87,226,67,209,10,52,142,29,49,199,189,107,161,95,142,101,182,230,0,3,181,31,212,100,211,194,68,88,239,122,38,199,231,62,143,195,76,198,217,49,152,198,98,169,6,111,161,208,229,37,157,26,175,58,235,194,12,130,208,47,58,96,40,177,162,78,24,167,121,80,70,17,255,86,54,223,60,120,243,107,155,52,51,131,168,140,230,94,207,167,67,162,146,199,15,19,23,147,144,161,222,118,19,234,109,214,155,142,65,191,43,26,239,28,102,167,172,222,237,26,148,36,49,105,211,242,73,60,84,80,26,221,208,83,138,48,87,250,120,37,33,218,171,246,97,171,6,247,86,59,64,65,8,160,226,204,127,68,59,77,12,12,224,140,114,52,166,11,25,44,233,41,5,3,182,252,41,105,251,215,25,153,44,189,144,150,73,1,142,202,175,232,240,68,218,90,200,93,130,163,19,144,168,137,22,244,71,172,30,111,151,230,127,28,105,156,154,140,249,220,201,203,136,93,28,117,47,165,141,138,122,248,160,217,119,113,167,209,245,182,1,252,150,25,54,36,62,194,197,136,4,190,12,126,29,230,234,246,252,254,36,99,6,237,175,42,95,94,164,0,220,157,137,123,47,38,152,42,140,245,31,54,38,211,14,178,164,2,211,234,250,121,117,69,98,190,78,20,238,181,194,96,144,209,138,137,232,226,205,225,115,24,57,129,221,89,191,35,96,149,25,151,73,139,213,145,7,162,175,53,142,12,248,115,235,28,27,222,249,253,184,233,157,176,24,138,48,219,6,132,62,41,213,69,73,110,37,72,178,91,57,202,151,2,180,18,216,169,25,181,105,47,144,143,2,187,101,193,163,107,54,42,18,254,14,108,234,166,29,33,219,251,212,119,76,247,204,242,159,49,224,204,189,75,30,135,183,182,147,252,14,187,185,86,6,228,160,111,45,122,79,195,199,30,106,201,237,247,201,72,29,186,226,152,54,181,133,122,118,173,45,197,146,66,247,83,25,176,166,117,207,96,149,25,198,175,41,154,59,109,225,184,107,236,150,25,34,202,13,43,92,96,249,85,73,54,22,172,123,6,174,149,76,59,19,63,195,115,254,12,143,253,116,104,204,9,75,118,200,248,23,178,80,193,61,48,128,232,47,156,18,18,158,148,238,118,11,167,70,41,112,70,48,178,1,174,82,110,22,16,245,110,154,81,216,72,211,37,132,72,185,141,157,102,134,78,205,218,30,109,59,236,102,25,38,221,165,122,246,131,120,66,137,225,50,184,190,74,195,26,32,155,162,132,142,156,141,32,2,209,213,139,198,59,168,211,168,199,46,189,74,203,219,127,108,221,43,124,185,228,187,250,239,195,8,221,31,84,161,24,80,133,244,168,50,199,166,173,233,92,225,38,1,54,145,7,160,122,105,0,32,234,2,89,146,61,78,132,101,85,31,164,226,151,123,53,197,167,56,212,124,226,220,252,7,161,98,26,46,140,40,136,42,158,224,188,172,96,245,228,231,224,19,99,127,123,162,38,111,213,4,169,9,38,253,178,208,83,237,62,224,131,82,90,104,235,13,88,191,215,199,182,210,225,25,64,216,125,102,252,136,181,125,116,52,11,149,169,37,139,183,73,178,160,210,184,143,164,202,70,104,52,141,189,138,2,105,15,214,66,15,180,136,205,72,233,248,103,141,34,179,176,190,125,226,194,107,143,147,164,226,90,12,17,135,137,31,15,146,15,78,151,177,88,61,19,157,195,159,16,1,144,109,100,25,169,117,64,189,36,176,62,18,199,120,137,164,82,192,209,137,235,200,110,117,175,96,198,31,20,251,69,110,100,70,184,11,0,0,206,99,32,159,72,64,138,233,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +static const uint32_t DT_IP_BASE_LEN = 3056; +static const uint8_t DT_IP_PATCH[266] = {18,128,128,4,128,64,128,192,3,176,47,184,50,0,3,0,183,46,1,137,1,0,0,3,58,70,58,1,208,10,0,0,1,90,1,218,11,0,0,219,1,129,4,161,65,21,222,118,227,83,116,130,47,46,29,77,101,152,18,250,150,181,146,187,69,168,41,231,203,39,100,60,10,171,117,166,25,196,223,139,175,135,160,165,105,80,177,67,238,254,178,160,71,28,52,19,182,119,243,6,138,208,97,27,67,219,113,216,204,202,205,248,201,87,118,153,109,114,73,143,254,2,242,154,38,46,102,225,149,144,52,199,233,250,158,219,149,126,61,148,56,5,192,133,20,207,187,123,188,13,103,205,254,252,168,177,233,227,201,226,244,110,112,157,146,184,209,213,57,222,245,174,112,135,212,136,219,201,165,19,83,42,252,113,219,24,136,72,17,243,212,100,222,153,200,61,81,236,19,226,122,18,18,186,90,31,101,103,96,250,243,52,123,4,252,143,86,100,29,235,253,116,35,103,161,211,45,146,97,128,89,98,232,29,89,4,210,177,153,51,113,37,130,194,69,110,100,70,128,12,0,0,252,28,232,94,154,58,84,206,1,40,0,0,1,56}; + +static const uint32_t DT_IP_PATCH_LEN = 266; +static const uint8_t DT_IP_TARGET[3256] = {120,46,186,148,77,51,227,185,104,193,183,194,67,136,62,162,208,188,127,90,106,134,186,157,246,55,79,139,180,84,132,19,187,198,255,221,52,176,192,186,119,236,181,212,223,167,37,136,54,222,105,250,14,197,89,160,106,119,31,185,190,35,195,83,99,84,88,203,51,83,109,106,81,145,54,231,222,104,58,52,10,191,57,195,4,248,221,66,216,129,81,197,245,145,205,180,107,157,28,84,217,167,155,199,59,60,254,118,93,34,51,94,126,152,214,160,36,67,99,159,86,85,240,181,255,182,119,220,43,175,178,196,220,33,84,236,52,206,245,74,25,240,215,44,1,230,38,112,180,60,89,58,20,50,205,72,61,177,118,154,67,123,134,225,111,169,248,106,51,215,18,77,77,71,34,144,169,187,64,134,25,126,55,228,50,200,99,45,131,217,57,81,90,192,179,228,204,11,148,230,238,173,139,96,239,189,184,243,162,18,30,58,14,132,32,241,212,53,232,162,157,236,22,242,129,44,60,124,149,204,187,42,41,22,32,158,26,207,241,152,143,207,254,154,161,7,152,27,143,46,139,178,80,0,31,71,7,46,15,26,162,219,159,172,158,187,53,148,53,165,48,118,47,121,80,69,187,116,162,112,213,183,206,210,55,102,150,221,114,221,107,152,179,34,225,53,41,79,101,50,192,45,91,116,175,3,30,85,172,0,197,57,192,129,107,168,249,9,54,155,118,141,127,140,206,12,110,85,2,130,87,141,249,230,240,224,65,170,187,40,57,154,248,27,211,203,216,110,17,245,225,34,44,6,220,86,78,242,234,64,126,41,92,213,119,237,111,241,125,157,83,40,9,197,31,30,93,108,162,244,46,129,180,24,13,168,111,228,6,207,233,227,240,69,59,30,81,139,222,145,35,54,145,149,27,110,26,241,153,180,178,68,111,143,40,195,59,240,0,131,31,50,96,137,146,104,114,146,201,44,212,165,236,63,141,235,195,74,230,208,70,151,91,115,163,28,103,101,194,72,81,128,133,58,60,210,199,206,91,58,107,201,119,146,79,73,245,172,175,236,49,119,165,138,13,64,97,211,166,53,67,105,132,34,167,80,72,176,137,206,241,34,195,23,129,56,118,155,71,75,63,165,132,99,189,72,244,47,246,228,233,247,122,206,93,247,7,152,165,96,177,16,193,185,231,34,25,108,156,82,48,255,196,244,244,19,194,148,65,8,206,163,198,66,171,217,133,48,241,218,204,111,42,49,182,120,211,68,17,118,31,25,151,68,33,191,98,200,250,150,212,165,25,57,193,149,60,42,75,166,229,35,209,177,238,206,98,175,27,249,33,86,105,84,161,179,85,140,210,192,60,5,154,71,97,35,145,68,43,129,204,230,65,55,225,230,140,33,179,109,189,138,48,32,208,33,172,177,59,64,6,163,157,173,28,251,108,135,107,8,121,39,70,182,92,118,88,74,123,227,173,148,114,232,141,165,8,174,233,72,47,98,166,229,126,163,92,128,124,93,240,40,16,129,188,248,249,141,68,50,46,112,119,83,159,1,36,188,29,108,12,72,193,168,191,20,181,224,21,171,122,118,241,53,134,128,172,191,216,59,171,163,169,80,167,131,162,77,124,75,148,14,173,54,172,186,138,121,182,62,79,166,255,80,64,84,10,35,159,137,202,138,66,88,88,38,13,89,3,158,80,192,80,50,47,239,72,206,116,135,12,251,40,25,201,123,163,67,100,13,105,51,174,34,34,93,3,115,92,192,106,231,63,31,87,218,156,115,83,1,188,172,152,212,206,133,105,183,160,198,113,51,32,213,29,130,254,173,239,245,104,126,255,101,127,115,186,56,236,11,217,178,248,114,215,168,163,134,209,19,244,68,229,206,194,29,94,160,221,137,217,92,17,83,227,202,123,155,151,121,220,191,199,202,241,205,234,70,164,104,185,211,96,128,163,65,230,28,4,63,219,134,230,237,183,181,229,109,41,192,38,48,3,205,3,69,15,27,85,41,249,58,60,229,132,70,199,19,39,247,213,215,10,64,234,230,209,250,91,21,134,94,143,43,27,92,64,200,3,206,207,147,130,194,137,110,114,158,192,62,200,9,173,197,36,195,222,90,68,139,0,117,232,231,62,93,112,14,37,53,86,17,150,199,31,117,20,200,185,21,58,0,193,20,229,210,41,161,119,53,225,179,50,59,120,212,104,243,159,148,20,197,167,106,194,135,192,98,133,68,210,210,227,227,161,183,180,36,62,92,189,50,39,122,5,177,246,255,185,32,70,105,173,233,213,61,174,111,102,212,174,40,98,96,113,237,146,163,30,186,69,139,67,157,37,83,30,161,170,92,20,88,126,31,148,49,32,133,35,206,117,26,155,154,102,119,184,196,144,146,104,188,112,247,229,124,82,237,146,81,215,157,134,60,215,44,249,56,157,202,243,236,105,6,130,117,190,131,93,11,78,190,251,41,176,233,229,147,70,59,56,145,165,174,147,111,242,160,241,201,203,118,88,132,232,178,22,117,168,133,225,76,86,240,4,246,158,51,191,121,245,52,164,72,112,109,131,246,21,37,123,166,143,107,76,69,128,184,87,200,23,39,48,21,138,248,161,140,8,151,174,127,172,55,217,205,164,191,41,40,21,65,102,38,231,245,193,137,82,79,200,219,185,83,168,181,87,125,247,47,112,61,195,99,115,20,131,186,193,11,9,106,72,43,175,52,216,11,212,247,27,151,35,162,53,237,20,208,201,47,218,30,26,86,4,185,26,142,255,250,59,219,212,222,152,155,131,117,49,122,51,2,78,187,225,215,90,99,196,255,71,7,19,218,205,190,132,213,178,193,114,94,81,104,244,138,51,254,116,38,23,73,190,214,169,31,220,41,172,172,205,57,159,93,237,199,135,219,63,101,42,222,90,192,55,33,98,171,182,18,47,63,214,206,6,76,251,28,178,150,174,154,63,127,87,170,172,107,230,55,12,253,165,15,70,55,191,80,114,158,203,222,55,160,212,2,147,59,21,136,61,126,64,193,123,132,221,255,44,162,133,94,13,143,204,9,115,165,105,81,111,100,16,20,44,80,204,209,171,181,144,67,195,225,253,33,209,171,193,155,183,25,142,150,232,170,231,94,127,241,58,4,97,162,46,174,96,95,35,15,98,225,46,228,222,216,179,230,92,153,238,220,253,247,20,57,60,168,242,236,186,70,34,78,184,1,123,95,111,107,91,156,13,3,71,10,125,232,250,215,249,13,223,48,132,48,156,61,129,121,46,148,222,129,228,3,189,217,19,25,6,29,125,180,13,205,152,222,79,198,73,205,97,155,156,229,15,195,235,128,254,9,137,30,63,146,187,223,104,18,14,16,87,252,21,24,8,109,65,199,250,20,169,27,205,213,146,211,166,109,129,203,224,196,235,198,154,251,215,11,228,122,121,254,118,28,97,98,132,36,48,194,97,45,127,162,252,193,144,38,51,235,54,12,75,128,236,76,100,184,5,223,113,92,189,7,229,144,154,126,214,210,14,217,255,3,240,73,227,232,82,220,33,93,55,112,7,32,76,178,247,134,245,50,157,101,68,55,237,191,114,53,220,235,56,124,190,163,8,192,216,1,26,101,153,181,14,174,1,213,255,111,61,46,65,109,153,124,203,111,65,13,206,176,115,10,245,43,152,144,152,119,211,90,150,27,127,253,111,51,198,47,247,9,224,245,233,188,100,81,18,83,249,180,142,84,249,109,215,178,75,102,203,163,250,154,185,204,231,27,239,194,79,230,120,16,249,205,89,189,108,124,23,74,196,171,118,88,103,14,22,9,250,115,195,156,95,122,201,54,2,16,21,23,8,89,182,241,168,220,85,132,206,169,166,61,26,8,208,0,235,19,187,18,27,197,95,7,147,13,48,151,71,243,218,70,3,189,109,122,228,228,24,168,225,138,111,120,81,184,200,93,61,118,227,105,174,242,24,113,22,201,161,12,120,202,28,112,5,43,46,172,168,46,226,229,44,48,20,91,10,59,228,230,236,190,97,0,217,185,27,113,192,7,100,14,89,93,107,66,95,179,55,124,165,105,168,237,38,3,204,188,169,189,35,154,233,228,249,76,132,68,255,95,118,181,182,132,234,105,157,178,176,132,195,183,64,62,170,40,20,135,99,6,238,75,241,135,101,245,19,28,239,79,117,251,11,161,103,148,230,156,97,82,245,248,36,29,77,232,24,61,115,206,10,85,185,234,141,140,183,158,86,215,114,111,36,207,92,252,210,111,241,157,99,97,115,199,170,90,232,213,30,185,191,109,54,216,177,170,225,232,90,48,170,58,215,86,94,202,54,39,191,150,47,189,120,234,161,59,91,219,95,38,160,190,181,2,118,54,254,2,89,50,63,108,80,84,9,115,125,140,243,178,117,100,5,38,237,219,200,62,254,182,2,127,93,146,47,79,13,150,88,221,178,75,232,71,43,46,81,92,163,53,180,207,202,243,40,229,120,166,221,150,6,20,155,26,22,24,92,163,85,117,214,210,191,112,30,227,92,77,38,111,245,111,152,252,10,35,129,158,153,153,20,150,170,209,86,177,142,81,169,6,55,32,170,218,25,23,47,109,30,135,107,196,169,200,79,178,229,12,27,72,239,20,61,227,166,234,174,86,177,184,197,72,161,19,162,9,20,149,29,178,171,11,75,218,23,33,14,131,126,156,122,48,129,25,221,92,199,2,61,248,38,79,17,27,76,70,170,222,166,233,192,96,154,178,148,64,21,136,4,86,222,208,52,174,19,163,74,215,130,27,118,18,129,120,192,188,202,75,171,253,246,36,163,136,10,247,100,10,119,218,67,158,103,253,48,145,245,89,110,244,154,197,9,238,221,133,47,78,160,159,204,225,4,169,209,223,136,127,179,234,176,178,32,244,109,158,123,117,143,142,122,200,37,130,29,87,226,67,209,10,52,142,29,49,199,189,107,161,95,142,101,182,230,0,3,181,31,212,100,211,194,68,88,239,122,38,199,231,62,143,195,76,198,217,49,152,198,98,169,6,111,161,208,229,37,157,26,175,58,235,194,12,130,208,47,58,96,40,177,162,78,24,167,121,80,70,17,255,86,54,223,60,120,243,107,155,52,51,131,168,140,230,94,207,167,67,162,146,199,15,19,23,147,144,161,222,118,19,234,109,214,155,142,65,191,43,26,239,28,102,167,172,222,237,26,148,36,49,105,211,242,73,60,84,80,26,221,208,83,138,48,87,250,120,37,33,218,171,246,97,171,6,247,86,59,64,65,8,160,226,204,127,68,59,77,12,12,224,140,114,52,166,11,25,44,233,41,5,3,182,252,41,105,251,215,25,153,44,189,144,150,73,1,142,202,175,232,240,68,218,90,200,93,130,163,19,144,168,137,22,244,71,172,30,111,151,230,127,28,105,156,154,140,249,220,201,203,136,93,28,117,47,165,141,138,122,248,160,217,119,113,167,209,245,182,1,252,150,25,54,36,62,194,197,136,4,190,12,126,29,230,234,246,252,254,36,99,6,237,175,42,95,94,164,0,220,157,137,123,47,38,152,42,140,245,31,54,38,211,14,178,164,2,211,234,250,121,117,69,98,190,78,20,238,181,194,96,144,209,138,137,232,226,205,225,115,24,57,129,221,89,191,35,96,149,25,151,73,139,213,145,7,162,175,53,142,12,248,115,235,28,27,222,249,253,184,233,157,176,24,138,48,219,6,132,62,41,213,69,73,110,37,72,178,91,57,202,151,2,180,18,216,169,25,181,105,47,144,143,2,187,101,193,163,107,54,42,18,254,14,108,234,166,29,33,219,251,212,119,76,247,204,242,159,49,224,204,189,75,30,135,183,182,147,252,14,187,185,86,6,228,160,111,45,122,79,195,199,30,106,201,237,247,201,72,29,186,226,152,54,181,133,122,118,173,45,197,146,66,247,83,25,176,166,117,207,96,149,25,198,175,41,154,59,109,225,184,107,236,150,25,34,202,13,43,92,96,249,85,73,54,22,172,123,6,174,149,76,59,19,63,195,115,254,12,143,253,116,104,204,9,75,118,200,248,23,178,80,193,61,48,128,232,47,156,18,18,158,148,238,118,11,167,70,41,112,70,48,178,1,174,82,110,22,16,245,110,154,81,216,72,211,37,132,72,185,141,157,102,134,78,205,218,30,109,59,236,102,25,38,221,165,122,246,131,120,66,137,225,50,184,190,74,195,26,32,155,162,132,142,156,141,32,2,209,213,139,198,59,168,211,168,199,46,189,74,203,219,127,108,221,43,124,185,228,187,250,239,195,8,221,31,84,161,24,80,133,244,168,50,199,166,173,233,92,225,38,1,54,145,7,160,122,105,0,32,234,2,89,146,61,78,132,101,85,31,164,226,151,123,53,197,167,56,212,124,226,220,252,7,161,98,26,46,140,40,136,42,158,224,188,172,96,245,228,231,224,19,99,127,123,162,38,111,213,4,169,9,38,253,178,208,83,237,62,224,131,82,90,104,235,13,88,191,215,199,182,210,225,25,64,216,125,102,252,136,181,125,116,52,11,149,169,37,139,183,73,178,160,210,184,143,164,202,70,104,52,141,189,138,2,105,15,214,66,15,180,136,205,72,233,248,103,141,34,179,176,190,125,226,194,107,143,147,164,226,90,12,17,135,137,31,15,146,15,78,151,177,88,61,19,157,195,159,16,1,144,109,100,25,169,117,64,189,36,176,62,18,199,120,137,164,82,192,209,137,235,200,110,117,175,96,198,31,20,161,65,21,222,118,227,83,116,130,47,46,29,77,101,152,18,250,150,181,146,187,69,168,41,231,203,39,100,60,10,171,117,166,25,196,223,139,175,135,160,165,105,80,177,67,238,254,178,160,71,28,52,19,182,119,243,6,138,208,97,27,67,219,113,216,204,202,205,248,201,87,118,153,109,114,73,143,254,2,242,154,38,46,102,225,149,144,52,199,233,250,158,219,149,126,61,148,56,5,192,133,20,207,187,123,188,13,103,205,254,252,168,177,233,227,201,226,244,110,112,157,146,184,209,213,57,222,245,174,112,135,212,136,219,201,165,19,83,42,252,113,219,24,136,72,17,243,212,100,222,153,200,61,81,236,19,226,122,18,18,186,90,31,101,103,96,250,243,52,123,4,252,143,86,100,29,235,253,116,35,103,161,211,45,146,97,128,89,98,232,29,89,4,210,177,153,51,113,37,130,194,69,110,100,70,128,12,0,0,252,28,232,94,154,58,84,206,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +static const uint32_t DT_IP_TARGET_LEN = 3256; +static const uint32_t DT_IP_MEM = 32768u; diff --git a/test/test_ota/test_ota_core.cpp b/test/test_ota/test_ota_core.cpp new file mode 100644 index 000000000..bd3b8c83b --- /dev/null +++ b/test/test_ota/test_ota_core.cpp @@ -0,0 +1,972 @@ +#include +#include +#include +#include + +#include "helpers/ota/MotaContainer.h" +#include "helpers/ota/MerkleTree.h" +#include "helpers/ota/BlockBitmap.h" +#include "helpers/ota/Multihash.h" +#include "helpers/ota/FirmwareInfo.h" +#include "helpers/ota/SignerAllowlist.h" +#include "helpers/ota/OtaStore.h" +#include "helpers/ota/OtaProtocol.h" +#include "helpers/ota/OtaManager.h" +#include "mota_vectors.h" // auto-generated by tools/mota/gen_vectors.py + +extern "C" { + #include "helpers/ota/detools/detools.h" // vendored detools 0.53.0 embeddable decoder +} + +using namespace mesh::ota; + +// Build a flashed-image layout (body || fixed 56-byte EndF) the way the host packager / build hook do: +// marker(4) body_len(4) body_hash8(8) fw_version(4) target_id(4) hw_id(32). Identity is always present +// (zero/"" = unknown). +static std::vector make_image_id(const std::vector& body, uint32_t fw_version, + uint32_t target_id, const char* hw_id) { + std::vector img = body; + img.insert(img.end(), ENDF_MAGIC, ENDF_MAGIC + 4); + uint32_t n = (uint32_t)body.size(); + for (int i = 0; i < 4; i++) img.push_back((uint8_t)(n >> (8 * i))); + uint8_t h[8]; mh8(h, body.data(), body.size()); + img.insert(img.end(), h, h + 8); + for (int i = 0; i < 4; i++) img.push_back((uint8_t)(fw_version >> (8 * i))); + for (int i = 0; i < 4; i++) img.push_back((uint8_t)(target_id >> (8 * i))); + uint8_t hw[32] = {0}; size_t k = hw_id ? strlen(hw_id) : 0; if (k > 32) k = 32; if (k) memcpy(hw, hw_id, k); + img.insert(img.end(), hw, hw + 32); // -> fixed 56-byte trailer + return img; +} +static std::vector make_image(const std::vector& body) { + return make_image_id(body, 0, 0, ""); // zero identity (still a full 56-byte trailer) +} + +// --- cross-check the C++ parser/merkle against the Python reference vectors ---------------- + +TEST(OtaParse, ParsesReferenceContainer) { + MotaManifest m; + ASSERT_TRUE(mota_parse(MOTA_VEC, MOTA_VEC_LEN, m)); + EXPECT_EQ(m.format_ver, MOTA_FORMAT_VER); + EXPECT_TRUE(m.is_full()); + EXPECT_FALSE(m.is_signed()); + EXPECT_EQ(m.target_id, EXP_TARGET_ID); + EXPECT_EQ(m.fw_version, EXP_FW_VERSION); + EXPECT_EQ(m.image_size, EXP_IMAGE_SIZE); + EXPECT_EQ(m.payload_size, EXP_PAYLOAD_SIZE); + EXPECT_EQ(m.block_count, EXP_BLOCK_COUNT); + EXPECT_EQ(m.block_size_log2, EXP_BLOCK_SIZE_LOG2); + EXPECT_EQ(m.codec_id, EXP_CODEC_ID); + EXPECT_EQ(0, memcmp(m.merkle_root, EXP_MERKLE_ROOT, 4)); + EXPECT_EQ(0, memcmp(m.image_hash, EXP_IMAGE_HASH, 32)); + ASSERT_NE(m.hw_id, nullptr); + EXPECT_EQ(0, memcmp(m.hw_id, EXP_HW_ID, 32)); // v2 hardware tag ("TESTHW" NUL-padded) + EXPECT_EQ(0, memcmp(m.approval, APPROVAL_NOT, 4)); // distributed = not approved + EXPECT_FALSE(m.is_approved()); +} + +TEST(OtaParse, RejectsTampering) { + MotaManifest m; + // bad magic + std::vector b(MOTA_VEC, MOTA_VEC + MOTA_VEC_LEN); + b[0] ^= 0xFF; + EXPECT_FALSE(mota_parse(b.data(), b.size(), m)); + // bad trailer + b.assign(MOTA_VEC, MOTA_VEC + MOTA_VEC_LEN); + b[b.size() - 1] ^= 0xFF; + EXPECT_FALSE(mota_parse(b.data(), b.size(), m)); + // wrong total-size field + b.assign(MOTA_VEC, MOTA_VEC + MOTA_VEC_LEN); + b[4] ^= 0x01; + EXPECT_FALSE(mota_parse(b.data(), b.size(), m)); +} + +// block_idx is a uint16 on the wire, so a manifest needing > 65535 blocks can't be addressed and must be +// rejected at parse (this also keeps block_count*4 from overflowing the leaves-length computation). +TEST(OtaParse, RejectsTooManyBlocks) { + auto manifest = [](uint32_t payload_size, uint8_t bsl) { // fixed-layout unsigned-full manifest + std::vector m(MOTA_MFL, 0); + m[0] = MOTA_FORMAT_VER; m[1] = MFLAG_FULL; m[2] = 0x12; + m[15] = payload_size; m[16] = payload_size >> 8; m[17] = payload_size >> 16; m[18] = payload_size >> 24; + m[19] = bsl; + return m; + }; + MotaManifest mm; + auto over = manifest(65536u * 1024u, 10); // 65536 blocks -> rejected + EXPECT_FALSE(mota_parse_manifest(over.data(), over.size(), mm)); + auto ok = manifest(65535u * 1024u, 10); // 65535 blocks -> allowed + EXPECT_TRUE(mota_parse_manifest(ok.data(), ok.size(), mm)); + EXPECT_EQ(mm.block_count, 65535u); +} + +TEST(OtaMerkle, RootMatchesVectorAndLeaves) { + MotaManifest m; + ASSERT_TRUE(mota_parse(MOTA_VEC, MOTA_VEC_LEN, m)); + // root recomputed from stored leaves[] == merkle_root field == Python's EXP_MERKLE_ROOT + uint8_t root[4]; + merkle_root(root, m.leaves, m.block_count); + EXPECT_EQ(0, memcmp(root, EXP_MERKLE_ROOT, 4)); + EXPECT_TRUE(mota_check_root(m)); + // recompute each leaf from the payload block and compare to the stored leaf + uint32_t bs = m.block_size(); + for (uint32_t i = 0; i < m.block_count; i++) { + uint32_t off = i * bs; + uint32_t len = (off + bs <= m.payload_size) ? bs : (m.payload_size - off); + uint8_t leaf[4]; + merkle_leaf(leaf, m.payload + off, len); + EXPECT_EQ(0, memcmp(leaf, m.leaves + i * 4, 4)) << "leaf " << i; + } +} + +TEST(OtaMerkle, FullImageHashMatches) { + MotaManifest m; + ASSERT_TRUE(mota_parse(MOTA_VEC, MOTA_VEC_LEN, m)); + EXPECT_TRUE(mota_check_image_hash_full(m)); +} + +TEST(OtaMerkle, ProofFromReferenceVerifies) { + MotaManifest m; + ASSERT_TRUE(mota_parse(MOTA_VEC, MOTA_VEC_LEN, m)); + uint32_t bs = m.block_size(); + uint32_t off = PROOF_INDEX * bs; + uint32_t len = (off + bs <= m.payload_size) ? bs : (m.payload_size - off); + + EXPECT_TRUE(merkle_verify(m.payload + off, len, PROOF_INDEX, + PROOF_SIBLINGS, PROOF_NSIB, EXP_MERKLE_ROOT, m.block_count)); + + // tampered block -> fails + std::vector blk(m.payload + off, m.payload + off + len); + blk[0] ^= 0xFF; + EXPECT_FALSE(merkle_verify(blk.data(), len, PROOF_INDEX, + PROOF_SIBLINGS, PROOF_NSIB, EXP_MERKLE_ROOT, m.block_count)); + + // wrong index with the same proof -> fails + EXPECT_FALSE(merkle_verify(m.payload + off, len, PROOF_INDEX + 1, + PROOF_SIBLINGS, PROOF_NSIB, EXP_MERKLE_ROOT, m.block_count)); +} + +// --- validate the O(log n) binary-counter root vs a plain level-by-level reference ---------- + +static void ref_root(uint8_t out[4], std::vector> level) { + while (level.size() > 1) { + std::vector> nxt; + for (size_t i = 0; i < level.size(); i += 2) { + if (i + 1 < level.size()) { + std::array p; + merkle_combine(p.data(), level[i].data(), level[i + 1].data()); + nxt.push_back(p); + } else { + nxt.push_back(level[i]); // promote lone last node + } + } + level.swap(nxt); + } + std::memcpy(out, level[0].data(), 4); +} + +TEST(OtaMerkle, BinaryCounterMatchesLevelByLevel) { + uint32_t state = 0x12345678; + auto rnd = [&]() { state = state * 1103515245u + 12345u; return (uint8_t)(state >> 16); }; + // O(log n) root must equal the plain level-by-level root for every count + for (uint32_t count = 1; count <= 600; count++) { + std::vector leaves(count * 4); + std::vector> ref(count); + for (uint32_t i = 0; i < count; i++) + for (int j = 0; j < 4; j++) { uint8_t v = rnd(); leaves[i * 4 + j] = v; ref[i][j] = v; } + uint8_t a[4], b[4]; + merkle_root(a, leaves.data(), count); + ref_root(b, ref); + ASSERT_EQ(0, std::memcmp(a, b, 4)) << "root mismatch count=" << count; + } +} + +// Verify every block's proof for several tricky counts, using proofs generated by the Python +// reference (the oracle) — covers deep promotion chains (100, 255, 256, ...). +TEST(OtaMerkle, ReferenceProofsAllIndices) { + for (int c = 0; c < N_PROOF_CASES; c++) { + const ProofCase& pc = PROOF_CASES[c]; + uint8_t root[4]; + merkle_root(root, pc.leaves, pc.count); + EXPECT_EQ(0, std::memcmp(root, pc.root, 4)) << "root mismatch count=" << pc.count; + for (uint32_t i = 0; i < pc.count; i++) { + EXPECT_TRUE(merkle_verify_from_leaf(pc.leaves + i * 4, i, + pc.pblob + pc.poff[i], pc.pnsib[i], pc.root, pc.count)) + << "count=" << pc.count << " idx=" << i; + } + // a wrong sibling for index 0 must fail + if (pc.pnsib[0] > 0) { + std::vector bad(pc.pblob + pc.poff[0], pc.pblob + pc.poff[0] + pc.pnsib[0] * 4); + bad[0] ^= 0xFF; + EXPECT_FALSE(merkle_verify_from_leaf(pc.leaves, 0, bad.data(), pc.pnsib[0], pc.root, pc.count)); + } + } +} + +// --- availability bitmap (derived from leaves[]) ------------------------------------------- + +TEST(OtaBitmap, AllPresentForCompleteContainer) { + MotaManifest m; + ASSERT_TRUE(mota_parse(MOTA_VEC, MOTA_VEC_LEN, m)); + EXPECT_TRUE(all_present(m.leaves, m.block_count)); + EXPECT_EQ(count_present(m.leaves, m.block_count), m.block_count); + + // a leaf slot of all-FF (erased) means "missing"; bitmap round-trips + std::vector leaves(m.leaves, m.leaves + m.block_count * 4); + std::memset(&leaves[4], 0xFF, 4); // mark block 1 missing + EXPECT_FALSE(leaf_present(leaves.data(), 1)); + EXPECT_FALSE(all_present(leaves.data(), m.block_count)); + EXPECT_EQ(count_present(leaves.data(), m.block_count), m.block_count - 1); + + std::vector bm(bitmap_bytes(m.block_count)); + leaves_to_bitmap(leaves.data(), m.block_count, bm.data()); + EXPECT_FALSE(bitmap_get(bm.data(), 1)); + EXPECT_TRUE(bitmap_get(bm.data(), 0)); +} + +// --- EndF self-firmware scan (P2) ----------------------------------------------------------- + +TEST(OtaFirmwareInfo, FindsEndFInImage) { + std::vector body(4321); + for (size_t i = 0; i < body.size(); i++) body[i] = (uint8_t)(i * 37 + 11); + std::vector img = make_image(body); + + // simulate a flash region: image, then erased 0xFF up to the partition end + std::vector region = img; + region.resize(img.size() + 4096, 0xFF); + + SelfFwInfo fi; + ASSERT_TRUE(find_self_firmware(region.data(), (uint32_t)region.size(), fi, /*verify_body=*/true)); + EXPECT_EQ(fi.body_len, body.size()); + EXPECT_EQ(fi.image_len, img.size()); + EXPECT_EQ(fi.endf_offset, body.size()); + uint8_t h[8]; mh8(h, body.data(), body.size()); + EXPECT_EQ(0, std::memcmp(fi.body_hash, h, 8)); +} + +// The self-describing identity lives at fixed offsets in the 56-byte EndF and is always parsed; a +// zero-identity trailer reports zero/"" (unknown), still at the fixed 56-byte size. +TEST(OtaFirmwareInfo, ParsesIdentity) { + std::vector body(2000); + for (size_t i = 0; i < body.size(); i++) body[i] = (uint8_t)(i * 13 + 5); + + auto img = make_image_id(body, 0x01100000u, 0x04d413fdu, "RAK4631"); + std::vector region = img; region.resize(img.size() + 4096, 0xFF); + SelfFwInfo fi; + ASSERT_TRUE(find_self_firmware(region.data(), (uint32_t)region.size(), fi, /*verify_body=*/true)); + EXPECT_EQ(fi.body_len, body.size()); + EXPECT_EQ(fi.image_len, body.size() + 56); // fixed trailer length + EXPECT_EQ(fi.fw_version, 0x01100000u); + EXPECT_EQ(fi.target_id, 0x04d413fdu); + EXPECT_STREQ(fi.hw_id, "RAK4631"); + + auto img1 = make_image(body); // zero-identity trailer (still 56 bytes) + std::vector r1 = img1; r1.resize(img1.size() + 64, 0xFF); + SelfFwInfo fi1; + ASSERT_TRUE(find_self_firmware(r1.data(), (uint32_t)r1.size(), fi1, true)); + EXPECT_EQ(fi1.fw_version, 0u); + EXPECT_EQ(fi1.target_id, 0u); + EXPECT_STREQ(fi1.hw_id, ""); + EXPECT_EQ(fi1.image_len, body.size() + 56); +} + +TEST(OtaFirmwareInfo, IgnoresStagedMotaHigherInRegion) { + // The firmware's own EndF must win even when a staged .mota (which embeds its own EndF) sits + // above it in the same region — the body_len == offset check disambiguates. + std::vector body(2000); + for (size_t i = 0; i < body.size(); i++) body[i] = (uint8_t)(i ^ 0x5A); + std::vector img = make_image(body); + + std::vector region = img; + region.resize(8192, 0xFF); // gap + // drop the reference .mota (which contains an embedded EndF in its payload) higher up + region.insert(region.end(), MOTA_VEC, MOTA_VEC + MOTA_VEC_LEN); + + SelfFwInfo fi; + ASSERT_TRUE(find_self_firmware(region.data(), (uint32_t)region.size(), fi, true)); + EXPECT_EQ(fi.endf_offset, body.size()); // found OUR firmware, not the .mota's + EXPECT_EQ(fi.body_len, body.size()); +} + +TEST(OtaFirmwareInfo, NoMarkerReturnsFalse) { + std::vector region(1000, 0xAB); + SelfFwInfo fi; + EXPECT_FALSE(find_self_firmware(region.data(), (uint32_t)region.size(), fi)); +} + +// --- signer allowlist (P3) ------------------------------------------------------------------ + +TEST(OtaAllowlist, AddContainsRemoveSerialize) { + SignerAllowlist a; + uint8_t k1[32], k2[32], k3[32]; + memset(k1, 0x11, 32); memset(k2, 0x22, 32); memset(k3, 0x33, 32); + EXPECT_FALSE(a.contains(k1)); + EXPECT_TRUE(a.add(k1)); + EXPECT_TRUE(a.add(k2)); + EXPECT_TRUE(a.add(k1)); // idempotent + EXPECT_EQ(a.count(), 2); + EXPECT_TRUE(a.contains(k1)); + EXPECT_FALSE(a.contains(k3)); + + uint8_t buf[1 + MAX_OTA_SIGNERS * 32]; + uint32_t n = a.serialize(buf, sizeof(buf)); + EXPECT_EQ(n, 1u + 2 * 32); + SignerAllowlist b; + EXPECT_TRUE(b.deserialize(buf, n)); + EXPECT_EQ(b.count(), 2); + EXPECT_TRUE(b.contains(k1) && b.contains(k2)); + + EXPECT_TRUE(a.remove(k1)); + EXPECT_EQ(a.count(), 1); + EXPECT_FALSE(a.contains(k1)); + EXPECT_TRUE(a.contains(k2)); +} + +// --- RAM store: out-of-order writes + availability via leaves[] -------------------------------- + +TEST(OtaStoreRamTest, RandomAccessAndErasedSentinel) { + OtaStoreRam<4096> s; + ASSERT_TRUE(s.begin(1000)); + EXPECT_EQ(s.staged_size(), 1000u); + uint8_t blk[8] = {1,2,3,4,5,6,7,8}; + EXPECT_TRUE(s.write(500, blk, 8)); // out-of-order offset + EXPECT_TRUE(s.write(0, blk, 8)); + EXPECT_FALSE(s.write(998, blk, 8)); // out of range + uint8_t rd[8]; + EXPECT_TRUE(s.read(500, rd, 8)); + EXPECT_EQ(0, memcmp(rd, blk, 8)); + // untouched region reads as erased 0xFF (so an unfilled leaf slot is "missing") + EXPECT_TRUE(s.read(100, rd, 8)); + for (int i = 0; i < 8; i++) EXPECT_EQ(rd[i], 0xFF); +} + +// --- merkle proof GENERATION (server side) matches the Python oracle --------------------------- + +TEST(OtaMerkle, GenProofMatchesPythonAndVerifies) { + for (int c = 0; c < N_PROOF_CASES; c++) { + const ProofCase& pc = PROOF_CASES[c]; + std::vector scratch(pc.count * 4); + uint8_t out[32 * 4]; + for (uint32_t i = 0; i < pc.count; i++) { + uint8_t n = merkle_gen_proof(pc.leaves, pc.count, i, scratch.data(), out); + ASSERT_EQ(n, pc.pnsib[i]) << "count=" << pc.count << " idx=" << i; + EXPECT_EQ(0, std::memcmp(out, pc.pblob + pc.poff[i], (size_t)n * 4)) + << "gen_proof != python count=" << pc.count << " idx=" << i; + EXPECT_TRUE(merkle_verify_from_leaf(pc.leaves + i * 4, i, out, n, pc.root, pc.count)); + } + } +} + +// --- protocol codec round-trips --------------------------------------------------------------- + +TEST(OtaProtocol, CodecRoundTrips) { + uint8_t buf[200]; + + // OTA_ADV is now a tiny per-node beacon: seeder_id + n_motas + set_digest + AdvMsg adv{{0x29,0x17,0xe4,0xf7}, 7, {0xde,0xad,0xbe,0xef}}; + uint16_t n = encode_adv(buf, sizeof(buf), adv); + ASSERT_GT(n, 0); EXPECT_EQ(ota_msg_type(buf, n), OTA_ADV); EXPECT_EQ(n, 10); + AdvMsg a2; ASSERT_TRUE(decode_adv(buf, n, a2)); + EXPECT_EQ(0, memcmp(a2.seeder_id, adv.seeder_id, 4)); + EXPECT_EQ(a2.n_motas, 7); + EXPECT_EQ(0, memcmp(a2.set_digest, adv.set_digest, 4)); + + // OTA_QUERY: ask a source (by seeder_id) for the offering set_digest, optionally filtered to a target + QueryMsg qy{{0x29,0x17,0xe4,0xf7}, {0xd1,0xd2,0xd3,0xd4}, 0x11223344}; + n = encode_query(buf, sizeof(buf), qy); + ASSERT_GT(n, 0); EXPECT_EQ(ota_msg_type(buf, n), OTA_QUERY); + QueryMsg q2; ASSERT_TRUE(decode_query(buf, n, q2)); + EXPECT_EQ(0, memcmp(q2.seeder_id, qy.seeder_id, 4)); + EXPECT_EQ(0, memcmp(q2.set_digest, qy.set_digest, 4)); + EXPECT_EQ(q2.filter_target, 0x11223344u); + + // OTA_HAVE: a 2-row catalog (mid, target, fwver, codec, flags per row) tagged with the offering digest + uint8_t rows[2 * OTA_HAVE_ROW_BYTES]; + for (int i = 0; i < 2 * OTA_HAVE_ROW_BYTES; i++) rows[i] = (uint8_t)(i + 1); + HaveMsg hv{{0x29,0x17,0xe4,0xf7}, {0xd1,0xd2,0xd3,0xd4}, 0, 1, 2, rows}; + n = encode_have(buf, sizeof(buf), hv); + ASSERT_GT(n, 0); EXPECT_EQ(ota_msg_type(buf, n), OTA_HAVE); + HaveMsg h2; ASSERT_TRUE(decode_have(buf, n, h2)); + EXPECT_EQ(0, memcmp(h2.seeder_id, hv.seeder_id, 4)); + EXPECT_EQ(0, memcmp(h2.set_digest, hv.set_digest, 4)); + EXPECT_EQ(h2.frag_total, 1); EXPECT_EQ(h2.n_rows, 2); + EXPECT_EQ(0, memcmp(h2.rows, rows, 2 * OTA_HAVE_ROW_BYTES)); + + GetManifestMsg gm{{1,2,3,4}}; + n = encode_get_manifest(buf, sizeof(buf), gm); + GetManifestMsg g2; ASSERT_TRUE(decode_get_manifest(buf, n, g2)); + EXPECT_EQ(0, memcmp(g2.manifest_id, gm.manifest_id, 4)); + + uint8_t mbytes[40]; for (int i = 0; i < 40; i++) mbytes[i] = (uint8_t)(i + 1); + ManifestMsg mm{{9,8,7,6}, 0, 1, mbytes, 40}; + n = encode_manifest(buf, sizeof(buf), mm); + ManifestMsg m2; ASSERT_TRUE(decode_manifest(buf, n, m2)); + EXPECT_EQ(m2.frag_idx, 0); EXPECT_EQ(m2.frag_total, 1); EXPECT_EQ(m2.len, 40); + EXPECT_EQ(0, memcmp(m2.bytes, mbytes, 40)); + + ReqMsg rq{{4,3,2,1}, 7, 5}; + n = encode_req(buf, sizeof(buf), rq); + ReqMsg r2; ASSERT_TRUE(decode_req(buf, n, r2)); + EXPECT_EQ(r2.start_block, 7); EXPECT_EQ(r2.count, 5); + + // DATA is one self-describing fragment of a block (frag_off places it; proof is fetched separately) + uint8_t data[100]; for (int i = 0; i < 100; i++) data[i] = (uint8_t)(i * 3); + DataMsg dm{{0,1,2,3}, 42, 0, data, 100}; // block 42, fragment at offset 0 + n = encode_data(buf, sizeof(buf), dm); + DataMsg d2; ASSERT_TRUE(decode_data(buf, n, d2)); + EXPECT_EQ(d2.block_idx, 42); EXPECT_EQ(d2.frag_off, 0); + EXPECT_EQ(d2.data_len, 100); EXPECT_EQ(0, memcmp(d2.data, data, 100)); + + // a later slice of the same block (non-zero frag_off) + DataMsg dm2{{0,1,2,3}, 42, 160, data, 50}; + n = encode_data(buf, sizeof(buf), dm2); + DataMsg d3; ASSERT_TRUE(decode_data(buf, n, d3)); + EXPECT_EQ(d3.block_idx, 42); EXPECT_EQ(d3.frag_off, 160); EXPECT_EQ(d3.data_len, 50); + + // REQ_PROOF: request the merkle proof for one (reassembled) block + ReqProofMsg rp{{7,7,8,8}, 13}; + n = encode_req_proof(buf, sizeof(buf), rp); + ASSERT_GT(n, 0); EXPECT_EQ(ota_msg_type(buf, n), OTA_REQ_PROOF); + ReqProofMsg rp2; ASSERT_TRUE(decode_req_proof(buf, n, rp2)); + EXPECT_EQ(0, memcmp(rp2.manifest_id, rp.manifest_id, 4)); EXPECT_EQ(rp2.block_idx, 13); + + // PROOF: ordered sibling digests for one block + uint8_t proof[12]; for (int i = 0; i < 12; i++) proof[i] = (uint8_t)(0xA0 + i); + ProofMsg pm{{7,7,8,8}, 13, 3, proof}; + n = encode_proof(buf, sizeof(buf), pm); + ASSERT_GT(n, 0); EXPECT_EQ(ota_msg_type(buf, n), OTA_PROOF); + ProofMsg pm2; ASSERT_TRUE(decode_proof(buf, n, pm2)); + EXPECT_EQ(0, memcmp(pm2.manifest_id, pm.manifest_id, 4)); + EXPECT_EQ(pm2.block_idx, 13); EXPECT_EQ(pm2.n_proof, 3); + EXPECT_EQ(0, memcmp(pm2.proof, proof, 12)); +} + +// --- full transfer simulation between two OtaManagers (P4b) ------------------------------------ + +namespace { +struct SimMsg { OtaManager* dest; std::vector bytes; }; +static std::vector g_q; +struct SendTo { OtaManager* dest; }; +static void sim_send(void* ctx, const uint8_t* msg, uint16_t len, bool /*flood*/) { + g_q.push_back({((SendTo*)ctx)->dest, std::vector(msg, msg + len)}); +} +// Drive the bus to quiescence: deliver queued messages; when idle, advance the client's clock (monotonic +// across calls, so a jittered query scheduled in a prior pump still comes due) and call loop() (fires the +// scheduled catalog query / block re-requests). Two idle ticks in a row = quiescent. +static uint32_t g_clk = 0; +static void pump(OtaManager& client, int guard_max = 200000) { + int idle = 0, guard = 0; + while (guard++ < guard_max) { + if (!g_q.empty()) { + SimMsg m = std::move(g_q.front()); g_q.erase(g_q.begin()); + m.dest->on_message(m.bytes.data(), (uint16_t)m.bytes.size()); + idle = 0; + } else { + g_clk += 5000; client.set_clock(g_clk); client.loop(); + if (!g_q.empty()) { idle = 0; continue; } + if (++idle >= 2) break; + } + } +} + +// A test MotaSource backing an external "folder" with one or more complete `.mota` images held in RAM — +// the simplest concrete transport (a real device uses serial/BLE/WiFi/FS, same interface). describe() +// parses each container for the catalog + region offsets; read() is a bounds-checked memcpy. +class RamMotaSource : public mesh::ota::MotaSource { +public: + void add(const uint8_t* buf, uint32_t len) { if (_n < 8) { _buf[_n] = buf; _len[_n] = len; _n++; } } + uint8_t count() override { return _n; } + bool describe(uint8_t idx, mesh::ota::MotaDesc& d) override { + if (idx >= _n) return false; + MotaManifest m; + if (!mota_parse(_buf[idx], _len[idx], m)) return false; + std::memcpy(d.mid, m.merkle_root, 4); + d.target_id = m.target_id; d.fw_version = m.fw_version; + d.codec_id = m.codec_id; d.flags = m.flags; + d.total_size = _len[idx]; + d.leaves_off = (uint32_t)(m.leaves - _buf[idx]); + d.block_count = m.block_count; + d.payload_off = (uint32_t)(m.payload - _buf[idx]); + d.payload_size = m.payload_size; + return true; + } + bool read(uint8_t idx, uint32_t off, uint8_t* out, uint32_t len) override { + if (idx >= _n || (uint64_t)off + len > _len[idx]) return false; + std::memcpy(out, _buf[idx] + off, len); + return true; + } +private: + const uint8_t* _buf[8] = {nullptr}; uint32_t _len[8] = {0}; uint8_t _n = 0; +}; +} + +TEST(OtaTransfer, TwoManagersFullTransfer) { + g_q.clear(); + OtaManager server, client; + OtaStoreRam<4096> store; + SendTo to_client{&client}, to_server{&server}; + + server.begin(/*server's own target irrelevant for serving*/ 0, sim_send, &to_client); + client.begin(SIM_TARGET_ID, sim_send, &to_server); + client.set_fetch_store(&store); + client.set_autofetch(OtaManager::AUTOFETCH_ANY); // tests exercise fetch-on-advert; policy default is OFF + + ASSERT_TRUE(server.serve(SIM_MOTA, SIM_MOTA_LEN)); + server.announce(); // -> client hears the beacon, queries, catalogs, then fetches + + pump(client); // beacon -> query -> have -> startFetch -> full transfer + + EXPECT_EQ(client.fetchState(), OtaManager::COMPLETE); + EXPECT_EQ(client.blocksHave(), client.blocksTotal()); + EXPECT_GT(client.blocksTotal(), 1u); + + // the client's reassembled container must be byte-identical to the original .mota... + ASSERT_EQ(store.staged_size(), SIM_MOTA_LEN); + EXPECT_EQ(0, std::memcmp(store.data(), SIM_MOTA, SIM_MOTA_LEN)); + + // ...and independently re-verify it parses with a matching root + image_hash + MotaManifest m; + ASSERT_TRUE(mota_parse(store.data(), store.staged_size(), m)); + EXPECT_TRUE(mota_check_root(m)); + EXPECT_TRUE(mota_check_image_hash_full(m)); +} + +// Same end-to-end transfer, but with 1 KB logical blocks: each block is delivered as several +// self-describing DATA fragments (frag_off), reassembled by the client, then its merkle PROOF is +// requested + verified separately before the block is committed. Exercises the multi-fragment path. +TEST(OtaTransfer, MultiFragmentBlocks) { + g_q.clear(); + OtaManager server, client; + OtaStoreRam<4096> store; + SendTo to_client{&client}, to_server{&server}; + + server.begin(0, sim_send, &to_client); + client.begin(SIM_TARGET_ID, sim_send, &to_server); + client.set_fetch_store(&store); + client.set_autofetch(OtaManager::AUTOFETCH_ANY); + + ASSERT_TRUE(server.serve(SIM_MOTA_1K, SIM_MOTA_1K_LEN)); + server.announce(); + + pump(client); + + EXPECT_EQ(client.fetchState(), OtaManager::COMPLETE); + EXPECT_EQ(client.blocksTotal(), SIM_MOTA_1K_BLOCKS); // 1 KB blocks => fewer, larger blocks + EXPECT_EQ(client.blocksHave(), client.blocksTotal()); + + ASSERT_EQ(store.staged_size(), SIM_MOTA_1K_LEN); + EXPECT_EQ(0, std::memcmp(store.data(), SIM_MOTA_1K, SIM_MOTA_1K_LEN)); + MotaManifest m; + ASSERT_TRUE(mota_parse(store.data(), store.staged_size(), m)); + EXPECT_TRUE(mota_check_root(m)); + EXPECT_TRUE(mota_check_image_hash_full(m)); +} + +// Multi-mota folder serve: a node serves its OWN fw (view0) PLUS an external folder (RamMotaSource) of +// other `.mota`. Peers discover BOTH via the tiny beacon -> query -> broadcast HAVE catalog, then fetch an +// external mota end-to-end. The relaying node never holds the folder image in RAM — it streams the +// manifest/leaves/blocks from the source on demand (loadSource + srcReadTramp + proof-gen from read +// leaves). The fetched bytes must equal the original `.mota` (proves the trustless relay is byte-exact). +TEST(OtaFolder, ServesSelfPlusFolderAndFetchesExternal) { + g_q.clear(); + OtaManager server, client; + OtaStoreRam<4096> store; + SendTo to_client{&client}, to_server{&server}; + + server.begin(/*own target irrelevant for serving*/ 0, sim_send, &to_client); + uint8_t srv_id[4] = {0xAB, 0xCD, 0xEF, 0x01}; server.set_seeder_id(srv_id); + client.begin(SIM_TARGET_ID, sim_send, &to_server); + client.set_fetch_store(&store); + + MotaManifest mSelf, mExt; + ASSERT_TRUE(mota_parse(SIM_MOTA, SIM_MOTA_LEN, mSelf)); // served as our own fw (view0) + ASSERT_TRUE(mota_parse(SIM_MOTA_1K, SIM_MOTA_1K_LEN, mExt)); // served from the external folder + + ASSERT_TRUE(server.serve(SIM_MOTA, SIM_MOTA_LEN)); // entry 0 = self + static RamMotaSource folder; + folder.add(SIM_MOTA_1K, SIM_MOTA_1K_LEN); // an external image (different mid) + folder.add(SIM_MOTA, SIM_MOTA_LEN); // same as self -> must be DEDUPED + ASSERT_TRUE(server.add_source(&folder)); + EXPECT_EQ(server.servedCount(), 2); // self + 1 distinct folder mota (dedup) + + // discovery: beacon -> the client catalogs the source, queries it, and the broadcast HAVE fills the + // catalog with BOTH served mids. + server.announce(); + pump(client); + client.queryAll(); + pump(client); + EXPECT_EQ(client.catalogCount(), 2); + + // fetch the EXTERNAL (folder) mota by mid -> served via the source, relayed block-by-block. + client.pull(mExt.merkle_root, mExt.target_id); + pump(client); + + EXPECT_EQ(client.fetchState(), OtaManager::COMPLETE); + EXPECT_EQ(client.blocksHave(), client.blocksTotal()); + ASSERT_EQ(store.staged_size(), SIM_MOTA_1K_LEN); + EXPECT_EQ(0, std::memcmp(store.data(), SIM_MOTA_1K, SIM_MOTA_1K_LEN)); // byte-exact relay + MotaManifest got; + ASSERT_TRUE(mota_parse(store.data(), store.staged_size(), got)); + EXPECT_TRUE(mota_check_root(got)); + EXPECT_TRUE(mota_check_image_hash_full(got)); +} + +// --- swarm: a completed peer re-seeds beyond the origin (epidemic spread) --------------------- +namespace { +// A topology-aware bus: each node delivers only to its listed neighbours (so we can build multi-hop chains +// the origin can't reach directly). DATA emits are counted per node to observe who actually sources blocks. +struct TopoNode { int idx; }; +static std::vector g_tn; +static std::vector> g_adj; +static std::vector g_tdata; +static std::vector>> g_tq; +static size_t g_th = 0; +static uint32_t g_tclk = 0; +static void topo_send(void* ctx, const uint8_t* msg, uint16_t len, bool) { + int from = ((TopoNode*)ctx)->idx; + if (len && msg[0] == OTA_DATA) g_tdata[from]++; + for (int nb : g_adj[from]) g_tq.push_back({nb, std::vector(msg, msg + len)}); +} +static void topo_pump(int guard = 2000000) { + int idle = 0, g = 0; + while (g++ < guard) { + if (g_th < g_tq.size()) { + auto m = g_tq[g_th++]; + g_tn[m.first]->on_message(m.second.data(), (uint16_t)m.second.size()); + idle = 0; + if (g_th > 8192) { g_tq.erase(g_tq.begin(), g_tq.begin() + g_th); g_th = 0; } + } else { + g_tclk += 1000; + for (auto* nd : g_tn) { nd->set_clock(g_tclk); nd->loop(); } + if (g_th < g_tq.size()) { idle = 0; continue; } + if (++idle >= 3) break; + } + } +} +} + +// Line topology: origin <-> relay <-> leaf, with origin and leaf NOT connected. The relay fetches from the +// origin, COMPLETEs, and re-seeds; the leaf — which can ONLY hear the relay — must then obtain the whole +// firmware from the relay. If the leaf completes, the load provably spread off the origin (the origin never +// served the leaf). Validates re-serve-after-complete (and the partial-re-serve serve path it shares). +TEST(OtaSwarm, CompletedPeerReSeedsBeyondOrigin) { + g_tn.clear(); g_adj.clear(); g_tdata.clear(); g_tq.clear(); g_th = 0; g_tclk = 0; + static OtaManager origin, relay, leaf; + static OtaStoreRam<4096> rstore, lstore; + g_tn = {&origin, &relay, &leaf}; + g_adj = {{1}, {0, 2}, {1}}; // origin<->relay<->leaf + g_tdata = {0, 0, 0}; + static TopoNode t0{0}, t1{1}, t2{2}; + uint8_t id0[4] = {1,1,1,1}, id1[4] = {2,2,2,2}, id2[4] = {3,3,3,3}; + origin.begin(0, topo_send, &t0); origin.set_seeder_id(id0); + relay.begin(SIM_TARGET_ID, topo_send, &t1); relay.set_seeder_id(id1); + relay.set_fetch_store(&rstore); relay.set_autofetch(OtaManager::AUTOFETCH_ANY); + leaf.begin(SIM_TARGET_ID, topo_send, &t2); leaf.set_seeder_id(id2); + leaf.set_fetch_store(&lstore); leaf.set_autofetch(OtaManager::AUTOFETCH_ANY); + + ASSERT_TRUE(origin.serve(SIM_MOTA, SIM_MOTA_LEN)); + origin.announce(); + topo_pump(); + ASSERT_EQ(relay.fetchState(), OtaManager::COMPLETE); // relay sourced it from the origin + + relay.announce(); // relay now beacons its catalog (incl. the re-seeded mota) + topo_pump(); + EXPECT_EQ(leaf.fetchState(), OtaManager::COMPLETE); // leaf got it ONLY via the relay (re-serve) + ASSERT_EQ(lstore.staged_size(), SIM_MOTA_LEN); + EXPECT_EQ(0, std::memcmp(lstore.data(), SIM_MOTA, SIM_MOTA_LEN)); // byte-exact through the relay + EXPECT_GT(g_tdata[1], 0); // the relay actually served DATA (re-seeded) +} + +// Fetch-resume across a reboot: a client commits some blocks, "reboots" (a fresh OtaManager on the SAME +// persisted store), and resumeStaged() re-adopts the partial container and finishes the remaining blocks — +// without re-fetching the manifest or the blocks already present. +TEST(OtaTransfer, ResumeAfterReboot) { + g_q.clear(); + OtaManager server, client; + OtaStoreRam<4096> store; + SendTo to_client{&client}, to_server{&server}; + + server.begin(0, sim_send, &to_client); + client.begin(SIM_TARGET_ID, sim_send, &to_server); + client.set_fetch_store(&store); + client.set_autofetch(OtaManager::AUTOFETCH_ANY); + + ASSERT_TRUE(server.serve(SIM_MOTA_1K, SIM_MOTA_1K_LEN)); + server.announce(); + + // drive only until the first block commits, then "crash" + int idle = 0, guard = 0; + while (guard++ < 100000) { + if (!g_q.empty()) { + SimMsg msg = std::move(g_q.front()); g_q.erase(g_q.begin()); + msg.dest->on_message(msg.bytes.data(), (uint16_t)msg.bytes.size()); + idle = 0; + } else { + g_clk += 5000; client.set_clock(g_clk); client.loop(); + if (!g_q.empty()) { idle = 0; } else if (++idle >= 2) break; + } + if (client.blocksHave() >= 1) break; + } + ASSERT_GE(client.blocksHave(), 1u); + ASSERT_LT(client.blocksHave(), client.blocksTotal()); // genuinely partial + uint32_t had = client.blocksHave(); + g_q.clear(); // in-flight packets are lost in the "reboot" + + // "reboot": a brand-new manager on the SAME store (its bytes survived) resumes the partial + OtaManager client2; + to_client.dest = &client2; // server now replies to the rebooted client + SendTo to_server2{&server}; + client2.begin(SIM_TARGET_ID, sim_send, &to_server2); + client2.set_fetch_store(&store); + ASSERT_TRUE(client2.resumeStaged(nullptr)); // adopt whatever is staged + EXPECT_EQ(client2.blocksHave(), had); // resumed exactly where we left off + EXPECT_EQ(client2.fetchState(), OtaManager::FETCHING); + EXPECT_EQ(client2.blocksTotal(), SIM_MOTA_1K_BLOCKS); + + pump(client2); + EXPECT_EQ(client2.fetchState(), OtaManager::COMPLETE); + ASSERT_EQ(store.staged_size(), SIM_MOTA_1K_LEN); + EXPECT_EQ(0, std::memcmp(store.data(), SIM_MOTA_1K, SIM_MOTA_1K_LEN)); // byte-identical to the original +} + +TEST(OtaTransfer, ClientRejectsWrongTarget) { + g_q.clear(); + OtaManager server, client; + OtaStoreRam<4096> store; + SendTo to_client{&client}, to_server{&server}; + server.begin(0, sim_send, &to_client); + client.begin(SIM_TARGET_ID ^ 0x1u, sim_send, &to_server); // different target -> not interested + client.set_fetch_store(&store); + client.set_autofetch(OtaManager::AUTOFETCH_ANY); // tests exercise fetch-on-advert; policy default is OFF + ASSERT_TRUE(server.serve(SIM_MOTA, SIM_MOTA_LEN)); + server.announce(); + pump(client); // catalogs the row but wantRow rejects it (wrong target) -> never fetches + EXPECT_EQ(client.fetchState(), OtaManager::IDLE); // never started +} + +TEST(OtaTransfer, ManualCrossTargetFetch) { + // A node whose own target differs from the served firmware normally won't fetch (role-switch case: + // e.g. companion wanting repeater firmware). An explicit want() override lets it fetch deliberately. + g_q.clear(); + OtaManager server, client; + OtaStoreRam<4096> store; + SendTo to_client{&client}, to_server{&server}; + server.begin(0, sim_send, &to_client); + client.begin(SIM_TARGET_ID ^ 0xABCDu, sim_send, &to_server); // DIFFERENT own target + client.set_fetch_store(&store); + client.set_autofetch(OtaManager::AUTOFETCH_ANY); // tests exercise fetch-on-advert; policy default is OFF + ASSERT_TRUE(server.serve(SIM_MOTA, SIM_MOTA_LEN)); + + // without the override: catalogs the row but won't fetch (wrong target) + server.announce(); + pump(client); + EXPECT_EQ(client.fetchState(), OtaManager::IDLE); + + // with want(): deliberately fetch the different-target firmware to completion + client.want(SIM_TARGET_ID); + server.announce(); + pump(client); + EXPECT_EQ(client.fetchState(), OtaManager::COMPLETE); + ASSERT_EQ(store.staged_size(), SIM_MOTA_LEN); + EXPECT_EQ(0, std::memcmp(store.data(), SIM_MOTA, SIM_MOTA_LEN)); +} + +// Encode a 1-row OTA_HAVE catalog (the discovery reply a peer acts on). +static uint16_t make_have1(uint8_t* buf, uint16_t cap, const uint8_t mid[4], + uint32_t target, uint32_t fwver, uint8_t codec, uint8_t flags) { + uint8_t row[OTA_HAVE_ROW_BYTES]; + memcpy(row, mid, 4); + row[4]=target; row[5]=target>>8; row[6]=target>>16; row[7]=target>>24; + row[8]=fwver; row[9]=fwver>>8; row[10]=fwver>>16; row[11]=fwver>>24; + row[12]=codec; row[13]=flags; + row[14]=0; row[15]=0; // have_count (unused in this 1-row discovery test) + HaveMsg hv{{0xAA,0xBB,0xCC,0xDD}, {0,0,0,0}, 0, 1, 1, row}; + return encode_have(buf, cap, hv); +} + +// A node must not fetch firmware it can't apply: a catalog row whose codec the platform can't decode is +// not fetched. FULL + the platform's delta codec(s) are accepted. +TEST(OtaTransfer, RejectsIncompatibleCodec) { + g_q.clear(); + OtaManager client; OtaStoreRam<4096> store; + SendTo to_server{&client}; // dest unused (we only check client state) + client.begin(SIM_TARGET_ID, sim_send, &to_server); + client.set_fetch_store(&store); + client.set_autofetch(OtaManager::AUTOFETCH_ANY); + client.set_apply_codec(CODEC_DETOOLS_INPLACE); // nRF52-style: accepts only full + in-place + uint8_t b[64]; + + // a SEQUENTIAL delta for our target -> incompatible -> not fetched (stays IDLE) + uint8_t midA[4] = {1,2,3,4}; + client.on_message(b, make_have1(b, sizeof(b), midA, SIM_TARGET_ID, 0x01000000, CODEC_DETOOLS_SEQUENTIAL, 0)); + EXPECT_EQ(client.fetchState(), OtaManager::IDLE); + + // an IN-PLACE delta for our target -> compatible -> begins fetching (requests the manifest) + uint8_t midB[4] = {5,6,7,8}; + client.on_message(b, make_have1(b, sizeof(b), midB, SIM_TARGET_ID, 0x01000000, CODEC_DETOOLS_INPLACE, 0)); + EXPECT_EQ(client.fetchState(), OtaManager::WANT_MANIFEST); + g_q.clear(); +} + +// Encode a 1-row OTA_HAVE from a specific seeder, carrying have_count (Phase-2 awareness). +static uint16_t make_have_row(uint8_t* buf, uint16_t cap, const uint8_t mid[4], uint32_t target, + uint32_t fwver, uint8_t codec, uint8_t flags, + const uint8_t seeder[4], uint16_t have_count) { + uint8_t row[OTA_HAVE_ROW_BYTES]; + memcpy(row, mid, 4); + row[4]=target; row[5]=target>>8; row[6]=target>>16; row[7]=target>>24; + row[8]=fwver; row[9]=fwver>>8; row[10]=fwver>>16; row[11]=fwver>>24; + row[12]=codec; row[13]=flags; + row[14]=(uint8_t)(have_count & 0xFF); row[15]=(uint8_t)(have_count >> 8); + HaveMsg hv; memcpy(hv.seeder_id, seeder, 4); memset(hv.set_digest, 0, 4); + hv.frag_idx=0; hv.frag_total=1; hv.n_rows=1; hv.rows=row; + return encode_have(buf, cap, hv); +} + +// Catalog accounting: "N nodes have it" must count DISTINCT seeders (a repeated HAVE from one node must +// not inflate it), and have_max tracks the best progress any source reported. +TEST(OtaCatalog, DistinctSeederCountAndHaveCount) { + OtaManager m; SendTo none{&m}; m.begin(SIM_TARGET_ID, sim_send, &none); + uint8_t b[64]; uint8_t mid[4]={9,9,9,9}; + uint8_t s1[4]={1,0,0,0}, s2[4]={2,0,0,0}; + m.on_message(b, make_have_row(b, sizeof b, mid, SIM_TARGET_ID, 0x01020300, CODEC_FULL, 0, s1, 5)); + m.on_message(b, make_have_row(b, sizeof b, mid, SIM_TARGET_ID, 0x01020300, CODEC_FULL, 0, s1, 7)); // same seeder + ASSERT_EQ(m.catalogCount(), 1); + EXPECT_EQ(m.catalogRow(0)->n_seeders, 1); // counted once despite two HAVEs + EXPECT_EQ(m.catalogRow(0)->have_max, 7u); // max progress seen + m.on_message(b, make_have_row(b, sizeof b, mid, SIM_TARGET_ID, 0x01020300, CODEC_FULL, 0, s2, 3)); // new seeder + EXPECT_EQ(m.catalogRow(0)->n_seeders, 2); + EXPECT_EQ(m.catalogRow(0)->have_max, 7u); // still the max, not overwritten by the lower one + g_q.clear(); +} + +// An unanswered GET_MANIFEST must not pin the fetch slot forever: after OTA_MANIFEST_MAX_RETRY ticks with +// no manifest, the session gives up (FAILED) so a new pull can take the slot. (Lowest-priority + bounded.) +TEST(OtaTransfer, ManifestGiveUpAfterRetries) { + g_q.clear(); + OtaManager client; OtaStoreRam<4096> store; SendTo to_none{&client}; + client.begin(SIM_TARGET_ID, sim_send, &to_none); + client.set_fetch_store(&store); + uint8_t mid[4]={7,7,7,7}; + client.pull(mid, SIM_TARGET_ID); // no server -> stuck WANT_MANIFEST + EXPECT_EQ(client.fetchState(), OtaManager::WANT_MANIFEST); + for (int i = 0; i < OTA_MANIFEST_MAX_RETRY + 2; i++) { g_clk += 5000; client.set_clock(g_clk); client.loop(); g_q.clear(); } + EXPECT_EQ(client.fetchState(), OtaManager::FAILED); +} + +// Re-seeding a completed download must stop when the session is dropped (the staging store is cleared right +// after), so the node never advertises a mota it can no longer serve. +TEST(OtaSwarm, ReSeedStopsAfterDrop) { + g_q.clear(); + OtaManager server, client; OtaStoreRam<4096> store; + SendTo to_client{&client}, to_server{&server}; + server.begin(0, sim_send, &to_client); + client.begin(SIM_TARGET_ID, sim_send, &to_server); + client.set_fetch_store(&store); + client.set_autofetch(OtaManager::AUTOFETCH_ANY); + ASSERT_TRUE(server.serve(SIM_MOTA, SIM_MOTA_LEN)); + server.announce(); + pump(client); + ASSERT_EQ(client.fetchState(), OtaManager::COMPLETE); + EXPECT_EQ(client.servedCount(), 1); // re-seeding the completed download to peers + client.reset_session(); + EXPECT_EQ(client.servedCount(), 0); // dropped -> stops advertising it +} + +// --- detools delta decode (vendored detools C decoder, CRLE-only build) ---------------------- +// Mirrors the device apply path (src/helpers/ota/OtaApply.cpp): base read via from_read/from_seek, +// patch streamed via patch_read, output written via to_write. Proves the on-device delta apply uses +// detools 0.53.0's own decoder and reproduces the exact target the host packager targeted. +namespace { +struct DTMem { + const uint8_t* base; long base_len; long base_pos; + const uint8_t* patch; long patch_len; long patch_pos; + std::vector out; +}; +int dt_from_read(void* a, uint8_t* b, size_t n) { + DTMem* c = (DTMem*)a; + if (c->base_pos < 0 || c->base_pos + (long)n > c->base_len) return -DETOOLS_IO_FAILED; + std::memcpy(b, c->base + c->base_pos, n); c->base_pos += (long)n; return DETOOLS_OK; +} +int dt_from_seek(void* a, int off) { + DTMem* c = (DTMem*)a; c->base_pos += off; + if (c->base_pos < 0 || c->base_pos > c->base_len) return -DETOOLS_IO_FAILED; + return DETOOLS_OK; +} +int dt_patch_read(void* a, uint8_t* b, size_t n) { + DTMem* c = (DTMem*)a; + if (c->patch_pos + (long)n > c->patch_len) return -DETOOLS_IO_FAILED; + std::memcpy(b, c->patch + c->patch_pos, n); c->patch_pos += (long)n; return DETOOLS_OK; +} +int dt_to_write(void* a, const uint8_t* b, size_t n) { + DTMem* c = (DTMem*)a; c->out.insert(c->out.end(), b, b + n); return DETOOLS_OK; +} + +// In-place apply over a flat memory region (models the nRF52 app workspace / the bootloader's flash). +struct DTInPlace { + std::vector mem; // [0,memory_size): base in, target out + const uint8_t* patch; long plen, ppos; int step; +}; +int ip_mem_read(void* a, void* dst, uintptr_t src, size_t n) { + DTInPlace* c = (DTInPlace*)a; if (src + n > c->mem.size()) return -DETOOLS_IO_FAILED; + std::memcpy(dst, c->mem.data() + src, n); return DETOOLS_OK; +} +int ip_mem_write(void* a, uintptr_t dst, void* src, size_t n) { + DTInPlace* c = (DTInPlace*)a; if (dst + n > c->mem.size()) return -DETOOLS_IO_FAILED; + std::memcpy(c->mem.data() + dst, src, n); return DETOOLS_OK; +} +int ip_mem_erase(void* a, uintptr_t addr, size_t n) { + DTInPlace* c = (DTInPlace*)a; if (addr + n > c->mem.size()) return -DETOOLS_IO_FAILED; + std::memset(c->mem.data() + addr, 0xFF, n); return DETOOLS_OK; +} +int ip_step_set(void* a, int s) { ((DTInPlace*)a)->step = s; return DETOOLS_OK; } +int ip_step_get(void* a, int* s) { *s = ((DTInPlace*)a)->step; return DETOOLS_OK; } +int ip_patch_read(void* a, uint8_t* b, size_t n) { + DTInPlace* c = (DTInPlace*)a; if (c->ppos + (long)n > c->plen) return -DETOOLS_IO_FAILED; + std::memcpy(b, c->patch + c->ppos, n); c->ppos += (long)n; return DETOOLS_OK; +} +} // namespace + +TEST(Detools, SequentialCrlePatchReproducesTarget) { + DTMem c{DT_BASE, (long)DT_BASE_LEN, 0, DT_PATCH, (long)DT_PATCH_LEN, 0, {}}; + int r = detools_apply_patch_callbacks(dt_from_read, dt_from_seek, dt_patch_read, + (size_t)DT_PATCH_LEN, dt_to_write, &c); + ASSERT_EQ(r, (int)DT_TARGET_LEN); // returns to-size on success + ASSERT_EQ(c.out.size(), (size_t)DT_TARGET_LEN); + EXPECT_EQ(0, std::memcmp(c.out.data(), DT_TARGET, DT_TARGET_LEN)); +} + +TEST(Detools, WrongBaseDoesNotReproduceTarget) { + // a base that differs from the one the patch was built against must NOT yield the target + std::vector bad(DT_BASE, DT_BASE + DT_BASE_LEN); + for (size_t i = 0; i < bad.size(); i += 7) bad[i] ^= 0xFF; + DTMem c{bad.data(), (long)bad.size(), 0, DT_PATCH, (long)DT_PATCH_LEN, 0, {}}; + int r = detools_apply_patch_callbacks(dt_from_read, dt_from_seek, dt_patch_read, + (size_t)DT_PATCH_LEN, dt_to_write, &c); + bool reproduced = (r == (int)DT_TARGET_LEN && c.out.size() == (size_t)DT_TARGET_LEN && + std::memcmp(c.out.data(), DT_TARGET, DT_TARGET_LEN) == 0); + EXPECT_FALSE(reproduced); // wrong base -> wrong/short output (the device then fails image_hash) +} + +TEST(Detools, TruncatedPatchFails) { + DTMem c{DT_BASE, (long)DT_BASE_LEN, 0, DT_PATCH, (long)(DT_PATCH_LEN / 2), 0, {}}; + int r = detools_apply_patch_callbacks(dt_from_read, dt_from_seek, dt_patch_read, + (size_t)(DT_PATCH_LEN / 2), dt_to_write, &c); + EXPECT_TRUE(r < 0 || c.out.size() != (size_t)DT_TARGET_LEN); +} + +// nRF52 path: the bootloader applies an in-place patch over the single app slot. Model the app +// region as a DT_IP_MEM buffer holding the base; after apply, region[0:to_size] must equal the target. +TEST(Detools, InPlaceCrlePatchReproducesTarget) { + DTInPlace c; c.mem.assign(DT_IP_MEM, 0xFF); + std::memcpy(c.mem.data(), DT_IP_BASE, DT_IP_BASE_LEN); // base loaded at offset 0 + c.patch = DT_IP_PATCH; c.plen = DT_IP_PATCH_LEN; c.ppos = 0; c.step = 0; + int r = detools_apply_patch_in_place_callbacks(ip_mem_read, ip_mem_write, ip_mem_erase, + ip_step_set, ip_step_get, ip_patch_read, + (size_t)DT_IP_PATCH_LEN, &c); + ASSERT_EQ(r, (int)DT_IP_TARGET_LEN); // returns to-size on success + EXPECT_EQ(0, std::memcmp(c.mem.data(), DT_IP_TARGET, DT_IP_TARGET_LEN)); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}