← Documents Documentation/userspace-api/media/dvb/ca_high_level.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / DVB / CA

The High level CI API

오래된 고수준 EN50221 CI API의 모델과 데이터 흐름을 설명합니다.

Source pathDocumentation/userspace-api/media/dvb/ca_high_level.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

ca_high_level.rst:1-157

원문이 오래된 문서라고 경고하는 고수준 CI 설계입니다. 애플리케이션은 EN50221 APDU만 교환하고 세션·링크·전송 계층과 하드웨어 의존 처리는 드라이버와 장치가 맡습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 The High level CI API
4 =====================
5
6 .. note::
7
8 This documentation is outdated.
9
10 This document describes the high level CI API as in accordance to the
11 Linux DVB API.
12
13
14 With the High Level CI approach any new card with almost any random
15 architecture can be implemented with this style, the definitions
16 inside the switch statement can be easily adapted for any card, thereby
17 eliminating the need for any additional ioctls.
18
19 The disadvantage is that the driver/hardware has to manage the rest. For
20 the application programmer it would be as simple as sending/receiving an
21 array to/from the CI ioctls as defined in the Linux DVB API. No changes
22 have been made in the API to accommodate this feature.
23
24
25 Why the need for another CI interface?
26 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27
28 This is one of the most commonly asked question. Well a nice question.
29 Strictly speaking this is not a new interface.
30
31 The CI interface is defined in the DVB API in ca.h as:
32
33 .. code-block:: c
34
35 typedef struct ca_slot_info {
36 int num; /* slot number */
37
38 int type; /* CA interface this slot supports */
39 #define CA_CI 1 /* CI high level interface */
40 #define CA_CI_LINK 2 /* CI link layer level interface */
41 #define CA_CI_PHYS 4 /* CI physical layer level interface */
42 #define CA_DESCR 8 /* built-in descrambler */
43 #define CA_SC 128 /* simple smart card interface */
44
45 unsigned int flags;
46 #define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */
47 #define CA_CI_MODULE_READY 2
48 } ca_slot_info_t;
49
50 This CI interface follows the CI high level interface, which is not
51 implemented by most applications. Hence this area is revisited.
52
53 This CI interface is quite different in the case that it tries to
54 accommodate all other CI based devices, that fall into the other categories.
55
56 This means that this CI interface handles the EN50221 style tags in the
57 Application layer only and no session management is taken care of by the
58 application. The driver/hardware will take care of all that.
59
60 This interface is purely an EN50221 interface exchanging APDU's. This
61 means that no session management, link layer or a transport layer do
62 exist in this case in the application to driver communication. It is
63 as simple as that. The driver/hardware has to take care of that.
64
65 With this High Level CI interface, the interface can be defined with the
66 regular ioctls.
67
68 All these ioctls are also valid for the High level CI interface
69
70 #define CA_RESET _IO('o', 128)
71 #define CA_GET_CAP _IOR('o', 129, ca_caps_t)
72 #define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t)
73 #define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t)
74 #define CA_GET_MSG _IOR('o', 132, ca_msg_t)
75 #define CA_SEND_MSG _IOW('o', 133, ca_msg_t)
76 #define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
77
78
79 On querying the device, the device yields information thus:
80
81 .. code-block:: none
82
83 CA_GET_SLOT_INFO
84 ----------------------------
85 Command = [info]
86 APP: Number=[1]
87 APP: Type=[1]
88 APP: flags=[1]
89 APP: CI High level interface
90 APP: CA/CI Module Present
91
92 CA_GET_CAP
93 ----------------------------
94 Command = [caps]
95 APP: Slots=[1]
96 APP: Type=[1]
97 APP: Descrambler keys=[16]
98 APP: Type=[1]
99
100 CA_SEND_MSG
101 ----------------------------
102 Descriptors(Program Level)=[ 09 06 06 04 05 50 ff f1]
103 Found CA descriptor @ program level
104
105 (20) ES type=[2] ES pid=[201] ES length =[0 (0x0)]
106 (25) ES type=[4] ES pid=[301] ES length =[0 (0x0)]
107 ca_message length is 25 (0x19) bytes
108 EN50221 CA MSG=[ 9f 80 32 19 03 01 2d d1 f0 08 01 09 06 06 04 05 50 ff f1 02 e0 c9 00 00 04 e1 2d 00 00]
109
110
111 Not all ioctl's are implemented in the driver from the API, the other
112 features of the hardware that cannot be implemented by the API are achieved
113 using the CA_GET_MSG and CA_SEND_MSG ioctls. An EN50221 style wrapper is
114 used to exchange the data to maintain compatibility with other hardware.
115
116 .. code-block:: c
117
118 /* a message to/from a CI-CAM */
119 typedef struct ca_msg {
120 unsigned int index;
121 unsigned int type;
122 unsigned int length;
123 unsigned char msg[256];
124 } ca_msg_t;
125
126
127 The flow of data can be described thus,
128
129 .. code-block:: none
130
131 App (User)
132 -----
133 parse
134 |
135 |
136 v
137 en50221 APDU (package)
138 --------------------------------------
139 | | | High Level CI driver
140 | | |
141 | v |
142 | en50221 APDU (unpackage) |
143 | | |
144 | | |
145 | v |
146 | sanity checks |
147 | | |
148 | | |
149 | v |
150 | do (H/W dep) |
151 --------------------------------------
152 | Hardware
153 |
154 v
155
156 The High Level CI interface uses the EN50221 DVB standard, following a
157 standard ensures futureproofness.
158

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

