diff -Nru ./sc-0.5.0_original/system-cc.mk ./sc-0.5.0/system-cc.mk
--- ./sc-0.5.0_original/system-cc.mk	2004-11-29 19:20:39.000000000 +0100
+++ ./sc-0.5.0/system-cc.mk	2005-10-01 02:07:26.000000000 +0200
@@ -2,7 +2,7 @@
 # Cardclient
 #
 OBJS += system-cc.o system-cc-camd.o system-cc-radegast.o system-cc-aroureos.o \
-        system-cc-newcamd.o
+        system-cc-newcamd.o system-cc-satbazaar.o
 ifdef CARDCLIENT
 DEFINES    += -DCARDCLIENT
 SHAREDLIBS += -lcrypt -lz
diff -Nru ./sc-0.5.0_original/system-cc-satbazaar.c ./sc-0.5.0/system-cc-satbazaar.c
--- ./sc-0.5.0_original/system-cc-satbazaar.c	1970-01-01 01:00:00.000000000 +0100
+++ ./sc-0.5.0/system-cc-satbazaar.c	2005-10-02 14:13:31.000000000 +0200
@@ -0,0 +1,199 @@
+/*
+ * Softcam plugin to VDR (C++)
+ * SatBazaar implementation (c) 2005 by Manio
+ * (v. 0.1)
+ *
+ * This code 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.
+ *
+ * This code 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
+ */
+
+#if defined(CARDCLIENT) && defined(OPENSSL)
+
+#include <stdio.h>
+#include <string.h>
+
+#include "common.h"
+#include "system-cc.h"
+#include "data.h"
+#include "network.h"
+
+#include <openssl/md5.h>
+#define CWBUFFSIZE 25
+#define CWTIMEOUT 7000 //ms
+
+// -- cCardClientSatBazaar ------------------------------------------------------
+
+struct ecm_reply
+{
+  unsigned char md5sum[16];
+  unsigned char cryptedword[16];
+};
+
+class cCardClientSatBazaar : public cCardClient {
+private:
+  cNetSocket so;
+  ecm_reply cwbuff[CWBUFFSIZE];
+  int iBuffIndex;
+protected:
+  bool ListenThread();
+  bool CheckInBuff(unsigned char *md5, unsigned char *cw);
+  virtual bool Login(void);
+public:
+  cCardClientSatBazaar(const char *Name);
+  virtual bool Init(const char *config);
+  virtual bool ProcessECM(const cEcmInfo *ecm, const unsigned char *source, unsigned char *cw);
+};
+
+static cCardClientLinkReg<cCardClientSatBazaar> __sbaz("SatBazaar");
+
+cCardClientSatBazaar::cCardClientSatBazaar(const char *Name)
+:cCardClient(Name)
+,so(DEFAULT_CONNECT_TIMEOUT,CWTIMEOUT/1000,DEFAULT_IDLE_TIMEOUT)
+{}
+
+bool cCardClientSatBazaar::Init(const char *config)
+{
+    dc(printf("cc-satbazaar: Init\n"))
+    cMutexLock lock(this);
+    so.Disconnect();
+    return ParseStdConfig(config);
+}
+
+bool cCardClientSatBazaar::Login(void)
+{
+    dc(printf("cc-satbazaar: Login\n"))
+    so.Disconnect();
+    if(!so.Connect(hostname,port)) return false;
+    dc(printf("cc-satbazaar: connected to %s:%d\n",hostname,port))
+    //czyszczenie bufora na klucze
+    memset(cwbuff,0,CWBUFFSIZE*sizeof(ecm_reply));
+    iBuffIndex=0;
+    //watek sluchajacy
+    return true;
+}
+
+bool cCardClientSatBazaar::ProcessECM(const cEcmInfo *ecm, const unsigned char *source, unsigned char *cw)
+{
+    cMutexLock lock(this);
+    so.Flush();
+    const int ecmlen=(SCT_LEN(source))-8;
+    bool bResult;
+
+    /* przygotowanie pakietu i sumy MD5 */
+    unsigned char buff[256+32];
+    char szPakiet[(256+33)*2];
+    unsigned char *md5;
+    buff[0]=0x06;			// ECM (ECM packet intended for decryption)
+
+    buff[1]=0x00;			// len dla calego pakietu
+    buff[2]=0x1f+ecmlen;		// = 7B (reszta pakietu (0x1f) + dlugosc ECM)
+
+    buff[3]=0x01;			// CAID
+    buff[4]=0x02;			// len
+    buff[5]=0x01;			// CA
+    buff[6]=0x00;			// ID
+
+    buff[7]=0x02;			// PROVID (provider ID)
+    buff[8]=0x02;			// len (1-8)
+    buff[9]=0x00;			// wpisane
+    buff[10]=0x65;			// na stale (bo ecm->provID jest w formacie ASCII)
+    //sprintf((char*)&buff[9],"%02X",ecm->provId);
+
+    buff[11]=0x03;			// KEYNO (operation key number)
+    buff[12]=0x01;			// len (1-2)
+    buff[13]=source[7];			// = 9C
+
+    buff[14]=4;				// PACKET (raw ECM packet)
+    buff[15]=ecmlen;			// len (<FF)
+    memcpy(&buff[16],source+8,ecmlen);	// ECM wlasciwy (pomijamy 8 pierwszych bajtow)
+
+    int i=16+ecmlen;			// aktualny wskanik w buforze
+    buff[i++]=0x05;			// HASH (MD5 hash of the raw ECM packet)
+    buff[i++]=0x10;			// len (0x10)
+    md5=&buff[i];
+    MD5(buff+16,ecmlen,md5);		// MD5 hash
+
+    /* sprawdz bufor czy jest juz taka odpowiedz */
+    dc(printf("cc-satbazaar: ProcessECM\n"))
+    bResult=CheckInBuff(md5,&cw[0]);
+    if (bResult==true)	//znalazl i skopiowal
+    {
+	dc(printf("cc-satbazaar: cw found in buffor\n"))
+	return true;
+    }
+    else	//nie znalazl w buforze - wysylamy zapytanie
+    {
+	dc(printf("cc-satbazaar: TX[ECM]: "))
+	for (int j=0; j<(i+16); j++)
+	    snprintf(szPakiet+(j*2),3,"%02X",buff[j]);
+	dc(printf("%s\n",szPakiet))
+
+	if(!SendMsg(&so,buff,i+16)) return false;
+	//czekaj SBTIMEOUT
+    }
+    for (int j=0;j<16;j++)
+    {
+	ListenThread();	//odbieramy pakiet
+	bResult=CheckInBuff(md5,&cw[0]);
+	if (bResult==true)
+	    return true;
+    }
+    return false;
+    //return CheckInBuff(md5,&cw);
+}
+
+bool cCardClientSatBazaar::CheckInBuff(unsigned char *md5, unsigned char *cw)
+{
+    for (int i=0; i<CWBUFFSIZE; i++)
+    {
+	if (memcmp(md5,cwbuff[i].md5sum,16)==0)	//suma sie zgadza
+	{
+	    dc(printf("cc-satbazaar: correct md5 hash found, sending cw to card\n"))
+	    memcpy(cw,&cwbuff[i].cryptedword,16);	//kopiujemy klucz
+	    return true;
+	}
+    }
+    return false;
+}
+
+bool cCardClientSatBazaar::ListenThread()
+{
+    static unsigned char ecm_reply_ok[]={0x08,0x00,0x24,0x01,0x10};
+    unsigned char buff[256+32];
+    char szPakiet[(256+33)*2];
+
+    int n=RecvMsg(&so,buff,sizeof(buff));
+    if(n>0)	//cos odebral
+    {
+	dc(printf("cc-satbazaar: RX: "))
+	for (int j=0; j<(buff[2]+3); j++)
+	    snprintf(szPakiet+(j*2),3,"%02X",buff[j]);
+	dc(printf("%s\n",szPakiet))
+
+	if ( (memcmp(buff,ecm_reply_ok,5)==0) && (buff[21]==0x02 && buff[22]==0x10) )	//ramka z cw
+	{
+	    dc(printf("cc-satbazaar: placing cw with iBuffIndex=%d\n",iBuffIndex))
+	    memcpy(cwbuff[iBuffIndex].md5sum,&buff[5],16);		//kopiujemy MD5
+	    memcpy(cwbuff[iBuffIndex].cryptedword,&buff[23],16);	//kopiujemy klucz
+	    //inkrementacja wskaznika bufora
+	    iBuffIndex++;
+	    if (iBuffIndex>CWBUFFSIZE-1)
+		iBuffIndex=0;
+	}
+    }
+    return true;
+}
+
+#endif //CARDCLIENT

