OpenVPN / ovpn-dco-win

OpenVPN Data Channel Offload driver for Windows
MIT License
47 stars 22 forks source link

crypto.c: ensure we don't pass too large key size to CryptoNG #63

Closed lstipakov closed 4 months ago

lstipakov commented 4 months ago

We use BCryptGenerateSymmetricKey() to generate a symmetric key object, passing a buffer containing a key and a key length. While buffer length is guaranteed not to exceed 32 bytes, the key length value is passed from userspace and could be at max 256 bytes.

The documentation says that:

If the data passed in exceeds the target key size, the data will be truncated and the excess will be ignored.

which means that passing large length should not be a problem. I confirmed it with test with driver verifier enabled - I passed "256" as key length and haven't got any errors (and got key objected created and VPN session set up).

Nevertheless, let's be good citizens and error out if passed key length exceeds 32 bytes - maximum key length for AES-GCM and ChaCha20 ciphers.

Bump version to 1.0.1.

Reported-by: Vladimir Tokarev vtokarev@microsoft.com

cron2 commented 4 months ago

Looks good to me.