문서 상태와 고수준 접근법

1-24

이 문서는 GPL-2.0 라이선스를 따르며 Linux DVB API의 고수준 Common Interface(CI) API를 설명합니다.

주의: 원문은 이 문서가 오래되었다고 명시합니다.

고수준 CI 접근법을 사용하면 거의 임의의 아키텍처를 가진 새 카드도 이 방식으로 구현할 수 있습니다. switch 문의 정의를 카드에 맞게 쉽게 조정할 수 있어 추가 IOCTL이 필요하지 않습니다.

단점은 나머지 처리를 드라이버와 하드웨어가 맡아야 한다는 점입니다. 애플리케이션 개발자는 Linux DVB API가 정의한 CI IOCTL로 배열을 보내고 받기만 하면 되며, 이 기능을 수용하기 위한 API 변경은 없습니다.

고수준 CI 역할 분담
항목설명
애플리케이션CI IOCTL로 배열 송수신
드라이버/하드웨어세션·전송·링크 계층과 카드별 동작 처리
DVB API추가 IOCTL 없이 기존 호출 유지

단순한 사용자 공간 API를 위해 드라이버와 하드웨어가 프로토콜 처리를 맡습니다.

.. SPDX-License-Identifier: GPL-2.0

The High level CI API
=====================

.. note::

   This documentation is outdated.

This document describes the high level CI API as in accordance to the
Linux DVB API.


With the High Level CI approach any new card with almost any random
architecture can be implemented with this style, the definitions
inside the switch statement can be easily adapted for any card, thereby
eliminating the need for any additional ioctls.

The disadvantage is that the driver/hardware has to manage the rest. For
the application programmer it would be as simple as sending/receiving an
array to/from the CI ioctls as defined in the Linux DVB API. No changes
have been made in the API to accommodate this feature.

다른 CI 인터페이스가 필요한 이유

25-49

엄밀히 말하면 이것은 새 인터페이스가 아닙니다. DVB API의 `ca.h`는 `ca_slot_info_t`로 CI 인터페이스를 정의합니다.

ca_slot_info_t 필드
필드의미
int numslot number
int type슬롯이 지원하는 CA interface
unsigned int flags모듈 삽입과 준비 상태

슬롯 번호, 인터페이스 종류, 상태 플래그를 보관합니다.

CA 인터페이스 type 비트
항목설명
CA_CI = 1CI high level interface
CA_CI_LINK = 2CI link layer level interface
CA_CI_PHYS = 4CI physical layer level interface
CA_DESCR = 8built-in descrambler
CA_SC = 128simple smart card interface

`ca_slot_info_t.type`이 나타내는 인터페이스입니다.

CA 슬롯 flags
항목설명
CA_CI_MODULE_PRESENT = 1module 또는 card가 삽입됨
CA_CI_MODULE_READY = 2module이 준비됨

