// encode41.c : Defines the entry point for the console application.
//


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "decode41.h"


extern int decode41(char *data, int len, char *text);
extern int show_memory(char *mem, int len, char *text);
extern int set_packet_size(char *a1, int c);
extern int get_packet_size(char *data,int len);
extern int encode_to_7bit(char *buf, uint word, int limit);

extern int encode41_setup1pkt(char *buf, int buf_limit_len);
extern int encode41_setup2pkt(char *buf, int buf_limit_len);

extern int encode41_sess1pkt1(char *buf, int buf_limit_len);
extern int encode41_sess1pkt2(char *buf, int buf_limit_len);

extern int encode41_sess2pkt1_ack(char *buf, int buf_limit_len);
extern int encode41_sess2pkt2(char *buf, int buf_limit_len);
extern int encode41_sess2pkt3(char *buf, int buf_limit_len);
extern int encode41_sess2pkt4_ack(char *buf, int buf_limit_len);

extern int encode41_sess3pkt1_ack(char *buf, int buf_limit_len);
extern int encode41_sess3pkt2(char *buf, int buf_limit_len);
extern int encode41_sess3pkt3_ack(char *buf, int buf_limit_len);
extern int encode41_sess3pkt4(char *buf, int buf_limit_len);
extern int encode41_sess3pkt5(char *buf, int buf_limit_len);
extern int encode41_sess3pkt6_ack(char *buf, int buf_limit_len);
extern int encode41_sess3pkt7(char *buf, int buf_limit_len);
extern int encode41_sess3pkt8(char *buf, int buf_limit_len);
extern int encode41_sess3pkt9_ack(char *buf, int buf_limit_len);

extern int encode41_sess4pkt1_ack(char *buf, int buf_limit_len);
extern int encode41_sess4pkt2_ack(char *buf, int buf_limit_len);
extern int encode41_sess4pkt3(char *buf, int buf_limit_len);
extern int encode41_sess4pkt4(char *buf, int buf_limit_len);
extern int encode41_sess4pkt5_ack(char *buf, int buf_limit_len);

extern int encode41_newblk1(char *buf, int buf_limit_len);
extern int encode41_newblk2(char *buf, int buf_limit_len);
extern int encode41_newblk3(char *buf, int buf_limit_len);


// 1 setup pkt
unsigned char aes_41data_setup1pkt[]=
"\xDD\x81\x01\x43\x41\x06\x00\x03\x9F\x49\x04\x01\x15\x75\x4E\xCB"
"\x75\x38\x34\xFA\x8E\x01\xC0\xA8\x01\x28\x81\xA5\x43\xA3\x14\xA9"
"\xEF\x08\x01\x09\xF7\xB4\x55\xAA\xDB\x3F\xCE\x66\x00\x1B\x00\x03"
"\x00\x78\x6F\x74\x5F\x69\x61\x6D\x00\x00\x18\x01\xBB\xFD"
"\x00\x00"
;


