Understanding INIT log in Viaccess

Kui soovid välja käia mingi tarkusetera siis postita siia. Vastusteks olgu ainult teema edasiarendused.
Kasutaja avatar
admin
Admin
Postitusi: 594
Liitunud: 15:06, 11 Jaan 2003
Asukoht: Saaremaa
    unknown unknown
On tänanud: 6 korda
On tänatud: 22 korda
Kontakt:

Understanding INIT log in Viaccess

PostitusPostitas admin » 20:59, 14 Jaan 2003

Thanx to wolfman

LOG OF INIT AND ECM DIALOGUE IN VIACCESS BETWEEN CAM AND CARD
With thanx to wolfman
This FAQ explains in small details the init dialogue between the card and a CAM and the ECM dialog that follows.

After a reset and an ATR (Answer To Reset) sent by the card. The Cam is ready to start dialog.

(->) means info is sent TO the card BY the CAM
(<-) means info is sent BY the card TO the CAM

General Info 02
-> 87 02 00 00 03
-> 00 00 28
<- 90 00

This command searches for FAC block. FACs (FACility block) are data stored on the card by the provider if he wants to. Some of them are defined by the viaccess specs.
In this case the request is for block 00 28.

Instruction 04
-> 87 04 00 00 07
<- 00 00 00 04 00 00 00
<- 90 00

This commands ask for the result of the previous command.
The result is 00 00 00 04 00 00 00 which means:
00 00 : reference to allow a direct access to the block
00 04 : length in bytes of the found block
00 00 00 : means nothing

Instruction 06
-> 87 06 00 00 04
<- 10 02 CA 20
<- 90 00

This command reads the block previously selected. Note the 04 which is the length returned by the previous command.
Data is this block is 10 02 CA 20
It is coded in TLV (Type Length Value)
T = 10 for CA system
L = 02 two bytes
V = CA 20 id for viacess system with CA class (commands start with CA)

So now the CAM knows that the inserted card is able to handle viaccess.

General Info 02
-> 87 02 00 00 03
-> 40 00 28
<- 90 08

Ask for the rest of the block. Answer 90 08 means no more data. Which is normal since the block was only 4 bytes long.

Request Ins A4/Entities
-> CA A4 00 00 00
<- 90 00

Select the first entity on the card. This first entity is the master by which you can add/modify/remove providers.

Ins AC/Inquiry
-> CA AC A4 00 00
<- 90 00

Request to have the UA of this entity.

Ins B8/Inquiry
-> CA B8 00 00 07
<- A4 05 XX XX XX XX XX
<- 90 08

Read the result (encoded in TLV). UA = XX XX XX XX XX

Request Ins A4/Entities
-> CA A4 00 00 00
<- 90 00

Select again the first entity.

Request Ins A4/Entities
-> CA A4 02 00 00
<- 90 00

And then immediately selects the next one.

Information Request
-> CA C0 00 00 1A
<- 01 54 08 20 00 8F 1F 7A 1A 9E 00 01 FF FF FF FF
FF FF 08 FF FF FF FF FF FF 0F
<- 90 00

Ask information about this new service (or provider if you like) found. Answer is:
01 54 08 : Provider id or SOID (01 54 00 in fact)
20 00 : Memory size allowed for this entity
8F : acces types allowed
1F 7A : memory size allowed less what is already allocated
1A 9E : total memory available on the card
00 01 FF ... FF 08 FF ... FF 0F : keys in service in the card. In this case, keys 00, 01, 08 and 0F are in service.

Ins AC/Inquiry
-> CA AC A5 00 00
<- 90 00

Ask for PPUA or SOUA.

Ins B8/Inquiry
-> CA B8 00 00 02
<- A5 04
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 04
<- YY YY YY YY
<- 90 08

Get results in two steps.
PPUA = YY YY YY YY

Ins AC/Inquiry
-> CA AC A6 00 00
<- 90 00

Ask for GCA.

Ins B8/Inquiry
-> CA B8 00 00 02
<- A6 04
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 04
<- FF FF FF FF
<- 90 08

Get result. GCA = FF FF FF FF

Ins AC/Inquiry
-> CA AC A7 00 00
<- 90 00

Ask for service label

Ins B8/Inquiry
-> CA B8 00 00 02
<- A7 0A
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 0A
<- 47 4C 4F 42 45 43 41 53 54 33
<- 90 08

Get result.
LABEL = GLOBECAST3 (!)

Request Ins A4/Entities
-> CA A4 02 00 00
<- 90 08

Ask for the next service on the card. Answer 90 08 means there's no more services.

Request Ins A4/Entities
-> CA A4 00 00 00
<- 90 00

Select again first entity.

Information Request
-> CA C0 00 00 1A
<- FF F4 00 20 00 00 1F A4 1A 9E FF FF 02 03 FF FF
FF FF FF FF FF FF FF FF FF FF
<- 90 00

Ask information about it.
FF F4 00 : entity id
20 00 : Memory size allowed for this entity
00 : acces types allowed
1F A4 : memory size allowed less what is already allocated
1A 9E : total memory available on the card
FF FF 02 03 ... FF : keys in service in the card for the first entity. In this case, keys 02 and 03 are in service.

Ins AC/Inquiry
-> CA AC 06 00 00
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- 06 01
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 01
<- 07
<- 90 08

Ask for morality level.
result is 07

Ins AC/Inquiry
-> CA AC 07 00 00
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- 07 04
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 04
<- 00 00 00 00
<- 90 08

Ask for maximum credit.
Result is 00 00 00 00

Ins AC/Inquiry
-> CA AC 08 00 00
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- 08 01
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 01
<- 00
<- 90 08

Ask for lock/unlock status.
Result is 00

