Professional Documents
Culture Documents
by StuntGuy
Revision: 12282000
CONTENTS:
The NagraVision cards, on the other hand, use a variant of the ISO-7816 protocol
called the "T=1" or "asynchronous half-duplex block transfer" format.
This “T=1” protocol is defined such that any of 7 devices all connected to the
same ISO-7816 bus may initiate a transmission to any of the other devices on the
bus. In addition, the message will either be sent all at once (if it is short
enough to fit in the destination device's receive buffer), or broken into
smaller packets if the message is too long to be sent all at once.
The protocol used by the NagraVision smartcards (and in fact, by any ISO-7816
compliant smart card) is requested by the card when it is reset by a master
device. After reset, the card will send a sequence of data at a fixed baud rate
(input clock frequency/372 so for a 3.579545 MHz clock the baud rate will be
9622 bps) and this data will include information about the data format the card
wants to use, the baud rate at which it will want to communicate, and so on. To
better understand the NagraVision cards, let's look at the ATR sent by a ROM10
Nagra.
3F FF 95 00 FF 91 81 71 A0 47 00 44 4E 41 53 50
30 31 30 20 52 65 76 41 33 42 3B
3B Checksum character
|_____________ Checksum (all other bytes XORed together)
The baud rate is defined by byte Ta1. The upper nibble of this byte defines
parameter F (frequency) as being 512, while the lower nibble defines parameter D
(divisor) as being 16. The bit rate is found by dividing the card's input clock
frequency by the quantity (F/D) (in the case of NagraVision cards, F/D = 512/16
= 32). If we check the clock being fed to the smartcard by an EchoStar IRD, we
find that the master clock frequency, f, is either 4.5 MHz or 4.0 MHz, depending
on the model IRD being used. Thus, the final baud rate for communication
between an EchoStar IRD and smartcard is 4,500,000/32 (140,625) bps, or
4,000,000/32 (125,000) bps .
Note that this bit rate is only necessarily 140,625 bps when the card is in an
EchoStar IRD. If the card is in a programmer that feeds a 3.6864 MHz clock to
the card, the final baud rate will be 115,200 bps (though the ATR baud rate will
become 9909 bps).
The parameters such as "guard time", "character wait time", and "block wait
time" apply only to messages being sent to the card from the IRD. These delays
exist to allow the card enough time to move received data into its internal
buffers and perform any necessary decryption on the received data before the
next byte is received. It is assumed that the master device will not need such
delays, since the master device most likely has a great deal more processing
horsepower than the smartcard. In the case of the NagraVision smartcard, a
delay of at least 25 bit times (178 microseconds) is required between bytes, and
a delay of at least 635 milliseconds is required between whole blocks.
The Tc3 byte specifies that the card is going to use LRC (Longitudinal
Redundancy Checking) as its means of error correction. This means that for any
message sent, the final byte of the message will be the XOR-sum of all of the
other bytes in the message. The other possibility for error checking (which is
required by the ISO-7816 spec) is CRC checking, which would be selected if Tc3
was equal to 1.
The Ta3 byte specifies that the maximum message size that the card can accept is
0xA0 (160 decimal) bytes. If the receiver wants to send a message that's longer
than this, it has to break it up into smaller packets. In NagraVision ROM
version 1 cards, Ta3 was 0x60 (96 decimal). One interesting thing to note,
however, is that the first thing most IRDs I've seen do after they reset the
smartcard is request that the smartcard shrink its buffer size to 0x68 (104
decimal) bytes.
The historical bytes are really nothing more than superfluous identification
bytes that are used by the master device to learn additional information about
the smartcard. In this case, the card sends ASCII text indicating that it is a
Nagra/Dish Network smartcard, ("DNASP"), with ROM version 10("010"), and its
current EEPROM code revision ("RevA3B").
The NAD is used to route messages. The upper nibble of the NAD is defined
as the target address, and the lower nibble is defined as the source address.
In the NagraVision system, only two addresses are defined: Address 1 is the
receiver, and address 2 is the smartcard. Although 4 bits appear to be
available for addressing, in reality, only the lower 3 bits of each nibble are
available for addresses. The upper bit of each nibble is reserved for Vpp
control requests. Since the NagraVision system doesn't use these bits, they
won't be discussed here. Actually, it's also interesting to note that the
smartcarts don't do any sanity checking on the NAD...they just assume that
whatever NAD they received was the correct one and swap its nibbles when they
send a response.
The PCB is used to identify what type of data is being sent, whether it's part
of a block that's been broken up due to buffer size restrictions, if it's a
special type of control request, and so forth. There are 3 basic formats for
the PCB, as follows:
% 0 N C 0 0 0 0 0
| | |
| | |____________ "Chain" bit. If this bit is set, it means that this
| | packet requires at least one more packet before the
| | entire message is considered "sent".
| |______________ "sequence Number" bit. This bit should toggle between
| messages. It's used to help ensure that packets were
| not missed if the chain bit is set...if the smartcard
| misses a single packet (or any odd number of packets)
| from the master, it will know that data is corrupt.
|________________ "0" in bit 7 indicates "instruction block".
A standard ISO 7816 T=1 response block from will have a PCB like this:
% 1 0 0 N 0 0 O E
|_| | | |__ Errors detected either in LRC byte or in parity.
| | |____ Other errors occurred
| |__________ "sequence Number" bit. This bit should match the N
| bit for the message to which the smartcard is
| responding.
|_______________ "10" in bits 7-6 indicates "response block"
One would ordinarily expect that the CAM responses would be sent in a response
block as defined by the ISO 7816 T=1 spec, but it turns out that for the most
part, when the CAM responds, it responds with an instruction block of its own.
And as if that deviation from the ISO spec weren't enough, the CAM's instruction
block responses don't have INS, CLA, P1, P2, or P3 bytes at the start of the
information field (though the IRD's messages do).
Note that if a command is sent with an incorrect checksum, the CAM will respond
with one of the following messages:
12 81 00 93 -or-
12 91 00 83
| | | |_ Checksum
| | |____ Info field size (no data in this response)
| |_______ Error response: Parity/LRC error
|__________ NAD
% 1 1 R 0 0 0 T T
|_| | |_|
| | |___ Request type as follows:
| | 00=Resync (complete reset)
| | 01=IFS (Information Field Size)
| | 10=Abort
| | 11=WTX (Wait time)
| |____________ Request/Response (0=request, 1=response)
|_______________ "11" in bits 7-6 indicates "control request"
For an IFS request, a single byte of data will be included that tells the target
what size the source would like it to change its IFS to. Note that although it
is theoretically possible to request that the card change its IFS to a value
larger than the one specified in the ATR, the target would probably not respond
favorably to such a request. A sample IFS request might look like this:
Note that it is necessary to command the card to adjust its IFS after resetting
it, since the NagraVision cards default their IFS to $20 when they are reset.
As a result, any commands whose response is > $20 bytes either have deal with a
response that is chained, or the IFS has to be adjusted upwards. Note that the
cards don't do any sort of sanity checking against the IFS on received messages.
Oops.
For a WTX request, a single byte of data will be included that tells the target
what new value the source would like it to use as a block wait time when the
target is sending data to the source. This value is a multiple of the Block
Wait Time (BWT) specified by the source in its ATR.
The LEN byte is fairly straightforward: It specifies the total number of bytes
to be included in the information field.
The LRC byte is the checksum for the message. Note that this can either be an
LRC (which is what NagraVision uses) or a CRC.
If the receiving device sends a response whose PCB indicates that an error of
some sort was detected, the sending device will resend the block that was in
error. If the receiving device sends some message that performs a request of
any kind, it can expect the sending device to abort the remainder of the
transmission and respond to its request.
For data being transferred from the IRD to the CAM, the information field (not
including the checksum) will always look like this:
A0 CA 00 00 CL CN DL <data0..dataDL-1> RL
|____ ____| | | | | |_ Expected length of response
| | | | |_____ Command data...total of DL bytes
| | | | will be sent, including RL
| | | |______________________ Command Data length
| | |_________________________ Command Number
| |____________________________ Command Length. Note that this
| is essentially the ISO-7816 T=0
| "P3" (or length) byte.
|____________________________________ Header: Always A0 CA 00 00. Note
that these are essentially the
ISO-7816 T=0 "CLA INS P1 P2"
bytes.
Note that there are two length bytes. Command Length (CL) and command Data
Length (DL). In actual practice, DL should always be equal to CL minus 2, since
CL counts the Command Number (CN) and the command Data Length byte (DL) in its
total.
Note also that although CL and DL define the number of bytes that will be
present in the entire message, these numbers may be larger than the overall size
of the receive buffer in the smartcard. These bytes are what the card uses to
determine how many bytes the entire packet will contain after being put back
together (the LEN byte always specifies the total number of bytes to be sent in
a single burst).
Note also that the IRD indicates how much data it wants to see back from the
CAM. The Response Length byte (RL) specifies how many bytes of data the IRD
expects to see in the CAM's response, not including the 3-byte ISO-7816 header
and the SW1/SW2/LRC trailer. Thus, if the IRD specifies a value of 03 for the
RL, the CAM will send a total of 9 bytes back (3 bytes of ISO-7816 header, 1
byte of response type, 1 byte of data length, 1 byte of data, 2 bytes of SW1/SW2
info, and 1 byte of LRC). Note that the only time the response length byte is
actually used to determine how many bytes of data will be sent back to the IRD
is for command $21. All other commands have fixed-length responses which they
send without regard to that value of the value of the response length byte.
Messages sent from the CAM to the IRD look like this:
Cmd # Function
----- ------------------------------------------------------------------
$00 Entitlement Management Message (EMM)
$01 PPV Entitlement Management Message
$02 MECM key update
$03 Entitlement Control Message
$12 Serial Number Request
$13 Control Word Request (video decryption key request)
$14 Processing cycle request
$20 Data items available request
$21 Data item request
$30 Request for encryption of data to be sent in callback
$31 Request for data encrypted by previous command $30
$40 EEPROM data space available request
$41 PPV buy write
$42 PPV buy link
$55 Read email
$56 Delete email
$60 Get IRD command
$61 Write IRD info
$99 Anti-piracy message
$C0 CAM status request
$C1 Request for ID of updated data items
Expected Response
Cmd # Length response length
----- ------ -------- --------
$00 $53 $80 $07
$01 $56 $81 $07
$02 $53 $82 $07
$03 variable $83 $07
$12 $08 $92 $08
$13 $09 $93 $1B
$14 $08 $94 $08
$20 $0C $A0 $05
$21 $0D $A1 variable
$30 $0B $F0 $07
$31 $08 $F1 $54
$40 $08 $70 $04
$41 variable $71 $05
$42 $0F $72 $05
$55 $0B $D5 $08
$56 $0B $D6 $08
$60 $08 $E0 $44
$61 $1C $E1 $03
$99 $20 $99 $1C
$C0 $08 $B0 $08
$C1 $08 $B1 $06
Note that although the data block is always 64 bytes long, not all of the bytes
are necessarily used. The data block is padded to 64 bytes, probably with
random data, prior to encryption. Immediately preceding the 64 byte data block
is an 8-byte signature which is computed based on the unencrypted data to
confirm that the data is authentic before the commands within are executed. In
the DVB world, this type of message is referred to as an Entitlement Management
Message, or EMM. The 00 EMM is a public EMM, though it may be directed at a
specific group of cards.
21 40 53 ; A0 CA 00 00 ;Standard header
4D ;Command length
00 ;Command
4B ;Command data length
01 01 ;System ID ($0101=EchoStar)
82 ;Key select byte (see below)
DC E9 1B 55 89 A0 D5 22 ;Signature
16 48 08 B1 A4 84 8F 2B ;Encrypted packet number 1
3B DA AC 07 A2 31 B0 83 ;Encrypted packet number 2
E2 27 5D 47 C8 27 D5 0E ;Encrypted packet number 3
7C 9C A6 51 E5 0D FE 18 ;Encrypted packet number 4
54 04 80 26 49 FC A6 71 ;Encrypted packet number 5
B2 F4 69 51 0C 22 B7 24 ;Encrypted packet number 6
BF 7E 3F 64 D0 1A BC 24 ;Encrypted packet number 7
F3 6E 88 6E 69 0F 0F 61 ;Encrypted packet number 8
05 ;Expected response length
EB ;Checksum
Key select byte: This byte is used to select which EMM decrypt key set is used
(EMMKEY0 or EMMKEY1), and which parity key within that EMM key is used (0, 1, or
2). This byte is encoded as follows:
% x x x x x x x x
| | | | | | |_|__ Parity key select: 0, 1, or 2. Note: No sanity
| | | | | | checking is done on this. (see below)
| | | | | |______ unknown
| | | | |________ Key type select bit. (see below)
| | | |__________ unknown
| | |____________ unknown
| |______________ unknown
|________________ unknown
Parity key select: These two bits allow one of three 15-byte parity keys within
the selected EMM key to be used. No sanity checking is done on this data, so a
value of 3 is also valid, and causes the verify key plus the first 7 bytes of
the EMM key to be used as the parity key.
Key type select bit: This bit is used to match against the "key type" byte in
the type $07 data item. If this bit is clear, a key type byte of 0 will be
matched, if it is set, a key type byte of $01 will be matched.
As you can see, the first $28 bytes of decrypted data are EMM commands (see
section 3, EMM commands), and the last $18 bytes are just random data that
exists only to reduce the chances of two encrypted 00 commands looking even
remotely alike.
21 00 53 ; A0 CA 00 00 ;Standard header
4D ;Command length
01 ;Command
4B ;Command data length
01 01 ;System ID
82 ;Key select byte
00 00 00 00 00 00 00 00 ;Unused
00 11 22 33 44 55 66 77 ;Encrypted packet number 1
88 99 AA BB CC DD EE FF ;Encrypted packet number 2
00 11 22 33 44 55 66 77 ;Encrypted packet number 3
88 99 AA BB CC DD EE FF ;Encrypted packet number 4
00 11 22 33 44 55 66 77 ;Encrypted packet number 5
88 99 AA BB CC DD EE FF ;Encrypted packet number 6
00 11 22 33 44 55 66 77 ;Encrypted packet number 7
88 99 AA BB CC DD EE FF ;Encrypted packet number 8: valid hash
05 ;Expected response length
80 ;Checksum
12 00 07 ; 81 ;Response type
03 ;Response data length
B1 01 ;Decode succeeded
05 ;Sequence number
90 00 ;SW1/SW2
B2 ;Checksum
21 00 53 ; A0 CA 00 00 ;Standard header
4D ;Command length
02 ;Command
4B ;Command data length
01 01 ;System ID
01 ;Key select byte
00 00 00 00 00 00 00 00 ;Unused
00 11 22 33 44 55 66 77 ;Encrypted packet 1
88 99 AA BB CC DD EE FF ;Encrypted packet 2
00 11 22 33 44 55 66 77 ;Encrypted packet 3
88 99 AA BB CC DD EE FF ;Encrypted packet 4
00 11 22 33 44 55 66 77 ;Encrypted packet 5
88 99 AA BB CC DD EE FF ;Encrypted packet 6
00 11 22 33 44 55 66 77 ;Encrypted packet 7
88 99 AA BB CC DD EE FF ;Encrypted packet 8: valid hash
05 ;Expected response length
08 ;Checksum
Once the ciphertext block is decrypted, the computed hash value of the first 7
blocks of decrypted data is compared to the valid hash, which is stored in the
last 8 bytes of encrypted data. If the valid hash matches, 17 bytes of the
decrypted data are then used as MECM decrypt data. The structure of the data
within the encrypted block is as follows:
00 00 ;Probably system ID
00 ;Probably key select byte
01 ;MECM data start address (see below)
00 11 22 33 44 55 66 77 ;MECM key data (16 bytes)
88 99 AA BB CC DD EE FF
00 00 00 00 ;Unknown, probably random data
00 00 00 00 00 00 00 00 ;Unknown, probably random data
00 00 00 00 00 00 00 00 ;Unknown, probably random data
00 00 00 00 00 00 00 00 ;Unknown, probably random data
00 00 00 00 00 00 00 00 ;Unknown, probably random data
01 23 45 67 89 AB CD EF ;Valid hash
MECM start address: This byte tells the CAM the addresses within the full 256-
byte MECM key the 16-byte block of data included with this command $02
represents. It appears as though the CAM is able to hold 16 only bytes of the
full 256 byte MECM key, so the MECM start address is used to tell the CAM which
byte of the overall key is the first one it has in its 16-byte buffer. So, for
example, a MECM start address of 0x12 specifies that the 02 command includes
bytes 0x24 thru 0x33 of the entire MECM key.
Since the CAM always remembers only 16 bytes of the overall MECM key, the 03
commands that intend to use the MECM data also include a start address which
tells the CAM the address within the full 256-byte MECM key at which the 8-byte
block the CAM should XOR a decrypted control word with starts.
Note that the start address requested by a 03 command can only ever be larger in
magnatude than the start address in the most recent 02 command by a value of 4
(ie., if the start address in the most recent 02 command was 0x12 (MECM bytes
0x24 thru 0x33), the maximum start address allowed in a 03 command is 0x16 (MECM
bytes 0x2C thru 0x33).
Example of a $03 command, both encrypted and decrypted, and its response:
21 00 35 ; A0 CA 00 00 ;Standard header
2F ;Instruction length
03 ;Command
2D ;Command data length
01 01 ;System ID
10 ;ECM type
29 ;Data field length
05 ;Key select byte (see below)
12 D4 70 4D 34 FB 3C DF ;Valid hash (signature)
90 DD 23 D3 7B A9 79 DC ;Encrypted packet 1
CF DE 68 4E A4 43 0F 1B ;Encrypted packet 2
F5 E0 9B B3 30 58 FB 75 ;Encrypted packet 3
4F 3E AB EB 4C 8F F0 6F ;Encrypted packet 4
05 ;Expected response length
29 ;Checksum
12 00 07 ; 83 ;Response code
03 ;Response data length
B1 01 ;Decode succeeded
03 ;Sequence number
90 00 ;SW1/SW2: Successful completion
B6 ;Checksum
Here's what the data in the encrypted packets looks like after decryption:
Key select byte: This byte is used to tell the $03 decode routine which public
key (if any) was used to encrypt the data in the 03 command. If the low 3 bits
of this byte are "101", then the CAM uses the standard E* DES-like decrypt on
the data. If the low 3 bits are "111", the CAM doesn't perform any decryption
on the data at all. If the low 3 bits are anything other than "101" or "111",
the CAM discards the packet. Bit 4 of this byte indicates which public key was
used: 0 for key 0, 1 for key 1. Bit 3 is a flag which selects which verify key
is used to compute the signature for the message.
Control word control byte: If this byte is $10, then the CAM knows that two
control words are present. If this byte is $11, then the CAM only tries to
decrypt the first control word, but it returns it as the second return word
in the next command 13.
MECM index byte: If bit 7 of this byte is clear, then before the CAM re-encrypts
the control words for return to the IRD, it XORs them with a sequence of bytes
that come from a $02 command. The $02 command includes 16 bytes of MECM data
and an address byte which tells the CAM which 16 bytes of the 256-byte MECM key
the CAM currently knows about. The 03 command's MECM index byte specifies the
address within the full 256-byte MECM key of the first of 8 bytes to be XORed
with its control word. So, for example, a MECM index byte in a 03 command with
a value of 0x14 specifies that bytes 0x28 thru 0x2F (0x14*2 thru (0x14*2)+7) are
to be XORed with the decrypted control words before re-encryption and return to
the IRD. If the index byte in the 03 command refers to any data that is outside
the range of MECM data currently known to the CAM, the CAM will invalidate its
current MECM data and set the "CAM suggests $02 command" bit in the C0 status
response, prompting the IRD to provide it with the most recent 02 command it
(the IRD) knows about.
Note that the above version of the 03 packet is a "group access" packet, which
is usually used to provide access to free informational channels (with programs
like Charlie Chat). An example of a $03 command that requires a specific
program tier might look like this:
21 00 3D ; A0 CA 00 00 ;Standard header
37 ;Instruction length
03 ;Command
35 ;Command data length
01 01 ;System ID. $0101=EchoStar
10 ;Control word tag byte
31 ;Data field length
05 ;Key select byte
B8 2E A0 FF B4 F9 2C 2F ;Valid hash (signature)
3C 4F C7 CB 26 E1 FF 3E ;Encrypted packet 1
C0 4D F2 6F 37 C3 22 8D ;Encrypted packet 2
4B 42 B2 BC 99 15 3B D4 ;Encrypted packet 3
5D 95 0D 0A 93 57 0F 7A ;Encrypted packet 4
69 50 D7 4E 2C B5 ED CB ;Encrypted packet 5
05 ;Expected response length
A6 ;Checksum
12 00 07 ; 83 ;Response code
03 ;Response data length
B1 01 ;Decode succeeded
03 ;Sequence number
90 00 ;SW1/SW2: Successful completion
B6 ;Checksum
Date Time
---------------------------- ------------------------------
Bits 0..4=day 1-31 Bits 0..4=second/2 0-29
Bits 5..8=month 1-12 Bits 5..10=minute 0-59
Bits 9..15=year-1992 0-127 Bits 11..15=hour 0-23
Further notes about the 03 packet: The two control words, the MECM control
bytes, and the control word control byte must ALWAYS be located at the start of
the encrypted data as shown above. The NagraVision CAM is hard-coded to expect
the control word data and associated control bytes to be in those locations.
Within the ECM, lots of commands and filters are possible. The first variable
is the ECM type:
21 00 35 ; A0 CA 00 00 ;Standard header
2F ;Instruction length
03 ;Command
2D ;Command data length
01 01 ;System ID
>>> 10 ;ECM type
29 ;Data field length
05 ;Key select byte (see below)
12 D4 70 4D 34 FB 3C DF ;Valid hash (signature)
90 DD 23 D3 7B A9 79 DC ;Encrypted packet 1
CF DE 68 4E A4 43 0F 1B ;Encrypted packet 2
F5 E0 9B B3 30 58 FB 75 ;Encrypted packet 3
4F 3E AB EB 4C 8F F0 6F ;Encrypted packet 4
05 ;Expected response length
29 ;Checksum
Type Description
---- ---------------------------------------------------------
$10 Double control-word ECM
$11 Even control-word-only ECM
$12 Odd control-word-only ECM
ECM types $10, $11, and $12 all have packets that should look pretty much the
same, except that type 10 contains even and odd control words, type 11 only
contains an even control word, and type 12 only contains an odd control word.
In addition to the control words, ECM types 10, 11, and 12 also can contain a
variety of data filtering fields. These fields allow the CAM to decide if the
user is authorized to view the program of not. Below is an example of a
decrypted type 10 ECM:
Type Description/Format
---- ----------------------------------------------------------
$20 Straight subscription
20 ;Filter type
01 02 ;Tier ID
01 02 ;"Component"
01 ;Theme (program type?)
01 ;Level (Rating?)
01 02 ;Program start date
03 04 ;Program start time
01 02 ;Current date
03 04 ;Current time
For ECM command 21, it appears that various charge options are available: The
program provider can choose to charge once for the impulse buy and leave it at
that (which is the most common mode of usage), or allow "tokens" to be bought
which can be deducted in varying amounts when the user tunes to the event. In
addition, both cash and tokens can be applied per unit of time, so the longer
the user watches, the more they have to pay.
The "watched" odometer threshold tells the card how many ECMs may be processed
for a given PPV data item before that PPV is considered "watched" and must
therefore be charged to the customer.
Note that although ECM command $21 contains sufficient information to validate
an ECM, it will usually be preceded by an ECM command $20 which provides a tier
ID, component, theme, level, and time/date info. Presumably, this is so that
employees of program providers can have subscriptions in their cards which allow
them to watch any PPV they want at any time.
The two blackout ECM commands ($22 and $23) allow the card to decide whether or
not to return the control words for a given channel based on the blackout
information stored in the type $06 data item whose system ID high matches the
system ID high of the ECM. Note that if a blackout ECM command is used, no tier
ID is needed. The two blackout ECM commands are formatted as follows:
% x 1 x x x x x x
| | |_________|__ Bits 0..5: Blackout data byte pointer
| |______________ Bit 6: Sanity flag
|________________ Bit 7: Viewability flag
The blackout data pointer specifies which of the 12 bytes of blackout info in
the appropriate type $06 data item is to be used to determine whether the
program is blacked out. This value is sanity-checked, and if it is found to be
greater than $0C (the total number of blackout info bytes in a type $06 data
item), the blackout command is assumed to have reached a "program not viewable"
conclusion, and the next ECM command is executed. If this pointer is found to
be valid, the byte it specifies within the blackout info bytes is retrieved and
operated on to determine whether the program is blacked out.
For example, a blackout data byte pointer of $00 would mean that the first
blackout info byte in the appropriate type $06 data item is to be used to
determine whether the program is blacked out. How that byte is used depends on
whether the blackout command was $22 (program type) or $23 (regional).
For a $22 ECM command (program type blackout), the byte identified by this
pointer is compared to the "program type" byte included in the ECM command. If
the two match, a blackout match is declared (see "viewability flag", below for
further information on what happens in the event of a blackout match). This
would allow, for example, programming which is illegal (say, hard-core
pornography) in a customer's city/county/state to be rendered unviewable.
For a $23 ECM command (regional blackout), the byte identified by the blackout
category byte is treated as a bit number within the blackout bitmap which is to
be tested. If the specified bit is set, then a blackout match is declared.
This would allow sporting events to be blacked out in their local markets in the
event the event did not sell out, and so on. It could also be used to allow (or
disallow) specific types of program by region. The blackout data byte pointer
in this case would point to a byte in the blackout info data which contains a
region code. The ECM command contains a 256-bit bitmap which indicates for
which regions a blackout match should be declared (see "viewability flag", below
for further information on what happens in the event of a blackout match).
The sanity flag bit must always be set. If it is found to be clear, the
entire ECM is treated as insane and discarded.
The viewability flag determines the default (no match) "viewability" state of
the program. If the viewability flag is 0 and no match occurs, the card moves
on to the next ECM command to decide whether the program is viewable. If the
viewability flag is 0 and a blackout match occurs, the card declares a "program
valid" condition, and returns the control words to the IRD. Note that the
viewability flag can be set to '1' by default. In this event, the program is
viewable (and control words are returned) if a blackout match does NOT occur,
and a blackout match would cause the program to be unviewable.
21 00 08 ; A0 CA 00 00 ;Standard header
02 ;Instruction length
12 ;Command
00 ;Command data length
06 ;Expected response length
55 ;Checksum
12 00 08 ; 92 ;Response code
04 ;Response data length
03 6B A5 9A ;CAM ID: 036BA59A (00 5738 6394 07)
90 00 ;SW1/SW2: Successful completion
4B ;Checksum
Note that the two-digit check code isn't included as part of the response. This
check code is only used by the Dish Network customer service drone to ensure
that you do (or at one time did), in fact, have physical possession of the card
when you call to subscribe.
21 00 09 ; A0 CA 00 00 ;Standard header
03 ;Instruction length
13 ;Command
01 ;Command data length
03 ;Command data
19 ;Expected response length
48 ;Checksum
12 00 1B ; 93 ;Response code
17 ;Response data
B1 01 ;Decode succeeded
06 ;Sequence number
11 ;Video key 1 header
08 ;Video key length
11 22 33 44 55 66 77 88 ;Encrypted even control word
12 ;Video key 2 header
08 ;Video key length
11 22 33 44 55 66 77 88 ;Encrypted odd control word
90 00 ;SW1/SW2: Successful completion
A8 ;Checksum
Note: If the card is using the MECM extension, once the box has finished
decoding the 13 command, it will need to XOR the video keys with the same data
the CAM did, if it expects to recover the raw data that was present in the 03
command. Note also that regardless of whether the 03 command had a $10 or $11
control byte (indicating the presence of two or one control words,
respectively), the 13 command will ALWAYS have two control words in it, and
will always be formatted as above.
Also note: If the IRD is requesting keys for a channel that the CAM thinks it's
not authorized for, the CAM will return all 00s for the encrypted video keys.
2.3.7- Command $14/Response $94
I don't know much about this command, other than the fact that it's always the
same in virgin cards. An example of a virgin $14 command is:
21 00 08 ; A0 CA 00 00 ;Standard header
02 ;Instruction length
14 ;Command
00 ;Command data length
06 ;Expected response length
53 ;Checksum
12 00 08 ; 94 ;Response code
04 ;Response data length
0F 4C 54 60 ;Data
90 00 ;SW1/SW2: Successful completion
6D ;Checksum
The last byte of the 4-byte block of returned data is the CAM's firmware
revision status flag. This byte changes as firmware updates happen.
21 00 0C ; A0 CA 00 00 ;Standard header
06 ;Instruction length
20 ;Command
04 ;Command data length
01 ;Data type being queried
;(see section 4, "data types")
02 ;Second data field length
FF FF ;Misc. data
03 ;Expected response length
65 ;Checksum
12 00 05 ; A0 ;Response code
01 ;Response data length
01 ;Number of data items to return
90 00 ;SW1/SW2: Successful completion
27 ;Checksum
21 00 0D ; A0 CA 00 00 ;Standard header
07 ;Instruction length
21 ;Command
05 ;Command data length
01 ;Data type being requested
;(see section 4, "data types")
03 ;Second data field length
FF FF ;Misc. data
00 ;Element number being requested
20 ;Expected response length
47 ;Checksum
Note that the IRD already knows how long the response to its query should be.
This is because most data types are fixed-length. For data types that are NOT
fixed-length, the data will always have a fixed-length field to start, and one
or more variable-length fields to follow. An example of a series of 21 commands
that retrieve a variable-length data item is as follows:
21 40 0D ; A0 CA 00 00 ;Standard header
07 ;Instruction length
21 ;Command
05 ;Command data length
11 ;Data type
03 ;Second data field length
FF FF ;Misc. data
00 ;Element number being requested
04 ;Expected response length
33 ;Checksum
12 40 06 ; A1 ;Response code
02 ;Response data length
01 ;Subtype of data in this element
11 ;Length of this element
90 00 ;SW1/SW2: Successful completion
69 ;Checksum
21 00 0D ; A0 CA 00 00 ;Standard header
07 ;Instruction length
21 ;Command
05 ;Command data length
11 ;Data type
03 ;Second data field length
FF FF ;Misc. data
00 ;Element number being requested
15 ;Expected response length (note:
;Equals length reported by CAM above
;plus 4, to account for command
;overhead
64 ;Checksum
12 00 17 ; A1 ;Response code
13 ;Response data length
01 ;Data type to follow: date/time
0F 0E ;Purchase date: 14 Aug, 1999
35 28 :Purchase time: 06:41:16 GMT
00 ;End of date/time
44 65 65 70 20 49 6D
70 61 63 74 90 ;"Deep Impact" in ASCII
00 ;End of PPV title
90 00 ;SW1/SW2: Successful completion
0C ;Checksum (note no SW1/SW2)
21 40 0D ; A0 CA 00 00 ;Standard header
07 ;Instruction length
21 ;Command
05 ;Command data length
11 ;Data type
03 ;Second data field length
FF FF ;Misc. data
01 ;Element number being requested
04 ;Expected response length
32 ;Checksum
12 40 06 ; A1 ;Response code
02 ;Response data length
02 ;Subtype of data in this element
05 ;Length of this element
90 00 ;SW1/SW2: Successful completion
60 ;Checksum
21 00 0D ; A0 CA 00 00 ;Standard header
07 ;Instruction length
21 ;Command
05 ;Command data length
11 ;Data type
03 ;Second data field length
FF FF ;Misc. data
01 ;Element number being requested
09 ;Expected response length
7F ;Checksum
12 00 0B ; A1 ;Response code
07 ;Response data length
02 ;Data type to follow: Channel
05 ;Length of channel ID
50 50 56 31 31 ;"PPV11" in ASCII
90 00 ;SW1/SW2: Successful completion
7E ;Checksum
21 00 0B ; A0 CA 00 00 ;Standard header
05 ;Instruction length
30 ;Command
03 ;Command data length
01 01 ;System ID for callback data
00 ;Block number being requested
05 ;Expected response length
73 ;Checksum
12 00 07 ; F0 ;Response code
03 ;Response data length
B1 01 ;Packet OK
01 ;Sequence number
90 00 ;SW1/SW2: Successful completion
C7 ;Checksum
For the "block number being requested", note that if a block number less than
$80 is requested, the card will perform it's callback initialization sequence.
In theory, the sequence of blocks requested would be $00, $81, $82, and so on.
21 00 08 ; A0 CA 00 00 ;Standard header
02 ;Instruction length
31 ;Command
00 ;Command data length
52 ;Expected response length
22 ;Checksum
12 00 54 ; F1 ;Response code
50 ;Response data length
B1 01 ;Decode succeeded
01 ;Sequence number
04 ;Length of status bytes
4B ;Length of callback data
01 01 ;System ID for callback data
xx ;Key select byte indicating which
; key was used to encrypt the data
xx xx xx xx xx xx xx xx ;Valid hash
xx xx xx xx xx xx xx xx ;Encrypted packet 1
xx xx xx xx xx xx xx xx ;Encrypted packet 2
xx xx xx xx xx xx xx xx ;Encrypted packet 3
xx xx xx xx xx xx xx xx ;Encrypted packet 4
xx xx xx xx xx xx xx xx ;Encrypted packet 5
xx xx xx xx xx xx xx xx ;Encrypted packet 6
xx xx xx xx xx xx xx xx ;Encrypted packet 7
xx xx xx xx xx xx xx xx ;Encrypted packet 8
90 00 ;SW1/SW2: Successful completion
xx ;Checksum
The encrypted packets contain the actual callback information to be sent to the
program provider. The information is encrypted using the same algorithm and key
that would be used to decrypt an EMM (command 00) with the same system ID as the
one included in the $30 command that produced the callback data. This means that
the data would be decrypted using the same algorithm and key as those used to
encrypt EMMs (most likely, the algorithm is the same for both encryption and
decryption, only the key differs). The format of the data, prior to encryption,
is as follows:
First packet:
Packets 2 through N:
Note that up to 6 PPVs can be reported in packets after the first, and that the
packets are always padded to the end with 00s.
21 00 08 ; A0 CA 00 00 ;Standard header
02 ;Instruction length
40 ;Command
00 ;Command data length
04 ;Expected response length
05 ;Checksum
12 00 06 ; 70 ;Response code
02 ;Response data length
0A 52 ;EEPROM space available: $A52 bytes
90 00 ;SW1/SW2: Successful completion
AE ;Checksum
Note that the returned value does not necessarily reflect the amount of
contiguous data space available in the card's EEPROM...the data storage
mechanism used in the E* CAM is sort of a crude flash file system kind of thing,
so when a data item is removed, the space it once occupied is considered to be
"available", even though that space may be wedged between two other active data
items. This approach makes the E* CAMs more flexible than the DSS CAMs, but
also means that the amount of code required to support the data storage system
is much larger.
2.3.13- Command $41/Response $71
The $41 command is used to create type $11 data items with various text
information such as movie title of PPV items, channel description of channel
records, etc. After a $41 command, a $42 command will be issued to link the
data from the $41 command to a specific data item of type $08..$0B so that when
the data item that the type $11 data item is linked to is deleted, the type $11
data item can be deleted as well. After a command $41 is issued to create a
type $11 data item, a command $42 (see below) should be issued to link the
newly-created string to a specific type $08..$0B data item within the card. If
no command $42 is issued to link a type $11 data item to a specific type
$08..$0B data item, then the unlinked type $11 data item will be deleted the
next time the card performs garbage collection.
21 00 0B ; A0 CA 00 00 ;Standard header
05 ;Instruction length
41 ;Command
03 ;Command data length (note: I believe
;that if this value is >$7F, no data
;item is created
50 50 56 ;Command data (in this case, "PPV" in
; ASCII
03 ;Expected response length
52 ;Checksum
12 00 05 ; 71 ;Response code
01 ;Response data length
14 ;String ID of newly-created type $11
; data item
90 00 ;SW1/SW2: Successful completion
E3 ;Checksum
To link a type $11 item to a particular type $08..$0B data item, the SYSTEM ID
and RIGHTS IDENTIFIER of the data item to be linked to the type $11 item must be
supplied (so that the card can find the item to be linked), and the card must be
told what string ID to write to the item to be linked, and whether the string ID
byte should be written to the field at byte 7 (STRING ID for types $08..$0A, PPV
ID WITHIN CARD for type $0B), or byte F (STRING ID for type $0B). Note that
writing to byte F is not allowed for data types other than $0B.
21 00 0F ; A0 CA 00 00 ;Standard header
09 ;Instruction length
42 ;Command
07 ;Command data length
01 01 ;System ID of data item to link
7F 08 14 ;Rights identifier of data item to
; link
01 ;String ID to write
00 ;$00=String ID stored at byte 7
03 ;Expected response length
69 ;Checksum
12 00 05 ; 72 ;Response code
01 ;Response data length
01 ;String ID that was written
90 00 ;SW1/SW2: Successful completion
F5 ;Checksum
21 00 0F ; A0 CA 00 00 ;Standard header
09 ;Instruction length
42 ;Command
07 ;Command data length
01 01 ;System ID of data item to link
7F 08 14 ;Rights identifier of data item to
; link
01 ;String ID to write
01 ;non-zero=String ID stored at byte F
03 ;Expected response length
68 ;Checksum
12 00 05 ; 72 ;Response code
01 ;Response data length
01 ;String ID that was written
90 00 ;SW1/SW2: Successful completion
F5 ;Checksum
The system ID and the Email ID (00..FF). If a matching EMail entry is found,
it is marked as "read" by setting bit 4 of the data item's "received" flags
byte. An example of a $55 command is as follows:
21 00 0B ; A0 CA 00 00 ;Standard header
05 ;Instruction length
55 ;Command
03 ;Command data length
01 01 ;System ID
01 ;Email entry to locate
06 ;Expected response length
14 ;Checksum
12 00 08 ; D5 ;Response code
04 ;Response data length
01 01 ;System ID
01 ;Email entry requested
00 ;00=match found, FF=no match
90 00 ;SW1/SW2: Successful completion
5A ;Checksum
2.3.16- Command $56/Response $D6
The $56 command's function is "delete mail". Like the $55 command, the $56
command is passed a system ID and mail ID to locate. If a matching entry is
found, the it will be marked such that the EEPROM space it had been occupying is
shown as "unused", and the Email itself is shown as "read and deleted". One
interesting thing to note is that there is an apparant bug with this command in
the ROM2 and ROM3 cards: if a matching entry is not found, the card will respond
with a $D5 command instead of the $D6 command that the IRD should be expecting.
An example of a $56 command is as follows:
21 00 0B ; A0 CA 00 00 ;Standard header
05 ;Instruction length
56 ;Command
03 ;Command data length
01 01 ;System ID
01 ;Email ID to locate
06 ;Expected response length
17 ;Checksum
12 00 08 ; D6 ;Response code
04 ;Response data length
01 01 ;System ID
01 ;Email entry requested
00 ;00=match found
90 00 ;SW1/SW2: Successful completion
59 ;Checksum
Note: If a match is not found, the response will look like this:
12 00 08 ; D5 ;Response code
04 ;Response data length
01 01 ;System ID
01 ;Email entry requested
FF ;00=match found
90 00 ;SW1/SW2: Successful completion
A5 ;Checksum
21 00 08 ; A0 CA 00 00 ;Standard header
02 ;Instruction length
60 ;Command
00 ;Command data length
42 ;Expected response length
63 ;Checksum
12 00 44 ; E0 ;Response code
40 ;Response data length
xx xx xx xx xx xx xx xx ;Response data
xx xx xx xx xx xx xx xx
xx xx xx xx xx xx xx xx
xx xx xx xx xx xx xx xx
xx xx xx xx xx xx xx xx
xx xx xx xx xx xx xx xx
xx xx xx xx xx xx xx xx
xx xx xx xx xx xx xx xx
90 00 ;SW1/SW2: Successful completion
xx ;Checksum
21 00 1C ; A0 CA 00 00 ;Standard header
16 ;Instruction length
61 ;Command
14 ;Command data length
33 22 11 00 ;IRD serial number
aa aa aa aa aa aa aa aa ;IRD firmware info in ASCII
aa aa aa aa aa aa aa aa
03 ;Expected response length
xx ;Checksum
12 00 05 ; E1 ;Response code
01 ;Response data length
00 ;Response data (always 00)
90 00 ;SW1/SW2: Successful completion
67 ;Checksum
21 00 1F ; A0 CA 00 00 ;Standard header
1A ;Command length
99 ;Command
18 ;Command data length
4E 69 70 50 45 72 20 49 ;ASCII string:
73 20 61 20 62 75 54 74 ; "NipPEr Is a buTt liCkeR!"
20 6C 69 43 6B 65 52 21
A8 ;Checksum
12 00 1C ; 99 ;Response code
18 ;Resposne data length
72 13 A7 7A 92 B4 49 34 ;Response block 1
72 13 A7 7A 92 B4 49 34 ;Response block 2
72 13 A7 7A 92 B4 49 34 ;Response block 3
90 00 ;SW1/SW2: Successful completion
F8 ;Checksum
Note that because ROM2 cards don't support this command, it's possible to keep
an IRD from attempting to use it by reporting a firmware revision level of
Rev052.
21 00 08 ; A0 CA 00 00 ;Standard header
02 ;Instruction length
C0 ;Command
00 ;Command data length
06 ;Expected response length
87 ;Checksum
12 00 08 ; B0 ;Response code
04 ;Response data length
08 ;Response byte 1
00 ;CAM status flags 1
00 ;CAM status flags 2
16 ;CAM status flags 3
90 00 ;SW1/SW2: Successful completion
20 ;Checksum
Notes: CC="Callback", flags 1 bit 4 and flags 2 bits 6+7 not supported by
current EchoStar IRDs.
CAM tamper detected: This bit is only present in ROM3 cards, and it is only ever
set by EMM F3 commands that check for other flags set in OTP memory. At resent,
only location E010 is used to contain those flags, but in theory, any location
from E010 to E01F could be used. The EMM F3 commands that set flags in OTP
memory do so based on sanity checks of the card's EEPROM data, checking such
things as the CAM ID, making sure that no data is present in the portion of code
space set aside for bug-catchers, but which has not been specifically used by
"official" bug-catchers, and so on.
21 00 08 ; A0 CA 00 00 ;Standard header
02 ;Instruction length
C1 ;Command
00 ;Command data length
04 ;Expected response length
84 ;Checksum
12 00 06 ; B1 ;Response code
02 ;Response data length
CF ;Response data byte 1 (see below)
FF ;Response data byte 2 (see below)
90 00 ;SW1/SW2: Successful completion
07 ;Checksum
In order to better understand the overall operation of the EchoStar system, it's
important to understand which commands relate to each other, and in what way.
In this section, I'll provide overviews of which commands would be used by the
IRD to accomplish some common tasks.
2.4.1- Finding out if the card is busy or has any new information
Often, it's useful for the receiver to know if the card is busy, or if the card
has received (or computed) some new information that the receiver might find
useful. When this happens, the receiver polls the card for its current status,
and examines the card's response to determine whether further commands are
necessary. The sequence for this operation is:
For detailed information on the $C0 command and $B0 response, see section
2.3.31, "CAM status request".
2.4.2- Finding out what data types in the card's database have changed
When data in the card's internal database has changed, the card will set one
of the status bits sent in the response to command $C0. When this bit is set,
the receiver will understand that data of some kind has been changed in the card
(or that for whatever reason, the card doesn't think the receiver has current
knowledge of the information in its database), so the receiver will poll the
card to find out what data types have changed. The sequence for this operation
is:
For detailed information on the $C1 command and $B1 response, see section
2.3.32, "Request for ID of updated data items".
For detailed information on the $20 command and $A0 resposne, and the $21
command and $A1 response, see sections 2.3.10 and 2.3.11, "Data items available
request", and "Data item request", respectively.
In general, when a $C1 command sequence (see section 2.4.2, above) indicates
that the card has new data that the receiver might be interested in, the
receiver will immediately do a whole series of data retrieval commands and
download the card's entire database. A good example of this can be observed by
logging the interaction between a card and the receiver when the card is first
inserted.
The process, in english, is this: The IRD receives one or two encrypted video
decryption keys which it doesn't know how to decrypt from the satellite, along
with encrypted information which can be used to determine the specific channel
service to which the customer must be subscribed to watch the video images.
Because the IRD doesn't know how to decrypt this information, it passes it along
to the card. The card decrypts the information and examines the embedded
subscription requirement data to decide whether the customer is allowed to watch
the program. If the card decides that the customer should be allowed to watch
the program, it re-encrypts the video decryption keys in such a way that the IRD
into which the card is inserted (and theoretically, no other IRD) can decrypt
them, allowing it to successfully decrypt the video stream and contribute to the
overall expansion of everyone's ass. Step-by- step, the process is as follows:
For detailed information on the $03 command and $83 response, and the $13
command and $93 response, see sections 2.3.4 and 2.3.8, "Entitlement control
message" and "Control word request", respectively.
3: EMM commands
Note that although I think I know what all of the valid EMM commands are, I
don't know what they all do. Also note that because of the differences in the
ROM2, ROM3 and ROM10 cards' ROM images, there are at least three EMM commands
which will work on one of the cards, but not the others (see section 5, inside
NagraVision cards).
10 ;EMM command
00 50 53 ;Rights identifier
00 32 ;Spending limit in units (hex)
25 ;Spending limit in 1/100 units
; (BCD)
04 99 ;Phone home threshold
In this example, the rights identifier for the newly-created spending limit item
will be 005053, the customer will be given a spending limit of $50.25, and the
"phone home threshold" (the point at which a call to E* to report PPV purchases)
will be forced if the amount of credit remaining falls below $4.99. This is a
fixed-length EMM command with a length of 9 bytes.
11 ;EMM command
00 02 ;Cost of this item in units (hex)
99 ;Cost of this item in 1/100 of
; units (BCD): This item is $2.99
20 ;Item attribute byte (see below)
03 ;String length byte
50 50 56 ;String associated with this
; item ("PPV" in ASCII")
xx ;Next EMM command: $12, $13, $14,
; or $15. Any other EMM command
; here will abort EMM processing
; (see below for details on EMM
; commands $12..$15)
01 02 03 ;Rights ID/PPV ID for next EMM
; command
00 00 ;Unused data for EMM commands
; $12..$14, expiration date for
; EMM command $15
FF FF ;Begin date
00 00 ;Data item lifespan/expire date
; for next EMM command if
; $12..$14
00 00 ;Rights date for next EMM command
; if $12..$14
As you can see, this EMM command is actually only the first half of a 2-part EMM
sequence. It requires that the EMM command that follows be $12..$15, or EMM
processing is aborted. Note that successful processing of EMM commands $12..$15
requires they be preceded by an EMM $11 command, since the cost of the item to
be purchased is provided by the EMM $11 command. As the type $11 command is
processed, a number of tests occur to make sure that the EMM command will be
creating a valid purchase item. First the 'begin date' is checked. If the
begin date is $FFFF, the rights date is checked to see if the rights date
represents a date that is in the past, and if so, EMM processing is aborted.
Next, we check the IRD status data item to see if the IRD's subscription is
suspended, and if so, EMM processing is aborted.
Next, we make sure that there will be sufficient space in EEPROM for both the
type $11 item created by the $11 EMM command, but also the data item that will
be created by the follow-up command, and if sufficient space does not exist, EMM
processing is aborted.
Next, bit 5 of the item attribute byte is checked to see if this is an impulse
purchase. If this EMM represents an impulse purchase, then the cost associated
with this EMM command is checked against the spending limit data (type $0C data
item) in the card, and if sufficient credit is not available, or if this
purchase would cause the "credit used" count to roll over past 0, then EMM
processing is aborted. If sufficient credit is available, the cost of the item
is added to the "credit used" count. At this point, the EMM has been determined
to be valid, so the string length byte is checked to see if a string was sent
with this EMM command. If one was, then a type $11 data item (string) is
created, a string ID is assigned, and the string included with this EMM command
is written to the new string data item. Once all this is finished, EMM
processing continues with the next EMM command.
This is a variable-length EMM command, whose length is equal to 6 plus the value
of the STRING LENGTH BYTE.
12 ;EMM command
01 02 03 ;Rights identifier
00 00 ;Unused data
FF FF ;Begin date
00 00 ;Data item lifespan/expire date
00 00 ;Rights date
00 00 ;Min channel
7F FF ;Max channel
00 00 ;Component
00 ;Min theme
00 FF ;Max theme
00 ;Level
The 'begin date' field is used to determine if the date fields are valid at
all: If the 'begin date' field contains $FFFF, the rights date is checked to see
if it represents a date that happened before today, and if so, the data item is
not created (note that this check is superfluous- if this check fails here, it
would also have failed when the preceding $11 EMM command was processed, causing
EMM processing to be aborted). If the begin date contains a valid date, then
the information in the begin date field is taken as absolute. If the begin date
was $FFFF, the data item's expire date is calculated by adding the "data item
lifespen" field (which is expressed as an encoded number of years, months, and
days) to yesterday's date, otherwise the absolute expire date is taken directly
from the received EMM data. This is a fixed-length EMM command with a length of
$16.
13 ;EMM command
01 02 03 ;Rights identifier
00 00 ;Unused data
FF FF ;Begin date
00 00 ;Data item lifespan/expire date
00 00 ;Rights date
00 00 00 ;Debit in tokens
00 ;Rights ID high byte low bit
00 00 ;Min channel
7F FF ;Max channel
00 00 ;Component
00 ;Min theme
00 FF ;Max theme
00 ;Level
As with EMM command $12, the 'begin date' field is checked for validity, and the
expiration date is calculated before the data item is created. One minor change
from the way EMM command $12 operates is that the low bit of the rights
identifier is ORed with the low bit of the "Rights ID high byte low bit" field.
This is a fixed-length EMM command with a length of $1A.
3.2.6- EMM command $14
This command is used to write PPV-by-number data items to the CAM. I'm not
really sure what these data items are used for, but I would guess that they
allow the purchase of a group of PPV channels that are all broadcasting
different aspects of a single event (like, say, the olympics). As with EMM
command $12, this command must be preceded by an EMM command $11. The format
for this EMM command is as follows:
13 ;EMM command
01 02 03 ;Rights identifier
00 00 ;Unused data
FF FF ;Begin date
00 00 ;Data item lifespan/expire date
00 00 ;Rights date
00 00 00 ;Debit in tokens
00 ;Rights ID high byte low bit
00 00 ;Min channel
7F FF ;Max channel
00 00 ;Component
00 00 00 ;Min PPV ID
7F FF FF FF ;Max PPV ID
As with EMM command $12, the 'begin date' field is checked for validity, and the
expiration date is calculated before the data item is created. One minor change
from the way EMM command $12 operates is that the low bit of the rights
identifier is ORed with the low bit of the "Rights ID high byte low bit" field.
This is a fixed-length EMM command with a length of $1D.
13 ;EMM command
01 02 03 ;PPV ID
00 00 ;Expiration date
00 ;Rights ID high byte low bit
00 00 ;Min channel
7F FF ;Max channel
00 00 ;Component
00 00 00 ;Min PPV ID
7F FF FF FF ;Max PPV ID
Unlike EMM command $12, the date fields in this EMM command are not checked for
validity. The expiration date is not calculated, but instead is simply taken
from the received data, as is the purchase date. Another change from the way
EMM command $12 operates is that the low bit of the rights identifier is ORed
with the low bit of the "Rights ID high byte low bit" field. This is a fixed-
length EMM command with a length of $14.
20 ;EMM command
20 ;Search type/Begin date op type
; (see below)
B0 ;Expiration date op type/
; Rights date op type (see below)
00 00 00 ;Rights ID to match
FF FF ;Date to compare to mod date
00 00 ;Date factor for begin date
; (see below)
00 20 ;Date factor for expiration date
00 00 ;Date factor for rights date
Search type/begin date operation type byte: This byte specifies two things. In
the upper nibble is a value which tells the card what type of data to search
for, and how broadly the data types to be modified should be filtered. This data
is stored in the upper nibble of the search type/begin date operation type byte,
and is encoded as follows:
0=Modify all data items of type 08..0B whose system ID and rights
ID match (should only be one item)
2=Modify all data items of type 08..09 whose full system ID matches
3=Modify all data items of type 08..09 whose system ID hi matches
4=Modify all data items of type 08..09
The begin date operation type data is stored in the lower nibble of the search
type/begin date operation type byte, and is a series of binary flags encoded as
follows:
% - - - - x x x x
|_____| |_| |_|__ Item begin date replacement condition
| | 00=never
| | 01=replace if item date >= compare date
| | 10=replace if item date < compare date
| | 11=always replace
| |
| |________ Operation type for computing begin date compare date:
| 0x=none: use absolute date in "EMM date" field
| 10=compare date=item begin date+EMM date
| 11=compare date=item begin date-EMM date
|
|______________ search type
The expiration date operation type/rights date operation type byte is encoded
exactly like the begin date operation type, with the operation to be performed
on the expiration date stored in the upper nibble, and the operation to be
performed on the rights date stored in the lower nibble.
Date factors: The date factors contain either an absolute date to be compared
against and possibly replace the appropriate data item date or an offset from
the current date's value. If the operation type for, say, the expiration date
specified that the compare date is computed by adding the EMM date to the data
item expiration date (operation type %10xx), then the offset factor stored in
the expiration date factor (in years, months, and days) is added to any matching
data item's current expiration date. I'm not really sure why this option is
available, since if the operation specifies that the date factor in the EMM is
to be added to the current item date, the "replace if item date >= compare date"
action will always be performed, and the "replace if item date < compare date"
action will never be performed.
In the example above, the EMM command specifies that all data items of type
$08/$09 whose system ID matches the EMM system ID will have their expiration
dates extended by one month. Another possible EMM command of this type that we
might see is:
20 ;EMM command
01 ;Search type/Begin date op type
00 ;Expiration date op type/
; Rights date op type
12 34 56 ;Rights ID to match
FF FF ;Date to compare to mod date
10 FE ;Date factor for begin date
00 00 ;Date factor for expiration date
00 00 ;Date factor for rights date
In this case, any type $08..$0B data item with a rights identifier of $123456
will have its begin date replaced with 10 FE (July 30, 2000) if the item's begin
date is further in the future than July 30, 2000. This is a fixed-length EMM
command with a length of $0E.
21 ;EMM command
00 ;Item type byte (see below)
12 34 56 ;Rights ID byte
Item type byte: This byte tells the CAM which type of system information item is
being invalidated by this commmand. Valid values for this byte are:
In the example above, the CAM will invalidate the next type $08..$0B data item
it finds with a rights ID of $123456 and a system ID that matches the EMM's
system ID. This is a fixed-length EMM with a length of $05.
22 ;EMM command
00 ;Item type byte (see below)
12 34 56 ;Rights ID byte
Item type byte: This byte tells the CAM which type of system information item is
being invalidated by this commmand. Valid values for this byte are:
In the example above, the CAM will validate the next type $08..$0B data item it
finds with a rights ID of $123456 and a system ID that matches the EMM's system
ID. This is a fixed-length EMM command with a length of $05.
23 ;EMM command
00 ;Search type (see below)
12 34 56 ;Rights ID
00 02 99 ;Item cost
Search type: This byte tells the CAM what type of data we're going to look for
and how to identify data items that we want to delete. It is encoded as
follows:
00=Search for the item of type 08..0C whose rights ID matches the rights
ID in the EMM command and delete it. In addition, add the value of the
item cost field to the "debit paid" field of the spending limit item
if the deleted item was an impluse buy that was not watched.
20=Delete all data items of type 08..0C whose full system ID matches
30=Delete all data items of type 08..0C whose system ID hi matches
40=Delete all data items of type 08..0C
In the example above, only the type 08..0C data item whose rights ID is $123456
will be deleted. In addition, the card will record a credit of $2.99 if the
item was an impulse buy that was not watched. Another example of this type of
EMM command might be:
23 ;EMM command
20 ;Search type
00 00 00 ;Rights ID
00 00 00 ;Item cost
This example does a search and destroy on all type $08..$0C items with a system
ID that matches the system ID sent in the EMM. Note that no item cost is
specified, since it's likely that more than one item will be deleted. This is s
fixed-length EMM command with a length of $08.
24 ;EMM command
12 34 56 ;Rights ID
00 ;Action byte (see below)
00 02 99 ;Token offset/new min channel
10 FE ;Modification date
Action byte: The value of this byte determines the action that will be taken if
a matching item with a valid date can be found. It is encoded as follows:
24 ;EMM command
12 34 56 ;Rights ID
05 ;Action byte (see below)
01 FE ;Token offset/new min channel
00 ;unused date
10 FE ;Modification date
25 ;EMM command
12 34 56 ;Rights ID
00 ;Action byte (see below)
00 02 99 ;Cash offset/phone home threshold
10 FE ;Modification date
Action byte: The value of this byte determines the action that will be taken if
a spending limit item with a valid date can be found. It is encoded as follows:
In the example above, the amount $2.99 is being added to the "debit paid" field.
Other possible examples of this command could be:
25 ;EMM command
12 34 56 ;Rights ID
03 ;Action byte
00 32 00 ;Cash offset
10 FE ;Modification date
In the above example, the "credit used" figure will be set to 0, and the "debit
paid" will be set to $32.00 (hex), which is $50.00 decimal.
25 ;EMM command
12 34 56 ;Rights ID
05 ;Action byte
00 06 ;New phone home threshold
00 ;unused data
10 FE ;Modification date
In the above example, the "phone home threshold" will be replaced with a value
of 00 06. This is a fixed-length EMM command with a length of $0A.
26 ;EMM command
12 34 56 ;Rights ID
In this example, the first subscription item (type $08..$0C) with a rights ID of
$123456 will be marked as "phoned in". Note that no check is performed to
ensure that a matching item was actually located. This is a fixed-length EMM
command with a length of $04.
This EMM command allows the information in an arbitrary data field of a type
$08..$0C data item to be updated. As with EMM command $26, a specific item is
chosen according to its rights ID field. If a suitable item is found, the EMM
is parsed to determine the offset within the data item where the update is to
begin, the length of the update, and the actual data values that are to replace
the data in the existing item. This EMM command is formatted as follows:
2F ;EMM command
12 34 56 ;Rights ID
13 ;Data offset
04 ;Data length
00 00 7F FF ;Updated data
In this example, a data item with a rights ID of $123456 will have the 4 bytes
starting at its offset $13 replaced with the values 00 00 7F FF (if the matching
data item is a type $08 item, this would change the minimum channel for that
item to $0000, and the maximum channel for that item to $7FFF. Note that
haphazard use of this command can cause data corruption, since the command
doesn't perform any kind of field position validity checking. For example, if
the data item found by the above command were a type $0C item rather than a type
$08 item, the resultant write would cause the header of the _next_ data item to
become corrupted. Persumably, the providers who use NagraVision work around
this limitation by assigning ranges of rights ID values to specific data types
(ie., $000000..$2FFFFF would be type $08, $300000..$3FFFFF would be type $09,
etc.) This is a variable-length EMM command whose length is equal to 6 plus
the value of the DATA LENGTH byte.
30 ;EMM command
Following execution of this EMM command, the remainder of the EMM buffer is
discarded, so this EMM command should always be the last EMM command in a
given EMM.
This is a fixed-length EMM command with a length of $01.
This EMM command checks all type $08..$0B and type $04 data items in EEPROM
to see if they've expired, and if they have (and if they're not impulse buys
that haven't been phoned in), it deletes them. This EMM command is formatted
as follows:
31 ;EMM command
00 FE ;Begin date to compare
10 FE ;Expiration date to compare
In almost all cases, the begin date will probably be the date on which
subscription items were last expired so that only items which have been
created since that time will be expired. In addition, the expiration date
probably always be the date on which the command was broadcast so that items
which had expired as of that day will be deleted.
This is a fixed-length EMM command with a length of $05.
In almost all cases, the begin date will probably be the date on which
subscription items were last expired so that only items which have been
created since that time will be expired. In addition, the expiration date
probably always be the date on which the command was broadcast so that items
which had expired as of that day will be deleted.
This is a fixed-length EMM command with a length of $05.
40 ;EMM command
00 ;New EMM address pointer
12 34 56 ;New shared address
78 ;New customer word pointer
01 ;New key type byte (see below)
11 22 33 44 55 66 77 88 ;New 15-byte block of key info
99 AA BB CC DD EE FF ; (see below)
Key type byte: The low 3 bits of this byte must be %001 for this EMM command
to be processed. If the high bit of this byte is clear, a type $07 data item
whose 3rd data byte is 00 will be selected (or created), otherwise a type $07
data item whose 3rd data byte is 01 will be selected (or created).
Key info block: This data is written to the second 15-byte block of key
data in the selected/created type $07 data item.
In the above example, a type $06 data item with a system ID high matching
the EMM's system ID high will be sought, and a type $07 data item with a
matching system ID high and a key type byte of 00 will be sought. If both
items are located (or if the type $06 item is located and a type $07 item
can be created), the type $06 item's EMM address pointer will be changed to
00, its shared address will be changed to $123456, and its customer data
pointer will be changed to $78. In addition, the second 15-byte block of key
info in the type $07 item will be changed to $112233445566778899AABBCCDDEEFF.
This is a fixed-length EMM command with a length of $16.
41 ;EMM command
0A ;New provider category
In this example, the card will search for the first type $02 data item whose
system ID matches the system ID of the EMM, then it will update its provider
category byte with the byte in the EMM command.
This is a fixed-length EMM command with a length of $02.
This command is used to change the public keys that are used to decrypt
the $03 command data. It takes two data fields: One byte to tell it which
key to change, and 8 bytes of new key data. The $42 command looks like this:
42 ;EMM command
05 ;Key ID byte (see below)
11 22 33 44 55 66 77 88 ;New key
Key ID byte: This byte is used to select which key is updated by the
$42 command, as follows:
The key types associated with the verify keys refer to the "key type byte"
of the type $07 data item (since this is the data type where verify keys are
stored).
In the above example, decrypt key 0 will be changed to 1122334455667788.
This is a fixed-length EMM command with a length of $0A.
43 ;EMM command
01 ;Key select byte (see below)
11 22 33 44 55 66 77 88 ;Updated key information
99 AA BB CC DD EE FF
Key select byte: This byte selects which of the 3 15-byte blocks of key
information in the type $07 data item whose system ID hi matches the system ID
hi of the EMM will be updated. The upper 5 bits of this byte are don't-case
bits, and the low 3 bits are encoded as follows:
In the above example, key block 1 of the matching type $07 data item will be
updated to 112233445566778899AABBCCDDEEFF.
This is a fixed-length EMM command with a length of $11.
Control byte: It seems as though this byte is used to control which 4-byte
blocks of the $1C byte data block are actually written to the 21-01 data in
the CAM. The breakdown of the bits appears to me to be as follows:
Note that the command will always have $1C bytes of data, regardless of how
many bytes are actually going to be written to EEPROM...blocks that aren't
written are simply ignored. Thus, if you wanted to set your box key to, let's
say 11 22 33 44 55 66 77 88, you could send either of the following EMM
messages:
44 ;EMM command
01 ;Control byte
xx xx xx xx xx xx xx xx ;Discarded data
xx xx xx xx xx xx xx xx ;Discarded data
xx xx xx xx 11 22 33 44 ;Discarded data+1st 4 bytes
; of IRD key
55 66 77 88 ;Last 4 bytes of IRD key
44 ;EMM command
C0 ;Control byte
xx xx xx xx xx xx xx xx ;Discarded data
xx xx xx xx xx xx xx xx ;Discarded data
xx xx xx xx 11 22 33 44 ;Discarded data+1st 4 bytes
; of IRD key
55 66 77 88 ;Last 4 bytes of IRD key
44 ;EMM command
40 ;Control byte
xx xx xx xx xx xx xx xx ;Discarded data
xx xx xx xx xx xx xx xx ;Discarded data
xx xx xx xx 11 22 33 44 ;Discarded data+1st 4 bytes
; of IRD key
xx xx xx xx ;Discarded data
44 ;EMM command
80 ;Control byte
xx xx xx xx xx xx xx xx ;Discarded data
xx xx xx xx xx xx xx xx ;Discarded data
xx xx xx xx xx xx xx xx ;Discarded data
55 66 77 88 ;Last 4 bytes of IRD key
Note that although the 2-pass key change _could_ fit entirely in a single
EMM, it's unlikely that E* would change the key that way...I only offer the
example to further illustrate the workings of the command.
This is a fixed-length EMM command with a length of $1E.
45 ;EMM command
C3 ;Key select byte (see below)
11 22 33 44 55 66 77 88 ;Updated EMM key information
99 AA BB CC DD EE FF 00
11 22 33 44 55 66 77 88
99 AA BB CC DD EE FF 00
Key select byte: This byte determines not only which EMM key type is
updated, but also which half of the EMM key is updated. It is encoded as
follows:
In the above example, a type $07 data item with a matching system ID hi and
a key type byte of 01 will be sought (and created if necessary). The upper
half of the EMM key in the located (or created) item will be updated with
the key information from the EMM command.
This is a fixed-length EMM command with a length of $22.
50 ;EMM command
00 01 38 F0 ;New ZIP code
In the above example, the ZIP code in the IRD information data item will be
changed to $000138F0, which is the hex equivalent of 80112.
This is a fixed-length EMM command with a length of $05.
3.2.26- EMM command $51
This EMM command updates the time zone in the IRD information data item if
the ZIP code in the IRD information data item falls between the two ZIP codes
sent with the EMM command. This command is formatted as follows:
51 ;EMM command
00 01 38 80 ;Lowest ZIP for this EMM
00 01 40 4F ;Highest ZIP for this EMM
E8 ;New time zone
In the above example, the IRD's time zone will be updated if the ZIP code
stored in the IRD information data item is between $00013880 and $0001404F,
inclusive (80000..81999). In this case, the time zone would be updated to
$E8 (mountain daylight time). Note that the high byte of the highest ZIP code
may not be greater than $7F, or the means by which the EMM command is handled
will fail and unexpected results may occur.
This is a fixed-length EMM command with a length of $0A.
52 ;EMM command
E8 ;New time zone
In the above example, the IRD's time zone will be updated to $E8 (mountain
daylight time).
This is a fixed-length EMM command with a length of $02.
53 ;EMM command
00 01 38 80 ;Lowest ZIP for this EMM
00 01 40 4F ;Highest ZIP for this EMM
03 ;Blackout byte to update
04 ;New blackout byte
In the above example, if the ZIP code in the IRD information data item is
between $00013880 and $0001404F, inclusive (80000..80199), byte 3 of the
blackout data in the type $06 data item whose system ID high matches the
system ID high of the EMM will be updated to be $04. Note that the "blackout
byte to update" must be less than $0C, since there are only 12 blackout bytes
stored in the type $06 data item.
This is a fixed-length EMM command with a length of $0B.
54 ;EMM command
03 ;Blackout byte to update
04 ;New blackout byte
In the above example, byte 3 of the blackout data in the type $06 data item
whose system ID high matches the system ID high of the EMM will be updated to
be $04. Note that the "blackout byte to update" must be less than $0C, since
there are only 12 blackout bytes stored in the type $06 data item.
This is a fixed-length EMM command with a length of $03.
61 ;EMM command
01 FE ;Email postmark date
7C A2 ;Email postmark time
08 ;Email status byte
01 ;Email ID
0D ;Overall email length
FF ;Email received bits (see below)
00 ;Offset to email text
0D ;Email text length
43 68 65 72 6C 69 65 20 ;Email text: "Charlie sucks"
73 75 63 6B 73
61 ;EMM command
01 FE ;Email postmark date
7C A2 ;Email postmark time
08 ;Email status byte
01 ;Email ID
0D ;Overall email length
01 ;Email received bits
00 ;Offset to email text
08 ;Email text length
43 68 65 72 6C 69 65 20 ;Email text: "Charlie "
61 ;EMM command
01 FE ;Email postmark date
7C A2 ;Email postmark time
08 ;Email status byte
01 ;Email ID
0D ;Overall email length
FE ;Email received bits
00 ;Offset to email text
05 ;Email text length
73 75 63 6B 73 ;Email text: "sucks"
Note that the "received bits" in the second packet fill the bits that
the first packet didn't, causing the value of the "received bits" byte to
become $FF. Note also that even though the second EMM assumes that the
first EMM has already been received, it includes redundant data from the
first EMM in case the first EMM was missed. Most likely, the first n EMMs
that make up an email would have bits 0 to n-1 set, progressively (1st EMM
would have bit 0 set, 2nd would have bit 1 set, and so on) in the "received
bits" byte, and the final EMM would have bits n through 7 set to complete the
"received bits" byte.
This is a variable-length EMM command whose length is equal to $0B plus the
value of the "email text length" byte.
62 ;EMM command
0C ;Callback period in hours
01 FE ;Callback date
7C A2 ;Callback time
00 ;Callback retry period
In the above example, the callback period will be set to $0C (12 hours),
and the regular callback date and time will be set to $01FE and $7CA2,
respectively. The callback retry period will not be altered. If the callback
period value had been $00, then rather than updating the "regular callback"
date and time, the EMM command would have updated the "immediate callback"
date and time. In addition, if the callback retry period value is anything
other than $00, the callback retry period will be updated with the value from
the EMM as well.
this is a fixed-length EMM command with a length of $07.
63 ;EMM command
18 00 55 51 21 2F FF FF ;New callback phone #
FF FF
In the above example, the callback phone number for the type $06 data item
whose system ID high matches the EMM's system ID high will be changed to
1-800-555-1212. Note that the maximum length of the phone number is 20
digits, and the phone number is padded to the right with Fs.
This is a fixed-length EMM command with a length of $0B.
64 ;EMM command
xx ;Length of IRD command
xx xx xx xx xx xx xx xx ;IRD command
The CAM will first compute an LRC for all of the bytes in the IRD command,
including the EMM command byte and the length byte and store that LRC in the
byte immediately following the IRD command. The CAM will then pad the command
to a total length of $40 bytes with random data. After all this, the CAM will
DES encrypt the entire EMM buffer using the IRD key, and set the "IRD command
waiting" bit in status byte 2 (returned by command $C0). An example of a
complete IRD command EMM might look like this:
64 ;EMM command
0C ;Length of IRD command
55 ;IRD command: Sequence #=00000001
00 00 00 01
06 ;IRD command: Filter for IRD
12 34 56 78 ; number 12345678
09 ;IRD command: Reset password and
; unlock receiver
81 ;EMM command
01 01 ;System ID
In the above exmaple, if type $06 and/or type $02 data items for a program
provider with a system ID of $0101 doesn't exist, it will create them and
populate them with default information. For example, if the above command
were executed by a CAM with a CAM ID of $11223344, the following data items
would be created:
Note that either data item, both data items, or neither data item may be
created by this command.
This is a fixed-length EMM command with a length of $03.
This command changes the effective system ID for the remainder of the EMM
commands in a given EMM. If IRD information (type $01) data and secondary
provider information (type $02) data does not exist for the new system ID,
EMM processing is aborted. This command is formatted as follows:
83 ;EMM command
41 01 ;New system ID
In the above example, the system ID for the remainder of the EMM commands
would be changed to $4101, provided type $01 and $02 items with that system
ID exist in the CAM's EEPROM.
This is a fixed-length EMM command with a length of $03.
84 ;EMM command
01 01 ;System ID to kill
In this example, all type $01, $03, $04, $05, $08, $09, $0A, $0B, $0C, and
$10 data items with a system ID matching the system ID in the EMM command
will be deleted. Note that the system ID in the EMM command must differ from
the system ID in the EMM itself. Also note that not only are type $04 items
whose source system ID matches the EMM command's system ID deleted, so are
type $04 items whose target system ID matches the EMM command's system ID.
This is a fixed-length EMM command with a length of $03.
85 ;EMM command
41 01 ;Target system ID
00 00 ;Min channel to alias
7F FF ;Max channel to alias
01 FE ;Last date of validity for this
; indirection information
86 ;EMM command
41 01 ;Target system ID
00 00 ;Min channel to alias
7F FF ;Max channel to alias
ROM3-based card:
ROM10-based card:
The reason the ROM2-, ROM3-, and ROM10-based cards have different EMM
commands for the same function is because the ROM2 cards and ROM3 cards have
different ROM code inside them. The code is very similar (see section 5,
inside NagraVision cards), but because it's not identical, a mechanism is
needed to ensure that code fragments that are calling routines in the ROM2 ROM
won't be executed on a ROM3 or ROM10 card, and vice-versa. When the code is
executed, the first instruction is always at address $81 in RAM.
This is the command that is used to perform EEPROM updates to the card.
This is accomplished by checking a special "sequence" byte (in ROM3 cards,
this byte is stored at $E050) to see if it has been loaded with a value that
indicates that the data in a particular Fx command is "next in line", and if
the value matches, the code fragment writes whatever data it can to EEPROM
and then updates the "sequence" byte. The final code fragment in an EEPROM
update generally hooks in the code that was added by all the other fragments
and updates the ascii firmware revision number in EEPROM.
In this example, only a CAM with a CAM ID of 11223344 will execute the
remainder of the EMM. This is a fixed-length command with a length of 7.
3.4.2- EMM filter commands $01..$20
If the EMM filter command is $01..$20, this tells the CAM that there are
three conditions that must be met for the EMM to be executed. First, the
CAM's shared access group (which is usually the same as the 3 high bytes of
the CAM ID) for the type $06 data item whose system ID high byte matches the
filter command's system ID high byte must match the data in the EMM command.
Second, the CAM's customer word pointer (which is usually the same as the low
byte of the CAM ID) must be in the range of cliques being addressed by the
EMM filter (lowest cust word ptr allowed = lowest clique times 8, highest
cust word ptr allowed = lowest clique times 8 + number of cliques times 8).
Third, the bit in the "CAM address bitmap" which corresponds to the CAM's
customer word pointer must be set. The format of this EMM filter command is:
In this case, in order for a CAM to execute the remainder of the EMM, its
shared access group for the system ID hi 01 must be 010203, and its customer
word pointer must be either $07 (enabled by the set bit in byte 0 of the CAM
address bitmap), $29 (enabled by the set bit in byte 5 of the CAM address
bitmap) or $FF (enabled by the set bit in byte 31 of the CAM address bitmap).
Note that an entire group of 256 CAMs are potentially addressed by this
filter. A similar filter for a CAM whose customer word pointer is $29 or $2F
could be done in fewer bytes like this:
01
01 01
01 02 03
05
41
Because this filter only intends to address two cards whose customer word
pointers are in a common clique, only a single byte of bitmap information is
required. This is a variable-length command with a length of $07 plus the
filter number (which is also the number of cliques being addressed).
In this case, the EMM will be executed if the CAM contains a type $02 data
item with a system ID of 0101 and a provider category no less than 5 but
no greater than 0A. Note that although the provider category field in the
type 02 data item is a single-byte field, the maximum provider category field
in this EMM filter command must be a two-byte value, because the routine in
the CAM that does the range-checking has a special case that gets executed
in the event the byte that immediately follows the first comparison value (in
this case, the minimum provider category) has its high bit set. Therefore,
in order to be able to check the entire 8-bit range of provider categories,
the maximum provider category value must be treated as a 16-bit number whose
high byte will always be 00 (actually, any value less than $80 would work,
but 00 will be the norm). This is a fixed-length command with a length of 6.
In this case, the EMM will be executed bu all cards with a master system
ID of 0101. This is a fixed-length command with a length of 3.
4: 21-xx data types
It's interesting to note that the "system type" field is pretty much the
same as the "system ID" field that appears in other data types, except that
in "system ID", the low bit of the high byte seems to be always set, while in
"system type" it seems always to be clear.
IRD status byte: Several status flags relating to the IRD and/or
subscription are passed in this byte as follows:
Bit Description
--- ------------------------------------------------------------
7 Subscription suspended (1=yes) if type $01, $02, $06, or $07
Item suspended if type $08, $09, $0A, or $0B
Email deleted if type $10
6 Callback performed for this item ($08..$0B only)
5 Impulse subscription channel ($08 only)
4 PPV watched if type $09..$0B
Email read if type $10
3 High priority (type $10 only)
2 Predefined message (type $10 only)
1 Data item compressed
0 PPV charge applies per unit time (1=yes) ($08..$0B only)
Time zone encoding: The time zone is expressed as an 8-bit signed integer
which represents the number of 15-minute ticks that need to be added or sub-
tracted from GMT. Thus, 00 is GMT, FF is GMT minus 15 minutes, etc. The
following table details CONUS time zones:
Note that NagraVision handles daylight savings time by simply adjusting the
time zone byte for all IRDs in areas that are affected by daylight savings
time, causing the time to shift an hour back in the fall/winter (on the last
Sunday in October, in fact) and an hour forward in the spring/summer (on the
first Sunday in April).
Note also that the data that is returned for a 21-01 request is NOT the
raw type 01 data: The IRD key field is omitted.
01 01 ;System ID
01 02 03 ;PPV Event ID
01 02 ;System ID of event provider
01 02 03 ;Rights identifier
01 02 ;Purchase date
Note that the service identifier here is the same type of service identifier
that is associated with data type $08.
01 01 ;System ID
01 ;IRD Status flag (see data type $01)
01 ;Date identifier (cluster number) (?)
01 02 ;Modification date
01 02 ;Begin date
01 02 ;End date
01 02 ;Rights date
As you can see, there's lots of information in the type $06 data that gets
used for billing, etc.
Note that when type $06 data is returned, key 0 and key 1 are omitted.
Note that the verify key in key set 1 is the one that's used to validate
most ECMs received by the EchoStar cards, but that for EMMs, the verify key
that goes with the selected EMM key is used to validate the decrypted EMM.
Also note that only the first byte of type $07 data is ever returned.
01 01 ;System ID
00 ;IRD status byte (see data type 1)
00 00 00 ;Rights identifier
00 ;String ID (Optional: 00=no string)
00 00 00 ;Impulse subscription price
00 00 ;Modification date
00 00 ;Begin date
4C 21 ;Expire date
4C 21 ;Rights date
00 00 ;Min. channel authorized by this
; packet
7F FF ;Max. channel authorized by this
; packet
80 00 ;Component (?)
FF ;Theme (?)
00 FF ;Theme extension (?)
00 ;Level (?)
Note that presenting this data to the IRD is not enough to receive
programming: the IRD will still depend on the CAM to provide the video
decryption keys, and if the CAM knows that a channel for which the IRD is
requesting information isn't subscribed, it won't return the proper keys.
01 01 ;System ID
01 ;IRD flags (see data type $01)
01 02 03 ;Rights identifier (pay-per-view
; event ID)
01 ;String ID (optional: 0=no string)
01 02 03 ;Impulse buy price
01 02 ;Modification Date
01 02 ;Begin Date
01 02 ;Expiration Date
01 02 ;Rights Date
01 02 ;Last date of operation on token
01 02 03 ;Credit in tokens
01 02 03 04 ;Debit in tokens
01 02 ;Min. channel authorized by this
; packet
01 02 ;Max. channel authorized by this
; packet
01 02 ;Component
01 ;Theme (lowest theme for this event)
01 02 ;Theme extension (highest theme for
; this event)
01 ;Level
01 01 ;System ID
01 ;IRD flags (see data type $01)
01 02 03 ;Rights identifier (pay-per-view
; event ID
01 ;String ID (optional: 0=no string)
01 02 03 ;Impulse buy price
01 02 ;Modification Date
01 02 ;Begin Date
01 02 ;Expiration Date
01 02 ;Rights Date
01 02 ;Last date of operation on token
01 02 03 ;Credit in tokens
01 02 03 04 ;Debit in tokens
01 02 ;Min. channel authorized by this
; packet
01 02 ;Max. channel authorized by this
; packet
01 02 ;Component
01 02 03 ;Pay-per-view number (lowest PPV ID
; for this event)
01 02 03 04 ;Pay-per-view extension (highest PPV
; ID for this event)
01 01 ;System ID
00 ;IRD flags
00 00 00 ;Pay-per-view event ID 000000..7FFFFF
01 ;PPV ID within card
00 02 99 ;Event price (BCD dollars+cents)
00 00 ;Purchase date
80 00 ;Event expiration date
00 ;Service string ID (optional: 0=no
; string)
00 00 ;Min. channel authorized by this
; packet
7F FF ;Max. channel authorized by this
; packet
80 00 ;Component (?)
00 00 00 ;Lowest PPV ID for this event
7F FF FF FF ;Highest PPV ID for this event
00 00 ;ECM odometer (allows decision as to
; whether or not enough of the event
; was watched to merit charging the
; user for it)
00 01 ;View start date
0F 51 ;View start time
Note that presenting this packet to the IRD is not enough to receive
programming: the IRD will still depend on the CAM to provide the video and
audio decryption keys, and if the CAM knows that a PPV for which the IRD is
requesting information isn't authorized, it won't return the proper keys.
This data type relates to the user's spending limit and credit with the
program provider. It's used to determine whether or not an impulse PPV
purchase will be allowed. The data breaks down as follows:
01 01 ;System ID
01 ;IRD status byte (see data type $01)
01 02 03 ;Rights identifier
01 02 ;Last date of operation on cash
01 02 03 ;Credit in cash
01 02 03 04 ;Debit in cash
01 02 ;Phone home threshold
01 01 ;System ID
01 ;IRD status byte (see data type $01)
01 ;Mail item ID within CAM
01 ;Received flags ($FF=received)
<var> ;Email data
It would appear that the information in these data items is linked to the
type $0B data items that actually enable the viewing of the PPVs through the
"PPV ID within card" field.
The encoded data bytes encode a single nibble of data into a 7-bit data
byte in which the lower nibble is the raw data, and the low 3 bits of the
upper nibble contain parity information about the data in the lower nibble as
shown below:
This type of encoding is called Hamming encoding (named after the guy who
invented it). It allows correction of any single-bit error in a byte. It's
not entirely clear why the guys who wrote the NagraVision code decided to do
this with the data headers in the ROM2 cards (and apparantly, they decided
it wasn't worthwhile, see section 4.3.2: ROM3 headers, below), since they
just store the data in raw format, with no way to correct it if a problem
should come up. In a ROM2 card, the data area should generally start at
$E933, meaning that at best, a ROM2 card can hold $06CD (1741) bytes' worth
of data items and headers. This number is actually quite small, but it is
necessary since almost all of the other EEPROM space is taken up by various
bug-catchers which have been installed in the EEPROM to correct problems
with the card's ROM-based code. It's pretty clear that Kudelski wasn't very
happy with this number, since they expended the time, effort, and money to
create the ROM3 version of the card, which incorporates most of the bug
fixes contained in the ROM2 cards' EEPROM, as well as other improvements
to things like the EEPROM data storage system.
Note that in an earlier version of this FAQ I incorrectly reported that
bytes 1 and 2 of the 4-byte header were an encoded version of the data type.
I'm not real sure what led me to that conclusion...I can only assume that I
must have been _really_ tired when I wrote it (and commented the CAM
disassembly to match). I've since had occasion to look over that piece of
code again, and noticed the error, which I still can't explain; the code is
really straightforward...I have no idea what would have caused me to make
that mistake.
The flags byte indicates the current "state of being" of the data item with
which it is associated. By looking at the value of the flags byte, the
card can hopefully figure out what addresses in EEPROM were being used by the
associated data item, and what was being done to the data item when the
problem occurred. The structure of the flags byte is as follows:
Each of the first 5 bits implies certain things about the other fields in
the data item, and if any of the low 5 bits of the flags byte is set, all of
the other bits below it should be set as well (for example, if bit 2 [data
written successfully] is set, then bits 1 and 0 should also be set, if the
flags byte is to be treated as valid. Assuming that we're examining a FLAGS
byte at address ADDR, based on the value of the FLAGS byte, we can assume the
following about the other data fields:
Header created successfully If this bit is set, it can be assumed that the
length byte is a valid one, and can be used to
calculate the position of the next valid data
item header. If this bit is set, recovery is
possible simply by writing a value of $0F to
the flags byte, indicating that the data area
is reusable. The card, however, goes a step
further: It erases the data field of the data
item to all 00s, then it erases the length
byte, followed by the FLAGS byte.
Data no longer in use If this bit is set, it indicates that the data
in this data item is no longer in use, and can
therefore be treated as reusable space. In
some cases, this bit indicates that the data
area of this data item has been filled with all
$00 bytes.
The length byte's value of "data item length+1" is derived from the fact
that it actually represents the total number of data field bytes that follow
the 2-byte header. The first byte of the data field contains the data item
type identifier, hence the +1.
When a ROM3 card is reset, it scans its EEPROM area, looking for data items
that appear to need to have some sort of recovery performed. If any such
items are found, the necessary recovery steps are taken to try and ensure that
the EEPROM is always "healthy". After data items that appear to have suffered
an interruption have had their recovery performed, the card checks through all
of the "linked" data items (type $11 data) to ensure that every type $11 item
that exists in the EEPROM has a link to a valid type $8, $9, $A, or $B data
item. The link is established through the "PPV ID within card" field of the
type $11 data item: It must match the "String ID" byte of a type $8, $9, or $A
item, or the "PPV ID within card" or "Service string ID" byte of a type $11
data item. Any type $11 items that are found to not have valid links are
erased.
As a final initialization step, the card goes through the EEPROM space and
converts all of the reusable (or unused) data space it finds into reusable
data items with lengths no longer than $FE bytes. Presumably, this is so that
the card can more easily search for data item space when a "write data item"
operation is performed.
Whenever a data item is created, the card will always attempt to ensure
that at least $2E bytes of data space remain in the EEPROM. Presumably, this
is so that a modification of up to $28 bytes of data can always be performed.
Lastly, in a ROM3 card, the data area generally should start at $E400. Note
that this number is "soft", and may change if a large number of bug-catchers
are installed in the EEPROM area.
==============================================================================
5: The backdoors
The start address for the EEPROM erasure must be set as with the D6 backdoor
command, below.
The end address is defined as an offset from the base address generated by
the "init" address set the first time this command is sent. An example of
this command would be:
Note that although the second form of this command theoretically allows up
to $FFFF bytes of memory to be dumped, dumping more than about $50 or so bytes
of data will result in a chained message sequence, whereby the host device
(that's you) must respond to each chunk of data as the card provides it. The
proper resposne to get the CAM to continue with the message depends on the
header for the most recently-received block, as shown below:
Received
NAD and PCB Correct response
----------- ----------------
12 20 21 80 00 A1
12 60 21 90 00 B1
The start address has two possible means of encoding. The first means,
illustrated above, causes the address pointers in the card to be initialized.
Five different possible values are useful for this:
Note that although the addresses are initialized to the absolute addresses
shown, the effective address for the first command will be the initialization
address plus xx, so a value of $9320 will result in the address being
initialized to $4000, and an effective address for that command of $4020.
Similarly, a value of $9438 will result in the address being initialized to
$E000, and an effective address for that command of $E038.
Once the address pointers in the card have been initialized using one of the
five constants above, the address bytes can be filled with an offset from the
address with which the pointers were initialized. Thus, if the pointers were
initialized to $4000 by sending $90 $00, if the next dump specifies an address
of $3040, the start address will actually be $4000+$3040, or $7040.
The start address has two possible means of encoding. As with backdoor
command A0 B0, the first means causes the address pointers in the card to be
initialized. The only useful initialization value for the write EEPROM
command is:
Addr Description
----- -------------------------------------------------------------
$00 I/O register
$01 Security register
$03 EEPROM control register
$04 Test status register
$06 Random number generator high byte
$07 Random number generator low byte
$0A Cryptoprocessor I/O byte 1
$0B Cryptoprocessor I/O byte 2
$0C Cryptoprocessor control byte 1
$0D Cryptoprocessor control byte 2
By default, the stack occupies the RAM space from $40 through $7F (the RSP
instruction resets the stack pointer to $7F). If the stack overflows, it
will wrap around, destroying the least-recently-used data on the stack.
However, there's no rule that says that the lower end of the stack can't be
used to store variables: The firmware just has to be written so that JSRs and
interrupts never nest deeply enough to destroy the variables that are stored
in stack space.
The processor's reset and interrupt vectors are as follows:
Addr Description
----- -------------------------------------------------------------
$4000 Reset vector. Execution starts here on reset.
$4008 SWI vector. SWI interrupt begins execution here.
$4010 NMI vector. Security interrupt begins execution here.
$4018 INT interrupt vector. Maskable interrupt begins execution
here.
Note that ST Micro has "recommended code" that they like to see placed at
the vector locations. If you get hold of the SECA ROM dump that's floating
around the 'net, you'll see code that's pretty much straight out of the ST
Micro manual at $4000..$401F.
START END
RAM SYSROM ROMA ROMB EEPROMA EEPROMB ADDR ADDR
--- ------ ---- ---- ------- ------- ----- ----
REGISTERS ? X X X X X 0000 001F
RAM X X X X X X 0020 021F
SYSROM X 2000 3FFF
ROMA X X X X X X 4000 5FFF
ROMB X X X X X X 6000 7FFF
EEPROMA X X X X X X E000 E7FF
EEPROMB X X X X X X E000 FFFF
EXECUTE X X X X X X
In this example, code may execute from any of the memory areas, and all
memory areas may read from all other memory areas, except for SYSROM, which
is only readable by code executing within the SYSROM area. In theory, this
mechanism should be able to provide a fair level of security for a smartcard
based on the 16CF54. Fortunately for us, the Nagra guys decided they wanted
to take advantage of the TSA instruction to embed parameters right in the
code, so their MACM setup is pretty weak. In fact, the only thing that's
protected is the system ROM area where the crypto libraries are stored.
From a hacking standpoint, the worst-case scenario, as I see it, for the
NagraVision MACM is:
START END
RAM SYSROM ROMA ROMB EEPROMA EEPROMB ADDR ADDR
--- ------ ---- ---- ------- ------- ----- ----
REGISTERS ? X X X X X 0000 001F
RAM X X X X X X 0020 021F
SYSROM 2000 3FFF
ROMA X 4000 5FFF
ROMB X 6000 7FFF
EEPROMA X E000 E7FF
EEPROMB X E000 FFFF
EXECUTE X X X X X X
In this example, code may execute from any of the memory areas, and no
memory area may read from any other memory areas, except for RAM, which is
allowed to read from everything except SYSROM. In theory, this arrangement
doesn't restrict us any more than the best-case scenario (see above), since
we'd probably use RAM-based code to get a byte of data from the ROM or
EEPROM before sending it out the serial port anyway.
Finally, new information released to the public (and which I've verified
personally) indicates that there's a bug in the 16CF54 silicon. It seems as
though the addressing hardware for the RAM in the card doesn't fully decode
the address being requested, and as a result, reads and writes to RAM at
addresses above $021F wrap to $0020. So, for example, executing a STA $1FF,X
instruction with X=$41 will result not in a useless write to $240 (which isn't
a valid RAM address), but rather a perfectly fine write to $0040. Although
this might not seem terribly useful, this in fact allows a very handy backdoor
into the EchoStar cards: Due to the fact that the serial I/O buffer is located
where it is, it's possible to take advantage of this shortcoming and cause the
"receive message" routine to write received serial data into the stack area,
where you could then replace the return address that's normally there (to get
back to the main idle loop from the interrupt-driven message receive routine)
with an address that would cause raw code that you sent as part of your
message to be executed. Obviously, this allows lots of interesting things to
happen, such as dumping the EEPROM-based password, which would effectively
allow unlimited access to the factory backdoors.
6.2- 288-01 vs. 288-02 vs. 288-09, or ROM2 vs. ROM3 vs. ROM10
There are three known versions of the NagraVision smartcard. They can be
identified by a number printed on the back of the card (the side with the
contacts) in fine print. If you hold the card so that the contacts are at the
top, near the bottom right corner of the card, you should see a release code.
This should be a 288-xx number or an A20xx number. It seems like xx is the
release number in both cases. Cards with a release of 288-01 are referred to
as ROM2 cards, while cards with a release of 288-02 and higher, as well as all
of the A20xx cards that I'm aware of are ROM3 cards. Presumably, there was a
ROM1 as well, but was so bad that it never saw the light of day.
In September of 2000, I became aware of a new version of Nagra's ROM code:
ROM10. The first cards I was told use this code are EchoStar cards marked
"288-09". From examination of photomicrographs of the ROM10 die, it appears
that the ROM10 cards are based on the ST19 series of microcontrollers.
The 288-01 cards were the first release. Their code was quite buggy, and
had a large amount of patched code (and code that just wouldn't fit in the ROM
area) in the EEPROM (about $900 bytes). Most of the NagraVision ROM dumps
you'll see on the 'net came from these cards.
The later cards have basically the same code, but with all of the fixes
that were in the 288-01 EEPROM area integrated back into the ROM.
Although the code in the two cards does the same thing (and in many cases
is identical), because of the differences in lengths of some of the routines,
the ROMs are not identical. This is the reason for separate EMM "execute
code" commands.
It's not entirely clear to me why there are so many releases of cards that
are dedicated to ExpressVu. My suspicion is that each came pre-loaded with
different data in the EEPROM area.
These cards are used by ExpressVu, Sky Vista, Via Digital, and several other
services. Check your cards...you never know what you might find. Each
service should have a unique system ID (though EchoStar and Sky Vista seem to
share the system ID of 0101, probably because Sky Vista is actually operated
by EchoStar (with Loral)). Known system IDs are as follows:
ID Provider
----- -----------------------------------------------
$0101 EchoStar
$0101 Sky Vista
$0901 ExpressVu
$4101 Via Digital (Spain)
7: Glossary
7.1- Glossary
This is just a list of terms that are frequently used when talking about
EchoStar, NagraVision, DVB, and the related hacks.
110: The orbital slot located at 110 degrees west longitude. EchoStar has
one satellite (EchoStar V) in this location. EchoStar VIII, which is
scheduled for launch in early 2002, will be placed in this slot,
augmenting the programming provided by EchoStar V.
119: The orbital slot located at 119 degrees west longitude. EchoStar has
three satellites (EchoStar I, II, and IV) in this location. EchoStar
plans to replace EchoStar I, which is nearing the end of its useful
life, with the recently-launched EchoStar VI. EchoStar VII, which is
planned for launch in early 2002, will be placed in this slot, replacing
EchoStar II, which is also nearing the end of its useful life.
121: The orbital slot located at 121 degrees west longitude. EchoStar does
not currently have a satellite located in this position, but EchoStar IX.
which is scheduled for launch in mid-2002, will be located in this
position.
148: The orbital slot located at 148 degrees west longitude. EchoStar does
not currently have a satellite permanently located in this position, but
it's likely that a future satellite will go here. In the meantime,
however, EchoStar uses this orbital slot as a test slot for newly-
launched satellites. Currently, EchoStar VI is located in this slot
undergoing testing prior to being moved to the 119 slot where it will
replace the aging EchoStar I.
175: The orbital slot located at 175 degrees west longiture. EchoStar does
not currently have a satellite in this location, but it does own the
right to control 22 out of a possible 32 transponders that may operate
from this slot, should a satellite (or satellites) ever be positioned
there.
2313: A microcontroller that's somewhat popular for use in EchoStar hacks.
Its full part number is AT90S2313. It's one of the AVR family of
microcontrollers from Atmel. Primarily used only in the dual-AVR
hack, but also seen in some versions of the EchoStar logger. See also
AVR, Atmel, dual-AVR, logger.
61.5: The orbital slot located at 61.5 degrees west longitude. EchoStar has
one satellite (EchoStar III) in this location. It is likely that
EchoStar III will be replaced or augmented sometime in 2003, possibly
by EchoStar X.
6805: A microcontroller whose instruction set is nearly identical to the
instruction set in the microcontroller used in the NagraVision
smartcards. See also ST16CF54.
8515: A microcontroller that's very popular for use in NagraVision hacks. Its
full part number is AT90S8515. It's one of the AVR family of
microcontrollers manufactured by Atmel. See also AVR, Atmel, Xfile,
Jethro, logger.
Able: An EchoStar internal code name for one of their IRD platforms. IRDs
based on this platform include the model 2000.
Atmel: The company that manufactures one of the more popular microcontroller
families for NagraVision hacks, See also AVR.
ATR: Answer To Reset. A string of data sent by an ISO7816-compliant
smartcard when it comes out of reset. The data tells the host device
what communication parameters the card expects, what type of card it
is, and so on.
Attacker: A person, program, or entity that is attempting to breach some
form of security. In the context of NagraVision hacking, an
attacker is someone who wants to circumvent the card's security,
either for the purposes of watching TV for free or just for looking
at the code in the ROMs.
Autoroll: 1: A hack that can update itself to include current decryption
keys or other dynamically-changing information that the hack
requires in order to function.
2: The process of determining current decryption keys or other
dynamically-changing information that a hack requires in order
to function.
AVR: A family of microcontrollers manufactured by Atmel. They are very
popular for use in EchoStar hacks because of their high ratio of
instructions per clock cycle as compared to other microcontrollers.
AVR2: A commercial enabler-style EchoStar hack. It does not auto-roll, and
requires frequent key updates using TALK or WINTALK. See also
enabler, talk, and wintalk.
Baker: An EchoStar internal code name for one of their IRD platforms. IRDs
based on this platform include the model 3000, 4000, 5000, and the
JVC HM-DSR100 DVHS unit.
Batt card: A commercial and freeware emulator-style enabler NagraVision hack.
It was based on the batt card hacks for the DSS 'F' card. It is no
longer viable because the commercial dealer who was trying to
make money with it found that too many people had batt cards
lying around from the F card days and were simply applying his
code to their cards without paying him any money, so he stopped
supplying keys for it.
Blocker: A freeware wedge-style NagraVision semi-hack. It doesn't actually
provide unlimited TV and PPVs as with most other hacks...instead,
the blocker tries to prevent the normal NagraVision EMM messages
which would expire a subscription from getting to the card. In
theory, someone who is using a blocker should be able to cancel
their subscription to EchoStar (or ExVu or SkyVista or ...) and have
their card continue to work. In practice, however, the blocker is
impractical because the same type of EMM messages that expire
subscriptions also carry key updates, to the blocker prevents the
card from getting the information it needs to be able to properly
decrypt the ECM messages that it receives. Some more recent blockers
have attempted, with limited success, to add some intelligence to the
logic that blocks the EMM messages, but the results so far have been
less than a total success. See also wedge, EMM, ECM.
Bones: An EchoStar internal code name for one of their IRD platforms. IRDs
based on this platform include the model 1000.
CAM: Conditional Access Module. Strictly speaking, the conditional access
module is the portion of any DVB-compliant system which allows the
set-top box to decide whether or not to allow the user to view a given
program. For some DVB systems, the CAM is a two-piece unit, with one
piece resembling a PCMCIA card, and the other being a smartcard which
fits inside the PCMCIA card-type piece. For the NagraVision system, the
CAM is the smartcard.
Charlie: Charlie Ergen, CEO of EchoStar Communications, among other
companies. He's the guy who's getting rich off EchoStar.
Charlie Chat: Charlie Ergen's periodic elbow-rubbing with the public. Every
now and again, he does an hour-long broadcast wherein he tells
the EchoStar subscriber base (those of them who tune in,
anyway) how much he appreciates their business, how great
everything is at EchoStar, and so on. Basically, just PR.
Cheyenne: The city in Wyoming where EchoStar's uplink center is located. See
also Wyoming, uplink center
Clipper: An EchoStar internal code name for one of their IRD platforms. IRDs
based on this platform include the model 2700 and 3700.
Colorado: The state where EchoStar is headquartered.
CRC: Cyclic Redudancy Check. A checksum method specified by the ISO-7816
T=1 protocol. The means by which a CRC is computed is fairly complex
and we won't go into it here because the NagraVision smart cards use the
LRC checksum method. See also ISO-7816, LRC.
Cutter: An EchoStar internal code name for one of their IRD platforms. IRDs
based on this platform include the model 4700.
DES: Data Encryption Standard. The encryption scheme used to obscure the
data in NagraVision's ECM messages as well as the return of the data
extracted from the ECMs to the IRD. See also ECM.
DirecTV: A company owned by General Motors and (at one time, anyway), coveted
by Rupert Murdock. DirecTV is a digital satellite television
provider that is in direct competition with EchoStar in the United
States. Until late 2000, DirecTV IRDs all used CAMs provided by
News Datacom (NDC), and incorporating NDC's VideoGuard security
system to secure their programming. In late 2000, however, DirecTV
IRDs began to appear with NagraVision CAMs. Presumably, this shift
to NagraVision was the result of NDC's botched job on DirecTVs
second-generation satellite cards, known as the 'H' card. DirecTV's
satellite system is generally known as "DSS". See also DSS, H card,
News Datacom, VideoGuard.
DishNetwork: The programming branch of EchoStar. EchoStar provides the
receivers, DishNetwork provides the programming, much like
RCA, Hughes, Sony, and others provide DSS receivers, but
DirecTV provides the DSS programming. In theory, DishNetwork
programming is available only to American subscribers, but in
practice, it's also available to viewers in Canada, Mexico, and
pretty much most other countries north of the equator and on
our side of the planet.
DishPlayer: One of the latest IRDs from EchoStar. The DishPlayer provides
not only satellite TV programming, but also web access and digital
time-shifting of programming: The DishPlayer has an integrated
hard drive which can be used to capture the MPEG data stream
coming from the satellite so that a user can, in effect, "pause" a
broadcast in progress while they make a sandwich, walk the dog,
strain the 'tatos, or whatever.
DSS: Digital Satellite System. The digital satellite programming service
provided by DirecTV. See also DirecTV, H card.
Dual-AVR: A freeware emulator-style enable NagraVision hack which used two
2313s: One to communicate with the IRD, and the other to perform the
cumbersome decryption functions. See also emulator, enabler, Atmel,
2313.
DVB: Digital Video Broadcasting. A standard established by the European
Broadcasting Union which specifies various means for digital transmission
of video signals, control over access to said signals, and so forth. If
you have some time on your hands and their website is up, you might want
to try going to http://www.dvb.org and seeing if you can download any
of their standards...they're great for battling those bouts with
insomnia.
E3M: EchoStar 3M. A commercial hack for the NagraVision system that involves
reprogramming a real NagraVision smartcard so that it will always return
valid channel decrypt keys to the IRD in response to an ECM.
Unfortunately, because of the architecture of the NagraVision smartcard's
microcontroller, this hack is unstable because protecting it from
attacks would prevent it from being able to autoroll. See also autoroll.
E*: A common abbreviation for EchoStar.
EchoSphere: One of many companies owned by Charlie Ergen. See also Charlie.
EchoStar: Yet another company owned by Charlie Ergen. EchoStar is responsible
for the design and manufacture of most of the IRDs that you see used
with the DishNetwork satellite programming service as well as IRDs
used for DVB satellite systems in other countries, including such
services as ExpressVu, VIA Digital, and Sky Vista. EchoStar also
makes FTA DVB receivers. See also Charlie, ExpressVu, VIA Digital,
Sky Vista, DishNetwork, FTA, and DVB.
ECM: 1: Entitlement Control Message. A message which contains the information
necessary to allow the IRD to decode an encoded datastream for some
period of time. The IRD sends the ECM to the card, the card extracts
the necessary information, then returns the data to the IRD if it thinks
the user should be allowed to watch the program that the IRD is trying
to decode. This term was coined by the DVB standards committee. For
NagraVision systems, command $03 is an ECM message. See also IRD.
2: Electronic Counter Measure. An attack sent by EchoStar and/or Nagra,
the intent of which is to disable a hack or otherwise render it
inoperable.
Unfortunately, the two very diverse definitions for ECM here often cause
a great deal of confusion. For this reason, it's generally preferable
to refer to an Electronic Counter Measure as an attack.
EMM: Entitlement Management Message. A message which contains the information
required to transfer subscription information and EEPROM updates to the
CAM. For NagraVision systems, command $00 contains most EMMs.
Emulator: 1: A hack which performs all (or a significant subset) of the
functions of a real CAM.
2: A hack which simulates the function of the MCU inside a smartcard
and uses an image of a genuine CAM to do most of its work, but which
also has sufficient smarts to substitute spoofed subscription
information to the ROM code that it is executing so that it will
think that the user is authorized to view every channel avaiable
to the CAM.
Enabler: A freeware wedge-style or stand-alone hack. For NagraVision, the
enabler can either be a stand-alone device (XFile is an example of
this) or a device which also requires a real CAM to operate (the
Jethro enabler is an example of this). An enabler's real job is to
decode ECMs and return the decrypted control words when the IRD next
sends a $13 command. See also Jethro, XFile, batt card, wedge,
emulator.
ExpressVu: A digital satellite service provided to Canadian residents.
ExpressVu uses IRDs, antennae, and CAMs provided by Nagra.
FTA: Free-to-air. A satellite television or audio broadcast which is not
a subscription service.
GAP: General Access Plastic (or Generic Access Plastic). A commercial
emulator-style enabler hack for NagraVision. GAP is basically XFile in a
smartcard. The MCU used in the GAP is a PIC 16C622A. See also XFile.
H card: The second generation of access cards used with the DirecTV digital
satellite system. H cards were produced by News Datacom (NDC), and
were based on the Siemens SLE44 series of smartcard controllers. The
H cards' firmware was very poorly written, not well thought out, had
many bugs that were exploited by DSS hackers, and was based on an
architecture that made counterattacks against hacked cards very
difficult. As a result of these deficiencies, DirecTV was widely
hacked. The follow-up to the H card was the HU card, which was based
on the Siemens SLE66 series of smartcard controllers, and which was
basically just a somewhat enhanced version of the H card,
incorporating many of the security fixes applied to H cards via
EEPROM update in the field. See also NDC, Siemens, SLE44, SLE66.
HTS: Houston Tracker Systems. Yet another of Charlie Ergen's companies. See
also Charlie.
Internal mod: A NagraVision hack which has been made completely internal to
the IRD in an effort to improve the aesthetics of the hack (most
NagraVision hacks involve a PC board hanging out of the IRD's
CAM slot). XFile is the most commonly internalized NagraVision
hack. See also XFile.
IRD: Integrated Receiver-Decoder. The set-top box which takes the
downconverted signal from the LNB and converts it to video and audio
for your enjoyment.
ISO: International Standards Organization. The standards organization that
established the ISO-7816 protocol used by most of the smartcards on the
planet today, including the CAMs used by NagraVision. See also ISO-7816.
ISO-7816: The international standard for interfacing with smartcards. The
ISO-7816 includes standards relating to the physical properties of
smartcards (including susceptibility to radiation, bendability,
contact locations, etc.), the electrical specifications, and
communications protocols. The ISO-7816 standard is in several
parts, but the most relevant to anything you're likely to want to
do is ISO-7816-3. It's not a terribly well-written standard, but
understanding it is pretty important for doing any serious hacking
with smartcards in general, so you should probably look for it...
there are typically several web sites with links to it or local
copies of it.
Jethro: A freeware enabler-style NagraVision hack. In particular, the Jethro
enabler is a wedge-style hack, because it relies on a real CAM to
handle most commands coming from the IRD, and the enabler itself only
deals with specific commands (like $03, $13, $21-08, $21-0B, etc.).
See also wedge, enabler.
Karl Osen: One of the guys at Kudelski who wrote the code in the NagraVision
cards. See also Marco Sasselli.
Key: A set of bytes used to encrypt or decrypt a message. The key and a
block of data to be encrypted or decrypted are fed into an encryption
or decryption routine, and the result is encrypted or decrypted data.
Key change: The process of altering the key used to encrypt or decrypt a
message. For our purposes, a key change will typically refer to
the changing of one of the keys that can be used to decrypt ECMs.
The EchoStar/Nagra system allows selection of one of two keys
(called KEY0 and KEY1) as the decryption key for a given ECM. If
the current key being used to encrypt ECMs is KEY0, EchoStar/Nagra
can change KEY1 without affecting the video decryption process,
and when they're pretty sure most valid subscribers' cards have
accepted the new KEY1, they switch the ECMs to use KEY1 for
decryption. It is the frequency of key changes that make all
current publicially-available NagraVision hacks cumbersome to use.
See also DES.
Kudelski: See S.A. Kudelski.
Littleton: The city in Colorado where EchoStar is headquartered.
LNB: Low-Noise Block. Technically, a specific circuit within the horn that's
mounted on the end of a digital satellite antenna, but more commonly used
to refer to the whole signal horn. A dual-LNB antenna has two connectors
on the horn, each of which can supply a distinct signal to an IRD or
multi-dish switch.
Logger: 1: A wedge-style device whose function is to eavesdrop on the data
being transferred between and IRD and smartcard. See also wedge.
2: A piece of software running on a host computer which takes the
data provided by (1) and saves it to a file for later examination.
The software may or may not filter the data so that only unusual or
otherwise interesting information is saved.
LRC: Longitudinal Redundancy Check. A checksum method specified by the
ISO-7816 T=1 smartcard communication protocol. The LRC of a given
message is computed by XORing all of the other bytes of the message
together. XORing all of the bytes of a message with an LRC appeneded to
it would produce a result of 0. Another possible checksum method that
can be used with the T=1 protocol is the CRC protocol. See also CRC,
ISO-7816.
Marco Sasselli: One of the guys at Kudelski who wrote the code in the
NagraVision cards. See also Karl Osen.
MECM: A further layer of encryption present in the NagraVision cards, whereby
once a $03 command is decrypted, the key data within is further decoded
by XORing it with data that had been transferred to the CAM in a
previous $02 command. EchoStar began using the MECM extension in
November of 2000.
Multi-dish switch: A device which allows one or more IRDs to be connected to
more than one antenna. This is critical for EchoStar,
because EchoStar splits their programming between
satellites in more than one orbital slot such that their
core programming can be received from satellites in one
slot, local-into-local programming can be received from
satellites in another, and specialty programming can be
received from satellites in a third or fourth slot. At
present, EchoStar offers multi-dish switches that can
multiples 2 dishes to 1 IRD (the SW21), 2 dishes to 2 IRDs
(the SW42), and 3 dishes to 4 IRDs (the SW64) See also
slot, 110, 119, 148, and 61.5.
Nagra: Short for "NagraVision". Many people (myself included) refer to the
makers of the EchoStar smartcard as Nagra or NagraVision, even though
the actual name of the company that produced the EchoStar smartcard is
S.A. Kudelski. See also NagraVision.
NagraVision: The name of the conditional access system used by EchoStar (and
many other digital satellite service providers). It was
developed by S.A. Kudelski (a Swiss company), and has been
licensed to each provider that uses it. As part of the security
of the system, there are certain aspects of the encryption
schemes and messaging that are (theoretically, anyway) known only
to employees of S.A. Kudelski.
News Datacom: The company that produced the original smartcards used with
DirecTV's DSS digital satellite programming service. News
Datacom is frequently abbreviated NDC. See also DirecTV,
VideoGuard.
Nipper: A hacker who was involved in much of the early release of information
about the EchoStar/NagraVision conditional access system. If the
CAM EEPROM dumps that have been released on the internet are to be
believed, then the guys at S.A. Kudelski are already familiar with
Nipper (or someone else called Nipper), because there is ASCII text
inside the Rev313 and higher EEPROM images that reads "Nipper is a
buttlicker", which leads me to believe that for one reason or another,
the people at Kudelski don't like him very much. See also ScP.
OTP: An acronym for One Time Programmable. This refers to a type of memory
(usually PROM) which comes from the factory in its erased state, and in
which, any bit that is programmed to the inverse of its erased state may
never be returned to its erased state. In some cases (such as the
NagraVision smartcards), some ranges of EEPROM are treated as OTP (by
causing the address logic to select whether Vpp may be applied to a
cell when an erase operation is attempted. This is to allow some areas
of the card to be written one (usually by the issuer, or as a test during
manufacturing), but never again. The 'erased' state of a bit varies,
depending on the particular implementation of PROM or EEPROM, but in the
NagraVision smartcards, their EEPROM implementation causes the erased
state of a bit to be '0'. This means that any '0' bit in the OTP area
can be programmed to a '1', but '1' bits in the OTP area may never be
erased to a '0'. Note: In this case, 'never' is an exaggeration: In
theory the bits could be erased, but extreme measures would be required.
Permuted key: A DES encryption/decryption key which has already passed through
the initial permutation algorithm. See also DES, raw key.
Pirate Girl: The name by which many hackers refer to the woman who did most
of the announcements on the EchoStar Pirate channel. This was a
channel which EchoStar began to broadcast shortly after a lot of
freeware hacks became available which allowed hackers to view
channels on the EchoStar system that were not available to normal
EchoStar subscribers. The main intent of the Pirate channel
was to convince the hackers that they were awful, awful people
who should repent and pay for their subscriptions.
PPV: Pay-Per-View. An event (or group of events) which is presented to the
viewer at a fixed cost for a single viewing (or single day of viewing).
The conditional access system that the NagraVision system uses transfers
PPV information to and from the CAM using commands $01, $41, $42, and
data types $0B, $0C, and $11.
Raw key: A DES encryption/decryption key which has not yet been passed through
the initial permutation algorithm. See also DES, permuted key.
ROM2: The name of the ROM image inside 288-01 NagraVision cards.
ROM3: The name of the ROM image inside 288-02 and later NagraVision cards.
ROM10: The name of the ROM image inside 288-09 NagraVision cards.
S.A. Kudelski: The name of the Swiss company which produced the NagraVision
conditional access system, which is the conditional access
system used by EchoStar and many other satellite systems
worldwide.
Scenix: The manufacturer of a microcontroller which was purported to have been
used in an auto-roll hack for NagraVision. The Scenix microcontroller
is basically a very high-speed knock-off of the Microchip PIC 16C54 or
16C57, with a few additional instructions and a larger stack. The
big advantage of Scenix microcontrollers is that they're available
rated to run at speeds up to 100 MHz.
ScP: Swiss Cheese Productions. The name of a group (or perhaps a single
individual) which was responsible for much of the technical information
initially released pertaining to the EchoStar/NagraVision conditional
access system and CAMs. See also Nipper.
SGS Thomson: The name of the company that produced the smartcard MCU used in
the EchoStar/NagraVision smartcards. See also ST Micro.
Siemens: The name of the company that produced the smartcard MCU used in the
second- and third-generation DirecTV/NDC smartcards.
Sky Vista: The name of a digital satellite service available to subscribers
in the United States, Puerto Rico, and other territories in the
Carribean. Sky Vista doesn't offer a very large selection of
programming, but they do offer a lot of specialty Ethnic channels.
They're really only mentioned here because, being operated by
EchoStar (with Loral), they use the same CAMs and IRDs as
EchoStar.
SLE44: A family of smartcard microcontrollers manufactured by Siemens. The
SLE44 is, at heart, a RISC processor with a unique instruction set
(probably known to few people outside Siemens), but which is made thru
the use of microcode to emulate an 8051 microcontroller. This is the
family of smartcard microcontrollers that was used in second generation
DSS smartcards. See also News Datacom, Siemens.
SLE66: A family of smartcard microcontrollers manufactured by Siemens. The
SLE66 is, at heart, a RISC processor with a unique instruction set
(probably known to few people outside Siemens), but which is made thru
the use of microcode to emulate an 8051 microcontroller. This is the
family of smartcard microcontrollers that was used in third generation
DSS smartcards. See also News Datacom, Siemens.
Slot: A geosynchronous orbital position where satellites may be stationed for
an indefinite period of time to provide a fixed location from which to
brodcast signals to the Earth. In our case, these signals would be
digital television and/or audio programming.
ST16: A family of smartcard microcontrollers manufactured by ST Micro. The
ST16 family of smartcard MCUs have a processor core that is basically
a slightly-modified 6805 and some additional peripherals to enhance
the card's security, provide high-speed math capability, and so on. See
also ST16CF54, ST19, ST Micro.
ST16CF54: The smartcard microcontroller used in ROM2 and ROM3 NagraVision
smartcards. See also ST Micro, ST16, ST19, ST7.
ST19: A family of smartcard microcontrollers manufactured by ST Micro. The
ST19 family of smartcard MCUs have a processor core that is based on the
ST Micro ST7 MCU and some additional peripherals to enhance the card's
security, provide high-speed math capability, and so on. It's likely
that this is the microcontroller family used in ROM10 NagraVision
smartcards. Note that like the ST16 series, the ST7/ST19 MCU core is
basically an enhanced 6805 (though the ST7/ST19 is much more heavily
augmented than the ST16). See also ST16, ST7, ST Micro.
ST7: A family of microcontrollers produced by ST Micro. Their MCU core is a
vastly improved 6805 with additional addressing modes and additional
registers. It is the MCU core on which the ST19 family of smartcard
MCUs is based.
ST Micro: The name of the company that produced the smartcard MCU used in the
NagraVision smartcards. ST Micro is really just a new name for SGS
Thomson.
SW21: A 2-dish-to-one-IRD antenna switchbox sold by EchoStar (21=2 inputs (one
for each dish, since only one receiver), one output).
SW42: A 2-dish-to-two-IRD antenna switchbox sold by EchoStar (42=4 inputs (two
for each dish, since more than one receiver), two outputs).
SW64: A 3-dish-to-four-IRD antenna switchbox sold by EchoStar (64=6 inputs
(two for each dish since more than one receiver), four outputs).
SWAJ: A 2-dish-to-one-IRD antenna switch sold by EchoStar. The SWAJ is really
just a relay which physically connects one antenna or the other using
a signal supplied by the IRD's accessory jack. (AJ=accessory jack).
Swiss Cheese Productions: See ScP.
Talk: The name of a PC-based host program which is used to upload key updates
and patches to the commercial GAP, AVR2, and E3M hacks. There is a
windows version of this program called WinTalk.
Uplink center: The central location from which all of a program provider's
programming and control information is managed. In addition,
the uplink center is usually also the location from which the
various datastreams are uplinked to the programming provider's
satellites, as well as the location from which the programming
provider receives the various signal feeds from their original
sources (ie., when EchoStar broadcasts HBO, the HBO feed isn't
sent directly to EchoStar's satellite by HBO. Instead, HBO
uplinks their signal to a satellite where they have leased
transponder space (in this case, HBO's digital uplink goes to
Galaxy 1R at 133 degrees west). HBO's signal is then received
from Galaxy 1R by the dishes at the EchoStar uplink center.
HBO's signal is then descrambled (most actual channel providers
scramble their feeds in one way or another), converted into
the DVB stream required by EchoStar's IRDs, rescrambled using
a key generated either by EchoStar or Nagra, then uplinked to
one of EchoStar's satellites (in this case, it's either
EchoStar I, II, or IV at 119 degrees west). That signal is
then beamed back down to earth where it's picked up by your
small dish and converted into moving pictures on your
television screen, as if by magic.
Valid hash: An 8-byte signature that is used to verify the authenticity of
an EMM or ECM. For further information about the valid hash,
see section 7, "Encryption"
VIA Digital: The name of a digital satellite service available to subcribers
in Spain (and probably most of the rest of Europe and northern
Africa). They're mentioned here because they use IRDs and
antennae provided by EchoStar and CAMs provided by Nagra.
VideoGuard: News Datacom's name for their digital video encryption and
security system. The most unique feature of the VideoGuard system
is its use of a zero-knowledge truth (ZKT) algorithm to allow the
IRD to decide whether or not the CAM is actually a genuine
NDC-produced device. Although Kudelski would like to incorporate
such an algorithm in the NagraVision system, they are unable to
do so because patents governing the use of ZKT algorithms are
held by News Datacom and its employees. See also ZKT.
Wedge: A style of hack or other device which involves a PC board that plugs
into the smartcard slot on the IRD and into which a CAM is plugged.
Wedge-style hacks offer an advantage not generally available to most
other hacks: Because they have a genuine CAM plugged into them, they
have the ability to use the CAM to perform complex tasks that would
be otherwise difficult to deal with in their own microcontroller.
Wintalk: The windows-based version of Talk. See also Talk.
Wyoming: The state where EchoStar's uplink center is located. See also
Cheyenne, uplink center
Xfile: A freeware emulator-styler enabler hack for NagraVision. Xfile runs in
an Atmel 90S8515 microcontroller, and attempts to mimic most known
commands of the genuine NagraVision CAM. Newer versions of Xfile
include such features as a keypad for entry of updated keys as they
become available, enhanced reset circuitry that allows them to work
with a wider range of EchoStar receivers, and so on.
ZKT: An means by which two entities (in our case, an IRD and a CAM) can
independently verify the authenticity of the other without divulging
data which would allow an attacker to pose as either entity and reliably
forge an authentication for the other entity. Patents governing ZKT
algorithms are held by employees of News Datacom, and as a result, ZKT
technology is incorporated into News Datacom's VideoGuard system, but
cannot be incorporated into Kudelski's NagraVision system. See also
NagraVision, News Datacom, S.A. Kudelski, VideoGuard.
8: Encryption
http://www.thoic.com/keyblitz/html/tkp__the_des_document.html
Unfortunately, that page has now moved, and I don't know where it is. If
you know where it is, please let me know.
Also note that the term "encryption" here will mean either encryption or
decryption, since DES and EDES are essentially symmetric algorithms.
It's pretty easy to understand how one might draw the conclusion that the
ECM encryption algorithm isn't DES. The routine as it was implemented in
publically available source code (and, one must conclude, the CAM) has been
optimized for size and for speed (in the AVR, anyway...in the CAM, speed seems
to bave been the major motivating factor), and as such, there are a couple of
things that obscured the origin of the algorithm.
-With DES, the data to be encrypted is broken into a left half and a right
half, with the right half being bits 0 through 31, and the left half being
bits 32 through 63. These bits are then passed through an initial
permutation which effectively interleaves the bytes. With EDES, the data
to be encrypted is operated upon in an interleaved fashion, simplifying
the initial permutation and making it faster.
-With DES, the key is split into left and right halves, each of which is
rotated either 1 or 2 bits to the left, depending on the round number, the
halves are put back together, and the resultant 56-bit key is passed
through a permutation which jumbles the bits. With EDES, the permutation
and rotation are combined into a single routine, making it faster.
-With DES, there are 8 64-byte s-boxes which are used to perform a
substitution on the data being encrypted. This arrangement is not terribly
efficient, however, since the values are only 4 bits long each. With EDES,
to save some space, the 8 64-byte s-boxes were compacted into a single
256-byte table, each entry of which contains an entry for DES s-box n in
the lower nibble, and an entry for DES s-box n+4 in the upper nibble.
-With DES, the substitution operation is performed by XORing a selected
portion of the key for a given round with an expanded version of the right-
half data for that round, and the resultant data is grouped into 8 6-bit
values, each of which is fed into a specific s-box to get the appropriate
substitution value. With EDES, the s-box (and its location within the
256-byte lookup table) for a given 6-bit portion of the data is pre-
determined by pre-loading the permuted output with values of 0, 1, 2, and 3
alternately in the upper and lower 2 bits. This effectively splits the
256-byte lookup table into 8 64-nibble lookup tables, organized as 4 4x16
s-boxes coded into the lower nibbles and 4 16x4 s-boxes coded into the
upper nibbles.
-With EDES, the s-boxes do not appear to match the DES s-boxes, because of
the pre-permutation (and, in some cases, the lack of permutation) of the
data to be encrypted. The EDES s-boxes are, however, exactly like the DES
s-boxes, as long as you read them in the correct order.
-Once all 16 rounds of encryption have been performed in DES, the data is
fed through final permutation. Again, due to the pre-interleaving of the
data bytes, this permutation in EDES is much more straightforward and
easier to implement.
-"Traditional" DES implementations perform a "key scheduling" step at the
start of the encryption process (or, more often, as part of system
initialization, since it's assumed that the encryption key won't be
changing frequently), which generates a unique key to be used for each
round of encryption. Unfortunately, this procedure is quite RAM-intensive,
requiring more RAM than can be practically applied in a microcontroller.
EDES gets around this by generating each round's key at the beginning of
the round, so that only 8 bytes of RAM are required to store the key.
The DES and EDES algorithms encrypt 8 bytes of data at a time. For this
reason, all encrypted messages in the EchoStar/Nagra system will consist of
a multiple of 8 bytes: This is because the EDES algorithm is used to compute
the valid hash data which the CAM uses to verify a message's authenticity, so
even though the EMM algorithm might not decrypt data in 8-byte blocks, the
routine that validates the data produced by that decryption does. For more
information on the valid hash, see section 7.3, "The valid hash". Note that
packets which do not include an exact multiple of 8 bytes to be encrypted
will usually be padded to the requisite number of bytes, usually with random
data, although Nagra has been known to use a value of $55 as a pad byte.
DES structure:
a c gg ii q s ww yy i k oo qq y aa eee ggg
b d hh jj r t xx zz j l pp rr z bb fff hhh
e g kk mm u w aaa ccc m o ss uu cc ee iii kkk
f h ll nn v x bbb ddd n p tt vv dd ff jjj lll
EDES structure:
S-box 1
14 4 3 15 2 13 5 3 13 14 6 9 11 2 0 5
0 15 10 5 14 4 9 10 7 8 12 3 13 1 3 6
4 1 10 12 15 6 9 10 1 8 12 7 8 11 7 0
15 12 6 11 2 9 5 0 4 2 11 14 1 7 8 13
S-box 2
15 0 9 5 6 10 12 9 8 7 2 12 3 13 5 2
3 13 12 11 15 3 6 0 4 10 1 7 8 4 11 14
1 14 7 8 11 4 0 3 14 11 13 6 4 1 10 15
13 8 0 6 2 15 9 5 7 1 10 12 14 2 5 9
S-box 3
10 13 1 11 6 8 11 5 9 4 12 2 15 3 2 14
13 1 2 4 3 6 12 11 0 13 5 14 6 8 15 2
0 6 13 1 3 15 4 10 14 9 7 12 5 0 8 7
7 10 8 15 4 9 11 5 9 0 14 3 10 7 1 12
S-box 4
7 10 1 15 0 12 11 5 14 9 8 3 9 7 4 8
13 3 4 9 6 10 1 12 11 0 2 5 0 13 14 2
13 6 2 1 6 11 12 2 3 0 5 14 10 13 15 4
8 15 7 4 15 1 10 7 5 6 12 11 3 8 9 14
S-box 5
2 4 8 15 7 10 13 6 4 1 3 12 11 7 14 0
14 11 5 6 4 1 3 10 2 12 15 0 13 2 8 5
12 2 5 9 10 13 0 3 1 11 15 5 6 8 9 14
11 8 0 15 7 14 9 4 12 7 10 9 1 13 6 3
S-box 6
12 9 0 7 9 2 14 1 10 15 3 4 6 12 5 11
10 4 6 11 7 9 0 6 4 2 13 1 9 15 3 8
1 14 13 0 2 8 7 13 15 5 4 10 8 3 11 6
15 3 1 14 12 5 11 0 2 12 14 7 5 10 8 13
S-box 7
4 1 3 10 15 12 5 0 2 11 9 6 8 7 6 9
13 6 14 9 4 1 2 14 11 13 5 0 1 10 8 3
11 4 12 15 0 3 10 5 14 13 7 8 13 14 1 2
0 11 3 5 9 4 15 2 7 8 12 15 10 7 6 12
S-box 8
13 7 10 0 6 9 5 15 8 4 3 10 11 14 12 5
1 2 12 15 10 4 0 3 13 14 6 9 7 8 9 6
2 11 9 6 15 12 0 3 4 1 14 13 1 2 7 8
15 1 5 12 3 10 14 5 8 7 11 0 4 13 2 11
The raw key is an 8-byte (64-bit) number. The low bit of each byte is
defined by the DES specification as a parity bit, but for EDES, it's actually
random. This is irrelevant, however, because these bits are discarded in step
2 of the key's initial permutation.
The permuted key is a 72-bit value, which contains 54 bits of the raw key,
plus 16 bits of known, preselected data.
After the parity bits (the former low bits, now the high bits) are
discarded, the key becomes...
And, in binary...
Next, the permutation process happens by initializing the permuted key to:
Permuted key: 00 00 40 01 80 02 C0 03 00
Key byte number: 0 1 2 3 4 5 6 7 8
0000 0000
0000 0000
0100 0000
0000 0001
1000 0000
0000 0010
1100 0000
0000 0011
0000 0000
Note that only certain bits of the permuted key are filled from the
compressed, reversed key. As a result, certain bits of the permuted key are
always the same, as shown below (a '-' represents a bit that gets filled from
the compressed, reversed key, a 1 or a 0 indicates a bit that's always a known
value). These bits are used to select the appropriate S-box for each 6-bit
word during enryption/decryption. In addition, this action participates in
the interleaving of the bytes.
Since 16 of the 72 bits of the permuted key are preset, 56 bits remain that
need to be filled from the compressed, reversed key. As it happens, the
compressed, reversed key contains exactly 56 bits, so each bit from the
compressed, reversed key gets moved to one and only one bit within the
permuted key. This step is the permutation, which happens next, according to
the following map:
Raw key: 00 C7 CF EC 71 A8 3E 65
Which is the permuted key that appears in the Jethro enabler as well as
the public batt card hacks.
Note that the permutation of the key is not the only difference between the
encryption and decryption processes- it's merely the only difference in the
key preparation processes.
At the end of this process, hash contains the valid hash result.
9: Hacks
9.1.1- Command $05: Write IRD key (Version 3.0: Write config item)
This command is used to write the 8-byte IRD key to the E3M card.
21 40 12 ; A0 CA 00 00 ;Standard header
0D ;Command length
05 ;Command (Write IRD key)
0B ;Command data length
95 01 ;Misc. data (probably ignored)
DC E9 1B 55 89 A0 D5 22 ;New IRD key
03 ;Expected response length
29 ;Checksum
Note that starting with version 3.0 (or maybe earlier), E3M cards allowed
the $05 command to update items other than the IRD key using this command.
The item to be updated is selected by putting the item number to be updated
in the "command data length" field of the command. The data for the item is
always stored starting at byte 9 of the information field. Values for the
item select byte and the length of the associated data item are as follows:
9.1.2- Command $06: Read IRD key (Version 3.0: Read config item)
This command is used to read the 8-byte IRD key from the hack. I'm not
real sure why this command exists, because getting the IRD key out isn't a
very useful thing to do (unless, I suppose, you just want to know your IRD's
box key out of curiosity).
21 40 08 ; A0 CA 00 00 ;Standard header
02 ;Command length
06 ;Command (Read IRD key)
00 ;Command data length
08 ;Expected response length
0F ;Checksum
DC E9 1B 55 89 A0 D5 22 ;IRD key
Note that starting with version 3.0 (or maybe earlier), E3M cards allowed
the $06 command to read items other than the IRD key using this command. The
item to be updated is selected by putting the item number to be updated in the
"command data length" field of the command. The amount of data returned
depends on the data item being requested. Values for the item select byte
and the length of the associated data item are as follows:
21 40 0E ; A0 CA 00 00 ;Standard header
09 ;Command length
07 ;Command (Write ZIP code/TZ)
07 ;Command data length
nn nn ;Misc. data (probably ignored)
Z2 Z3 Z4 ;Bytes 2..4 of ZIP code
TZ ;Time zone byte
03 ;Expected response length
xx ;Checksum
21 40 23 ; A0 CA 00 00 ;Standard header
1D ;Command length
08 ;Command (Write EEPROM)
1B ;Command data length
nn nn ;Misc. data, ignored
11 22 33 44 55 66 77 88 ;Valid hash
11 22 33 44 55 66 77 88 ;Encrypted block
11 22 33 44 55 66 77 88 ;Encrypted block
03 ;Expected response length
xx ;Checksum
Note that the keys above are what I believe to be the correct keys. The
actual data used in the E3M code is assumed to be "pre-prepared", and I have
not yet verified that I correctly calculated the "raw" keys from which can be
derived the "prepared" data that is used by the code.
21 40 1B ; A0 CA 00 00 ;Standard header
15 ;Command length
09 ;Command (update keys)
13 ;Command data length
nn nn ;Misc. data, ignored
11 22 33 44 55 66 77 88 ;Encrypted KEY0 data
99 AA BB CC DD EE FF 00 ;Encrypted KEY1 data
03 ;Expected response length
xx ;Checksum
Note that only early E3M cards support this command, and it was never really
used in the real world.
10: Firmware versions of the various E* cards
When adding backdoor commands to the card (or when intercepting $03 commands
or other information that's DES encrypted), a hacker may wish to use the DES
encrypt or decrypt routines that are included in the NagraVision cards. The
basic DES routines will be listed here, both in summary form and detailed
form, along with examples of how to call the more useful routines.
Stack manipulation:
683F PUSHXA Replaces the return address on the stack with
X:A, then JMPs to the former return address
687E POPXA Pulls the 16-bit value just below the current
return address off the stack, places it in X:A
685E PUSHRC1 Replaces the return address on the stack with
the contents of RC1ADDRH:L, then JMPs to the
former return address. Usually, this routine
is used to preserve the value in RC1ADDRH:L
689C POPRC1 Pulls the 16-bit value just below the current
return address off the stack, places it in
RC1ADDRH:L
6943 SWAPRC2RC1 Swaps the 16-bit value in RC1ADDRH:L with the
16-bit value in RC2ADDRH:L
69EC GET1FROMCALLER Gets a single embedded parameter byte that
followed the JSR/BSR to the routine that
called GET1FROMCALLER, and returns with that
byte in X. For example, the following code...
Operations affecting A:
68E5 SWAPAX Swaps the values in A and X
695C LDARC1 Gets the value in the memory address pointed to
by RC1ADDRH:L into A
6962 LDARC1IX Gets the value in the memory address pointed to
by (RC1ADDRH:L+X) into A
6968 LDARC2 Gets the value in the memory address pointed to
by RC2ADDRH:L into A
696E LDARC2IX Gets the value in the memory address pointed to
by (RC2ADDRH:L+X) into A
6C69 ADD_X_TO_A Adds value of X to value of A, places result in A
6D1C SUBXFROMA Subtracts value of X from value of A, places
result in A
Operations affected by A:
68E5 SWAPAX Swaps the values in A and X
6ACA STA_RC1 Stores the value in A to the address pointed to
by RC1ADDRH:L
6AD4 STA_RC1X Stores the value in A to the address pointed to
by (RC1ADDRH:L+X)
6ADE STA_RC2 Stores the value in A to the address pointed to
by RC2ADDRH:L
6AE8 STA_RC2X Stores the value in A to the address pointed to
by (RC2ADDRH:L+X)
6C69 ADD_X_TO_A Adds value of X to value of A, places result in A
6C6E ADD_A_TO_X Adds value of A to value of X, places result in X
6C77 ADDATORC1 Adds the value of A to the 16-bit value stored
at RC1ADDRH:L
6CA4 ADDXTIMESATORC1 Adds the 16-bit result of X*A to the 16-bit value
stored at RC1ADDRH:L
6CAB ADDRC3APLUSXTORC1 Adds the 16-bit result of ((RC3ADDR*A)+X) to the
16-bit value stored at RC1ADDRH:L
6CCE ADDATORC2 Adds the value of A to the 16-bit value stored
at RC2ADDRH:L
6CFB ADDXTIMESATORC2 Adds the 16-bit result of X*A to the 16-bit value
stored at RC2ADDRH:L
6D02 RC1PLXPLRC3ARC2 Adds the 16-bit result of ((RC3ADDR*A)+X) to the
16-bit value stored at RC1ADDRH:L, places result
in RC2ADDRH:L
6D0E ADDRC3APLUSXTORC2 Adds the 16-bit result of ((RC3ADDR*A)+X) to the
16-bit value stored at RC2ADDRH:L
6D1C SUBXFROMA Subtracts value of X from value of A, places
result in A
6D21 SUBAFROMX Subtracts value of A from value of X, places
result in X. Note: Z flag does not reflect
the result of the operation on exit from this
routine.
6D40 SUB_A_FROMRC1 Subtracts the value of A from the 16-bit value
stored at RC1ADDRH:L
6D84 SUB_A_FROMRC2 Subtracts the value of A from the 16-bit value
stored at RC2ADDRH:L
Operations affecting X:
68E5 SWAPAX Swaps the values in A and X
69A6 XFROMXA Gets the byte pointed to by X:A into X
69B4 LDXRC1 Gets the byte pointed to by RC1ADDRH:L into X
69BA LDXRC1IX Gets the byte pointed to by (RC1ADDRH:L+X) into X
69C4 LDXRC2 Gets the byte pointed to by RC2ADDRH:L into X
69CA LDXRC2IX Gets the byte pointed to by (RC2ADDRH:L+X) into X
6C6E ADD_A_TO_X Adds value of A to value of X, places result in X
6D21 SUBAFROMX Subtracts value of A from value of X, places
result in X. Note: Z flag does not reflect
the result of the operation on exit from this
routine.
Operations affected by X:
68B7 XTORC1 Places a value of $00xx into RC1ADDRH:L, where
xx is the value of the X register
68BC XTORC2 Places a value of $00xx into RC2ADDRH:L, where
xx is the value of the X register
68E5 SWAPAX Swaps the values in A and X
6962 LDARC1IX Gets the value in the memory address pointed to
by (RC1ADDRH:L+X) into A
696E LDARC2IX Gets the value in the memory address pointed to
by (RC2ADDRH:L+X) into A
6974 ZPX_XA Gets the 16-bit value pointed to by X in ZP into
X:A
69BA LDXRC1IX Gets the byte pointed to by (RC1ADDRH:L+X) into X
69CA LDXRC2IX Gets the byte pointed to by (RC2ADDRH:L+X) into X
69EC GET1FROMCALLER Gets a single embedded parameter byte that
followed the JSR/BSR to the routine that
called GET1FROMCALLER, and returns with that
byte in X. For example, the following code...
Summary
Addr Name Description
---- ------------------ --------------------------------------------------
45BF KILLDATAITEM Deletes the data item pointed to by RC1ADDRH:L
45DF SETDBUPDATEFLAG Indicates that a specific type of data in the
database has been updated and should therefore
be re-polled by the host device
45FD GETDATAITEM Finds a data item of a specific type, returns
some number of its data bytes in a ZP buffer
46E3 FINDNEXTACTIVE Advances RC1ADDRH:L to point to the next active
data item of a specified type
46FB GETMATCHINGITEM Finds a data item of a specific type, matching
any combination of the first 8 bytes with a
pattern stored in RAM
4740 CREATEDATAITEM Creates a data item of a specified type
4779 CREATEHEADER Creates a data item header
47A4 FINDABLOCK Finds a block of memory of a minimum specified
size in EEPROM
47C0 WRITEDATAAREA Writes data to the data area of a data item
4871 ACTIVATEITEM Activates a data item, marks its space as used
4B8B INITRC1TOEESTRT Initializes RC1ADDRH:L to point at the start of
EEPROM data space
Detail
Addr Name Description
---- ------------------ --------------------------------------------------
45BF KILLDATAITEM Deletes the data item pointed to by RC1ADDRH:L.
This routine programs the bits in the data item's
flags byte such that bit 3 (data item no longer
in use) is set. Setting this bit allows the
data space occupied by the data item to be
reclaimed so that new data can be stored there.
Exit: n/a
Embedded parameters:
PARM1: Data type to search for, or 0 to
use the data type in A. If both PARM1
and A are 0, this routine will match
the first active data item it finds.
PARM2: Destination of data in ZP RAM.
This is the first location where data
from the data item will be moved, if
PARM3 is non-zero. Note that the first
byte of data moved is the byte that
immediately follows the data type byte
in memory.
PARM3: Number of bytes to be retrieved
from data item. If this byte is zero,
no data is moved.
Exit: RC1ADDRH:L points to data item if found
Carry=clear if data item found
set if no matching data item found
Embedded parameters:
PARM1: Data type to search for, or 0 to
use the data type in A. If both PARM1
and A are 0, this routine will match
the first active data item it finds.
PARM2: Destination of data in ZP RAM.
This is the first location where data
from the data item will be moved, if
PARM3 is non-zero. Note that the first
byte of data moved is the byte that
immediately follows the data type byte
in memory.
PARM3: Number of bytes to be retrieved
from data item. If this byte is zero,
no data is moved.
PARM4: Compare mask. Each bit in this
byte is a flag indicating whether the
corresponding data byte and match byte
in the table below should be checked to
determine whether the correct data item
has been found.
Embedded parameters:
PARM1: Data type to create. Note that
it is necessary to specify a data item
type to create.
Embedded parameters:
PARM1: Length of block to find, or 0 if
length is to be passed in A.
Embedded parameters:
PARM1: Address in ZP RAM where data to
be written to EEPROM begins
PARM2: Offset from RC1ADDRH:L where data
is to be written to EEPROM
PARM3: Number of bytes of data to write
Exit: Carry=clear if data written
set if error occurred
Example:
JSR GET2PARMSTORC1 ;Get destination address
DW $E050 ;Destination addr=$E050
LDA #$10 ;16 bytes to write
LDX #$80 ;Data to write at $80..$8F
ASL EEWRITEOKBITS ;Enable writes
JSR WRITEATOEEFROMX ;Write the data
Example:
JSR GET2PARMSTORC1 ;Get destination address
DW $E020 ;Destination addr=$E050
JSR GET2PARMSTORC2 ;Get source address
DW $7AFC ;Source addr=$7AFC
LDA #$10 ;16 bytes to move
ASL WRITEEEOKBITS ;Enable writes
JSR WRITEEETOEE ;Move the data
Embedded parameters:
PARM1: Response header byte (P1)
PARM2: Response data length (P2)
Format of output:
12 PCB ELEN P1 P2 <DATA0..DATAN> SW1 SW2 LRC
Notes:
MLEN is usually equal to P2+4, unless P2
exceeds the maximum IFS. In this case,
MLEN will equal the maximum IFS, and the output
will be chained. For details concerning the
chaining of output data, see section 5.2.3,
which covers the "dump memory" backdoor command.
Format of output:
12 PCB LEN <DATA0..DATAN> SW1 SW2 LRC
Notes:
N's maximum value is the size of the info field.
For ROM3 cards, it defaults to $20 bytes, but
EchoStar IRDs request that the card change it's
IFS to $58 as part of the initialization
process. The maximum size to which the IFS can
be set on ROM3 cards is $64. If the number of
bytes to be dumped exceeds the IFS, then the
output will be chained. For details concerning
the chaining of output data, see section 5.2.3,
which covers the "dump memory" backdoor command.
Format of output:
12 PCB MLEN 21 LEN <DATA0..DATAN> SW1 SW2 LRC
Notes:
MLEN is usually equal to LEN+4, unless LEN
exceeds the maximum IFS. In this case,
MLEN will equal the maximum IFS, and the output
will be chained. For details concerning the
chaining of output data, see section 5.2.3,
which covers the "dump memory" backdoor command.
Format of output:
12 PCB MLEN <DATA0..DATAN> LRC
Notes:
MLEN is usually equal to LEN+4, unless LEN
exceeds the maximum IFS. In this case,
MLEN will equal the maximum IFS, and the output
will be chained. For details concerning the
chaining of output data, see section 5.2.3,
which covers the "dump memory" backdoor command.
Addr Description
---------- ----------------------------------
IOBUFF Response header byte
IOBUFF+1 Response data length byte (N)
IOBUFF+2 1st data byte (if present)
IOBUFF+1+N last data byte (if present)
IOBUFF+2+N SW1
IOBUFF+3+N SW2
Notes:
Minimum value for X:A on entry is $002C (44
decimal). Entering with a value less than
$002C will result in a delay of $10000+X:A
cycles.
Notes:
Minimum value of A on entry is $21 (33 decimal).
Entering with a value less than $21 will result
in a delay of $100+A cycles.
Notes:
It is generally necessary to call this routine
prior to performing DES decryption, unless the
key that has been stored at $F0..$F6 is already
parity-stripped, bit-reversed, and compressed.
Notes:
When decrypting a block of data using this
routine, only the first block should be
decrypted using DESDECFLOPPED. Subsequent
calls should be to DESDECRYPFLOPPED, since
DESDECFLOPPED will alter the key data, so
further calls to DESDECFLOPPED will result in
a mutation of the key data with each block of
decryption (which may or may not be desirable).
Notes:
When encrypting a block of data using this
routine, only the first block should be
encrypted using DESENCRYPTRAW. Subsequent
calls should be to DESENCRYPTPREPPED, since
DESENCRYPTRAW will alter the key data, so
further calls to DESENCRYPTRAW will result in
a mutation of the key data with each block of
encryption (which may or may not be desirable).
This function's primary use is in performing
chained DES encryption for the purpose of
computing a message's signature.
Notes:
In actuality, what this routine is doing is
performing chained DES encryption. It could
be used either to encrypt data which is
decrypted using chained decryption, or to
decrypt data which was encrypted using chained
decryption.
;
; Entry: DES key stored at RAWDESKEY
; Data to be decrypted stored starting at $80 (up to $58 bytes)
; A=# 8-byte blocks to decrypt
;
; Exit: Encrypted data replaced with decrypted data
;
; Notes: Uses $DE as loop counter for # blocks to decrypt because that's
; the location the $03 decrypt routine uses.
;
DECRYPTBLOCK:
STA $DE ;Save # blocks to decrypt
;
; Entry: DES key stored at RAWDESKEY
; Data to be encrypted stored starting at $80 (up to $58 bytes)
; A=# 8-byte blocks to encrypt
;
; Exit: Decrypted data replaced with encrypted data
;
; Notes: Uses $DE as loop counter for # blocks to encrypt because that's
; the location the $03 decrypt routine uses.
;
ENCRYPTBLOCK:
STA $DE ;Save # blocks to encrypt
11.2.4.1- ZP RAM
Zero-page (or, as Motorola and most other manufacturers of 6805-based
microcontrollers call it, direct page) RAM is a prime resource in the
NagraVision smart card. This is because there are certain instructions that
only work on zero-page RAM locations (like BSET, BCLR, and so on), because
instructions that access zero-page RAM take fewer bytes of code space than
instructions that access non-zero-page RAM, and because instructions that
access zero-page RAM execute more quickly than instructions that access
non-zero-page RAM (because they save the CPU cycle that would otherwise be
taken to fetch the high byte of the operand address). As a result, usage
of zero-page RAM is generally pretty carefully thought out in large programs
for 6805s or 6805-based MCUs (like the 16CF54A). In this section, details
concerning important zero-page RAM variables for ROM3 cards can be found.
Unless otherwise noted, it's not safe to store volatile information in any
of these RAM locations, since lots of routines in the card use them in one
way or another, and it's very difficult to keep track of which ones are safe
and which ones aren't. When in doubt, just use the RAM the same way the code
in the card would.
Addr Value
--------- --------------------------
NAD 21
PCB 00
LEN 08
IOBUFF A0
IOBUFF+1 CA
IOBUFF+2 00
IOBUFF+3 00
IOBUFF+4 02
IOBUFF+5 C0
IOBUFF+6 00
IOBUFF+7 06
LRC 87
Addr Value
--------- --------------------------
NAD 12
PCB 00
LEN 08
IOBUFF B0
IOBUFF+1 04
IOBUFF+2 08
IOBUFF+3 03
IOBUFF+4 00
IOBUFF+5 00
IOBUFF+6 90 (also could be at SW1)
IOBUFF+7 00 (also could be at SW2)
LRC 35
When adding backdoor commands to the card (or when intercepting $03 commands
or other information that's DES encrypted), a hacker may wish to use the DES
encrypt or decrypt routines that are included in the NagraVision cards. The
basic DES routines will be listed here, both in summary form and detailed
form, along with examples of how to call the more useful routines.
12.3- Contacting me
I realize that I'm not the ultimate authority on the NagraVision system, and
that there's a lot of information that I don't yet have. If you have any
corrections to the information in this FAQ, or if you have information you'd
like to add to it, email it to me at:
stuntguy@dishplex.com
Let me know how you want to be credited when you send the information.
-The four bytes right before the 90 00 in command 12 responses (CAM ID)
-Bytes 5..8 and B..E in the 21-01 response (ZIP code and IRD #)
-Bytes 4..7 in the 21-06 responses (CAM ID)
NOTE: In the 21-xx responses, the byte numbers I'm referring to are the
actual data bytes...The data starts after the sequence: 12 xx xx A1 xx,
where xx are bytes that vary depending on the the command sequence and/or
data length.