// 2 setup pkt
unsigned char aes_41data_setup2pkt[]=
"\xEF\x89\x01\x45\x41\x0A\x00\x16\x01\x00\x1A\x01\x00\x02\xA9\xB6"
"\xD2\xF9\x05\x04\x05\x88\x03\x00\x00\x01\x04\x00\x00\x00\x01\x9A"
"\x12\x47\xC4\x42\x25\x35\xE2\xD5\x28\xA7\x3E\x8C\x2B\x3E\x28\x26"
"\x63\x10\x55\x3F\xA3\x15\xDB\x93\xD7\xD3\xA5\xC4\x4B\x44\xEB\xE0"
"\xAE\xB9\x79\xE5\xCF\x3A\xBE\x8F\xA1\xD5\x71\x94\xD2\xE8\xE4\x0E"
"\x52\x6D\xA3\x7B\xDB\xE4\x9E\x2C\x9E\x18\x43\x38\x07\xF3\x50\x35"
"\x8E\x43\x0A\x7E\x69\xF0\x3D\x09\x26\x7F\x7E\x92\xB3\xE4\x3B\x17"
"\x3D\x24\x80\x50\x78\x2D\x52\xE4\xCE\x81\x85\x3E\xA3\x3B\xEC\x15"
"\x32\xF8\x5B\x22\x80\x04\xD3\xCD\xFA\x5B\xC6\x97\x34\xBE\xB7\x67"
"\xC6\xCD\x79\x47\x6A\x6B\x99\xA3\xF6\x68\x9C\x1E\x47\x1A\xA9\x43"
"\x16\x2E\xB9\x3E\xA4\x84\xAA\xCA\x0A\xCF\x97\x5D\x66\x09\x59\xFA"
"\xEB\x9C\x7D\x6D\xC0\x5B\x53\xCF\x57\xC3\x90\xC4\xA9\xFE\xCA\xEA"
"\x75\x84\xC9\x0D\x64\x9D\x14\x8C\x33\xA6\x80\x09\x4B\x86\x5E\xD8"
"\x15\xBB\xEE\xA0\xDA\x4B\x03\x47\x0B\xD2\xA2\x97\xAF\x32\x29\x94"
"\x9E\x71\xB1\x8C\xCB\x27\x6D\x84\x44\x78\x25\x27\x81\xD0\xC3\xA2"
"\xDD\x9A\x89\x4C\x4F\x91\x47\x25\x83\x49\xDE\x9A\x47\xD0\x51\x7F"
"\x22\x2B\xDB\xFD\xA5\xFF\x2C\x6F\xFD\xBC\xC6\x95\xE5\x89\xA2\xD0"
"\x03\x8C\x2C\x24\x9A\x2E\xFE\xCB\xA1\x9F\x69\x64\xB2\x10\x59\x77"
"\x6A\x4B\xDE\xCB\x63\x96\xCB\xBC\xC2\xC9\x10\xD0\x9B\x4A\x31\x73"
"\xC5\x60\x17\x18\x6C\xAB\x55\xD5\xCD\x8F\x0B\xE0\xC5\x46\x96\x04"
"\x0C\x21\x68\xC6\x1A\x44\x51\x2B\x44\x9C\x61\x2A\xF3\x86\xC0\xEB"
"\x51\x44\xD2\x42\xD8\x79\x64\xA0\xBD\x08\xAD\xFF\xBB\xD9\x65\x52"
"\x24\x11\xC2\xD9\x86\x00\x4B\x16\x72\xD1\x61\x7D\xB6\x74\xEC\xC4"
"\xCE\x23\xCF\x77\xD0\x41\x3B\x5A\x5E\xB6\xB6\x53\x7A\xA7\x63\x82"
"\xAC\x16\x2C\xD9\xD2\xE7\xCD\x7F\xA7\x74\xA1\xCE\x9F\x3C\xA3\x3F"
"\x6D\x7B\x32\x23\xC5\x67\x97\x57\x54\xD5\x5D\x89\x29\x28\x0C\x00"
"\x0D\x02\x04\x0A\x80\x01\x7D\xC1\xC3\x67\xC0\x36\x63\xD6\x12\x50"
"\x40\x35\x1F\xBC\x85\x3C\xCB\x29\x1A\x9D\x3C\x6F\xFC\x9D\x31\x3B"
"\x12\x16\x0A\xD4\xF2\xF0\x77\x18\x58\xB7\x9E\xD6\xB1\xDC\x74\x6C"
"\xB5\x56\x57\x11\xCF\x3A\x55\x90\x21\x5A\x98\x8D\x73\xAC\x4F\x7B"
"\xBA\x36\xFD\x63\x86\x42\xBE\xE4\xF2\xBE\x9E\xE2\x14\xE8\x85\xAA"
"\x29\x2E\x22\x52\x88\xB1\x89\xB5\x42\xDF\x79\xC5\xEE\x80\x7B\x88"
"\x67\xCF\xC9\xFA\xF7\xB2\x51\xE3\xF5\xFB\x6A\xCB\x01\x02\x53\x3F"
"\x8D\x8E\xE9\x2E\xAE\x21\xDD\xDB\x78\xCF\x21\xE9\x28\xAD\xEE\x04"
"\xCD\xC2\x79\xB1\x0B\xC9\x00\x19\x01\x04\x06\x80\x01\x96\x61\x3C"
"\x07\x06\x1A\x41\x0B\x24\xBB\xD5\x32\x96\x98\x9E\x30\xAB\x9F\x2C"
"\xBE\x8C\xAF\x51\x0C\xAE\x88\x65\xFD\x6A\xFC\x6F\xFC\x6E\xCD\xDB"
"\x1B\x50\xB2\x22\xA9\x06\x00\x92\x9E\xE7\x82\x3E\xBD\xA0\xA9\x6A"
"\x19\x08\x73\x64\xC1\x4D\xC5\x48\x19\x55\x01\x47\xFF\xF8\x1A\xE0"
"\xC4\x1D\xC0\x3F\xD1\xC9\x10\xF3\x24\xAA\x08\x90\x58\x08\x02\xEE"
"\x29\xFA\x05\x6B\x66\x23\x3E\x69\x7D\x0D\xAF\xA9\x9B\x82\xDB\x54"
"\xD1\xB2\x9C\x63\x7A\xF7\xCC\x4C\xB4\xF4\x3C\x6B\x24\xCF\xB7\x09"
"\x67\xEB\x8B\x42\x72\x1B\x50\xD3\x7B\xC3\x9C\xB6\xDE\x04\x11\x88"
"\x03\x00\x00\x01\x04\x00\x00\x00\x01\x4C\x74\x49\x0E\x80\x53\x5F"
"\xC5\x3F\xA2\x4F\x13\xE8\x91\xBF\x3B\x42\xF4\x78\x17\x3F\x1C\xBB"
"\xBB\xE5\x70\x89\xCC\xAC\xF1\xF2\x52\x9A\x83\x94\xDB\x8B\xB7\x7F"
"\xD0\xA4\x35\x65\xBB\x44\xBD\x16\xB2\xE8\x52\x01\x6B\x1E\x9F\x7B"
"\xAE\x15\x7C\x3D\xAD\x1A\x5F\x27\x6E\xA5\x02\xB0\xAB\x2B\xC4\xC2"
"\x60\xB0\x1C\x9F\x40\x93\xAB\xE9\x88\x73\xAF\x02\xEE\x48\x93\x7D"
"\x95\x0C\x50\x79\x38\xF7\xEF\x71\x34\x27\xC6\x2E\x6B\x05\x38\x48"
"\x61\x02\x01\x40\xBE\xC4\xC4\xD4\xA5\xD5\xDD\xEC\xC7\xA1\xC0\x61"
"\xDB\xD4\x11\xB4\x2F\xA9\xAC\xD0\x7B\x1F\x4B\x8C\xE6\xFB\x0B\x20"
"\xB4\x7A\xCA\x10\xDD\x4F\x2E\xF7\x62\xB8\x0B\x55\x6F\xD8\xCD\x2C"
"\xF2\xD4\xCA\xE2\x01\xF7\x8F\x90\xA0\x45\x73\xAA\x98\x3C\x9A\x2D"
"\xB7\x1C\x00\x28\x5E\x73\x2E\x41\x05\xDF\x62\xEA\x1E\x8F\x72\xFE"
"\x32\x6A\x97\x1E\xD8\x82\x9F\x18\xC7\xC9\xAA\x4B\x2F\x75\x4A\xFB"
"\x74\x4E\x8B\x9F\xBC\x72\x19\x58\x6F\x9A\x78\x8B\xB3\xEE\xAB\x8C"
"\x95\x80\x69\xA8\x11\x02\x60\x7B\x71\xD9\x85\x10\x94\x73\x0D\x1F"
"\xFA\xFB\xA4\x4D\x86\xC9\xA4\x54\x84\x3F\x47\x93\xB7\x97\x0E\x6B"
"\xB4\x3F\x8C\x37\x23\xF3\x27\xEB\xB8\x3F\xAA\x37\x57\xD4\x71\xA7"
"\x2F\x99\xD7\x36\xA7\x45\x4D\x45\xBB\x39\x2C\x29\x5D\x38\x9F\xF4"
"\x9F\x74\xDB\xDB\x07\x1B\x64\xDD\xB8\x63\x27\xCA\x64\x8C\x38\x71"
"\x23\x6D\xE6\x6C\xA4\x1C\x3D\xEA\x0C\xB2\x48\x1C\xA8\xC9\x7E\xFE"
"\xF3\xDF\x9B\x2A\xDE\xBF\xB3\xDF\xD3\xB4\x48\x25\x14\x39\x9E\x18"
"\xD5\x7F\xA6\x45\x45\x40\xBC\x6F\xFE\x1E\x70\x3B\x7E\x44\x29\x55"
"\x9A\x9D\x85\xB4\xC6\x90\x3D\x4D\x74\x67\xA2\x77\xEA\x45\xD1\x1A"
"\xA0\x31\xDF\x9B\xB9\x18\xAA\x96\x04\x2C\x9A\xF6\x28\xE8\xF5\x1D"
"\x7D\x3A\x46\x94\x41\x5C\x18\x26\xAC\x00\x14\x00\xFF\xFF"
"\x00\x00"
;


// session 1 pkt
u8 aes_41data_sess1pkt1[]=
"\x86\xC8\x01\x6D\x41\x04\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x00"
"\x04\x04\x32\x41\x04\x00\x01\x0D\x03\x02\x23\x78\x6F\x74\x65\x67"
"\x5F\x69\x61\x6D\x2F\x24\x78\x6F\x74\x5F\x69\x61\x6D\x3B\x34\x66"
"\x65\x66\x37\x62\x30\x31\x35\x63\x62\x32\x30\x61\x64\x30\x00\x00"
"\x1C\x01\x00\x1D\x01\x00\x07\x05\x8A\xDB"
"\x00\x00"
;