모듈 존재와 준비 상태를 구분합니다.

Why the need for another CI interface?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is one of the most commonly asked question. Well a nice question.
Strictly speaking this is not a new interface.

The CI interface is defined in the DVB API in ca.h as:

.. code-block:: c

	typedef struct ca_slot_info {
		int num;               /* slot number */

		int type;              /* CA interface this slot supports */
	#define CA_CI            1     /* CI high level interface */
	#define CA_CI_LINK       2     /* CI link layer level interface */
	#define CA_CI_PHYS       4     /* CI physical layer level interface */
	#define CA_DESCR         8     /* built-in descrambler */
	#define CA_SC          128     /* simple smart card interface */

		unsigned int flags;
	#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */
	#define CA_CI_MODULE_READY   2
	} ca_slot_info_t;

EN50221 APDU 전용 인터페이스

50-77

이 CI 인터페이스는 대부분의 애플리케이션이 구현하지 않는 CI 고수준 인터페이스를 따르므로 다시 검토되었습니다. 다른 범주에 속하는 여러 CI 기반 장치를 수용하려 한다는 점에서 일반적인 경우와 다릅니다.

애플리케이션 계층에서 EN50221 형식 태그만 처리하며 애플리케이션은 세션 관리를 맡지 않습니다. 드라이버와 하드웨어가 세션 관리를 처리합니다.

이 인터페이스는 순수한 EN50221 APDU 교환 인터페이스입니다. 애플리케이션과 드라이버 사이에는 세션 관리, 링크 계층, 전송 계층이 존재하지 않으며 이 부분은 드라이버와 하드웨어가 담당합니다.

고수준 CI 인터페이스는 기존 IOCTL로 정의할 수 있고 다음 호출이 모두 유효합니다.

고수준 CI IOCTL
항목설명
CA_RESET_IO('o', 128)
CA_GET_CAP_IOR('o', 129, ca_caps_t)
CA_GET_SLOT_INFO_IOR('o', 130, ca_slot_info_t)
CA_GET_DESCR_INFO_IOR('o', 131, ca_descr_info_t)
CA_GET_MSG_IOR('o', 132, ca_msg_t)
CA_SEND_MSG_IOW('o', 133, ca_msg_t)
CA_SET_DESCR_IOW('o', 134, ca_descr_t)

기존 DVB CA 요청 번호와 자료형을 보존합니다.

This CI interface follows the CI high level interface, which is not
implemented by most applications. Hence this area is revisited.

This CI interface is quite different in the case that it tries to
accommodate all other CI based devices, that fall into the other categories.

This means that this CI interface handles the EN50221 style tags in the
Application layer only and no session management is taken care of by the
application. The driver/hardware will take care of all that.

This interface is purely an EN50221 interface exchanging APDU's. This
means that no session management, link layer or a transport layer do
exist in this case in the application to driver communication. It is
as simple as that. The driver/hardware has to take care of that.

With this High Level CI interface, the interface can be defined with the
regular ioctls.

All these ioctls are also valid for the High level CI interface

#define CA_RESET          _IO('o', 128)
#define CA_GET_CAP        _IOR('o', 129, ca_caps_t)
#define CA_GET_SLOT_INFO  _IOR('o', 130, ca_slot_info_t)
#define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t)
#define CA_GET_MSG        _IOR('o', 132, ca_msg_t)
#define CA_SEND_MSG       _IOW('o', 133, ca_msg_t)
#define CA_SET_DESCR      _IOW('o', 134, ca_descr_t)

장치 질의와 메시지 예

78-109

장치에 `CA_GET_SLOT_INFO`를 질의한 예에서는 명령이 `info`이고 슬롯 번호 1, type 1, flags 1을 반환합니다. 애플리케이션은 이를 CI 고수준 인터페이스이면서 CA/CI 모듈이 존재하는 상태로 해석합니다.

`CA_GET_CAP`의 `caps` 예에서는 슬롯 1개, type 1, descrambler key 16개, descrambler type 1을 보고합니다.

`CA_SEND_MSG` 예는 프로그램 수준 CA descriptor `09 06 06 04 05 50 ff f1`을 찾고, ES type 2/PID 201과 ES type 4/PID 301을 포함한 25-byte `EN50221 CA MSG`를 전송합니다.

