-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
diaxen
committed
Jun 20, 2008
0 parents
commit 5a528f7
Showing
41 changed files
with
6,371 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
The bitslice implemetation is based on the great FFdecsa package, (c) | ||
2003-2004 by fatih89r. It has been rewritten by Alexandre Becoulet for | ||
flexibility, portability and encryption capabilities. | ||
|
||
The single packet implementation has been originally written by | ||
Alexandre Becoulet <[email protected]>. | ||
|
||
PowerPC Altivec support by Nicolas Pouillon <[email protected]>. | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Installation Instructions | ||
************************* | ||
|
||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, | ||
2006, 2007 Free Software Foundation, Inc. | ||
|
||
This file is free documentation; the Free Software Foundation gives | ||
unlimited permission to copy, distribute and modify it. | ||
|
||
Basic Installation | ||
================== | ||
|
||
Briefly, the shell commands `./configure; make; make install' should | ||
configure, build, and install this package. The following | ||
more-detailed instructions are generic; see the `README' file for | ||
instructions specific to this package. | ||
|
||
The `configure' shell script attempts to guess correct values for | ||
various system-dependent variables used during compilation. It uses | ||
those values to create a `Makefile' in each directory of the package. | ||
It may also create one or more `.h' files containing system-dependent | ||
definitions. Finally, it creates a shell script `config.status' that | ||
you can run in the future to recreate the current configuration, and a | ||
file `config.log' containing compiler output (useful mainly for | ||
debugging `configure'). | ||
|
||
The simplest way to compile this package is: | ||
|
||
1. `cd' to the directory containing the package's source code and type | ||
`./configure' to configure the package for your system. | ||
|
||
Running `configure' might take a while. While running, it prints | ||
some messages telling which features it is checking for. | ||
|
||
2. Type `make' to compile the package. | ||
|
||
3. Type `make install' to install the programs and any data files and | ||
documentation. | ||
|
||
|
||
Parallel operation mode | ||
======================= | ||
|
||
The parallel bitslice algorithm implementation heavily relies on | ||
logical operations. Its performances can change dramatically depending | ||
on selected bit manipulation method. | ||
|
||
Some method can be best suited for your processor. Performance can be | ||
checked using the benchmarking utilities located in the `test/' | ||
package sub-directory. | ||
|
||
The following methods are available: | ||
|
||
* 32 bits native integers, default on target where sizeof (long) == 4 | ||
|
||
* 64 bits native integers, default on target where sizeof (long) == 8 | ||
|
||
* MMX 64 bits operation, available on i386 and x86_64 targets | ||
|
||
* SSE2 128 bits operation, available on i386 and x86_64 targets | ||
|
||
* Altivec 128 bits operation, available on PowerPC targets | ||
|
||
The default choice can be changed with `--enable-uint32', | ||
`--enable-uint64', `--enable-mmx', `--enable-sse2' and | ||
`--enable-altivec' switches of the `configure' script. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
SUBDIRS = src test | ||
DIST_SUBDIRS = $(SUBDIRS) | ||
|
||
AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
|
||
|
||
Introduction | ||
============ | ||
|
||
libdvbcsa is a free and portable implementation of the DVB Common | ||
Scrambling algorithm with decryption and encryption capabilities. | ||
|
||
It comes in two flavors: a classical single packet implementation and | ||
a faster parallel bitslice implementation. | ||
|
||
|
||
Installation | ||
============ | ||
|
||
Some configuration options are available to tune performance of the | ||
parallel implementation. See INSTALL. | ||
|
||
|
||
Algorithm overview | ||
================== | ||
|
||
The DVB CSA is composed of a two distinct ciphers which are applied to | ||
scrambled content data packets. The block cipher and the stream cipher | ||
both use the same 64 bits key. This key is called a control word. | ||
|
||
|
||
Classical implementation API | ||
============================ | ||
|
||
The classical implementation can process a single packet on each | ||
function call. It is the slowest implementation and must be used when | ||
data packets are not available as a large batch at the same time. | ||
|
||
This implementation average processing bitrate is between 20 Mbits/s | ||
and 50 Mbits/s on modern PCs. | ||
|
||
#include <dvbcsa/dvbcsa.h> | ||
|
||
Two functions are available to allocate and free expanded key context: | ||
|
||
struct dvbcsa_key_s * dvbcsa_key_alloc(); | ||
void dvbcsa_key_free(struct dvbcsa_key_s *key); | ||
|
||
The control word can be changed as needed using this function: | ||
|
||
void dvbcsa_key_set (const dvbcsa_cw_t cw, | ||
struct dvbcsa_key_s *key); | ||
|
||
Data encryption and decryption is done with these functions: | ||
|
||
void dvbcsa_decrypt (const struct dvbcsa_key_s *key, | ||
unsigned char *data, unsigned int len); | ||
|
||
void dvbcsa_encrypt (const struct dvbcsa_key_s *key, | ||
unsigned char *data, unsigned int len); | ||
|
||
|
||
Parallel implementation API | ||
=========================== | ||
|
||
The parallel implementation is faster but data packets need to be | ||
batched together. | ||
|
||
This implementation average processing bitrate is between 80 Mbits/s | ||
and 200 Mbits/s on modern PCs. Performance heavily depends on bitslice | ||
word width used, see install section. | ||
|
||
#include <dvbcsa/dvbcsa.h> | ||
|
||
Two functions are available to allocate and free expanded key context: | ||
|
||
struct dvbcsa_bs_key_s * dvbcsa_bs_key_alloc(); | ||
|
||
void dvbcsa_bs_key_free(struct dvbcsa_bs_key_s *key); | ||
|
||
The control word can be changed as needed using this function: | ||
|
||
void dvbcsa_bs_key_set(const dvbcsa_cw_t cw, | ||
struct dvbcsa_bs_key_s *key); | ||
|
||
Packet batch must be available as an array of struct dvbcsa_bs_batch_s | ||
to invoke encryption or decryption functions. | ||
|
||
struct dvbcsa_bs_batch_s | ||
{ | ||
unsigned char *data; /* pointer to payload */ | ||
unsigned int len; /* payload bytes lenght */ | ||
}; | ||
|
||
The array must not be greater than the maximum batch size returned by: | ||
|
||
unsigned int dvbcsa_bs_batch_size(void); | ||
|
||
An extra entry with NULL data pointer must be added to terminate the | ||
array. Arrays with less entries than the maximum batch size will take | ||
the _same_ time to process as a full batch array. | ||
|
||
An additional maximum packet lenght parameter must be provided to the | ||
processing functions. Packet greater than this limit will only be | ||
partially processed. It must be a multiple of 8. This parameter | ||
directly control algorithm cycles count (and processing time) and | ||
should be kept as low as possible. When processing Mpeg TS packets, | ||
it should be 184. | ||
|
||
Encryption and decryption batch processing functions are: | ||
|
||
void dvbcsa_bs_decrypt(const struct dvbcsa_bs_key_s *key, | ||
const struct dvbcsa_bs_batch_s *pcks, | ||
unsigned int maxlen); | ||
|
||
void dvbcsa_bs_encrypt(const struct dvbcsa_bs_key_s *key, | ||
const struct dvbcsa_bs_batch_s *pcks, | ||
unsigned int maxlen); | ||
|
||
Example: | ||
|
||
int i, s = dvbcsa_bs_batch_size(); | ||
struct dvbcsa_bs_batch_s b[s + 1]; | ||
|
||
struct dvbcsa_bs_key_s *key = dvbcsa_bs_key_alloc(); | ||
unsigned char cw[8] = "testtest"; | ||
|
||
dvbcsa_bs_key_set(cw, key); | ||
|
||
for (i = 0; i < s; i++) | ||
{ | ||
b[i].data = ... ; | ||
b[i].len = ... ; | ||
} | ||
|
||
b[i].data = NULL; | ||
|
||
dvbcsa_bs_encrypt(key, b, 184); | ||
|
||
|
||
Portability | ||
=========== | ||
|
||
This library has been successfully tested on different platforms with | ||
32 bits and 64 bits word width, little-endian and big-endian bytes | ||
ordering. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#! /bin/sh | ||
|
||
# bootstrap: the ultimate bootstrap/autogen.sh script for autotools projects | ||
# Copyright (c) 2002, 2003, 2004, 2005, 2006 Sam Hocevar <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the Do What The Fuck You Want To | ||
# Public License, Version 2, as published by Sam Hocevar. See | ||
# http://sam.zoy.org/wtfpl/COPYING for more details. | ||
# | ||
# The latest version of this script can be found at the following place: | ||
# http://sam.zoy.org/autotools/ | ||
|
||
# Die if an error occurs | ||
set -e | ||
|
||
# Guess whether we are using configure.ac or configure.in | ||
if test -f configure.ac; then | ||
conffile="configure.ac" | ||
elif test -f configure.in; then | ||
conffile="configure.in" | ||
else | ||
echo "$0: could not find configure.ac or configure.in" | ||
exit 1 | ||
fi | ||
|
||
# Check for needed features | ||
auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *( *\([^ )]*\).*/\1/p' $conffile`" | ||
libtool="`grep -q '^[ \t]*A._PROG_LIBTOOL' $conffile && echo yes || echo no`" | ||
header="`grep -q '^[ \t]*A._CONFIG_HEADER' $conffile && echo yes || echo no`" | ||
aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am`" | ||
|
||
# Check for automake | ||
amvers="no" | ||
for v in "-1.10" "110" "-1.9" "19" "-1.8" "18" "-1.7" "17" "-1.6" "16" "-1.5" "15"; do | ||
if automake${v} --version >/dev/null 2>&1; then | ||
amvers="${v}" | ||
break | ||
fi | ||
done | ||
|
||
if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then | ||
amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`" | ||
if expr "$amvers" "<" "1.5" > /dev/null 2>&1; then | ||
amvers="no" | ||
else | ||
amvers="" | ||
fi | ||
fi | ||
|
||
if test "$amvers" = "no"; then | ||
echo "$0: you need automake version 1.5 or later" | ||
exit 1 | ||
fi | ||
|
||
# Check for autoconf | ||
acvers="no" | ||
for v in "" "259" "253"; do | ||
if autoconf${v} --version >/dev/null 2>&1; then | ||
acvers="${v}" | ||
break | ||
fi | ||
done | ||
|
||
if test "$acvers" = "no"; then | ||
echo "$0: you need autoconf" | ||
exit 1 | ||
fi | ||
|
||
# Check for libtool | ||
if test "$libtool" = "yes"; then | ||
libtoolize="no" | ||
if glibtoolize --version >/dev/null 2>&1; then | ||
libtoolize="glibtoolize" | ||
else | ||
for v in "16" "15" "" "14"; do | ||
if libtoolize${v} --version >/dev/null 2>&1; then | ||
libtoolize="libtoolize${v}" | ||
break | ||
fi | ||
done | ||
fi | ||
|
||
if test "$libtoolize" = "no"; then | ||
echo "$0: you need libtool" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Remove old cruft | ||
for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done | ||
rm -Rf autom4te.cache | ||
if test -n "$auxdir"; then | ||
if test ! -d "$auxdir"; then | ||
mkdir "$auxdir" | ||
fi | ||
aclocalflags="${aclocalflags} -I $auxdir" | ||
fi | ||
|
||
# Explain what we are doing from now | ||
set -x | ||
|
||
# Bootstrap package | ||
if test "$libtool" = "yes"; then | ||
${libtoolize} --copy --force | ||
if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then | ||
echo "$0: working around a minor libtool issue" | ||
mv ltmain.sh "$auxdir/" | ||
fi | ||
fi | ||
|
||
aclocal${amvers} ${aclocalflags} | ||
autoconf${acvers} | ||
if test "$header" = "yes"; then | ||
autoheader${acvers} | ||
fi | ||
#add --include-deps if you want to bootstrap with any other compiler than gcc | ||
#automake${amvers} --add-missing --copy --include-deps | ||
automake${amvers} --foreign --add-missing --copy | ||
|
||
# Remove cruft that we no longer want | ||
rm -Rf autom4te.cache | ||
|
Oops, something went wrong.