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
|
/*
* Copyright (C) 2005-2016 Team XBMC
* http://kodi.tv
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <inttypes.h>
#include <string.h>
//CryptoSession is usually obtained once per stream, but could change if an key expires
enum CryptoSessionSystem :uint8_t
{
CRYPTO_SESSION_SYSTEM_NONE,
CRYPTO_SESSION_SYSTEM_WIDEVINE,
CRYPTO_SESSION_SYSTEM_PLAYREADY
};
struct DemuxCryptoSession
{
DemuxCryptoSession(const CryptoSessionSystem sys, const uint16_t sSize, const char *sData, const uint8_t flags)
: sessionId(new char[sSize])
, sessionIdSize(sSize)
, keySystem(sys)
, flags(flags)
{
memcpy(sessionId, sData, sSize);
};
~DemuxCryptoSession()
{
delete[] sessionId;
}
// encryped stream infos
char * sessionId;
uint16_t sessionIdSize;
CryptoSessionSystem keySystem;
static const uint8_t FLAG_SECURE_DECODER = 1;
uint8_t flags;
private:
DemuxCryptoSession(const DemuxCryptoSession&) = delete;
DemuxCryptoSession& operator=(const DemuxCryptoSession&) = delete;
};
//CryptoInfo stores the information to decrypt a sample
struct DemuxCryptoInfo
{
explicit DemuxCryptoInfo(const unsigned int numSubs)
: numSubSamples(numSubs)
, flags(0)
, clearBytes(new uint16_t[numSubs])
, cipherBytes(new uint32_t[numSubs])
{};
~DemuxCryptoInfo()
{
delete[] clearBytes;
delete[] cipherBytes;
}
uint16_t numSubSamples; //number of subsamples
uint16_t flags; //flags for later use
uint16_t *clearBytes; // numSubSamples uint16_t's wich define the size of clear size of a subsample
uint32_t *cipherBytes; // numSubSamples uint32_t's wich define the size of cipher size of a subsample
uint8_t iv[16]; // initialization vector
uint8_t kid[16]; // key id
private:
DemuxCryptoInfo(const DemuxCryptoInfo&) = delete;
DemuxCryptoInfo& operator=(const DemuxCryptoInfo&) = delete;
};
|