openiked / openiked-portable

Internet Key Exchange version 2 (IKEv2) daemon - portable version of OpenBSD iked
https://openiked.org
ISC License
44 stars 23 forks source link

Wrong IDi key and length reported #88

Open bramton opened 2 years ago

bramton commented 2 years ago

I think there might be a bug in the parsing of the Identification payload. Here is my investigation:

From the logs:

ikev2_msg_decrypt: decrypted payload length 1644/1644 padding 0
2500000c 0b000000 6272616d 2600042a 04308204 21308202 ... etc

The relevant IDi payload has been summarised below:

2500000c # 25 = next payload (cert), 00 = reserved, 00 0c = length in octets (12 in this case)
0b000000 # 0b = ID_KEY_ID type, 00 00 00 = reserved
6272616d # bram in ASCII (data of the payload)

Furthermore, from the logs:

ikev2_pld_payloads: decrypted payload IDi nextpayload CERT critical 0x00 length 12
ikev2_pld_id: id KEY_ID/6766d length 8

What I would have expected:

ikev2_pld_id: id KEY_ID/6272616d length 4
tobhe commented 2 years ago

Looking into the code this isn't really a serious bug. The printed length count includes the ID specific header part (0b000000 in this case). I suppose changing the code to print the actual ID value length still makes sense, the header has a fixed size anyway.