Code Monkey home page Code Monkey logo

Comments (13)

 avatar commented on July 28, 2024 2

See https://github.com/oscam-emu/oscam-patched/blob/master/module-emulator-biss.c#L393

and https://github.com/oscam-emu/oscam-patched/blob/master/module-dvbapi.c#L2216

from oscam-patched-old.

 avatar commented on July 28, 2024 2

I assume you know how enigma2 creates the namespace (what info is included and how it is formed).

There are 2 namespace hashes, because there are 2 namespaces in enigma.
When the tsid and the onid are deemed valid by enigma, the frequency info is stripped off and the namespace contains only the orbital position. This is described here: https://github.com/oscam-emu/oscam-patched/wiki/BISS-config#note-6

So in case of "full" namespace (with frequency), we use only the namespace and the service id in the hash. We place them like this: [srvid][namespace], so we get a 2+4=6 byte long sequence. Then we create a crc32 hash of these (caid is 0x2600 for biss and used as initial value in our crc32).

In case of stripped namespace, we use the tsid and onid as well in our hash, so it is still unique. So we place then like this: [srvid][tsid][onid][namespace] and we get a 2+2+2+4=10 byte sequence, from which we calculate the crc32 hash again.

Another thing you should know is that our namespace is not exactly the same as enigma's. In our namespace, we clear the 4 most significant bits (in case of DVB-T or DVB-C they are 0xF or 0xE respectively - for DVB-S they are 0) and we replace them with 0xA. This is our flag, so the emu can tell that this is the namespace and not another pid like audio etc. This is done here: https://github.com/oscam-emu/oscam-patched/blob/master/module-dvbapi.c#L2216

So the ecm you asked is a byte sequence, part of which is the srvid, namespace, tsid, onid. The b2i and i2b functions mean buffer-to-integer and integer-to-buffer and are used to take some bytes from a buffer, e.g. take the namespace from the ecm, or vice versa, e.g. place the srvid to a specific position in the the ecm.

from oscam-patched-old.

 avatar commented on July 28, 2024 2

Stripped namespace is 4 byte long, as full namespace. 00460000 is the correct. Also you forgot the flag we put in the beginning. After flagging full namespace is A0460ACB and stripped is A0460000. It's a simple "or", ens = ens | 0xA0000000

crc32 algorith in general, takes a byte string as input and calculates a 32 bit (4 byte) output string, our namespace hash.

from oscam-patched-old.

momi133 avatar momi133 commented on July 28, 2024

Hi dear
I understand that you have not enough time. but I'm not expert in c language.
1.is it possible explain the calculation of namespace hash algorithmically. I want this code in python language. we assume that enigma2 namespace and sid in known.
2.what is ecm and ecmLen in writed code? most of variables like srvid,tsid and ... are function of these two variables.
3. I find crc32 function in web but what are these functions? b2i() and i2b_buf()
thanks for replying and responsibility

from oscam-patched-old.

momi133 avatar momi133 commented on July 28, 2024

crc32 function: is it right?
image

please get a valid web address about crc32 algorithm and it's function

hash = crc32(caid, ecmCopy + ecmLen - 10, 10);

is crc32() is "C" function or you create this function?

our namespace is not exactly the same as enigma's. we clear the 4 most significant bits

Is your namespace, crc32 output or input? it seems to be crc32 output.

thanks for replying and responsibility

from oscam-patched-old.

momi133 avatar momi133 commented on July 28, 2024

thank a lot! my problem is solved!
I am ashamed because I waste your time!
I admire and respect you because you are noble, unselfish and morally good.
I have a Criticism about oscam-emu(how read biss keys from softcam.key) that I will propose you tomorrow!
thanks for replying and responsibility

from oscam-patched-old.

sentarokun avatar sentarokun commented on July 28, 2024

Hi @oscam-emu , would you help me on this? I would like to understand how the oscam namespace hash is calculated. Can you follow this example?
data: E2 namespace: dec 4598562 (including freq)
hex namespace: => 0x00462B22
modified namespace 0xA0462B22 (adding oscam identifier)
[srvid][oscam namespace]: 0001A0462B22

How to go further? How do you calc the CRC32 on the above result.

Thak you so much.

from oscam-patched-old.

 avatar commented on July 28, 2024

The crc32 function is defined here: https://github.com/oscam-emu/oscam-patched/blob/master/oscam-string.c#L714

A python version that produces the same hash is:

table = array('L')

for byte in range(256):
    crc = 0
    for bit in range(8):
        if (byte ^ crc) & 1:
            crc = (crc >> 1) ^ 0xEDB88320
        else:
            crc >>= 1
        byte >>= 1
    table.append(crc)


def crc32(caid, string):

    value = caid ^ 0xffffffffL
    for char in string:
        value = table[(ord(char) ^ value) & 0xff] ^ (value >> 8)
    return value ^ 0xffffffffL

from oscam-patched-old.

sentarokun avatar sentarokun commented on July 28, 2024

So I need to study some Python before attempting it. But please, in my example above, is it correct to set the string (in the crc32 func) to "0001A0462B22"? Is it the correct approach?

thx!!

from oscam-patched-old.

 avatar commented on July 28, 2024

Yes, read the comments in the code:

https://github.com/oscam-emu/oscam-patched/blob/master/module-emulator-biss.c#L421
https://github.com/oscam-emu/oscam-patched/blob/master/module-emulator-biss.c#L426

from oscam-patched-old.

sentarokun avatar sentarokun commented on July 28, 2024

Hi, thank you.
I tried the whole process till Python, but the result differs from the suggested hash in the livelog.
Could you please have a fast look at my steps?

  1. Getting the E2 namespace from the DreamboxEDIT (freq 12550V, TSID 0001, ONID 0000, SID 0008 ==> E2 namespace 0x0046b106 ) or by the box itself
  2. Changing the namespace by adding the 0xA identifier: ==> 0xA046B106
  3. Adding the SRVID (SID 0008) ==> 0008A046B106
  4. Running the python CRC32 function, by using:
    - CAID (as an integer or its hex representation 0x2600)
    - ens (as a string, uppercase or lowercase? "0008A046B106", "0008a046b106")
  5. As a result ==> a39cb7c7 (not matching with the suggested hashes from the livelog: E2F2E27D , E700CC3D)

The python code is attached.

Thanks!

hash.py.txt

from oscam-patched-old.

 avatar commented on July 28, 2024

0x0008A046B106 is correct. You need to convert the hex data to acsii string first:

data = 0x0008A046B106
string = binascii.unhexlify(data)
b = crc32(0x2600, string)

from oscam-patched-old.

sentarokun avatar sentarokun commented on July 28, 2024

Great! Thank you so much for your support!

from oscam-patched-old.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.