//\x86\xC8\x01\x6D" -- fake one, for 41 decode
u8 aes_41data_sess1pkt1_recurs[]=
"\x86\xC8\x01\x6D"
"\x41\x04\x00\x01\x0D\x03\x02\x23\x78\x6F\x74\x65\x67"
"\x5F\x69\x61\x6D\x2F\x24\x78\x6F\x74\x5F\x69\x61\x6D\x3B\x34\x66"
"\x65\x66\x37\x62\x30\x31\x35\x63\x62\x32\x30\x61\x64\x30\x00\x00"
"\x1C\x01\x00\x1D\x01"
;


u8 aes_41data_sess1pkt2[]=
"\xAF\x8E\x02\x4C\x41\x03\x00\x00\x2A\x00\x02\x00\x03\x01\x00"
"\xFE\x55\x00\x00"
;


// session 2 pkt

u8 aes_41data_sess2pkt1[]=
"\xCC\x21\x47\x41\x00\xFF\xFF"
"\x00\x00"
;


u8 aes_41data_sess2pkt2[]=
"\xD8\xD4\x02\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x01"
"\x04\x04\x88\x04\x41\x06\x00\x01\x24\x03\x02\x23\x78\x6F\x74\x65"
"\x67\x5F\x69\x61\x6D\x2F\x24\x78\x6F\x74\x5F\x69\x61\x6D\x3B\x34"
"\x66\x65\x66\x37\x62\x30\x31\x35\x63\x62\x32\x30\x61\x64\x30\x00"
"\x00\x1B\x07\x03\x12\x78\x6F\x74\x5F\x69\x61\x6D\x20\x78\x6F\x74"
"\x65\x67\x5F\x69\x61\x6D\x00\x03\x1E\x00\x05\x19\x41\x04\x05\x00"
"\x41\x05\x00\x00\x08\x00\x01\x01\x00\x02\xA9\xA1\x85\xCE\x0E\x04"
"\x03\x92\x01\x1C\xF7\xB2\xBA\x00\xF3\x09\xDA\xC1\x45\x3A\xCE\xFE"
"\x29\x72\xE8\xED\xA5\xED\x57\xA4\x27\xD0\x21\x62\x65\x66\x1C\x8A"
"\x4A\x3A\x00\x15\x44\x9B\x87\x5C\x1A\xDE\xB9\x7A\xB2\x31\x6D\xE6"
"\xF2\x29\x56\x3A\xA1\x30\x39\x29\x96\xA4\x34\x40\x15\x2E\xBA\xDC"
"\xE3\xF4\x8B\x73\x4C\x76\x68\xE3\x80\x63\x9F\xD7\x81\xBC\x26\xEC"
"\xC1\xA7\x1D\x25\x0D\xBA\x16\xC0\x41\xC4\xB1\xC4\x99\x7E\xE6\xA4"
"\x0A\xAB\x8A\xAF\x96\x60\x0D\x88\xDA\xCB\xD9\xA6\x22\xFF\xC9\xBB"
"\x66\x5F\xB6\x4D\xDA\xD6\xD0\x09\x22\x85\x1B\x85\x4A\xD3\xCA\x00"
"\xB5\x4A\xFD\x01\x78\x6F\x74\x5F\x69\x61\x6D\x00\x00\x0A\xAA\xEE"
"\xF5\x46\x00\x0B\x01\x04\x04\x84\x02\x00\x00\x00\x01\x9A\x12\x47"
"\xC4\x42\x25\x35\xE2\xD5\x28\xA7\x3E\x8C\x2B\x3E\x28\x26\x63\x10"
"\x55\x3F\xA3\x15\xDB\x93\xD7\xD3\xA5\xC4\x4B\x44\xEB\xE0\xAE\xB9"
"\x79\xE5\xCF\x3A\xBE\x8F\xA1\xD5\x71\x94\xD2\xE8\xE4\x0E\x52\x6D"
"\xA3\x7B\xDB\xE4\x9E\x2C\x9E\x18\x43\x38\x07\xF3\x50\x35\x8E\x43"
"\x0A\x7E\x69\xF0\x3D\x09\x26\x7F\x7E\x92\xB3\xE4\x3B\x17\x3D\x24"
"\x80\x50\x78\x2D\x52\xE4\xCE\x81\x85\x3E\xA3\x3B\xEC\x15\x32\xF8"
"\x5B\x22\x80\x04\xD3\xCD\xFA\x5B\xC6\x97\x34\xBE\xB7\x67\xC6\xCD"
"\x79\x47\x6A\x6B\x99\xA3\xF6\x68\x9C\x1E\x47\x1A\xA9\x43\x16\x2E"
"\xB9\x3E\xA4\x84\xAA\xCA\x0A\xCF\x97\x5D\x66\x09\x59\xFA\xEB\x9C"
"\x7D\x6D\xC0\x5B\x53\xCF\x57\xC3\x90\xC4\xA9\xFE\xCA\xEA\x75\x84"
"\xC9\x0D\x64\x9D\x14\x8C\x33\xA6\x80\x09\x4B\x86\x5E\xD8\x15\xBB"
"\xEE\xA0\xDA\x4B\x03\x47\x0B\xD2\xA2\x97\xAF\x32\x29\x94\x9E\x71"
"\xB1\x8C\xCB\x27\x6D\x84\x44\x78\x25\x27\x81\xD0\xC3\xA2\xDD\x9A"
"\x89\x4C\x4F\x91\x47\x25\x83\x49\xDE\x9A\x47\xD0\x51\x7F\x22\x2B"
"\xDB\xFD\xA5\xFF\x2C\x6F\xFD\xBC\xC6\x95\xE5\x89\xA2\xD0\x03\x8C"
"\x2C\x24\x9A\x2E\xFE\xCB\xA1\x9F\x69\x64\xB2\x10\x59\x00\x06\x01"
"\x00\x07\xAA\xEE\xF5\x46\x00\x09\xD7\xE1\xEB\x09\x5B\xDD"
"\x00\x00"
;


