Check for key size before files decryption

This commit is contained in:
Grégory Soutadé 2022-02-22 20:58:26 +01:00
parent 7d93817e49
commit 7d161133c3
2 changed files with 6 additions and 1 deletions

View File

@ -119,7 +119,8 @@ namespace gourou
DRM_FILE_ERROR, DRM_FILE_ERROR,
DRM_FORMAT_NOT_SUPPORTED, DRM_FORMAT_NOT_SUPPORTED,
DRM_IN_OUT_EQUALS, DRM_IN_OUT_EQUALS,
DRM_MISSING_PARAMETER DRM_MISSING_PARAMETER,
DRM_INVALID_KEY_SIZE
}; };
/** /**

View File

@ -927,8 +927,12 @@ namespace gourou
void DRMProcessor::decryptADEPTKey(const std::string& encryptedKey, unsigned char* decryptedKey) 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); ByteArray arrayEncryptedKey = ByteArray::fromBase64(encryptedKey);
std::string privateKeyData = user->getPrivateLicenseKey(); std::string privateKeyData = user->getPrivateLicenseKey();
ByteArray privateRSAKey = ByteArray::fromBase64(privateKeyData); ByteArray privateRSAKey = ByteArray::fromBase64(privateKeyData);