Fixed: Use separate guid for download protection

Fixes #963
This commit is contained in:
Qstick
2022-05-13 18:41:36 -05:00
parent bc50fd937d
commit 6783514525
3 changed files with 9 additions and 4 deletions

View File

@@ -156,6 +156,8 @@ namespace NzbDrone.Core.Configuration
public string HmacSalt => GetValue("HmacSalt", Guid.NewGuid().ToString(), true);
public string DownloadProtectionKey => GetValue("DownloadProtectionKey", Guid.NewGuid().ToString().Replace("-", ""), true);
public bool ProxyEnabled => GetValueBoolean("ProxyEnabled", false);
public ProxyType ProxyType => GetValueEnum<ProxyType>("ProxyType", ProxyType.Http);

View File

@@ -33,6 +33,9 @@ namespace NzbDrone.Core.Configuration
string RijndaelSalt { get; }
string HmacSalt { get; }
//Link Protection
string DownloadProtectionKey { get; }
//Proxy
bool ProxyEnabled { get; }
ProxyType ProxyType { get; }

View File

@@ -15,16 +15,16 @@ namespace NzbDrone.Core.Security
public class ProtectionService : IProtectionService
{
private readonly IConfigFileProvider _configService;
private readonly IConfigService _configService;
public ProtectionService(IConfigFileProvider configService)
public ProtectionService(IConfigService configService)
{
_configService = configService;
}
public string Protect(string text)
{
var key = Encoding.UTF8.GetBytes(_configService.ApiKey);
var key = Encoding.UTF8.GetBytes(_configService.DownloadProtectionKey);
using (var aesAlg = Aes.Create())
{
@@ -70,7 +70,7 @@ namespace NzbDrone.Core.Security
Buffer.BlockCopy(fullCipher, 0, iv, 0, iv.Length);
Buffer.BlockCopy(fullCipher, iv.Length, cipher, 0, fullCipher.Length - iv.Length);
var key = Encoding.UTF8.GetBytes(_configService.ApiKey);
var key = Encoding.UTF8.GetBytes(_configService.DownloadProtectionKey);
using (var aesAlg = Aes.Create())
{