// "\xD8\xD4\x02\x6D -- fake for 41 deoce
u8 aes_41data_sess2pkt2_recurs[]=
"\x41\x06\x00\x01\x24\x03\x02\x23\x78\x6F\x74\x65"
"\x67\x5F\x69\x61\x6D\x2F\x24\x78\x6F\x74\x5F\x69\x61\x6D\x3B\x34"
"\x66\x65\x66\x37\x62\x30\x31\x35\x63\x62\x32\x30\x61\x64\x30\x00"
"\x00\x1B\x07\x03\x12\x78\x6F\x74\x5F\x69\x61\x6D\x20\x78\x6F\x74"
"\x65\x67\x5F\x69\x61\x6D\x00\x03\x1E\x00\x05\x19\x41\x04\x05\x00"
"\x41\x05\x00\x00\x08\x00\x01\x01\x00\x02\xA9\xA1\x85\xCE\x0E\x04"
"\x03\x92\x01\x1C\xF7\xB2\xBA\x00\xF3\x09\xDA\xC1\x45\x3A\xCE\xFE"
"\x29\x72\xE8\xED\xA5\xED\x57\xA4\x27\xD0\x21\x62\x65\x66\x1C\x8A"
"\x4A\x3A\x00\x15\x44\x9B\x87\x5C\x1A\xDE\xB9\x7A\xB2\x31\x6D\xE6"
"\xF2\x29\x56\x3A\xA1\x30\x39\x29\x96\xA4\x34\x40\x15\x2E\xBA\xDC"
"\xE3\xF4\x8B\x73\x4C\x76\x68\xE3\x80\x63\x9F\xD7\x81\xBC\x26\xEC"
"\xC1\xA7\x1D\x25\x0D\xBA\x16\xC0\x41\xC4\xB1\xC4\x99\x7E\xE6\xA4"
"\x0A\xAB\x8A\xAF\x96\x60\x0D\x88\xDA\xCB\xD9\xA6\x22\xFF\xC9\xBB"
"\x66\x5F\xB6\x4D\xDA\xD6\xD0\x09\x22\x85\x1B\x85\x4A\xD3\xCA\x00"
"\xB5\x4A\xFD\x01\x78\x6F\x74\x5F\x69\x61\x6D\x00\x00\x0A\xAA\xEE"
"\xF5\x46\x00\x0B\x01\x04\x04\x84\x02\x00\x00\x00\x01\x9A\x12\x47"
"\xC4\x42\x25\x35\xE2\xD5\x28\xA7\x3E\x8C\x2B\x3E\x28\x26\x63\x10"
"\x55\x3F\xA3\x15\xDB\x93\xD7\xD3\xA5\xC4\x4B\x44\xEB\xE0\xAE\xB9"
"\x79\xE5\xCF\x3A\xBE\x8F\xA1\xD5\x71\x94\xD2\xE8\xE4\x0E\x52\x6D"
"\xA3\x7B\xDB\xE4\x9E\x2C\x9E\x18\x43\x38\x07\xF3\x50\x35\x8E\x43"
"\x0A\x7E\x69\xF0\x3D\x09\x26\x7F\x7E\x92\xB3\xE4\x3B\x17\x3D\x24"
"\x80\x50\x78\x2D\x52\xE4\xCE\x81\x85\x3E\xA3\x3B\xEC\x15\x32\xF8"
"\x5B\x22\x80\x04\xD3\xCD\xFA\x5B\xC6\x97\x34\xBE\xB7\x67\xC6\xCD"
"\x79\x47\x6A\x6B\x99\xA3\xF6\x68\x9C\x1E\x47\x1A\xA9\x43\x16\x2E"
"\xB9\x3E\xA4\x84\xAA\xCA\x0A\xCF\x97\x5D\x66\x09\x59\xFA\xEB\x9C"
"\x7D\x6D\xC0\x5B\x53\xCF\x57\xC3\x90\xC4\xA9\xFE\xCA\xEA\x75\x84"
"\xC9\x0D\x64\x9D\x14\x8C\x33\xA6\x80\x09\x4B\x86\x5E\xD8\x15\xBB"
"\xEE\xA0\xDA\x4B\x03\x47\x0B\xD2\xA2\x97\xAF\x32\x29\x94\x9E\x71"
"\xB1\x8C\xCB\x27\x6D\x84\x44\x78\x25\x27\x81\xD0\xC3\xA2\xDD\x9A"
"\x89\x4C\x4F\x91\x47\x25\x83\x49\xDE\x9A\x47\xD0\x51\x7F\x22\x2B"
"\xDB\xFD\xA5\xFF\x2C\x6F\xFD\xBC\xC6\x95\xE5\x89\xA2\xD0\x03\x8C"
"\x2C\x24\x9A\x2E\xFE\xCB\xA1\x9F\x69\x64\xB2\x10\x59\x00\x06\x01"
"\x00\x07\xAA\xEE\xF5\x46\x00\x09\xD7\xE1\xEB\x09"
;


u8 aes_41data_sess2pkt3[]=
"\x81\x9B\x03\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x00"
"\x00\x08\x01\xA3\xF1"
"\x00\x00"
;


u8 aes_41data_sess2pkt4[]=
"\xF5\x67\x47\x41\x00\xFF\xFF"
"\x00\x00"
;




// session 3 pkt

u8 aes_41data_sess3pkt1[]=
"\xAE\x01\x47\x41\x00\xFF\xFF"
"\x00\x00"
;


u8 aes_41data_sess3pkt2[]=
"\xAA\xE1\x03\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x01"
"\x00\x08\x01\xAA\x52"
"\x00\x00"
;



u8 aes_41data_sess3pkt3[]=
"\xF4\x01\x47\x41\x00\xFF\xFF"
"\x00\x00"
;


u8 aes_41data_sess3pkt4[]=
"\xD3\x27\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x02\x04"
"\x04\xC2\x03\x41\x02\x00\x01\x2A\x05\x18\x41\x04\x05\x02\x41\x05"
"\x00\x00\x09\x00\x01\x01\x00\x02\xA9\xA1\x85\xCE\x0E\x04\x03\x8C"
"\x01\x58\x0A\x58\xFB\xF6\xA2\x1D\xD5\x40\x92\x16\xF6\x48\x05\x44"
"\x20\x66\x2D\xB2\x2A\x4E\x0E\xC8\xD7\xB9\xD5\x20\xE2\x0F\x48\x35"
"\xE4\xB3\x05\x00\xD0\x50\x3B\xC1\x2C\x5C\x66\xA4\x4D\xE6\xC3\x6C"
"\x75\x35\x94\xC0\x39\x38\xA2\x56\x1E\x8A\xCB\xAB\x67\x01\x6D\x1E"
"\x70\x72\xFD\x86\x1F\xFF\xAC\xF5\xF0\x84\x72\x06\x8E\x30\x1D\x8E"
"\x10\x97\x94\x8B\x4D\xCC\x5E\x00\xFE\x0B\xD9\xC2\x71\x64\x63\x98"
"\x08\x98\x6A\x69\xE0\xF2\xF9\xF7\xB0\x42\x6A\x3C\x5C\x20\x80\x5B"
"\x14\x4C\x4E\x0D\x8C\x2C\x8C\x97\xD0\x7E\xF4\xCB\xEE\xBF\xD4\x42"
"\xA5\x0E\x00\x00\x0F\x00\x00\x0A\x9D\xED\xA2\x90\x04\x04\x04\x84"
"\x02\x00\x00\x00\x01\x9A\x12\x47\xC4\x42\x25\x35\xE2\xD5\x28\xA7"
"\x3E\x8C\x2B\x3E\x28\x26\x63\x10\x55\x3F\xA3\x15\xDB\x93\xD7\xD3"
"\xA5\xC4\x4B\x44\xEB\xE0\xAE\xB9\x79\xE5\xCF\x3A\xBE\x8F\xA1\xD5"
"\x71\x94\xD2\xE8\xE4\x0E\x52\x6D\xA3\x7B\xDB\xE4\x9E\x2C\x9E\x18"
"\x43\x38\x07\xF3\x50\x35\x8E\x43\x0A\x7E\x69\xF0\x3D\x09\x26\x7F"
"\x7E\x92\xB3\xE4\x3B\x17\x3D\x24\x80\x50\x78\x2D\x52\xE4\xCE\x81"
"\x85\x3E\xA3\x3B\xEC\x15\x32\xF8\x5B\x22\x80\x04\xD3\xCD\xFA\x5B"
"\xC6\x97\x34\xBE\xB7\x67\xC6\xCD\x79\x47\x6A\x6B\x99\xA3\xF6\x68"
"\x9C\x1E\x47\x1A\xA9\x43\x16\x2E\xB9\x3E\xA4\x84\xAA\xCA\x0A\xCF"
"\x97\x5D\x66\x09\x59\xFA\xEB\x9C\x7D\x6D\xC0\x5B\x53\xCF\x57\xC3"
"\x90\xC4\xA9\xFE\xCA\xEA\x75\x84\xC9\x0D\x64\x9D\x14\x8C\x33\xA6"
"\x80\x09\x4B\x86\x5E\xD8\x15\xBB\xEE\xA0\xDA\x4B\x03\x47\x0B\xD2"
"\xA2\x97\xAF\x32\x29\x94\x9E\x71\xB1\x8C\xCB\x27\x6D\x84\x44\x78"
"\x25\x27\x81\xD0\xC3\xA2\xDD\x9A\x89\x4C\x4F\x91\x47\x25\x83\x49"
"\xDE\x9A\x47\xD0\x51\x7F\x22\x2B\xDB\xFD\xA5\xFF\x2C\x6F\xFD\xBC"
"\xC6\x95\xE5\x89\xA2\xD0\x03\x8C\x2C\x24\x9A\x2E\xFE\xCB\xA1\x9F"
"\x69\x64\xB2\x10\x59\x00\x06\x01\x00\x07\x9D\xED\xA2\x90\x04\x00"
"\x09\xD7\xE1\xEB\x09\xF7\x35"
"\x00\x00"
;

