• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-4,5883,303

test/H02-Apr-2011-2,1041,518

AUTHORSH A D10-Feb-2011456 137

COPYINGH A D28-Nov-200817.6 KiB341281

ChangeLogH A D17-Feb-201138 32

INSTALLH A D28-Nov-20082.4 KiB6845

Makefile.amH A D28-Nov-200893 73

Makefile.inH A D02-Apr-201121.9 KiB717628

NEWSH A D28-Nov-20080

READMEH A D28-Nov-20084.2 KiB14491

aclocal.m4H A D02-Apr-2011330.4 KiB9,3918,454

config.guessH A D10-Feb-201143.9 KiB1,5021,291

config.h.inH A D02-Apr-20112.4 KiB9967

config.subH A D10-Feb-201133.6 KiB1,7061,558

configureH A D02-Apr-2011410.2 KiB14,22411,858

configure.acH A D02-Apr-20112.8 KiB9674

depcompH A D10-Feb-201118.2 KiB631407

install-shH A D10-Feb-201113.3 KiB521344

ltmain.shH A D10-Feb-2011276.1 KiB9,6377,288

missingH A D10-Feb-201111.2 KiB377281

README

1
2
3Introduction
4============
5
6libdvbcsa is a free and portable implementation of the DVB Common
7Scrambling algorithm with decryption and encryption capabilities.
8
9It comes in two flavors: a classical single packet implementation and
10a faster parallel bitslice implementation.
11
12
13Installation
14============
15
16Some configuration options are available to tune performance of the
17parallel implementation. See INSTALL.
18
19
20Algorithm overview
21==================
22
23The DVB CSA is composed of a two distinct ciphers which are applied to
24scrambled content data packets. The block cipher and the stream cipher
25both use the same 64 bits key. This key is called a control word.
26
27
28Classical implementation API
29============================
30
31The classical implementation can process a single packet on each
32function call. It is the slowest implementation and must be used when
33data packets are not available as a large batch at the same time.
34
35This implementation average processing bitrate is between 20 Mbits/s
36and 50 Mbits/s on modern PCs.
37
38    #include <dvbcsa/dvbcsa.h>
39
40Two functions are available to allocate and free expanded key context:
41
42    struct dvbcsa_key_s * dvbcsa_key_alloc();
43    void dvbcsa_key_free(struct dvbcsa_key_s *key);
44
45The control word can be changed as needed using this function:
46
47    void dvbcsa_key_set (const dvbcsa_cw_t cw,
48                         struct dvbcsa_key_s *key);
49
50Data encryption and decryption is done with these functions:
51
52     void dvbcsa_decrypt (const struct dvbcsa_key_s *key,
53     	  	          unsigned char *data, unsigned int len);
54
55     void dvbcsa_encrypt (const struct dvbcsa_key_s *key,
56                          unsigned char *data, unsigned int len);
57
58
59Parallel implementation API
60===========================
61
62The parallel implementation is faster but data packets need to be
63batched together.
64
65This implementation average processing bitrate is between 80 Mbits/s
66and 200 Mbits/s on modern PCs. Performance heavily depends on bitslice
67word width used, see install section.
68
69    #include <dvbcsa/dvbcsa.h>
70
71Two functions are available to allocate and free expanded key context:
72
73    struct dvbcsa_bs_key_s * dvbcsa_bs_key_alloc();
74
75    void dvbcsa_bs_key_free(struct dvbcsa_bs_key_s *key);
76
77The control word can be changed as needed using this function:
78
79    void dvbcsa_bs_key_set(const dvbcsa_cw_t cw,
80                           struct dvbcsa_bs_key_s *key);
81
82Packet batch must be available as an array of struct dvbcsa_bs_batch_s
83to invoke encryption or decryption functions.
84
85    struct dvbcsa_bs_batch_s
86    {
87      unsigned char		*data;	/* pointer to payload */
88      unsigned int		len;	/* payload bytes lenght */
89    };
90
91The array must not be greater than the maximum batch size returned by:
92
93    unsigned int dvbcsa_bs_batch_size(void);
94
95An extra entry  with NULL data pointer must be  added to terminate the
96array. Arrays with less entries  than the maximum batch size will take
97the _same_ time to process as a full batch array.
98
99An additional maximum packet lenght  parameter must be provided to the
100processing  functions. Packet  greater than  this limit  will  only be
101partially  processed. It  must  be  a multiple  of  8. This  parameter
102directly  control algorithm  cycles  count (and  processing time)  and
103should be  kept as low as  possible. When processing  Mpeg TS packets,
104it should be 184.
105
106Encryption and decryption batch processing functions are:
107
108    void dvbcsa_bs_decrypt(const struct dvbcsa_bs_key_s *key,
109		           const struct dvbcsa_bs_batch_s *pcks,
110		           unsigned int maxlen);
111
112    void dvbcsa_bs_encrypt(const struct dvbcsa_bs_key_s *key,
113		           const struct dvbcsa_bs_batch_s *pcks,
114		           unsigned int maxlen);
115
116Example:
117
118    int i, s = dvbcsa_bs_batch_size();
119    struct dvbcsa_bs_batch_s b[s + 1];
120
121    struct dvbcsa_bs_key_s *key = dvbcsa_bs_key_alloc();
122    unsigned char cw[8] = "testtest";
123
124    dvbcsa_bs_key_set(cw, key);
125
126    for (i = 0; i < s; i++)
127      {
128        b[i].data = ... ;
129        b[i].len = ... ;
130      }
131
132    b[i].data = NULL;
133
134    dvbcsa_bs_encrypt(key, b, 184);
135
136
137Portability
138===========
139
140This library has been successfully tested on different platforms with
14132 bits and 64 bits word width, little-endian and big-endian bytes
142ordering.
143
144