diff --git a/PropertySheet.props b/PropertySheet.props index 986dfd5..5382bfd 100644 --- a/PropertySheet.props +++ b/PropertySheet.props @@ -4,7 +4,7 @@ 1 0 - 0 + 1 diff --git a/crypto.cpp b/crypto.cpp index ce0f809..b6a881a 100644 --- a/crypto.cpp +++ b/crypto.cpp @@ -262,6 +262,14 @@ OvpnCryptoNewKey(OvpnCryptoContext* cryptoContext, POVPN_CRYPTO_DATA cryptoData) algHandle = cryptoContext->ChachaAlgHandle; } + 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));