u8 aes_41data_sess3pkt4_recurs[]=
"\x41\x02\x00\x01\x2A\x05\x18\x41\x04\x05\x02\x41\x05"
"\x00\x00\x09\x00\x01\x01\x00\x02\xA9\xA1\x85\xCE\x0E\x04\x03\x8C"
"\x01\x58\x0A\x58\xFB\xF6\xA2\x1D\xD5\x40\x92\x16\xF6\x48\x05\x44"
"\x20\x66\x2D\xB2\x2A\x4E\x0E\xC8\xD7\xB9\xD5\x20\xE2\x0F\x48\x35"
"\xE4\xB3\x05\x00\xD0\x50\x3B\xC1\x2C\x5C\x66\xA4\x4D\xE6\xC3\x6C"
"\x75\x35\x94\xC0\x39\x38\xA2\x56\x1E\x8A\xCB\xAB\x67\x01\x6D\x1E"
"\x70\x72\xFD\x86\x1F\xFF\xAC\xF5\xF0\x84\x72\x06\x8E\x30\x1D\x8E"
"\x10\x97\x94\x8B\x4D\xCC\x5E\x00\xFE\x0B\xD9\xC2\x71\x64\x63\x98"
"\x08\x98\x6A\x69\xE0\xF2\xF9\xF7\xB0\x42\x6A\x3C\x5C\x20\x80\x5B"
"\x14\x4C\x4E\x0D\x8C\x2C\x8C\x97\xD0\x7E\xF4\xCB\xEE\xBF\xD4\x42"
"\xA5\x0E\x00\x00\x0F\x00\x00\x0A\x9D\xED\xA2\x90\x04\x04\x04\x84"
"\x02\x00\x00\x00\x01\x9A\x12\x47\xC4\x42\x25\x35\xE2\xD5\x28\xA7"
"\x3E\x8C\x2B\x3E\x28\x26\x63\x10\x55\x3F\xA3\x15\xDB\x93\xD7\xD3"
"\xA5\xC4\x4B\x44\xEB\xE0\xAE\xB9\x79\xE5\xCF\x3A\xBE\x8F\xA1\xD5"
"\x71\x94\xD2\xE8\xE4\x0E\x52\x6D\xA3\x7B\xDB\xE4\x9E\x2C\x9E\x18"
"\x43\x38\x07\xF3\x50\x35\x8E\x43\x0A\x7E\x69\xF0\x3D\x09\x26\x7F"
"\x7E\x92\xB3\xE4\x3B\x17\x3D\x24\x80\x50\x78\x2D\x52\xE4\xCE\x81"
"\x85\x3E\xA3\x3B\xEC\x15\x32\xF8\x5B\x22\x80\x04\xD3\xCD\xFA\x5B"
"\xC6\x97\x34\xBE\xB7\x67\xC6\xCD\x79\x47\x6A\x6B\x99\xA3\xF6\x68"
"\x9C\x1E\x47\x1A\xA9\x43\x16\x2E\xB9\x3E\xA4\x84\xAA\xCA\x0A\xCF"
"\x97\x5D\x66\x09\x59\xFA\xEB\x9C\x7D\x6D\xC0\x5B\x53\xCF\x57\xC3"
"\x90\xC4\xA9\xFE\xCA\xEA\x75\x84\xC9\x0D\x64\x9D\x14\x8C\x33\xA6"
"\x80\x09\x4B\x86\x5E\xD8\x15\xBB\xEE\xA0\xDA\x4B\x03\x47\x0B\xD2"
"\xA2\x97\xAF\x32\x29\x94\x9E\x71\xB1\x8C\xCB\x27\x6D\x84\x44\x78"
"\x25\x27\x81\xD0\xC3\xA2\xDD\x9A\x89\x4C\x4F\x91\x47\x25\x83\x49"
"\xDE\x9A\x47\xD0\x51\x7F\x22\x2B\xDB\xFD\xA5\xFF\x2C\x6F\xFD\xBC"
"\xC6\x95\xE5\x89\xA2\xD0\x03\x8C\x2C\x24\x9A\x2E\xFE\xCB\xA1\x9F"
"\x69\x64\xB2\x10\x59\x00\x06\x01\x00\x07\x9D\xED\xA2\x90\x04\x00"
"\x09\xD7\xE1\xEB\x09\xF7\x35"
"\x00\x00"
;


u8 aes_41data_sess3pkt5[]=
"\xFC\x6D\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x02\x00"
"\x08\x01\x5D\x80"
"\x00\x00"
;


u8 aes_41data_sess3pkt6[]=
"\xBA\x02\x47\x41\x00\xFF\xFF"
"\x00\x00"
;

u8 aes_41data_sess3pkt7[]=
"\xA5\xB4\x01\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x03"
"\x04\x04\x59\x41\x06\x00\x01\x13\x00\x0F\xA0\xFB\xE3\xEC\x03\x05"
"\x14\x41\x03\x00\x09\xA0\xFB\xE3\xEC\x03\x00\x0A\xA0\xFB\xE3\xEC"
"\x03\x00\x15\xFC\xBA\xB3\x8C\x07\x05\x14\x41\x03\x00\x09\xA1\xFB"
"\xE3\xEC\x03\x00\x0A\xA1\xFB\xE3\xEC\x03\x00\x15\xE7\xAD\xE4\x94"
"\x0A\x03\x12\x78\x6F\x74\x5F\x69\x61\x6D\x20\x78\x6F\x74\x65\x67"
"\x5F\x69\x61\x6D\x00\x05\x2F\x41\x01\x00\x02\x02\xDB\x1D"
"\x00\x00"
;