Ins AC/Inquiry
-> CA AC 09 00 00
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- 09 02
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- 00 00
<- 90 08

Ask for impulse buy threshold.
Result is 00 00

Ins AC/Inquiry
-> CA AC A3 00 00
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- A3 02
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- 00 28
<- 90 08

Ask for FAC.
Result is 00 28 (note that it's the one selected at first)

Ins AC/Inquiry
-> CA AC A4 00 00
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- A4 05
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 05
<- XX XX XX XX XX
<- 90 08

Ask for UA (again !)
Result is XX XX XX XX XX

Ins AC/Inquiry
-> CA AC A5 00 00
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- A5 04
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 04
<- YY YY YY YY
<- 90 08

Ask for PPUA.
Result is YY YY YY YY

Ins AC/Inquiry
-> CA AC A7 00 00
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 02
<- A7 06
<- 90 00
Ins B8/Inquiry
-> CA B8 00 00 06
<- 49 53 53 55 45 52
<- 90 08

Ask for name.
Result is ISSUER.

Request Ins A4/Entities
-> CA A4 04 00 03
-> 01 54 00
<- 90 00

Direct selection of entity with id 01 54 00

General Info 02
-> 87 02 00 00 03
-> 00 00 29
<- 90 08

Ask selection of FAC 00 29. Answer 90 08 means no data.

Request Ins A4/Entities
-> CA A4 04 00 03
-> FF F4 00
<- 90 00

Direct selection of entity with id FF F4 00 (ISSUER).

General Info 02
-> 87 02 00 00 03
-> 00 00 29
<- 90 08

Ask selection of FAC 00 29. Answer 90 08 means no data.

Request Ins A4/Entities
-> CA A4 00 00 00
<- 90 00

Select first entity again.

Request Ins 24
-> CA 24 00 00 09
-> 00 00 00 00 00 00 00 00 04
<- 90 00

Some PIN code command. This one unlocks the consultation with PIN code 0 0 0 0.

Request Ins A4/Entities
-> CA A4 00 00 00
<- 90 00
General Info 02
-> 87 02 00 00 03
-> 00 00 28
<- 90 00
Instruction 04
-> 87 04 00 00 07
<- 00 00 00 04 00 00 00
<- 90 00
Instruction 06
-> 87 06 00 00 04
<- 10 02 CA 20
<- 90 00
General Info 02
-> 87 02 00 00 03
-> 40 00 28
<- 90 08

Re-read again FAC 00 28. Don't know why it's done again.

Request Ins A4/Entities
-> CA A4 04 00 03
-> 01 54 00
<- 90 00

Direct selection of entity with id 01 54 00.

And now everything is ready to send ECW to the card for that selected entity.


And here's now an example of an ECM dialog (from another provider).

Processing ECM is done in two step (like with any system):
1) the cam send the full ECM to the card and ask it to decrypt it
2) the cam then ask the card to send back the results

So in a log you have:

Incoming ECM Instruction
-> CA 88 00 08 21
-> E2 03 2C E4 21 EA 10 B7 EC A6 C1 AC 6C 47 09 AC
E6 37 DD 1F C4 A3 15 F0 08 B5 4C 2F 96 8C D2 71
94
<- 90 00

This is the command that sends the ECM to the card (CA 8 .
The key to be used is key 08 and the leght of the ECM is 0x21 bytes.
Then comes the ECM (from E2 to 94). ECM are encoded in TLV (Type Length Value). They are

usually made of three parts:
1) the access conditions the card needs to have to decrypt the CW
2) the CWs themselves (present and following)
3) a hash field to check the integrity of the full ECM

In our case, the first field is E2 03 2C E4 21
E2 means that access rights are based on date and classes.
03 is the lenght
2C E4 is the date (this one is 4th July 2002)
21 is the class
This means that, in order for the card to decrypt the CWs, it has to have access rights to class 21 up till the 4th of July. Otherwise the card answers 90 08 (No rights).

Then we have:
EA 10 B7 EC A6 C1 AC 6C 47 09 AC E6 37 DD 1F C4 A3 15
EA means ECW/OCW, so we have two CW one for even period and the other for odd.
10 is the length
B7 EC A6 C1 AC 6C 47 09 is the first ECW
AC E6 37 DD 1F C4 A3 15 is the second ECW

And finally we have:
F0 08 B5 4C 2F 96 8C D2 71 94
F0 means HASH
08 is the leght
B5 4C 2F 96 8C D2 71 94 is the hash value

The card answers 90 00 which means everything's ok.
Usually the cam doesn't really have to bother about all those details. It just takes what comes into the ECM stream and forward it to the card as it is.

Some time later, the CAM asks for the decrypted CW:

Request Decrypted CW
-> CA C0 00 00 12
<- EA 10 A4 0B 9E 78 40 C5 57 A6 5A 1A 72 DD 6D 0C
ED FC
<- 90 00

This is the command that ask the card to send the DCWs back (CA C0). This command is not dedicated to CW but is more like a general command to ask for results after a request. The two bytes after CA C0 are always 00 and 12 is the length of the requested data. If the card has less than that length to send it is padded with FF.
The card answers with a TLV encoded message:
EA 10 A4 0B 9E 78 40 C5 57 A6 5A 1A 72 DD 6D 0C ED FC
EA still means ECW/OCW (but this time they are decrypted)
10 is the legnth
A4 0B 9E 78 40 C5 57 A6 is the first CW decrypted with OpKey 08
5A 1A 72 DD 6D 0C ED FC is the second CW decrypted with same OpKey

And then we have 90 00 which means everything's ok.

And that's it. We're ready for the next crypto period.

Mine

Kes on foorumil

Kasutajad foorumit lugemas: Registreeritud kasutajaid pole ja 25 külalist