1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "DrmCryptoSession.h"
#include "media/drm/CryptoSession.h"
using namespace XbmcCommons;
namespace XBMCAddon
{
namespace xbmcdrm
{
CryptoSession::CryptoSession(const String& UUID,
const String& cipherAlgorithm,
const String& macAlgorithm)
: m_cryptoSession(DRM::CCryptoSession::GetCryptoSession(UUID, cipherAlgorithm, macAlgorithm))
{
}
CryptoSession::~CryptoSession()
{
delete m_cryptoSession;
}
Buffer CryptoSession::GetKeyRequest(const Buffer &init, const String &mimeType, bool offlineKey, const std::map<String, String> ¶meters)
{
if (m_cryptoSession)
return m_cryptoSession->GetKeyRequest(init, mimeType, offlineKey, parameters);
return Buffer();
}
String CryptoSession::GetPropertyString(const String &name)
{
if (m_cryptoSession)
return m_cryptoSession->GetPropertyString(name);
return "";
}
String CryptoSession::ProvideKeyResponse(const Buffer &response)
{
if (m_cryptoSession)
return m_cryptoSession->ProvideKeyResponse(response);
return "";
}
void CryptoSession::RemoveKeys()
{
if (m_cryptoSession)
m_cryptoSession->RemoveKeys();
}
void CryptoSession::RestoreKeys(const String& keySetId)
{
if (m_cryptoSession)
m_cryptoSession->RestoreKeys(keySetId);
}
void CryptoSession::SetPropertyString(const String &name, const String &value)
{
if (m_cryptoSession)
return m_cryptoSession->SetPropertyString(name, value);
}
/*******************Crypto section *****************/
Buffer CryptoSession::Decrypt(const Buffer &cipherKeyId, const Buffer &input, const Buffer &iv)
{
if (m_cryptoSession)
return m_cryptoSession->Decrypt(cipherKeyId, input, iv);
return Buffer();
}
Buffer CryptoSession::Encrypt(const Buffer &cipherKeyId, const Buffer &input, const Buffer &iv)
{
if (m_cryptoSession)
return m_cryptoSession->Encrypt(cipherKeyId, input, iv);
return Buffer();
}
Buffer CryptoSession::Sign(const Buffer &macKeyId, const Buffer &message)
{
if (m_cryptoSession)
return m_cryptoSession->Sign(macKeyId, message);
return Buffer();
}
bool CryptoSession::Verify(const Buffer &macKeyId, const Buffer &message, const Buffer &signature)
{
if (m_cryptoSession)
return m_cryptoSession->Verify(macKeyId, message, signature);
return false;
}
} //namespace xbmcdrm
} //namespace XBMCAddon
|