From 7d161133c357619e120070dc1f03eb926066c73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Tue, 22 Feb 2022 20:58:26 +0100 Subject: [PATCH] Check for key size before files decryption --- include/libgourou_common.h | 3 ++- src/libgourou.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/libgourou_common.h b/include/libgourou_common.h index dbfedf6..6d4ed08 100644 --- a/include/libgourou_common.h +++ b/include/libgourou_common.h @@ -119,7 +119,8 @@ namespace gourou DRM_FILE_ERROR, DRM_FORMAT_NOT_SUPPORTED, DRM_IN_OUT_EQUALS, - DRM_MISSING_PARAMETER + DRM_MISSING_PARAMETER, + DRM_INVALID_KEY_SIZE }; /** diff --git a/src/libgourou.cpp b/src/libgourou.cpp index 22552dc..aa8ce32 100644 --- a/src/libgourou.cpp +++ b/src/libgourou.cpp @@ -927,8 +927,12 @@ namespace gourou void DRMProcessor::decryptADEPTKey(const std::string& encryptedKey, unsigned char* decryptedKey) { + if (encryptedKey.size() != 172) + EXCEPTION(DRM_INVALID_KEY_SIZE, "Invalid encrypted key size (" << encryptedKey.size() << "). DRM version not supported"); + ByteArray arrayEncryptedKey = ByteArray::fromBase64(encryptedKey); + std::string privateKeyData = user->getPrivateLicenseKey(); ByteArray privateRSAKey = ByteArray::fromBase64(privateKeyData);