u8 aes_41data_sess3pkt7_recurs[]=
"\x41\x06\x00\x01\x13\x00\x0F\xA0\xFB\xE3\xEC\x03\x05"
"\x14\x41\x03\x00\x09\xA0\xFB\xE3\xEC\x03\x00\x0A\xA0\xFB\xE3\xEC"
"\x03\x00\x15\xFC\xBA\xB3\x8C\x07\x05\x14\x41\x03\x00\x09\xA1\xFB"
"\xE3\xEC\x03\x00\x0A\xA1\xFB\xE3\xEC\x03\x00\x15\xE7\xAD\xE4\x94"
"\x0A\x03\x12\x78\x6F\x74\x5F\x69\x61\x6D\x20\x78\x6F\x74\x65\x67"
"\x5F\x69\x61\x6D\x00\x05\x2F\x41\x01\x00\x02\x02\xDB\x1D"
"\x00\x00"
;




u8 aes_41data_sess3pkt8[]=
"\xCE\xFA\x01\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x03"
"\x00\x08\x01\x8C\xCD"
"\x00\x00"
;


u8 aes_41data_sess3pkt9[]=
"\x81\x03\x47\x41\x00\xFF\xFF"
"\x00\x00"
;


// session 4 pkt


u8 aes_41data_sess4pkt1[]=
"\xC7\x03\x47\x41\x00\xFF\xFF"
"\x00\x00"
;

u8 aes_41data_sess4pkt2[]=
"\xEB\x0D\x47\x41\x00\xFF\xFF"
"\x00\x00"
;


u8 aes_41data_sess4pkt3[]=
"\xF7\xC0\x02\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x04"
"\x04\x04\xAD\x01\x41\x02\x00\x01\x2B\x05\x20\x41\x05\x00\x0A\xA1"
"\xFB\xE3\xEC\x03\x00\x00\x03\x00\x01\x01\x00\x02\xA1\xE6\xA6\xFF"
"\x0E\x04\x03\x8C\x01\x69\xCD\xFA\x20\xF7\xBA\xB1\xC2\x77\x7C\x6B"
"\x2A\x36\xBD\x7C\xFE\xCE\x15\x2E\xB6\x98\x2F\xB6\x30\x71\x31\x65"
"\x19\xC5\x71\x45\x17\xA3\x9E\x5C\x5C\x9B\xD0\x76\x37\x90\x1E\x10"
"\x36\x78\x39\x75\x25\xB8\x08\x97\xEC\xD2\xD8\x09\xC6\x60\x86\x8C"
"\x5E\x87\x8A\x68\xB0\xBC\xA0\x7E\x6E\xFD\xFA\x90\x1B\x17\x3E\xE6"
"\x9E\x6C\xC0\x31\x9D\xE1\x1D\x6A\xFC\x94\x41\x90\xE8\x78\xDC\x6B"
"\x3D\x34\xCD\x90\xA7\x22\x54\x6A\xFB\x88\xD6\xB4\x2E\xD2\x81\xDC"
"\xDD\x62\xD8\x8F\xF1\x68\x0F\x96\x2A\x07\xCB\xBC\x14\x4A\x07\x65"
"\xD2\x8A\x85\xC4\xE8"
"\x02\x68\x6F\x68\x6F\x61\x65\x65\x61\x00"
"\x32\xD7\x00\x00"
"\xFF\xFF"
;

u8 aes_41data_sess4pkt3_recurs[]=
"\xF7\xC0\x02\x6D\x41\x02\x00\x01\x2B\x05\x20\x41\x05\x00\x0A\xA1"
"\xFB\xE3\xEC\x03\x00\x00\x03\x00\x01\x01\x00\x02\xA1\xE6\xA6\xFF"
"\x0E\x04\x03\x8C\x01\x69\xCD\xFA\x20\xF7\xBA\xB1\xC2\x77\x7C\x6B"
"\x2A\x36\xBD\x7C\xFE\xCE\x15\x2E\xB6\x98\x2F\xB6\x30\x71\x31\x65"
"\x19\xC5\x71\x45\x17\xA3\x9E\x5C\x5C\x9B\xD0\x76\x37\x90\x1E\x10"
"\x36\x78\x39\x75\x25\xB8\x08\x97\xEC\xD2\xD8\x09\xC6\x60\x86\x8C"
"\x5E\x87\x8A\x68\xB0\xBC\xA0\x7E\x6E\xFD\xFA\x90\x1B\x17\x3E\xE6"
"\x9E\x6C\xC0\x31\x9D\xE1\x1D\x6A\xFC\x94\x41\x90\xE8\x78\xDC\x6B"
"\x3D\x34\xCD\x90\xA7\x22\x54\x6A\xFB\x88\xD6\xB4\x2E\xD2\x81\xDC"
"\xDD\x62\xD8\x8F\xF1\x68\x0F\x96\x2A\x07\xCB\xBC\x14\x4A\x07\x65"
"\xD2\x8A\x85\xC4\xE8"
"\x02\x68\x6F\x68\x6F\x61\x65\x65\x61\x00"
"\x32\xD7\x00\x00"
"\xFF\xFF"
;


u8 aes_41data_sess4pkt4[]=
"\xA0\x87\x03\x6D\x41\x03\x00\x01\x87\xBF\x86\xAC\x05\x00\x03\x04"
"\x00\x08\x01\x24\x92"
"\x00\x00"
;


u8 aes_41data_sess4pkt5[]=
"\x94\x54\x47\x41\x00\xFF\xFF"
"\x00\x00"
;

/*
u8 tmpbuf[]=
"\x9F\x01\x05\x77\x96"
;


u8 tmpbuf[]=
"\x2D\x05\x9A\x8B\x00"
;
*/


u8 aes_41data_newblk1[]=
"\x41\x08\x00\x00\x01\x04\x03"
"\x15\x75\x4E\xCB\x75\x38\x34\xFA\x8E\x01\xC0\xA8\x01\x28\x81\xA5"
"\x43\xA3\x14\xA9\xEF\x08\x00\x05\xE2\xF3\xC1\xCE\x04\x00\x06\xD7"
"\xE1\xEB\x09\x00\x07\xA0\xFB\xE3\xEC\x03\x03"
"\x01\x78\x6F\x74\x5F\x69\x61\x6D\x00\x00\x0A\xAA\xEE\xF5\x46\x00"
"\x0B\x01"
;


u8 aes_41data_newblk2[]=
"\x41\x08\x00\x00\x04\x04\x03"
"\x15\x75\x4E\xCB\x75\x38\x34\xFA\x8E\x01\xC0\xA8\x01\x28\x81\xA5"
"\x43\xA3\x14\xA9\xEF\x08\x00\x05\xE2\xF3\xC1\xCE\x04\x00\x06\xD7"
"\xE1\xEB\x09\x00\x07\x9F\xFB\xE3\xEC\x03\x03"
"\x0E\x00\x00\x0F\x00\x00\x0A\x9D\xED\xA2\x90\x04"
;



