Writing to USB HID device - usb
I have a problem writing to HID device;
Below are two logs made with Snoopy.
The first one is made using original demo SW of device manufacturer and the second is my SW log.
My software doesn't work with this device but works with another HID device.
Original software:
9 ??? down n/a 27.868 BULK_OR_INTERRUPT_TRANSFER 06 16 19 17 00 00 00 00
URB Header (length: 72)
SequenceNumber: 9
Function: 0009 (BULK_OR_INTERRUPT_TRANSFER)
TransferFlags: 0x00000002
TransferBuffer: 0x00000040 (64) length
0000: 06 16 19 17 00 00 00 00 00 00 00 00 00 00 00 00
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
9 ??? up n/a 27.874 BULK_OR_INTERRUPT_TRANSFER - 0x00000000
URB Header (length: 72)
SequenceNumber: 9
Function: 0009 (BULK_OR_INTERRUPT_TRANSFER)
TransferFlags: 0x00000002
No TransferBuffer
My software:
9 out down n/a 22.224 CLASS_INTERFACE 06 16 19 17 00 00 00 00
URB Header (length: 80)
SequenceNumber: 9
Function: 001b (CLASS_INTERFACE)
PipeHandle: 00000000
SetupPacket:
0000: 22 09 00 02 00 00 00 00
bmRequestType: 22
DIR: Host-To-Device
TYPE: Class
RECIPIENT: Endpoint
bRequest: 09
TransferBuffer: 0x00000040 (64) length
0000: 06 16 19 17 00 00 00 00 00 00 00 00 00 00 00 00
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
9 out up n/a 22.227 CONTROL_TRANSFER - 0x00000000
URB Header (length: 80)
SequenceNumber: 9
Function: 0008 (CONTROL_TRANSFER)
PipeHandle: 877af60c
SetupPacket:
0000: 21 09 00 02 00 00 40 00
bmRequestType: 21
DIR: Host-To-Device
TYPE: Class
RECIPIENT: Interface
bRequest: 09
No TransferBuffer
Code used to send the data looks like this:
hiddata.ReportID := 0;
hiddata.Data[0] := 6;
hiddata.Data[1] := $16;
hiddata.Data[2] := $19;
hiddata.Data[3] := $17;
for I := 4 to 64 do
hiddata.Data[I] := $0;
b := HidD_SetOutputReport(HidHandle, #hiddata, 65);
HidHandle is correct and variable "b" is True after execution.
Any ideas?
What I'm doing wrong?
Original:
Function: 0009 (BULK_OR_INTERRUPT_TRANSFER)
Your program:
Function: 0008 (CONTROL_TRANSFER)
HID spec allows both IIRC, but it seems your Hardware is picky and only works when using the interrupt endpoint.
Related
Needing help on CRC-8 reverse engineering
I have got the following messages: |pref|data |cs|post| |----|--------------------------------------|--|----| |1002|00070080000000000000000000000000000000|87|10fe| |1002|000700000c0000000000000000000000000000|19|10fe| |1002|00070081000000000000000000000000000000|86|10fe| |1002|00070001010000000000000000000000000000|15|10fe| |1002|00070082000000000000000000000000000000|85|10fe| |1002|00070005b00000000000000000000000000000|a0|10fe| |1002|00070083000000000000000000000000000000|84|10fe| |1002|000700b0140000000000000000000000000000|b1|10fe| |1002|00070084000000000000000000000000000000|83|10fe| |1002|00070000000000000000000000000000000000|15|10fe| |1002|00070085000000000000000000000000000000|82|10fe| |1002|00070000000000000000000000000000000000|15|10fe| |1002|00070086000000000000000000000000000000|81|10fe| |1002|00070000010000000000000000000000000000|14|10fe| |1002|00070087000000000000000000000000000000|80|10fe| |1002|00070000000000000000000000000000000000|15|10fe| |1002|00070088000000000000000000000000000000|8f|10fe| |1002|00070000000000000000000000000000000000|15|10fe| |1002|00070089000000000000000000000000000000|8e|10fe| |1002|00070000000000000000000000000000000000|15|10fe| |1002|0007008a000000000000000000000000000000|8d|10fe| |1002|00070000000000000000000000000000000000|15|10fe| |1002|0007008b000000000000000000000000000000|8c|10fe| |1002|000700979d0000000000000000000000000000|1f|10fe| |1002|00050300000000000000000000000000000000|06|10fe| |1002|000503044b0000000000000000000000000000|5b|10fe| |1002|00ff000000ff01000000000000000000000002|11|10fe| All number based 16 (hex) pref always 1002 start of message cs possible a 8-bit checksum post always 10fe end of message My question is "How to calculate the checksum?" Mark takes me closely the solution. I wrot a small test-code and let Marks algorithmus calculate a lot of message's checksum. Almost I gat 12h but sometimes 00h. Can you figure out why? #include <stdio.h> const unsigned char data[172][20] = { {0x01,0xf6,0x60,0x00,0x1e,0xb0,0x0f,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xcb}, {0x00,0xff,0x00,0x51,0x00,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40}, {0x01,0xf8,0x19,0xad,0x89,0x1d,0xd9,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x9d}, {0x01,0xf8,0x99,0xbd,0x85,0x81,0x01,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x25}, {0x01,0xf9,0x98,0x71,0x35,0x41,0x3f,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xc7}, {0x01,0xfa,0x98,0x4c,0x01,0x71,0xc9,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x6b}, {0x01,0xfb,0x18,0x00,0x01,0x36,0xcb,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x83}, {0x01,0xf8,0x1b,0xad,0xf0,0x5c,0x57,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x49}, {0x01,0xf8,0x9b,0xbd,0x0c,0x3a,0x45,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x31}, {0x01,0xf9,0x1b,0xa6,0x38,0x42,0x27,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xe5}, {0x01,0xf9,0x9a,0x71,0x3c,0x23,0xe7,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x76}, {0x01,0xfa,0x1b,0x94,0x00,0x82,0x63,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x68}, {0x01,0xfa,0x9a,0x4c,0x00,0x88,0xbb,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x83}, {0x01,0xfb,0x1a,0x00,0x00,0xcf,0xb9,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x6b}, {0x01,0xfb,0x9a,0x6c,0x00,0x1d,0xf5,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x79}, {0x01,0xf8,0x1d,0xac,0x4c,0xc2,0xb7,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x8c}, {0x01,0xf9,0x1d,0xa6,0x3c,0xe9,0x63,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x68}, {0x01,0xfa,0x1d,0x94,0x00,0xa1,0x6b,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x45}, {0x01,0xfa,0x9c,0x4c,0x00,0xab,0xb3,0x7f,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xae}, {0x01,0xfb,0x9c,0x6c,0x00,0x3e,0xfd,0x7f,0x10,0x0a,0xd5,0x7f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x34}, {0x01,0xf6,0x20,0x6c,0x00,0x38,0x43,0x1e,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x3c}, {0x00,0xff,0x00,0x53,0x00,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x42}, {0x01,0xf6,0x00,0x6c,0x00,0x7c,0x65,0x1e,0xd0,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x7e}, {0x01,0xe0,0x78,0x00,0x00,0x3c,0x61,0x2d,0xd0,0x00,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x0a}, {0x00,0xff,0x00,0x53,0x00,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,0xc2}, {0x00,0xff,0x00,0x53,0x00,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,0xc2}, {0x01,0xa0,0x78,0x00,0x02,0x00,0x00,0xb3,0x7b,0x87,0x87,0x87,0x7b,0x22,0x00,0x00,0x00,0x00,0x00,0xdf}, {0x01,0x60,0xb8,0x00,0x00,0xc0,0x3c,0x1b,0xd0,0x00,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0xdd}, {0x01,0x60,0xb8,0x00,0x00,0xc1,0xb7,0x29,0x7f,0xc2,0xaf,0x7f,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0xd8}, {0x01,0xf0,0x20,0x00,0x00,0x20,0x80,0x00,0x00,0x11,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x4a}, {0x01,0xf2,0x00,0x00,0x00,0x41,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x18}, {0x01,0xf0,0x20,0x00,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x3b}, {0x01,0xf2,0x00,0x00,0x00,0x21,0x80,0x00,0x00,0x11,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x69}, {0x01,0xf0,0x20,0x00,0x00,0x20,0x81,0x00,0x00,0x02,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x59}, {0x01,0xf2,0x00,0x00,0x00,0x41,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x19}, {0x01,0xf0,0x20,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x34}, {0x01,0xf2,0x00,0x00,0x00,0x21,0x8f,0x00,0x00,0x62,0xa2,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0xb7}, {0x01,0xf0,0x20,0x1e,0x1e,0x20,0x81,0x00,0x00,0x03,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x58}, {0x01,0xf2,0x00,0x00,0x00,0x41,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x19}, {0x01,0xf0,0x20,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x34}, {0x01,0xf2,0x00,0x00,0x00,0x21,0x8f,0x00,0x00,0xf5,0x7c,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0xfe}, {0x01,0xf0,0x20,0x1e,0x1e,0x20,0x81,0x00,0x00,0x08,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x53}, {0x01,0xf0,0x20,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x34}, {0x01,0xf2,0x00,0x00,0x00,0x21,0x8f,0x00,0x00,0x06,0x23,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x52}, {0x01,0xf0,0x20,0x1e,0x1e,0x20,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x5b}, {0x01,0xf2,0x00,0x00,0x00,0x41,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x18}, {0x00,0xff,0x00,0x53,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x80,0x00,0x00,0x00,0x02,0x3e}, {0x01,0x60,0xb8,0x02,0x00,0x02,0x1c,0x19,0x00,0x00,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0xef}, {0x01,0x60,0xb8,0x02,0x00,0x03,0x97,0x2b,0x7f,0x00,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x28}, {0x01,0xf2,0x00,0x02,0x00,0x42,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x19}, {0x01,0xf0,0x40,0x02,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x59}, {0x01,0xf2,0x00,0x02,0x00,0x22,0x80,0x00,0x00,0x12,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x6b}, {0x01,0xf0,0x40,0x02,0x00,0x20,0x81,0x00,0x00,0x06,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x3f}, {0x01,0xf2,0x00,0x02,0x00,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x18}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x02,0x00,0x22,0x8f,0x00,0x00,0x92,0xf2,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x16}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x02,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x38}, {0x01,0xf2,0x00,0x02,0x00,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x18}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x02,0x00,0x22,0x8f,0x00,0x00,0x3b,0xf7,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0xba}, {0x01,0xf2,0x00,0x02,0x00,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x18}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x02,0x00,0x22,0x8f,0x00,0x00,0x06,0x23,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x53}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x0a,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x31}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x02,0x00,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x56}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0x55,0x35,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x14}, {0x01,0xf0,0x40,0x02,0x00,0x20,0x81,0x00,0x00,0x03,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x3b}, {0x01,0xf2,0x00,0x02,0x00,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x18}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8c,0x00,0x00,0x04,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x53}, {0x01,0xf2,0x00,0x02,0x00,0x22,0x8c,0x00,0x00,0xf6,0xff,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x7d}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x85,0x00,0x00,0x08,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x36}, {0x01,0xf2,0x00,0x02,0x00,0x42,0x85,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1c}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8c,0x00,0x00,0x04,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x53}, {0x01,0xf2,0x00,0x02,0x00,0x22,0x8c,0x00,0x00,0x07,0x04,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x76}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8c,0x00,0x00,0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x56}, {0x01,0xf2,0x00,0x02,0x00,0x22,0x8c,0x00,0x00,0x02,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x77}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x0a,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x31}, {0x01,0xf2,0x00,0x02,0x00,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x18}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8a,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x51}, {0x01,0xf2,0x00,0x02,0x00,0x22,0x8a,0x00,0x00,0x20,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x53}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x0b,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x30}, {0x00,0xff,0x00,0x53,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,0x3c}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0xa7,0xce,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1d}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8a,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x51}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x19,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x22}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0xaf,0xac,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x77}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x0c,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x37}, {0x00,0xff,0x00,0x53,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,0x3c}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0xba,0xa5,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x6b}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8a,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x51}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8a,0x00,0x00,0x20,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x51}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x0d,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x36}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0x05,0x28,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x59}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x13,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x28}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0xee,0xd8,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x42}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x0e,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x35}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0x0f,0xe1,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x9a}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x14,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x2f}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0x81,0x3b,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0xce}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x81,0x00,0x00,0x11,0x00,0x01,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x2a}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x54}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x8f,0x00,0x00,0xbc,0xa9,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x61}, {0x01,0xf0,0x40,0x1e,0x1e,0x20,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x3b}, {0x01,0xf2,0x00,0x1e,0x1e,0x42,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1b}, {0x01,0xf0,0x40,0x1e,0x1e,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x9b}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x40,0x00,0x00,0x00,0x00,0x7f,0xff,0x38,0x00,0x00,0x00,0x00,0x00,0x3b}, {0x01,0xf2,0x00,0x1e,0x1e,0x22,0x50,0x00,0x00,0x7f,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0xd4}, {0x01,0x60,0xb8,0x00,0x00,0xc0,0x3c,0x1b,0x02,0x19,0xc1,0x7f,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0xa8}, {0x01,0xa1,0x98,0x00,0x00,0x00,0x00,0x62,0x9b,0x2f,0xe9,0x7f,0x7b,0x22,0x00,0x00,0x00,0x00,0x00,0x33}, {0x01,0xe1,0x98,0x00,0x08,0x97,0x33,0x14,0x00,0x0f,0x59,0x07,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0xab}, {0x01,0xe0,0x78,0x00,0x00,0x3c,0x61,0x2d,0x9b,0x2f,0xe9,0x7f,0x7b,0x21,0x00,0x00,0x00,0x00,0x00,0x83}, {0x00,0xff,0x00,0x53,0x02,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x02,0x3c}, {0x00,0x04,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06}, {0x01,0x60,0xb8,0x02,0x00,0x03,0x97,0x2b,0x3c,0x03,0x16,0xb3,0xd1,0x21,0x00,0x00,0x00,0x00,0x00,0x1c}, {0x01,0x60,0xb8,0x00,0x00,0xc1,0xb7,0x29,0x7f,0x87,0x87,0x87,0x7b,0x21,0x00,0x00,0x00,0x00,0x00,0x36}, {0x01,0xa0,0x78,0x00,0x02,0x00,0x00,0xb3,0x7b,0x87,0x87,0x87,0x7b,0x22,0x00,0x00,0x00,0x00,0x00,0xdf}, {0x00,0xff,0x00,0x01,0x02,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x02,0x6c}, {0x00,0x04,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05}, {0x01,0xa1,0x98,0x00,0x00,0x00,0x00,0x62,0x9b,0x87,0x87,0x87,0x7b,0x22,0x00,0x00,0x00,0x00,0x00,0x0d}, {0x01,0xf1,0xe0,0x00,0x00,0x20,0x80,0x00,0x00,0x1f,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xa7}, {0x01,0xf2,0x00,0x00,0x00,0x4f,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x16}, {0x01,0xf1,0xe0,0x00,0x00,0x20,0x81,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xba}, {0x01,0xf2,0x00,0x02,0x00,0x4f,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x15}, {0x01,0xe1,0x38,0x1e,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc4}, {0x01,0xf1,0xe0,0x00,0x00,0x40,0x89,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xd1}, {0x01,0xf2,0x00,0x1e,0x02,0x2f,0x89,0x00,0x00,0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x62}, {0x01,0xf1,0xe0,0x00,0x00,0x20,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xbc}, {0x01,0xf2,0x00,0x1e,0x1e,0x4f,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x12}, {0x01,0xf1,0xe0,0x00,0x00,0x40,0x86,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xde}, {0x01,0xf2,0x00,0x1e,0x02,0x2f,0x86,0x00,0x00,0x0d,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x61}, {0x01,0xf1,0xe0,0x00,0x00,0x20,0x85,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xbd}, {0x00,0xff,0x00,0x01,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,0x6e}, {0x01,0xf2,0x00,0x02,0x02,0x4f,0x85,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x13}, {0x01,0xf1,0xe0,0x00,0x00,0x50,0x8c,0x00,0x00,0x0d,0x00,0x00,0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x89}, {0x01,0xf2,0x00,0x1e,0x02,0x0f,0x8c,0x00,0x00,0x0d,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x4b}, {0x01,0xf2,0x1c,0x00,0x02,0xf6,0xff,0x01,0x00,0x01,0x07,0xf2,0xff,0x38,0x00,0x00,0x00,0x00,0x00,0xc4}, {0x01,0xf2,0x1e,0x00,0x04,0x07,0x04,0x00,0x00,0x02,0x1b,0x1d,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0xc9}, {0x01,0xf1,0xfe,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a}, {0x01,0xf2,0x00,0x00,0x04,0x8f,0x8c,0x00,0x00,0xe8,0x2c,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x1a}, {0x01,0xf1,0xe0,0x00,0x00,0x80,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x14}, {0x01,0xf1,0xe0,0x00,0x00,0x40,0x8a,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xd2}, {0x01,0xf2,0x00,0x02,0x02,0x2f,0x8a,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x7c}, {0x01,0xf1,0xe0,0x00,0x00,0x40,0x8b,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xd3}, {0x01,0xf2,0x00,0x00,0x04,0x2f,0x8b,0x00,0x00,0x75,0x4d,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x41}, {0x01,0xf1,0xe0,0x00,0x00,0x20,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xb8}, {0x01,0xf2,0x00,0x02,0x02,0x4f,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x16}, {0x01,0xf1,0xe0,0x00,0x00,0x40,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10}, {0x01,0xf2,0x00,0x02,0x02,0x2f,0x48,0x00,0x00,0x03,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0xbd}, {0x00,0x04,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06}, {0x00,0xff,0x00,0x01,0x02,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,0x6d}, {0x01,0x60,0xd8,0x02,0x02,0x03,0x01,0x01,0xa5,0x25,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0x0b}, {0x01,0xa1,0x98,0x00,0x00,0x00,0x00,0x62,0x9b,0x87,0x7f,0x87,0x7b,0x22,0x00,0x00,0x00,0x00,0x00,0xf5}, {0x01,0x60,0xb8,0x02,0x00,0x02,0x1c,0x19,0x9b,0x87,0x7f,0x87,0x7b,0x21,0x00,0x00,0x00,0x00,0x00,0x70}, {0x01,0x60,0xd8,0x02,0x02,0x02,0x01,0x01,0x45,0x0d,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0xc2}, {0x01,0x60,0xd8,0x02,0x02,0x05,0x01,0x01,0x78,0x83,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0x76}, {0x01,0xa0,0x78,0x00,0x02,0x00,0x00,0xb3,0x7b,0x83,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0xa0} }; int main(int argc, char **argv) { puts("Mark Adler has said ..."); for(int row=0;row<172;row++) { const unsigned char *prow = data[row]; unsigned char s = 0; for(int col=0;col<20;col++) { s ^= prow[col]; printf("%02x ",prow[col]); } printf(" ==> %02x\n",s); } return 0; } results in [juergen#nadhh ~]$ ./xor12 Mark Adler has said ... 01 f6 60 00 1e b0 0f 7f 10 0a d5 7f 00 20 00 00 00 00 00 cb ==> 12 00 ff 00 53 02 00 01 00 00 00 00 00 00 03 80 00 00 00 02 3c ==> 12 00 04 03 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 ==> 00 01 60 b8 02 00 03 97 2b 3c 03 16 b3 d1 21 00 00 00 00 00 1c ==> 12 01 60 b8 00 00 c1 b7 29 7f 87 87 87 7b 21 00 00 00 00 00 36 ==> 12 01 a0 78 00 02 00 00 b3 7b 87 87 87 7b 22 00 00 00 00 00 df ==> 12 00 ff 00 01 02 00 01 00 00 00 00 00 00 01 80 00 00 00 02 6c ==> 12 00 04 03 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ==> 00 01 a1 98 00 00 00 00 62 9b 87 87 87 7b 22 00 00 00 00 00 0d ==> 12 01 f1 e0 00 00 20 80 00 00 1f 00 00 00 08 00 00 00 00 00 a7 ==> 00 01 f2 00 00 00 4f 80 00 00 00 00 00 00 38 00 00 00 00 00 16 ==> 12 01 f1 e0 00 00 20 81 00 00 03 00 00 00 08 00 00 00 00 00 ba ==> 00 01 f2 00 02 00 4f 81 00 00 00 00 00 00 38 00 00 00 00 00 15 ==> 12 01 e1 38 1e 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c4 ==> 00 01 f1 e0 00 00 40 89 00 00 00 00 00 00 08 00 00 00 00 00 d1 ==> 00 01 f2 00 1e 02 2f 89 00 00 01 00 00 00 38 00 00 00 00 00 62 ==> 12 01 f1 e0 00 00 20 84 00 00 00 00 00 00 08 00 00 00 00 00 bc ==> 00 01 f2 00 1e 1e 4f 84 00 00 00 00 00 00 38 00 00 00 00 00 12 ==> 12 01 f1 e0 00 00 40 86 00 00 00 00 00 00 08 00 00 00 00 00 de ==> 00 01 f2 00 1e 02 2f 86 00 00 0d 00 00 00 38 00 00 00 00 00 61 ==> 12 01 f1 e0 00 00 20 85 00 00 00 00 00 00 08 00 00 00 00 00 bd ==> 00 00 ff 00 01 02 00 02 00 00 00 00 00 00 00 80 00 00 00 02 6e ==> 12 01 f2 00 02 02 4f 85 00 00 00 00 00 00 38 00 00 00 00 00 13 ==> 12 01 f1 e0 00 00 50 8c 00 00 0d 00 00 40 08 00 00 00 00 00 89 ==> 00 01 f2 00 1e 02 0f 8c 00 00 0d 00 00 00 38 00 00 00 00 00 4b ==> 12 01 f2 1c 00 02 f6 ff 01 00 01 07 f2 ff 38 00 00 00 00 00 c4 ==> 12 01 f2 1e 00 04 07 04 00 00 02 1b 1d 00 35 00 00 00 00 00 c9 ==> 12 01 f1 fe 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0a ==> 00 01 f2 00 00 04 8f 8c 00 00 e8 2c 00 00 38 00 00 00 00 00 1a ==> 12 01 f1 e0 00 00 80 8c 00 00 00 00 00 00 08 00 00 00 00 00 14 ==> 00 01 f1 e0 00 00 40 8a 00 00 00 00 00 00 08 00 00 00 00 00 d2 ==> 00 01 f2 00 02 02 2f 8a 00 00 00 00 00 00 38 00 00 00 00 00 7c ==> 12 01 f1 e0 00 00 40 8b 00 00 00 00 00 00 08 00 00 00 00 00 d3 ==> 00 01 f2 00 00 04 2f 8b 00 00 75 4d 00 00 38 00 00 00 00 00 41 ==> 12 01 f1 e0 00 00 20 80 00 00 00 00 00 00 08 00 00 00 00 00 b8 ==> 00 01 f2 00 02 02 4f 80 00 00 00 00 00 00 38 00 00 00 00 00 16 ==> 12 01 f1 e0 00 00 40 48 00 00 00 00 00 00 08 00 00 00 00 00 10 ==> 00 01 f2 00 02 02 2f 48 00 00 03 00 00 00 38 00 00 00 00 00 bd ==> 12 00 04 03 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 ==> 00 00 ff 00 01 02 00 01 00 00 00 00 00 00 00 80 00 00 00 02 6d ==> 12 01 60 d8 02 02 03 01 01 a5 25 00 00 00 23 00 00 00 00 00 0b ==> 12 01 a1 98 00 00 00 00 62 9b 87 7f 87 7b 22 00 00 00 00 00 f5 ==> 12 01 60 b8 02 00 02 1c 19 9b 87 7f 87 7b 21 00 00 00 00 00 70 ==> 12 01 60 d8 02 02 02 01 01 45 0d 00 00 00 23 00 00 00 00 00 c2 ==> 12 01 60 d8 02 02 05 01 01 78 83 00 00 00 23 00 00 00 00 00 76 ==> 12 01 a0 78 00 02 00 00 b3 7b 83 00 00 00 22 00 00 00 00 00 a0 ==> 12 [juergen#nadhh ~]$
It is not a CRC-8. Each "cs" value is the exclusive-or of all of the "data" values, or that exclusive-or'ed with 0x12. In your list, the exclusive-or of each row is 0, 0x12 alternating, except for the last row. I don't see anything obvious in the data that might indicate whether it should be 0 or 0x12.
to read the packet data from a cap file
i need to read the payload information from a udp packet which is in pcap file. tshark -x -c 10 -r traces/trace.pcap udp 0000 00 22 4d a8 1f 7f 80 3f 5d 08 52 35 08 00 45 00 ."M....?].R5..E. 0010 05 94 03 e6 40 00 40 11 3b 46 c0 a8 ba 6c c0 a8 ....#.#.;F...l.. 0020 ba 6f d4 80 05 dc 05 80 4e 9e 00 00 80 25 1b 3a .o......N....%.: 0030 fd 9e 00 00 00 01 00 00 00 06 5b 29 c2 5b 78 ed ..........[).[x. 0040 00 00 1b 6f c2 5b 78 ed 00 00 1e c4 30 5b 00 00 ...o.[x.....0[.. 0050 00 00 85 c7 09 00 00 00 00 00 01 00 00 00 06 00 ................ 0060 00 00 c0 07 1c 00 00 00 00 00 c0 07 3c 00 00 00 ............<... 0070 00 00 c0 07 3c 00 00 00 00 00 78 78 78 78 78 78 ....<.....xxxxxx i get the above output from tshark but the payload consists of packet arrival and departure time from a udp server how i need to retrieve arrival and departure time from above information.
To print both the packet as hex (-x) and the summary with the timestamp in tshark add the -P option. To get the timestamp as absolute instead of relative value add the -ta option. For more information see the documentation.
OpenSSL ClientHello fails in latest version
I need to connect to an SSL server. When I connect using OpenSSL 1.0.1r it works fine: CONNECTED(00000304) write to 0x6e13e8 [0x730a98] (297 bytes => 297 (0x129)) 0000 - 16 03 01 01 24 01 00 01-20 03 03 16 f2 71 5f 26 ....$... ....q_& 0010 - a5 9b 64 cb 8f 0b 27 65-8d a3 54 e6 de a5 18 7a ..d...'e..T....z 0020 - 3c 5a e4 08 ab ff 6a 92-d7 45 f3 00 00 8a c0 30 <Z....j..E.....0 0030 - c0 2c c0 28 c0 24 c0 14-c0 0a 00 a3 00 9f 00 6b .,.(.$.........k 0040 - 00 6a 00 39 00 38 00 88-00 87 c0 32 c0 2e c0 2a .j.9.8.....2...* 0050 - c0 26 c0 0f c0 05 00 9d-00 3d 00 35 00 84 c0 2f .&.......=.5.../ 0060 - c0 2b c0 27 c0 23 c0 13-c0 09 00 a2 00 9e 00 67 .+.'.#.........g 0070 - 00 40 00 33 00 32 00 9a-00 99 00 45 00 44 c0 31 .#.3.2.....E.D.1 0080 - c0 2d c0 29 c0 25 c0 0e-c0 04 00 9c 00 3c 00 2f .-.).%.......<./ 0090 - 00 96 00 41 00 07 c0 11-c0 07 c0 0c c0 02 00 05 ...A............ 00a0 - 00 04 c0 12 c0 08 00 16-00 13 c0 0d c0 03 00 0a ................ 00b0 - 00 15 00 12 00 09 00 ff-01 00 00 6d 00 0b 00 04 ...........m.... 00c0 - 03 00 01 02 00 0a 00 34-00 32 00 0e 00 0d 00 19 .......4.2...... 00d0 - 00 0b 00 0c 00 18 00 09-00 0a 00 16 00 17 00 08 ................ 00e0 - 00 06 00 07 00 14 00 15-00 04 00 05 00 12 00 13 ................ 00f0 - 00 01 00 02 00 03 00 0f-00 10 00 11 00 23 00 00 .............#.. 0100 - 00 0d 00 20 00 1e 06 01-06 02 06 03 05 01 05 02 ... ............ 0110 - 05 03 04 01 04 02 04 03-03 01 03 02 03 03 02 01 ................ 0120 - 02 02 02 03 00 0f 00 01-01 ......... >>> TLS 1.2 Handshake [length 0124], ClientHello 01 00 01 20 03 03 16 f2 71 5f 26 a5 9b 64 cb 8f 0b 27 65 8d a3 54 e6 de a5 18 7a 3c 5a e4 08 ab ff 6a 92 d7 45 f3 00 00 8a c0 30 c0 2c c0 28 c0 24 c0 14 c0 0a 00 a3 00 9f 00 6b 00 6a 00 39 00 38 00 88 00 87 c0 32 c0 2e c0 2a c0 26 c0 0f c0 05 00 9d 00 3d 00 35 00 84 c0 2f c0 2b c0 27 c0 23 c0 13 c0 09 00 a2 00 9e 00 67 00 40 00 33 00 32 00 9a 00 99 00 45 00 44 c0 31 c0 2d c0 29 c0 25 c0 0e c0 04 00 9c 00 3c 00 2f 00 96 00 41 00 07 c0 11 c0 07 c0 0c c0 02 00 05 00 04 c0 12 c0 08 00 16 00 13 c0 0d c0 03 00 0a 00 15 00 12 00 09 00 ff 01 00 00 6d 00 0b 00 04 03 00 01 02 00 0a 00 34 00 32 00 0e 00 0d 00 19 00 0b 00 0c 00 18 00 09 00 0a 00 16 00 17 00 08 00 06 00 07 00 14 00 15 00 04 00 05 00 12 00 13 00 01 00 02 00 03 00 0f 00 10 00 11 00 23 00 00 00 0d 00 20 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 03 00 0f 00 01 01 read from 0x6e13e8 [0x735ff8] (7 bytes => 7 (0x7)) 0000 - 16 03 03 00 57 02 ....W. 0007 - <SPACES/NULS> read from 0x6e13e8 [0x736002] (85 bytes => 85 (0x55)) 0000 - 00 53 03 03 56 bb 11 21-1a ac 49 84 2d be 94 ad .S..V..!..I.-... 0010 - a0 c4 57 46 bc 70 d0 84-95 ce 96 c6 8c 92 07 2e ..WF.p.......... 0020 - 4e 13 d6 f3 20 aa d7 86-ca 48 5e 01 a1 8c d3 f1 N... ....H^..... 0030 - d7 74 f9 2c 84 48 7d c1-95 6d 22 81 ff 53 ab d3 .t.,.H}..m"..S.. 0040 - 0c 89 81 7d a2 00 3d 00-00 0b 00 0b 00 02 01 00 ...}..=......... 0050 - ff 01 00 01 .... 0055 - <SPACES/NULS> <<< TLS 1.2 Handshake [length 0057], ServerHello 02 00 00 53 03 03 56 bb 11 21 1a ac 49 84 2d be 94 ad a0 c4 57 46 bc 70 d0 84 95 ce 96 c6 8c 92 07 2e 4e 13 d6 f3 20 aa d7 86 ca 48 5e 01 a1 8c d3 f1 d7 74 f9 2c 84 48 7d c1 95 6d 22 81 ff 53 ab d3 0c 89 81 7d a2 00 3d 00 00 0b 00 0b 00 02 01 00 ff 01 00 01 00 read from 0x6e13e8 [0x735ffb] (5 bytes => 5 (0x5)) // etc. However when I connect using OpenSSL 1.0.2f, the server closes the connection immediately: CONNECTED(00000300) write to 0x7812d0 [0x7ceef0] (317 bytes => 317 (0x13D)) 0000 - 16 03 01 01 38 01 00 01-34 03 03 45 1c 09 c2 2e ....8...4..E.... 0010 - 46 06 85 a1 01 fd 0a 2c-bb 6f 15 10 42 74 b3 bf F......,.o..Bt.. 0020 - 9f 2e 5c 00 9f f2 93 8e-c0 18 9c 00 00 b6 c0 30 ..\............0 0030 - c0 2c c0 28 c0 24 c0 14-c0 0a 00 a5 00 a3 00 a1 .,.(.$.......... 0040 - 00 9f 00 6b 00 6a 00 69-00 68 00 39 00 38 00 37 ...k.j.i.h.9.8.7 0050 - 00 36 00 88 00 87 00 86-00 85 c0 32 c0 2e c0 2a .6.........2...* 0060 - c0 26 c0 0f c0 05 00 9d-00 3d 00 35 00 84 c0 2f .&.......=.5.../ 0070 - c0 2b c0 27 c0 23 c0 13-c0 09 00 a4 00 a2 00 a0 .+.'.#.......... 0080 - 00 9e 00 67 00 40 00 3f-00 3e 00 33 00 32 00 31 ...g.#.?.>.3.2.1 0090 - 00 30 00 9a 00 99 00 98-00 97 00 45 00 44 00 43 .0.........E.D.C 00a0 - 00 42 c0 31 c0 2d c0 29-c0 25 c0 0e c0 04 00 9c .B.1.-.).%...... 00b0 - 00 3c 00 2f 00 96 00 41-00 07 c0 11 c0 07 c0 0c .<./...A........ 00c0 - c0 02 00 05 00 04 c0 12-c0 08 00 16 00 13 00 10 ................ 00d0 - 00 0d c0 0d c0 03 00 0a-00 15 00 12 00 0f 00 0c ................ 00e0 - 00 09 00 ff 01 00 00 55-00 0b 00 04 03 00 01 02 .......U........ 00f0 - 00 0a 00 1c 00 1a 00 17-00 19 00 1c 00 1b 00 18 ................ 0100 - 00 1a 00 16 00 0e 00 0d-00 0b 00 0c 00 09 00 0a ................ 0110 - 00 23 00 00 00 0d 00 20-00 1e 06 01 06 02 06 03 .#..... ........ 0120 - 05 01 05 02 05 03 04 01-04 02 04 03 03 01 03 02 ................ 0130 - 03 03 02 01 02 02 02 03-00 0f 00 01 01 ............. >>> TLS 1.2 [length 0005] 16 03 01 01 38 >>> TLS 1.2 Handshake [length 0138], ClientHello 01 00 01 34 03 03 45 1c 09 c2 2e 46 06 85 a1 01 fd 0a 2c bb 6f 15 10 42 74 b3 bf 9f 2e 5c 00 9f f2 93 8e c0 18 9c 00 00 b6 c0 30 c0 2c c0 28 c0 24 c0 14 c0 0a 00 a5 00 a3 00 a1 00 9f 00 6b 00 6a 00 69 00 68 00 39 00 38 00 37 00 36 00 88 00 87 00 86 00 85 c0 32 c0 2e c0 2a c0 26 c0 0f c0 05 00 9d 00 3d 00 35 00 84 c0 2f c0 2b c0 27 c0 23 c0 13 c0 09 00 a4 00 a2 00 a0 00 9e 00 67 00 40 00 3f 00 3e 00 33 00 32 00 31 00 30 00 9a 00 99 00 98 00 97 00 45 00 44 00 43 00 42 c0 31 c0 2d c0 29 c0 25 c0 0e c0 04 00 9c 00 3c 00 2f 00 96 00 41 00 07 c0 11 c0 07 c0 0c c0 02 00 05 00 04 c0 12 c0 08 00 16 00 13 00 10 00 0d c0 0d c0 03 00 0a 00 15 00 12 00 0f 00 0c 00 09 00 ff 01 00 00 55 00 0b 00 04 03 00 01 02 00 0a 00 1c 00 1a 00 17 00 19 00 1c 00 1b 00 18 00 1a 00 16 00 0e 00 0d 00 0b 00 0c 00 09 00 0a 00 23 00 00 00 0d 00 20 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 03 00 0f 00 01 01 read from 0x7812d0 [0x7d4450] (7 bytes => 0 (0x0)) 10124:error:140790E5:SSL routines:ssl23_write:ssl handshake failure:.\ssl\s23_lib.c:177: --- no peer certificate available --- No client certificate CA names sent --- SSL handshake has read 0 bytes and written 317 bytes --- New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : 0000 Session-ID: Session-ID-ctx: Master-Key: Key-Arg : None PSK identity: None PSK identity hint: None SRP username: None Start Time: 1455100247 Timeout : 300 (sec) Verify return code: 0 (ok) --- I don't suppose anyone speaks ClientHello sufficiently well to tell me what the difference is, and how to get OpenSSL 1.0.2f to behave like the old version (even if it is insecure; I don't control the server). I checked both traces with Wireshark, and the only significant differences I can see are that OpenSSL 1.0.2's ClientHello packet is identified as "SSL" by Wireshark, and the record layer is SSL: Whereas OpenSSL 1.0.1 is identified as TLS 1.2. It also has fewer cypher suites (I guess they removed some insecure ones?). I've tried the following combinations, and these are how Wireshark labels them in the "Protocol" column: 1.0.1: <no options>=TLSv1.2; -ssl2=SSLv2; -ssl3=SSLv3; -tls1_2=TLSv1.2 1.0.2: <no options>=SSL; -ssl2=SSLv2; -ssl3=SSLv3; -tls1_2=SSL Any ideas about: Why Wireshark decodes 1.0.1 and 1.0.2 differently? Why the connection is failing with 1.0.2? How I can get OpenSSL 1.0.2 to behave like 1.0.1?
Why Wireshark decodes 1.0.1 and 1.0.2 differently? See SSL Record Layer vs SSLv3 Record Layer on the Wireshark Q&A bulletin board and Secure Socket Layer (SSL) on the Wireshark wiki. Why the connection is failing with 1.0.2? Looks like a buggy server that's rejecting a record layer that's not an early one, like one used in SSLv3. The record layer is just that... It specifies the version of the record layer, which is simply the framing of SSL/TLS protocol messages. It is not a MIN-TLS-VERSION as many people think. The TLS protocol version is just that... It specifies the version of the SSL/TLS protocol. It is not a MAX-TLS-VERSION as many people think. How I can get OpenSSL 1.0.2 to behave like 1.0.1? Use the following in your client, but its not exactly the same. The OpenSSL client will do the right thing and select TLS 1.2 if its available: /* Uses the early record layer for downlevel servers */ const SSL_METHOD* method = SSLv23_method(); if(NULL == method) handleFailure(); ctx = SSL_CTX_new(method); if(ctx == NULL) handleFailure(); /* Cannot fail ??? */ const long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_COMPRESSION; SSL_CTX_set_options(ctx, flags); I checked OpenSSL 1.0.2's ssl/ssl.h, and both SSL_OP_NO_TLSv1 and SSL_OP_NO_TLSv1_1 are available. There's a different way to do it for OpenSSL Master (a.k.a, OpenSSL 1.1.0 and above); see Working around servers requiring SSL 2/3 record layer, and using TLS 1.2? ... [OpenSSL 1.0.2] also has fewer cipher suites (I guess they removed some insecure ones?). You should not leave cipher suites to chance. You should do something like the following: const char* const PREFERRED_CIPHERS = "HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4"; res = SSL_set_cipher_list(ssl, PREFERRED_CIPHERS); if(res != 1) handleFailure(); The !PSK and !SRP simply removes cipher suites that are not usually used. !MD5 and !RC4 are removed for servers to help avoid the Obsolete cryptography warning from Browser. You could even do the following: const char* const PREFERRED_CIPHERS = "ECDHE-ECDSA-AES256-GCM-SHA384:" "ECDHE-RSA-AES256-GCM-SHA384:" "ECDHE-ECDSA-AES128-GCM-SHA256:" "ECDHE-RSA-AES128-GCM-SHA256:" "DHE-DSS-AES256-GCM-SHA384:" "DHE-RSA-AES256-GCM-SHA384:" "DHE-DSS-AES128-GCM-SHA256:" "DHE-RSA-AES128-GCM-SHA256"; res = SSL_set_cipher_list(ssl, PREFERRED_CIPHERS); if(res != 1) handleFailure(); Be sure to always offer a AES/GCM cipher suite because as server configurations move to a TLS 1.2-only configuration, that's the cipher suite they usually choose. Also, each cipher suite takes up to bytes in the ClientHello, and you want to minimize the number of them. You want to minimize them because some older Proxies and Interception boxes use a fixed size buffer for the client's ClientHello, and they can't handle the proliferation of cipher suite options available in TLS 1.2. The older boxes include F5 and Ironport middleware.
Why Wireshark decodes 1.0.1 and 1.0.2 differently? No idea. Why the connection is failing with 1.0.2? Hard to tell but I've seen several servers having problems with some ciphers added to OpenSSL 1.0.2 or that too much ciphers were given or similar. I've seen similar problems with recent LibreSSL versions. In this case the servers have obviously broken TLS stacks. How I can get OpenSSL 1.0.2 to behave like 1.0.1? You can try to reduce the cipher set so that it only uses the same ciphers as OpenSSL 1.0.1. Notable I've seen servers croak ChaCha20-Poly1305 was inside the cipher set, probably they did not understand what kind of cipher this is.
How can I check INITIALIZE UPDATE and EXTERNAL AUTHENTICATE correctness?
I sent 80 50 00 00 08 00 00 00 00 00 00 00 00 [INITILIZE UPDATE Command] via opensc-tool to my java card and received 00 00 11 60 01 00 8A 79 0A F9 FF 02 00 11 79 11 36 5D 71 00 A5 A5 EC 63 BB DC 05 CC [Init Response] as its response from the card. As you see: In the command,I send 00 00 00 00 00 00 00 00 as Host Challenge, And in the response : 00 00 11 60 01 00 8A 79 0A F9 = Key diversification data FF 02 = Key information 00 11 79 11 36 5D 71 00 = Card challenge A5 A5 EC 63 BB DC 05 CC = Card cryptogram Now I want to check myself,if the card cryptogram is OK or not. How I can do it? for example I encrypt 00 00 00 00 00 00 00 00 in this site under a 3DES cryptography algorithm [with keys of my card = 4041...4F], but the output is not equal with card cryptogram that I wrote above. Why? And the next question is, if I want to send EXTERNAL AUTHENTICATION command to the card, what is its data field (after the above INITILIZE UPDATE)? Update: This is GPJ output : C:\Users\ghasemi\Desktop\gpj-20120310>GPJ C:\Users\ghasemi\Desktop\gpj-20120310>java -jar gpj.jar Found terminals: [PC/SC terminal ACS CCID USB Reader 0] Found card in terminal: ACS CCID USB Reader 0 ATR: 3B 68 00 00 00 73 C8 40 12 00 90 00 . . . DEBUG: Command APDU: 00 A4 04 00 08 A0 00 00 00 03 00 00 00 DEBUG: Response APDU: 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 01 FF 90 00 Successfully selected Security Domain OP201a A0 00 00 00 03 00 00 00 DEBUG: Command APDU: 80 50 00 00 08 7F 41 A9 E7 19 37 83 FA DEBUG: Response APDU: 00 00 11 60 01 00 8A 79 0A F9 FF 02 00 1B 9B 95 B9 5E 5E BC BA 51 34 84 D9 C1 B9 6E 90 00 DEBUG: Command APDU: 84 82 00 00 10 13 3B 4E C5 2C 9E D8 24 50 71 83 3A 78 AE 75 23 DEBUG: Response APDU: 90 00 DEBUG: Command APDU: 84 82 00 00 08 13 3B 4E C5 2C 9E D8 24 DEBUG: Response APDU: 90 00 C:\Users\ghasemi\Desktop\gpj-20120310> So : Host_Challenge :: 7F41A9E7193783FA Diversification_Data :: 0000116001008A790AF9 Key_Information :: FF02 Sequence_Counter :: 001B Card_Challenge :: 9B95B95E5EBC Card_Cryptogram :: BA513484D9C1B96E Host_Cryptogram[16,24] = 13 3B 4E C5 2C 9E D8 24 Now,lets make our Host_Cryptogram Manually : Derivation_data=derivation_const_ENC|sequence_counter|0000 0000 0000 0000 0000 0000 Derivation_Data = 0182001B000000000000000000000000 k_ENC :: 404142434445464748494A4B4C4D4E4F IV = 00 00 00 00 00 00 00 00 S_ENC = encrypt(TDES_CBC, K_ENC, IV, derivation_data) So : I used http://tripledes.online-domain-tools.com/ and its output for above values was : S_ENC = 448b0a5967ca246d058703ff0c694f15 And : Padding_DES = 80 00 00 00 00 00 00 00 Host_auth_data = sequence_counter | card_challenge | host_challenge | padding_DES IV = Card_Cryptogram :: BA513484D9C1B96E host_cryptogram = encrypt(TDES_CBC, S_ENC, IV, host_auth_data) So : Host_Authentication_Data : 001B9B95B95E5EBC7F41A9E7193783FA8000000000000000 Again, I used http://tripledes.online-domain-tools.com/ and : Host_Cryptogram : 3587b531db71ac52392493c08cff189ce7b9061029c63b62 So : Host_Cryptogram[16,24] = e7b9061029c63b62 Why these two way [manually and GPJ output] give us two host cryptogram?
From the INITIALIZE UPDATE command you send, you get host_challenge = 00 00 00 00 00 00 00 00 In response to the INITIALIZE UPDATE command, you get diversification_data = 00 00 11 60 01 00 8A 79 0A F9 key_information = FF 02 sequence_counter = 00 11 card_challenge = 79 11 36 5D 71 00 card_cryptogram = A5 A5 EC 63 BB DC 05 CC The key information indicates SCP02 (02). The key diversification data may be used to derive the card-specific K_ENC. Lets assume we have a K_ENC like this K_ENC = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 We can then derive the session encryption key like this derivation_const_ENC = 01 82 derivation_data = derivation_const_ENC | sequence_counter | 00 00 00 00 00 00 00 00 00 00 00 00 IV = 00 00 00 00 00 00 00 00 S_ENC = encrypt(TDES_CBC, K_ENC, IV, derivation_data) Next, we can assemble the authentication data used to calculate the host cryptogram: padding_DES = 80 00 00 00 00 00 00 00 host_auth_data = sequence_counter | card_challenge | host_challenge | padding_DES Then we can use the session encryption key to encrypt the authentication data: IV = 00 00 00 00 00 00 00 00 host_cryptogram = encrypt(TDES_CBC, S_ENC, IV, host_auth_data) The last 8 bytes of the encrypted authentication data are the actual host cryptogram that we would send to the card: EXTERNAL_AUTHENTICATE_data = host_cryptogram[16, 24] Now we can assemble the EXTERNAL AUTHENTICATE command: EXTERNAL_AUTHENTICATE = 84 82 03 00 08 | EXTERNAL_AUTHENTICATE_data We can then calculate the S_MAC key (analoguous to getting the S_ENC above) and the MAC over that command and append it to the command data to get the full EXTERNAL AUTHENTICATE command that can be sent to the card: EXTERNAL_AUTHENTICATE = 84 82 03 00 10 | EXTERNAL_AUTHENTICATE_data | MAC Update Using http://tripledes.online-domain-tools.com/ to reproduce the results of GPJ Your K_ENC is 404142434445464748494A4B4C4D4E4F. The online tools does not properly support 2-key-3DES, so you have to convert the key into its 3-key form first: K_ENC = 404142434445464748494A4B4C4D4E4F4041424344454647 Use this key and a zero IV to encrypt the derivation data (0182001B000000000000000000000000). You get S_ENC = fb063cc2e17b979b10e22f82110234b4 In 3-key notation, this is S_ENC = fb063cc2e17b979b10e22f82110234b4fb063cc2e17b979b Use this key and a zero IV to encrypt the host authentication data (001b9b95b95e5ebc7f41a9e7193783fa8000000000000000): HOST_CRYPTOGRAM = 773e790c91acce3167d99f92c60e2afd133b4ec52c9ed824
understand hexedit of an elf
Consider the following hexedit display of an ELF file. 00000000 7F 45 4C 46 01 01 01 00 00 00 00 00 .ELF........ 0000000C 00 00 00 00 02 00 03 00 01 00 00 00 ............ 00000018 30 83 04 08 34 00 00 00 50 14 00 00 0...4...P... 00000024 00 00 00 00 34 00 20 00 08 00 28 00 ....4. ...(. 00000030 24 00 21 00 06 00 00 00 34 00 00 00 $.!.....4... 0000003C 34 80 04 08 34 80 04 08 00 01 00 00 4...4....... 00000048 00 01 00 00 05 00 00 00 04 00 00 00 ............ How many section headers does it have? Is it an object file or an executable file? How many program headers does it have? If there are any program headers, what does the first program header do? If there are any section headers, at what offset is the section header table?
Strange, this hexdump looks like your homework to me... There are 36 section headers. It is an executable. It has 8 program headers. As you can tell by the first word (offset 0x34: 0x0006) in the first program header, it is of type PT_PHDR, which just informs about the characteristics of the program header table itself. The section header table begins at byte 5200 (which is 0x1450 in hex). How do I know this stuff? By dumping the hex into a binary and reading it with readelf -a (because I am lazy). Except for question no. 4, which I had to figure out manually by reading man 5 elf.