trombik / esp_wireguard

WireGuard Implementation for ESP-IDF.
Other
193 stars 34 forks source link

Cannot complete handshake if pre-shared key is in use #28

Closed droscy closed 2 years ago

droscy commented 2 years ago

Hi trombik, maybe this is a known limitation, but I report it.

If a pre-shared key is set (both in wireguard_config_t and in server conf file), the device can't complete the handshake.

This is what I observe in server's dmesg

wireguard: wg0: Receiving handshake initiation from peer 96 (xx.xx.xx.xx:yyyyy)
wireguard: wg0: Sending handshake response to peer 96 (xx.xx.xx.xx:yyyyy)
wireguard: wg0: Keypair 73332 created for peer 96
[...]
wireguard: wg0: Receiving handshake initiation from peer 96 (xx.xx.xx.xx:yyyyy)
wireguard: wg0: Sending handshake response to peer 96 (xx.xx.xx.xx:yyyyy)
wireguard: wg0: Keypair 73332 destroyed for peer 96
wireguard: wg0: Keypair 73333 created for peer 96
[...]
wireguard: wg0: Receiving handshake initiation from peer 96 (xx.xx.xx.xx:yyyyy)
wireguard: wg0: Sending handshake response to peer 96 (xx.xx.xx.xx:yyyyy)
wireguard: wg0: Keypair 73333 destroyed for peer 96
wireguard: wg0: Keypair 73334 created for peer 96
[...]

The same again ad again. It is repeated approximately every 3 seconds.

If you need more (or different) information feel free to ask, I'll try to do whatever tests you will need.

trombik commented 2 years ago

in my test environment, preshared_key has never been tested. there might be a bug.

trombik commented 2 years ago

i'm sure my implementation has a bug.

trombik commented 2 years ago

should be fixed in main. would you test?

droscy commented 2 years ago

Yes, it works now. Many thanks.