u8 aes_41data_newblk3[]=
"\x41\x06\x00\x00\x03\x04\x03"
"\x15\x75\x4E\xCB\x75\x38\x34\xFA\x8E\x01\xC0\xA8\x01\x28\x81\xA5"
"\x43\xA3\x14\xA9\xEF\x08\x00\x05\xE7\xF3\xC1\xCE\x04\x00\x06\xD7"
"\xE1\xEB\x09\x00\x07\xA1\xFB\xE3\xEC\x03\x03"
"\x02\x50\x6C\x65\x61\x73\x65\x20\x76\x69\x73\x69\x74\x20\x6F\x72"
"\x20\x73\x69\x74\x65\x20\x68\x65\x72\x65\x3A\x20\x77\x77\x77\x2E"
"\x72\x65\x2E\x6F\x72\x67\x0A\x00"
;




int main(int argc, char* argv[]){
	char buf[0x1000];
	int len;


	/*
	memset(buf,0,sizeof(buf));

	show_memory(tmpbuf,5,"header1");

	len=get_packet_size(tmpbuf,5);
	printf("len=0x%08X\n",len);

	//set_packet_size(buf,len);
	len=encode_to_7bit(buf, len*2+1, 5);
	show_memory(buf,5,"header2");
	exit(1);

	*/


	// setup


	//decode41(aes_41data_setup1pkt, sizeof(aes_41data_setup1pkt)-1,"PKT:");
	memset(buf,0,sizeof(buf));
    len=encode41_setup1pkt(buf, sizeof(buf));
	//show_memory(buf, len, "setup1pkt");
	if (memcmp(buf,aes_41data_setup1pkt,sizeof(aes_41data_setup1pkt)-5)==0){
		printf("BLOBs setup1pkt encoded successfully\n");
	}else{
		printf("BLOBs setup1pkt encoding failed\n");
	};
	

	//decode41(aes_41data_setup2pkt, sizeof(aes_41data_setup2pkt)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_setup2pkt(buf, sizeof(buf));
    //show_memory(buf, len, "setup2pkt");
	if (memcmp(buf,aes_41data_setup2pkt,sizeof(aes_41data_setup2pkt)-5)==0){
		printf("BLOBs setup2pkt encoded successfully\n");
	}else{
		printf("BLOBs setup2pkt encoding failed\n");
	};
	

	// session

	// 1 pkt 1

	//decode41(aes_41data_sess1pkt1_recurs, sizeof(aes_41data_sess1pkt1_recurs)-1,"RECURS PKT:");
	//decode41(aes_41data_sess1pkt1, sizeof(aes_41data_sess1pkt1)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess1pkt1(buf, sizeof(buf));
    //show_memory(buf, len, "sess1pkt1");
	if (memcmp(buf,aes_41data_sess1pkt1,sizeof(aes_41data_sess1pkt1)-5)==0){
		printf("BLOBs sess1pkt1 encoded successfully\n");
	}else{
		printf("BLOBs sess1pkt1 encoding failed\n");
	};


	// 1 pkt 2

	//decode41(aes_41data_sess1pkt2, sizeof(aes_41data_sess1pkt2)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess1pkt2(buf, sizeof(buf));
    //show_memory(buf, len, "sess1pkt2");
	if (memcmp(buf,aes_41data_sess1pkt2,sizeof(aes_41data_sess1pkt2)-5)==0){
		printf("BLOBs sess1pkt2 encoded successfully\n");
	}else{
		printf("BLOBs sess1pkt2 encoding failed\n");
	};



	// 2 pkt 1 ack

	//decode41(aes_41data_sess2pkt1, sizeof(aes_41data_sess2pkt1)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess2pkt1_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess2pkt1");
	if (memcmp(buf,aes_41data_sess2pkt1,sizeof(aes_41data_sess2pkt1)-5)==0){
		printf("BLOBs sess2pkt1 encoded successfully\n");
	}else{
		printf("BLOBs sess2pkt1 encoding failed\n");
	};
	

	// 2 pkt 2

	//in new unpack41
	//decode41(aes_41data_sess2pkt2_recurs, sizeof(aes_41data_sess2pkt2_recurs)-1,"PKT:");
	//decode41(aes_41data_sess2pkt2, sizeof(aes_41data_sess2pkt2)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess2pkt2(buf, sizeof(buf));
    //show_memory(buf, len, "sess2pkt2");
	if (memcmp(buf,aes_41data_sess2pkt2,sizeof(aes_41data_sess2pkt2)-5)==0){
		printf("BLOBs sess2pkt2 encoded successfully\n");
	}else{
		printf("BLOBs sess2pkt2 encoding failed\n");
	};
	
	

	// 2 pkt 3

	//decode41(aes_41data_sess2pkt3, sizeof(aes_41data_sess2pkt3)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess2pkt3(buf, sizeof(buf));
    //show_memory(buf, len, "sess2pkt3");
	if (memcmp(buf,aes_41data_sess2pkt3,sizeof(aes_41data_sess2pkt3)-5)==0){
		printf("BLOBs sess2pkt3 encoded successfully\n");
	}else{
		printf("BLOBs sess2pkt3 encoding failed\n");
	};
	
	
	// 2 pkt 3

	//decode41(aes_41data_sess2pkt3, sizeof(aes_41data_sess2pkt3)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess2pkt3(buf, sizeof(buf));
    //show_memory(buf, len, "sess2pkt3");
	if (memcmp(buf,aes_41data_sess2pkt3,sizeof(aes_41data_sess2pkt3)-5)==0){
		printf("BLOBs sess2pkt3 encoded successfully\n");
	}else{
		printf("BLOBs sess2pkt3 encoding failed\n");
	};
	
		
	// 2 pkt 4 ack

	//decode41(aes_41data_sess2pkt4, sizeof(aes_41data_sess2pkt4)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess2pkt4_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess2pkt4");
	if (memcmp(buf,aes_41data_sess2pkt4,sizeof(aes_41data_sess2pkt4)-5)==0){
		printf("BLOBs sess2pkt4 encoded successfully\n");
	}else{
		printf("BLOBs sess2pkt4 encoding failed\n");
	};






	// 3 pkt 1 ack

	//decode41(aes_41data_sess3pkt1, sizeof(aes_41data_sess3pkt1)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt1_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt1");
	if (memcmp(buf,aes_41data_sess3pkt1,sizeof(aes_41data_sess3pkt1)-5)==0){
		printf("BLOBs sess3pkt1 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt1 encoding failed\n");
	};
	


	// 3 pkt 2

	//decode41(aes_41data_sess3pkt2, sizeof(aes_41data_sess3pkt2)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt2(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt2");
	if (memcmp(buf,aes_41data_sess3pkt2,sizeof(aes_41data_sess3pkt2)-5)==0){
		printf("BLOBs sess3pkt2 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt2 encoding failed\n");
	};
	

	// 3 pkt 3 ack

	//decode41(aes_41data_sess3pkt3, sizeof(aes_41data_sess3pkt3)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt3_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt3");
	if (memcmp(buf,aes_41data_sess3pkt3,sizeof(aes_41data_sess3pkt3)-5)==0){
		printf("BLOBs sess3pkt3 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt3 encoding failed\n");
	};
	

	// 3 pkt 4

	//in new unpack41
	//decode41(aes_41data_sess3pkt4_recurs, sizeof(aes_41data_sess3pkt4_recurs)-1,"PKT:");
	//decode41(aes_41data_sess3pkt4, sizeof(aes_41data_sess3pkt4)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt4(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt4");
	if (memcmp(buf,aes_41data_sess3pkt4,sizeof(aes_41data_sess3pkt4)-5)==0){
		printf("BLOBs sess3pkt4 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt4 encoding failed\n");
	};



	// 3 pkt 5

	//decode41(aes_41data_sess3pkt5, sizeof(aes_41data_sess3pkt5)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt5(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt5");
	if (memcmp(buf,aes_41data_sess3pkt5,sizeof(aes_41data_sess3pkt5)-5)==0){
		printf("BLOBs sess3pkt5 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt5 encoding failed\n");
	};



	// 3 pkt 6 ack

	//decode41(aes_41data_sess3pkt6, sizeof(aes_41data_sess3pkt6)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt6_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt6");
	if (memcmp(buf,aes_41data_sess3pkt6,sizeof(aes_41data_sess3pkt6)-5)==0){
		printf("BLOBs sess3pkt6 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt6 encoding failed\n");
	};
	
	
	
	// 3 pkt 7

	//in new unpack41
	//decode41(aes_41data_sess3pkt7_recurs, sizeof(aes_41data_sess3pkt7_recurs)-1,"PKT:");
	//decode41(aes_41data_sess3pkt7, sizeof(aes_41data_sess3pkt7)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt7(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt7");
	if (memcmp(buf,aes_41data_sess3pkt7,sizeof(aes_41data_sess3pkt7)-5)==0){
		printf("BLOBs sess3pkt7 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt7 encoding failed\n");
	};


	// 3 pkt 8

	//decode41(aes_41data_sess3pkt8, sizeof(aes_41data_sess3pkt8)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt8(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt8");
	if (memcmp(buf,aes_41data_sess3pkt8,sizeof(aes_41data_sess3pkt8)-5)==0){
		printf("BLOBs sess3pkt8 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt8 encoding failed\n");
	};
	

	// 3 pkt 9 ack

	//decode41(aes_41data_sess3pkt9, sizeof(aes_41data_sess3pkt9)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess3pkt9_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess3pkt9");
	if (memcmp(buf,aes_41data_sess3pkt9,sizeof(aes_41data_sess3pkt9)-5)==0){
		printf("BLOBs sess3pkt9 encoded successfully\n");
	}else{
		printf("BLOBs sess3pkt9 encoding failed\n");
	};
	


	// 4 pkt 1 ack

	//decode41(aes_41data_sess4pkt1, sizeof(aes_41data_sess4pkt1)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess4pkt1_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess4pkt1");
	if (memcmp(buf,aes_41data_sess4pkt1,sizeof(aes_41data_sess4pkt1)-5)==0){
		printf("BLOBs sess4pkt1 encoded successfully\n");
	}else{
		printf("BLOBs sess4pkt1 encoding failed\n");
	};


	// 4 pkt 2 ack

	//decode41(aes_41data_sess4pkt2, sizeof(aes_41data_sess4pkt2)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess4pkt2_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess4pkt2");
	if (memcmp(buf,aes_41data_sess4pkt2,sizeof(aes_41data_sess4pkt2)-5)==0){
		printf("BLOBs sess4pkt2 encoded successfully\n");
	}else{
		printf("BLOBs sess4pkt2 encoding failed\n");
	};



	// 4 pkt 3

	//in new unpack41
	//decode41(aes_41data_sess4pkt3_recurs, sizeof(aes_41data_sess4pkt3_recurs)-1,"PKT:");
	//decode41(aes_41data_sess4pkt3, sizeof(aes_41data_sess4pkt3)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess4pkt3(buf, sizeof(buf));
    //show_memory(buf, len, "sess4pkt3");
	if (memcmp(buf,aes_41data_sess4pkt3,sizeof(aes_41data_sess4pkt3)-5)==0){
		printf("BLOBs sess4pkt3 encoded successfully\n");
	}else{
		printf("BLOBs sess4pkt3 encoding failed\n");
	};



	// 4 pkt 4

	//decode41(aes_41data_sess4pkt4, sizeof(aes_41data_sess4pkt4)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess4pkt4(buf, sizeof(buf));
    //show_memory(buf, len, "sess4pkt4");
	if (memcmp(buf,aes_41data_sess4pkt4,sizeof(aes_41data_sess4pkt4)-5)==0){
		printf("BLOBs sess4pkt4 encoded successfully\n");
	}else{
		printf("BLOBs sess4pkt4 encoding failed\n");
	};


	// 4 pkt 5 ack

	//decode41(aes_41data_sess4pkt5, sizeof(aes_41data_sess4pkt5)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_sess4pkt5_ack(buf, sizeof(buf));
    //show_memory(buf, len, "sess4pkt5");
	if (memcmp(buf,aes_41data_sess4pkt5,sizeof(aes_41data_sess4pkt5)-5)==0){
		printf("BLOBs sess4pkt5 encoded successfully\n");
	}else{
		printf("BLOBs sess4pkt5 encoding failed\n");
	};





	// newblk1

	//decode41(aes_41data_newblk1, sizeof(aes_41data_newblk1)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_newblk1(buf, sizeof(buf));
    //show_memory(buf, len, "newblk1");
	if (memcmp(buf,aes_41data_newblk1,sizeof(aes_41data_newblk1)-5)==0){
		printf("BLOBs newblk1 encoded successfully\n");
	}else{
		printf("BLOBs newblk1 encoding failed\n");
	};


	// newblk2

	//decode41(aes_41data_newblk2, sizeof(aes_41data_newblk2)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_newblk2(buf, sizeof(buf));
    //show_memory(buf, len, "newblk2");
	if (memcmp(buf,aes_41data_newblk2,sizeof(aes_41data_newblk2)-5)==0){
		printf("BLOBs newblk2 encoded successfully\n");
	}else{
		printf("BLOBs newblk2 encoding failed\n");
	};


	// newblk3

	//decode41(aes_41data_newblk3, sizeof(aes_41data_newblk3)-1,"PKT:");
	memset(buf,0,sizeof(buf));
	len=encode41_newblk3(buf, sizeof(buf));
    //show_memory(buf, len, "newblk3");
	if (memcmp(buf,aes_41data_newblk3,sizeof(aes_41data_newblk3)-5)==0){
		printf("BLOBs newblk3 encoded successfully\n");
	}else{
		printf("BLOBs newblk3 encoding failed\n");
	};







	return 0;
};






