|
SASC-NG
DVBSoftCAM
|
#include <ctype.h>#include <stdlib.h>#include <stdarg.h>#include <string.h>#include <vdr/tools.h>#include <vdr/thread.h>#include "misc.h"Go to the source code of this file.
Defines | |
| #define | CRCPOLY_LE 0xedb88320 |
Functions | |
| const char * | HexStr (char *str, const unsigned char *mem, int len) |
| static int | HexDigit (int asc) |
| int | GetChar (const char *&line, int *store, int count) |
| static int | GetHexBase (const char *&line, unsigned char *store, int count, bool fixedLen, bool asc) |
| int | GetHex (const char *&line, unsigned char *store, int count, bool fixedLen) |
| int | GetHexAsc (const char *&line, unsigned char *store, int count) |
| unsigned long long | Bin2LongLong (unsigned char *mem, int len) |
| bool | CheckNull (const unsigned char *data, int len) |
| bool | CheckFF (const unsigned char *data, int len) |
| void | SetSctLen (unsigned char *data, int len) |
| unsigned char | XorSum (const unsigned char *mem, int len) |
| char * | bprintf (const char *fmt,...) |
| unsigned int | crc32_le (unsigned int crc, unsigned char const *p, int len) |
| #define CRCPOLY_LE 0xedb88320 |
Definition at line 144 of file misc.c.
Referenced by crc32_le().
| unsigned long long Bin2LongLong | ( | unsigned char * | mem, |
| int | len | ||
| ) |
Definition at line 96 of file misc.c.
Referenced by cSmartCardViaccess::Init(), cSmartCardSeca::Init(), cProviderNDS::ProvId(), cProviderCryptoworks::ProvId(), and cProviderConax::ProvId().
| char* bprintf | ( | const char * | fmt, |
| ... | |||
| ) |
Definition at line 128 of file misc.c.
Referenced by cAction::cAction(), cEcmHandler::cEcmHandler(), cScPlugin::CommandLineHelp(), cPidFilter::cPidFilter(), cOpt::FullName(), cEmu::Init(), cPlainKeys::KeyString(), and cEcmHandler::ShiftCwIndex().
{
va_list ap;
va_start(ap,fmt);
char *str=0;
if(vasprintf(&str,fmt,ap)<0);
va_end(ap);
return str;
}
| bool CheckFF | ( | const unsigned char * | data, |
| int | len | ||
| ) |
Definition at line 109 of file misc.c.
Referenced by cCardClientCamd35::HandleEMMRequest().
{
while(--len>=0) if(data[len]!=0xFF) return false;
return true;
}
| bool CheckNull | ( | const unsigned char * | data, |
| int | len | ||
| ) |
Definition at line 103 of file misc.c.
Referenced by cShare::CheckAddProv(), cCardClientCamd35::HandleEMMRequest(), cCardClientCamd33::HandleEMMRequest(), cSmartCardConax::Init(), cCardClientNewCamd::Login(), cPlainKeyNagra::Parse(), cCardClientRadegast::ProcessECM(), cCardClientNewCamd::ProcessECM(), cCardClientCCcam2::ProcessECM(), cCardClientCamd35::ProcessECM(), cCardClientCommon::ProcessECM(), cCardClientAroureos::ProcessECM(), cSystemSeca::ProcessEMM(), cSystemIrd::ProcessEMM(), and cDeCSA::SetDescr().
{
while(--len>=0) if(data[len]) return false;
return true;
}
| unsigned int crc32_le | ( | unsigned int | crc, |
| unsigned char const * | p, | ||
| int | len | ||
| ) |
Definition at line 146 of file misc.c.
References CRCPOLY_LE, and i.
Referenced by cCardCryptoworks::Assemble(), cMsgCache::Get(), cCardClientCamd35::HandleEMMRequest(), cTpsKeys::ParseLinePlain(), cCardClientCamd35::ParseUserConfig(), cTpsKeys::PostSave(), cCardClientCamd35::RecvBlock(), cCardClientCamd35::SendBlock(), and cTpsKey::ToString().
{
crc^=0xffffffff; // zlib mod
while(len--) {
crc^=*p++;
for(int i=0; i<8; i++)
crc=(crc&1) ? (crc>>1)^CRCPOLY_LE : (crc>>1);
}
crc^=0xffffffff; // zlib mod
return crc;
}
| int GetChar | ( | const char *& | line, |
| int * | store, | ||
| int | count | ||
| ) |
Definition at line 44 of file misc.c.
References skipspace().
Referenced by cPlainKeyVia::Parse(), cPlainKeySeca::Parse(), cPlainKeyNagra::Parse(), cPlainKeyIrd::Parse(), cPlainKeyCryptoworks::Parse(), cPlainKeyConstCw::Parse(), cPlainKeyConax::Parse(), cPlainKeyStd::Parse(), and cPlainKeyDummy::Parse().
| int GetHex | ( | const char *& | line, |
| unsigned char * | store, | ||
| int | count, | ||
| bool | fixedLen | ||
| ) |
Definition at line 86 of file misc.c.
References GetHexBase().
Referenced by cCardClientNewCamd::Init(), cCardClientCCcam2::Init(), cViaccessCardInfo::Parse(), cPlainKeyVia::Parse(), cSecaCardInfo::Parse(), cPlainKeySeca::Parse(), cSmartCardDataVideoGuard2::Parse(), cSmartCardDataViaccess::Parse(), cSmartCardDataNagra::Parse(), cSmartCardDataIrdeto::Parse(), cSmartCardDataCryptoworks::Parse(), cSmartCardDataConax::Parse(), cPlainKeyNagra::Parse(), cIrdCardInfo::Parse(), cPlainKeyIrd::Parse(), cPlainKeyCryptoworks::Parse(), cPlainKeyConstCw::Parse(), cPlainKeyConax::Parse(), cPlainKeyStd::Parse(), cPlainKeyDummy::Parse(), cEcmData::Parse(), cCardClientCommon::ParseKeyConfig(), and cTpsKeys::ParseLinePlain().
{
return GetHexBase(line,store,count,fixedLen,false);
}
| int GetHexAsc | ( | const char *& | line, |
| unsigned char * | store, | ||
| int | count | ||
| ) |
Definition at line 91 of file misc.c.
References GetHexBase().
{
return GetHexBase(line,store,count/2,true,true)*2;
}
| static int GetHexBase | ( | const char *& | line, |
| unsigned char * | store, | ||
| int | count, | ||
| bool | fixedLen, | ||
| bool | asc | ||
| ) | [static] |
Definition at line 60 of file misc.c.
References count, HexDigit(), and skipspace().
Referenced by GetHex(), and GetHexAsc().
{
line=skipspace(line);
const char *sline=line;
unsigned char *sstore=store;
int scount=count;
while(count) {
if(line[0]==0 || line[1]==0 || !isxdigit(line[0]) || !isxdigit(line[1])) break;
if(asc) {
*store++=line[0]; *store++=line[1];
}
else {
int d1=HexDigit(line[0]);
int d0=HexDigit(line[1]);
*store++=(d1<<4) + d0;
}
line+=2; count--;
}
if(asc) *store=0; // make sure strings are NULL terminated
if((!count || (!fixedLen && count!=scount)) &&
(!*line || isspace(*line) || *line==';' || *line==']' || *line=='/') ) return scount-count;
memset(sstore,0,scount);
line=sline;
return 0;
}
| static int HexDigit | ( | int | asc | ) | [static] |
Definition at line 38 of file misc.c.
Referenced by GetHexBase().
{
if(asc>='A') return toupper(asc)-'A'+10;
return asc-'0';
}
| const char* HexStr | ( | char * | str, |
| const unsigned char * | mem, | ||
| int | len | ||
| ) |
Definition at line 32 of file misc.c.
References i.
Referenced by cCardClientCamd35::HandleEMMRequest(), cSmartCardVideoGuard2::Init(), cSmartCardSeca::Init(), cSmartCardCryptoworks::Init(), cSmartCardConax::Init(), cCardClientNewCamd::Init(), cCardClientNewCamd::Login(), cTpsKeys::PostSave(), cBNKey::Print(), cHexKey::Print(), cSystemViaccess::ProcessEMM(), cSystemSeca::ProcessEMM(), cTpsKey::ToString(), cIrdCardInfo::ToString(), cEcmData::ToString(), and cIrdCardInfos::Update().
| void SetSctLen | ( | unsigned char * | data, |
| int | len | ||
| ) |
Definition at line 115 of file misc.c.
Referenced by cParseNDS::Assemble(), cCardCryptoworks::Assemble(), cProviderViaccess::Assemble(), cCardClientGbox::ProcessECM(), cCardClientCamd35::ProcessEMM(), and cRewriterNagraBeta::Rewrite().
| unsigned char XorSum | ( | const unsigned char * | mem, |
| int | len | ||
| ) |
Definition at line 121 of file misc.c.
References cs.
Referenced by cSmartCardSlotSerial::DevicePTS(), cTripleDes::PadMessage(), and cSmartCardSlot::ParseAtr().