Commit 3f582d79 by Alexandre

initial commit

parents
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 <alexandre.becoulet@free.fr>.
PowerPC Altivec support by Nicolas Pouillon <nipo@ssji.net>.
This diff is collapsed. Click to expand it.
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.
SUBDIRS = src test
DIST_SUBDIRS = $(SUBDIRS)
AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects
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.
#! /bin/sh
# bootstrap: the ultimate bootstrap/autogen.sh script for autotools projects
# Copyright (c) 2002, 2003, 2004, 2005, 2006 Sam Hocevar <sam@zoy.org>
#
# 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
AC_INIT(libdvbcsa, 1.0.0)
AC_PREREQ(2.50)
AC_ARG_ENABLE(debug, AC_HELP_STRING(--enable-debug, [Enable debug]), enable_debug=$enableval, enable_debug=no)
if test "$enable_debug" = "yes" ; then
GCC_CFLAGS="$CFLAGS -g -DDVBCSA_DEBUG -D_XOPEN_SOURCE=600"
else
GCC_CFLAGS="$CFLAGS -O2 -fexpensive-optimizations -funroll-loops -fomit-frame-pointer -D_XOPEN_SOURCE=600"
fi
AC_ARG_ENABLE(uint32, AC_HELP_STRING(--enable-uint32, [Use native 32 bits integers for bitslice]), enable_uint32=$enableval, enable_uint32=no)
AC_ARG_ENABLE(uint64, AC_HELP_STRING(--enable-uint64, [Use native 64 bits integers for bitslice]), enable_uint64=$enableval, enable_uint64=no)
AC_ARG_ENABLE(mmx, AC_HELP_STRING(--enable-mmx, [Use MMX for bitslice]), mmx_debug=$enableval, enable_mmx=no)
AC_ARG_ENABLE(sse2, AC_HELP_STRING(--enable-sse2, [Use SSE2 for bitslice]), sse2_debug=$enableval, enable_sse2=no)
AC_ARG_ENABLE(altivec, AC_HELP_STRING(--enable-altivec, [Use AltiVec for bitslice]), altivec_debug=$enableval, enable_altivec=no)
AM_INIT_AUTOMAKE(libdvbcsa, 1.0.0)
AM_CONFIG_HEADER(config.h)
AC_PROG_CC
AM_PROG_LIBTOOL
AC_LANG(C)
AC_STDC_HEADERS
AC_CHECK_HEADERS(assert.h)
AC_C_CONST
AC_C_INLINE
AC_CHECK_SIZEOF(long)
if test "$enable_mmx" = "yes" ; then
transpose_64=yes
AC_DEFINE(DVBCSA_USE_MMX, 1, Using MMX bitslice.)
GCC_CFLAGS="$GCC_CFLAGS -mmmx"
elif test "$enable_sse2" = "yes" ; then
transpose_128=yes
AC_DEFINE(DVBCSA_USE_SSE, 1, Using SSE2 bitslice.)
GCC_CFLAGS="$GCC_CFLAGS -msse -msse2"
elif test "$enable_altivec" = "yes" ; then
transpose_128=yes
AC_DEFINE(DVBCSA_USE_ALTIVEC, 1, Using AltiVec bitslice.)
GCC_CFLAGS="$GCC_CFLAGS -maltivec -mabi=altivec"
elif test "$enable_uint32" = "yes" ; then
transpose_32=yes
AC_DEFINE(DVBCSA_USE_UINT32, 1, Using 32 bits integer bitslice.)
elif test "$enable_uint64" = "yes" ; then
transpose_64=yes
AC_DEFINE(DVBCSA_USE_UINT64, 1, Using 64 bits integer bitslice.)
else
case $ac_cv_sizeof_long in
8)
transpose_64=yes
AC_DEFINE(DVBCSA_USE_UINT64, 1, Using 64 bits integer bitslice.)
;;
*)
transpose_32=yes
AC_DEFINE(DVBCSA_USE_UINT32, 1, Using 32 bits integer bitslice.)
;;
esac
fi
AM_CONDITIONAL(TRANSPOSE_128, test "$transpose_128" = "yes")
AM_CONDITIONAL(TRANSPOSE_64, test "$transpose_64" = "yes")
AM_CONDITIONAL(TRANSPOSE_32, test "$transpose_32" = "yes")
if test "$GCC" = "yes" ; then
CFLAGS="-Wall $GCC_CFLAGS"
fi
AC_CHECK_FUNC(posix_memalign, AC_DEFINE(HAVE_POSIX_MEMALIGN, 1, posix_memalign is available))
AC_OUTPUT([
Makefile
src/Makefile
src/dvbcsa/Makefile
test/Makefile
])
SUBDIRS = dvbcsa
lib_LTLIBRARIES = libdvbcsa.la
libdvbcsa_la_SOURCES = dvbcsa_algo.c dvbcsa_block.c dvbcsa_bs_algo.c \
dvbcsa_bs_block.c dvbcsa_bs_key.c dvbcsa_bs_stream.c \
dvbcsa_stream.c dvbcsa_bs.h dvbcsa_pv.h dvbcsa_bs_uint64.h \
dvbcsa_bs_uint32.h dvbcsa_bs_mmx.h dvbcsa_bs_sse.h \
dvbcsa_bs_altivec.h dvbcsa_bs_transpose.c
if TRANSPOSE_128
libdvbcsa_la_SOURCES += dvbcsa_bs_transpose128.c
endif
if TRANSPOSE_64
libdvbcsa_la_SOURCES += dvbcsa_bs_transpose64.c
endif
if TRANSPOSE_32
libdvbcsa_la_SOURCES += dvbcsa_bs_transpose32.c
endif
libdvbcsa_la_LDFLAGS = -version-info 1:0:0 $(libtool_flags)
This diff is collapsed. Click to expand it.
pkgincludedir = $(includedir)/dvbcsa
pkginclude_HEADERS = dvbcsa.h
/*
This file is part of libdvbcsa.
libdvbcsa 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 of the License,
or (at your option) any later version.
libdvbcsa 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 libdvbcsa; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
Parallel bitslice implementation based on FFdecsa,
Copyright (C) 2003-2004 fatih89r
(c) 2006-2008 Alexandre Becoulet <alexandre.becoulet@free.fr>
*/
#ifndef LIBDVBCSA_H_
#define LIBDVBCSA_H_
/* csa control word */
typedef unsigned char dvbcsa_cw_t[8];
/***********************************************************************
Single packet CSA implemetation API
*/
/* single packet implementation key context */
typedef struct dvbcsa_key_s dvbcsa_key_t;
/** allocate a new csa key context */
struct dvbcsa_key_s * dvbcsa_key_alloc();
/** free a csa key context */
void dvbcsa_key_free(struct dvbcsa_key_s *key);
/** setup a csa key context to use the given control word */
void dvbcsa_key_set (const dvbcsa_cw_t cw, struct dvbcsa_key_s *key);
/** decrypt a packet payload */
void dvbcsa_decrypt (const struct dvbcsa_key_s *key,
unsigned char *data, unsigned int len);
/** encrypt a packet payload */
void dvbcsa_encrypt (const struct dvbcsa_key_s *key,
unsigned char *data, unsigned int len);
/***********************************************************************
Parallel bitslice CSA implemetation API
*/
/** packets batch structure, describe each data packet payload to process */
struct dvbcsa_bs_batch_s
{
unsigned char *data; /* pointer to payload */
unsigned int len; /* payload bytes lenght */
};
/** parallel bitslice implementation key context */
typedef struct dvbcsa_bs_key_s dvbcsa_bs_key_t;
/** allocate a new csa bitslice key context */
struct dvbcsa_bs_key_s * dvbcsa_bs_key_alloc();
/** free a csa bitslice key context */
void dvbcsa_bs_key_free(struct dvbcsa_bs_key_s *key);
/** setup a csa bitslice key context to use the given control word */
void dvbcsa_bs_key_set(const dvbcsa_cw_t cw, struct dvbcsa_bs_key_s *key);
/** get maximum number of packet per batch */
unsigned int dvbcsa_bs_batch_size(void);
/** decrypt a packet batch. batch is an array of struct
dvbcsa_bs_batch_s with an extra NULL data termination
entry. maxlen is the maximum data bytes lenght to process, must be
a multiple of 8, should be 184 for TS packets. */
void dvbcsa_bs_decrypt(const struct dvbcsa_bs_key_s *key,
const struct dvbcsa_bs_batch_s *pcks,
unsigned int maxlen);
/** encrypt a packet batch. batch is an array of struct
dvbcsa_bs_batch_s with an extra NULL data termination
entry. maxlen is the maximum data bytes lenght to process, must be
a multiple of 8, should be 184 for TS packets. */
void dvbcsa_bs_encrypt(const struct dvbcsa_bs_key_s *key,
const struct dvbcsa_bs_batch_s *pcks,
unsigned int maxlen);
#endif
/*
This file is part of libdvbcsa.
libdvbcsa 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 of the License,
or (at your option) any later version.
libdvbcsa 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 libdvbcsa; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
(c) 2006-2008 Alexandre Becoulet <alexandre.becoulet@free.fr>
*/
#include "dvbcsa/dvbcsa.h"
#include "dvbcsa_pv.h"
void dvbcsa_decrypt (const struct dvbcsa_key_s *key, uint8_t *data, unsigned int len)
{
unsigned int alen = len & (unsigned)~0x7;
int i;
if (len < 8)
return;
#ifndef DVBCSA_DISABLE_STREAM
dvbcsa_stream_xor(key->cws, data, data + 8, len - 8);
#endif
#ifndef DVBCSA_DISABLE_BLOCK
dvbcsa_block_decrypt(key->sch, data, data);
for (i = 8; i < alen; i += 8)
{
dvbcsa_xor_64(data + i - 8, data + i);
dvbcsa_block_decrypt(key->sch, data + i, data + i);
}
#endif
}
void dvbcsa_encrypt (const struct dvbcsa_key_s *key, uint8_t *data, unsigned int len)
{
unsigned int alen = len & (unsigned)~0x7;
int i;
if (len < 8)
return;
#ifndef DVBCSA_DISABLE_BLOCK
dvbcsa_block_encrypt(key->sch, data + alen - 8, data + alen - 8);
for (i = alen - 16; i >= 0; i -= 8)
{
dvbcsa_xor_64(data + i, data + i + 8);
dvbcsa_block_encrypt(key->sch, data + i, data + i);
}
#endif
#ifndef DVBCSA_DISABLE_STREAM
dvbcsa_stream_xor(key->cws, data, data + 8, len - 8);
#endif
}
struct dvbcsa_key_s * dvbcsa_key_alloc()
{
return malloc(sizeof (struct dvbcsa_key_s));
}
void dvbcsa_key_free(struct dvbcsa_key_s *key)
{
free(key);
}
/*
This file is part of libdvbcsa.
libdvbcsa 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 of the License,
or (at your option) any later version.
libdvbcsa 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 libdvbcsa; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
(c) 2006-2008 Alexandre Becoulet <alexandre.becoulet@free.fr>
*/
#include "dvbcsa/dvbcsa.h"
#include "dvbcsa_pv.h"
static const uint8_t csa_key_perm[64] =
{
19, 27, 55, 46, 1, 15, 36, 22, 56, 61, 39, 21, 54, 58, 50, 28,
7, 29, 51, 6, 33, 35, 20, 16, 47, 30, 32, 63, 10, 11, 4, 38,
62, 26, 40, 18, 12, 52, 37, 53, 23, 59, 41, 17, 31, 0, 25, 43,
44, 14, 2, 13, 45, 48, 3, 60, 49, 8, 34, 5, 9, 42, 57, 24,
};
static inline uint8_t swap_nbl (register uint8_t byte)
{
return ((byte >> 4) | (byte << 4));
}
void dvbcsa_key_set (const dvbcsa_cw_t cw, struct dvbcsa_key_s *key)
{
uint8_t s[7][8];
int i, j;
memset(s, 0, sizeof(s));
/* control word copy and swap */
for (i = 0; i < sizeof(dvbcsa_cw_t); i++)
key->cws[i] = swap_nbl(s[6][i] = key->cw[i] = cw[i]);
/* key schedule */
for(i = 5 ; i >= 0; i--)
{
/* 64 bits permutation */
for(j = 0; j < 64; j++)
{
unsigned int p = csa_key_perm[j];
uint8_t x;
/* extract bit */
x = ((s[i + 1][j / 8] >> (j % 8)) & 1);
/* write bit */
s[i][p / 8] |= x << (p % 8);
}
}
for(i = 0; i < 7; i++)
for(j = 0; j < 8; j++)
key->sch[i * 8 + j] = i ^ s[i][j];
}
static const uint8_t csa_block_perm[256] =
{
0x00, 0x02, 0x80, 0x82, 0x20, 0x22, 0xa0, 0xa2, 0x10, 0x12, 0x90, 0x92, 0x30, 0x32, 0xb0, 0xb2,
0x04, 0x06, 0x84, 0x86, 0x24, 0x26, 0xa4, 0xa6, 0x14, 0x16, 0x94, 0x96, 0x34, 0x36, 0xb4, 0xb6,
0x40, 0x42, 0xc0, 0xc2, 0x60, 0x62, 0xe0, 0xe2, 0x50, 0x52, 0xd0, 0xd2, 0x70, 0x72, 0xf0, 0xf2,
0x44, 0x46, 0xc4, 0xc6, 0x64, 0x66, 0xe4, 0xe6, 0x54, 0x56, 0xd4, 0xd6, 0x74, 0x76, 0xf4, 0xf6,
0x01, 0x03, 0x81, 0x83, 0x21, 0x23, 0xa1, 0xa3, 0x11, 0x13, 0x91, 0x93, 0x31, 0x33, 0xb1, 0xb3,
0x05, 0x07, 0x85, 0x87, 0x25, 0x27, 0xa5, 0xa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