diff --git a/PropertySheet.props b/PropertySheet.props
index 6b52bf1..f63952e 100644
--- a/PropertySheet.props
+++ b/PropertySheet.props
@@ -4,7 +4,7 @@
2
0
- 0
+ 1
diff --git a/crypto.cpp b/crypto.cpp
index 0e2d9a0..75005f4 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -249,6 +249,14 @@ OvpnCryptoNewKey(OvpnCryptoContext* cryptoContext, POVPN_CRYPTO_DATA cryptoData,
keySlot->DecKey = NULL;
}
+ if ((cryptoData->Encrypt.KeyLen > 32) || (cryptoData->Decrypt.KeyLen > 32))
+ {
+ status = STATUS_INVALID_DEVICE_REQUEST;
+ LOG_ERROR("Incorrect encrypt or decrypt key length", TraceLoggingValue(cryptoData->Encrypt.KeyLen, "Encrypt.KeyLen"),
+ TraceLoggingValue(cryptoData->Decrypt.KeyLen, "Decrypt.KeyLen"));
+ goto done;
+ }
+
// generate keys from key materials
GOTO_IF_NOT_NT_SUCCESS(done, status, BCryptGenerateSymmetricKey(algHandle, &keySlot->EncKey, NULL, 0, cryptoData->Encrypt.Key, cryptoData->Encrypt.KeyLen, 0));
GOTO_IF_NOT_NT_SUCCESS(done, status, BCryptGenerateSymmetricKey(algHandle, &keySlot->DecKey, NULL, 0, cryptoData->Decrypt.Key, cryptoData->Decrypt.KeyLen, 0));