1 /* 2 3 This file is part of libdvbcsa. 4 5 libdvbcsa is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 2 of the License, 8 or (at your option) any later version. 9 10 libdvbcsa is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with libdvbcsa; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 02111-1307 USA 19 20 Parallel bitslice implementation based on FFdecsa, 21 Copyright (C) 2003-2004 fatih89r 22 23 (c) 2006-2008 Alexandre Becoulet <alexandre.becoulet@free.fr> 24 25 */ 26 27 #ifndef LIBDVBCSA_H_ 28 #define LIBDVBCSA_H_ 29 30 /* csa control word */ 31 typedef unsigned char dvbcsa_cw_t[8]; 32 33 /*********************************************************************** 34 Single packet CSA implemetation API 35 */ 36 37 /* single packet implementation key context */ 38 typedef struct dvbcsa_key_s dvbcsa_key_t; 39 40 /** allocate a new csa key context */ 41 struct dvbcsa_key_s * dvbcsa_key_alloc(); 42 43 /** free a csa key context */ 44 45 void dvbcsa_key_free(struct dvbcsa_key_s *key); 46 47 /** setup a csa key context to use the given control word */ 48 49 void dvbcsa_key_set (const dvbcsa_cw_t cw, struct dvbcsa_key_s *key); 50 51 /** decrypt a packet payload */ 52 53 void dvbcsa_decrypt (const struct dvbcsa_key_s *key, 54 unsigned char *data, unsigned int len); 55 56 /** encrypt a packet payload */ 57 58 void dvbcsa_encrypt (const struct dvbcsa_key_s *key, 59 unsigned char *data, unsigned int len); 60 61 62 63 /*********************************************************************** 64 Parallel bitslice CSA implemetation API 65 */ 66 67 /** packets batch structure, describe each data packet payload to process */ 68 struct dvbcsa_bs_batch_s 69 { 70 unsigned char *data; /* pointer to payload */ 71 unsigned int len; /* payload bytes lenght */ 72 }; 73 74 /** parallel bitslice implementation key context */ 75 typedef struct dvbcsa_bs_key_s dvbcsa_bs_key_t; 76 77 /** allocate a new csa bitslice key context */ 78 79 struct dvbcsa_bs_key_s * dvbcsa_bs_key_alloc(); 80 81 /** free a csa bitslice key context */ 82 83 void dvbcsa_bs_key_free(struct dvbcsa_bs_key_s *key); 84 85 /** setup a csa bitslice key context to use the given control word */ 86 87 void dvbcsa_bs_key_set(const dvbcsa_cw_t cw, struct dvbcsa_bs_key_s *key); 88 89 /** get maximum number of packet per batch */ 90 91 unsigned int dvbcsa_bs_batch_size(void); 92 93 /** decrypt a packet batch. batch is an array of struct 94 dvbcsa_bs_batch_s with an extra NULL data termination 95 entry. maxlen is the maximum data bytes lenght to process, must be 96 a multiple of 8, should be 184 for TS packets. */ 97 98 void dvbcsa_bs_decrypt(const struct dvbcsa_bs_key_s *key, 99 const struct dvbcsa_bs_batch_s *pcks, 100 unsigned int maxlen); 101 102 /** encrypt a packet batch. batch is an array of struct 103 dvbcsa_bs_batch_s with an extra NULL data termination 104 entry. maxlen is the maximum data bytes lenght to process, must be 105 a multiple of 8, should be 184 for TS packets. */ 106 107 void dvbcsa_bs_encrypt(const struct dvbcsa_bs_key_s *key, 108 const struct dvbcsa_bs_batch_s *pcks, 109 unsigned int maxlen); 110 111 #endif 112 113