고수준 CI 질의 예
항목설명
CA_GET_SLOT_INFONumber=1, Type=1, flags=1
해석CI High level interface, CA/CI Module Present
CA_GET_CAPSlots=1, Type=1, Descrambler keys=16, Type=1
CA_SEND_MSGProgram-level descriptor와 25-byte EN50221 CA message

원문 명령 출력의 핵심 값을 구조화합니다.


On querying the device, the device yields information thus:

.. code-block:: none

	CA_GET_SLOT_INFO
	----------------------------
	Command = [info]
	APP: Number=[1]
	APP: Type=[1]
	APP: flags=[1]
	APP: CI High level interface
	APP: CA/CI Module Present

	CA_GET_CAP
	----------------------------
	Command = [caps]
	APP: Slots=[1]
	APP: Type=[1]
	APP: Descrambler keys=[16]
	APP: Type=[1]

	CA_SEND_MSG
	----------------------------
	Descriptors(Program Level)=[ 09 06 06 04 05 50 ff f1]
	Found CA descriptor @ program level

	(20) ES type=[2] ES pid=[201]  ES length =[0 (0x0)]
	(25) ES type=[4] ES pid=[301]  ES length =[0 (0x0)]
	ca_message length is 25 (0x19) bytes
	EN50221 CA MSG=[ 9f 80 32 19 03 01 2d d1 f0 08 01 09 06 06 04 05 50 ff f1 02 e0 c9 00 00 04 e1 2d 00 00]

CA_GET_MSG와 CA_SEND_MSG

110-125

API의 모든 IOCTL이 드라이버에 구현되는 것은 아닙니다. API로 직접 구현할 수 없는 하드웨어 기능은 `CA_GET_MSG`와 `CA_SEND_MSG` IOCTL을 사용합니다.

다른 하드웨어와의 호환성을 유지하기 위해 EN50221 형식 wrapper로 데이터를 교환합니다.

ca_msg_t
필드의미
unsigned int index메시지 index
unsigned int type메시지 type
unsigned int length유효한 메시지 길이
unsigned char msg[256]최대 256-byte payload

CI-CAM으로 보내거나 받는 메시지 구조체입니다.


Not all ioctl's are implemented in the driver from the API, the other
features of the hardware that cannot be implemented by the API are achieved
using the CA_GET_MSG and CA_SEND_MSG ioctls. An EN50221 style wrapper is
used to exchange the data to maintain compatibility with other hardware.

.. code-block:: c

	/* a message to/from a CI-CAM */
	typedef struct ca_msg {
		unsigned int index;
		unsigned int type;
		unsigned int length;
		unsigned char msg[256];
	} ca_msg_t;

사용자 공간에서 하드웨어까지의 흐름

126-157

사용자 애플리케이션이 데이터를 파싱하고 EN50221 APDU로 포장하면, 고수준 CI 드라이버가 APDU 포장을 풀고 sanity check를 수행한 뒤 하드웨어 의존 동작을 실행합니다.

고수준 CI 데이터 흐름
App(User)가 입력 파싱EN50221 APDU로 packageHigh Level CI driver가 APDU unpackage드라이버가 sanity checks 수행드라이버가 hardware-dependent 작업 실행Hardware로 전달

원문의 ASCII 그림을 같은 처리 순서의 구조화 도식으로 다시 그립니다.

고수준 CI 인터페이스는 EN50221 DVB 표준을 사용합니다. 표준을 따르면 앞으로의 호환성을 확보할 수 있습니다.


The flow of data can be described thus,

.. code-block:: none

	App (User)
	-----
	parse
	  |
	  |
	  v
	en50221 APDU (package)
   --------------------------------------
   |	  |				| High Level CI driver
   |	  |				|
   |	  v				|
   |	en50221 APDU (unpackage)	|
   |	  |				|
   |	  |				|
   |	  v				|
   |	sanity checks			|
   |	  |				|
   |	  |				|
   |	  v				|
   |	do (H/W dep)			|
   --------------------------------------
	  |    Hardware
	  |
	  v

The High Level CI interface uses the EN50221 DVB standard, following a
standard ensures futureproofness.