-
Notifications
You must be signed in to change notification settings - Fork 2
Collapse file tree
Files
Search this repository(forward slash) forward slash/
/
Copy pathcard_usersmanual.tex
More file actions
More file actions
Latest commit
executable file
·2144 lines (1761 loc) · 99.8 KB
/
Copy pathcard_usersmanual.tex
File metadata and controls
executable file
·2144 lines (1761 loc) · 99.8 KB
You must be signed in to make or propose changes
More edit options
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
\documentclass[a4paper,10.5ptj]{ltjsreport}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{biblatex}
\usepackage{listings}
\usepackage{tabularray}
\usepackage{xcolor}
\usepackage{xurl}
\usepackage{hyperref}
% Set table of contents depth
\setcounter{tocdepth}{1}
% Configure references
\addbibresource{../card_usersmanual.bib}
\graphicspath{ {../images/} }
\DefTblrTemplate{contfoot-text}{default}{次ページに続く}
\DefTblrTemplate{conthead-text}{default}{(続き)}
% Configure listings
\lstset{
basicstyle=\ttfamily,
columns=fullflexible,
frame=single,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space}
}
\renewcommand{\lstlistingname}{プレーンテキスト}
% Description
\title{FeliCaカードユーザーズマニュアル (非公式版)}
\author{切敷 裕大\thanks{アンノウン・テクノロジーズ株式会社}}
\date{2026年7月24日}
\begin{document}
\maketitle
\section*{おことわり}
内容の確かさには万全を期しておりますが、リバースエンジニアリングの性質上、不正確な結果が含まれている場合がありますので、ご了承ください。
本文書では、特筆ない限り以下が前提です。
\begin{itemize}
\item ビット順序は、最下位ビットをビット0とします。
\item データ長は、オクテット単位とします。
\end{itemize}
\tableofcontents
\chapter{はじめに}
FeliCaは、交通系ICカードを筆頭に多くのSF(ストアードフェア)型電子マネーや身分証明書等に使用されている一方、その仕様において最も重要な暗号に関する仕様は非公開とされており、広く知られていません。暗号に関するセキュリティは、公にされ広く専門家が検証してこそ安全性が担保されるものです。このため、本文書ではFeliCaの隠された仕様を明らかにします。本文書は、JIS X 6319-4\cite{jis-x-6319-4-2016}、FeliCaカード ユーザーズマニュアル 抜粋版(以下、U-MAN)\cite{felica-usersmanual}、felica-tool\cite{felica-tool}およびProxmark3\cite{proxmark3}を大いに参考にしています。より詳しい情報を知りたい方はこれらも併せてご確認ください。
\chapter{FeliCaとは}
FeliCaは、ソニー株式会社が開発した非接触型ICカード技術の一つで、NFC Type-Fとも呼ばれます。市場にある実装としてはFeliCa StandardとFeliCa Lite-Sがあります。本文書では、前者を取り扱います。
\chapter{通信プロトコル}
カードとカードリーダとの間の通信プロトコルを説明します。ただし、すべてが公になっている物理層およびデータリンク層の説明は割愛し、アプリケーション層のみを取り扱います。
\section{コマンドパケット}
コマンドパケットのデータ構造を以下に示します。(表\ref{table:felica-command-packet-structure})
\begin{tblr}[
long,
caption={コマンドパケットのデータ構造},
label={table:felica-command-packet-structure},
]{
colspec={|r|r|l|},
rowhead=1,
row{1}={c,m},
vlines,
hlines,
}
オフセット & 長さ & 項目 \\
0x00 & 0x01 & コマンドコード \\
0x01 & 可変 & コマンドデータ
\end{tblr}
\subsection{コマンドコード}
コマンドの種類を識別するための1バイトの値です。
\subsection{コマンドデータ}
コマンドの処理指示を規定するデータで、コマンドごとに形式が異なります。
\section{レスポンスパケット}
レスポンスパケットのデータ構造を以下に示します。(表\ref{table:felica-response-packet-structure})
\begin{tblr}[
long,
caption={レスポンスパケットのデータ構造},
label={table:felica-response-packet-structure},
]{
colspec={|r|r|l|},
rowhead=1,
row{1}={c,m},
vlines,
hlines,
}
オフセット & 長さ & 項目 \\
0x00 & 0x01 & レスポンスコード \\
0x01 & 可変 & レスポンスデータ
\end{tblr}
\subsection{レスポンスコード}
レスポンスの種類を識別するための8ビットの値です。
\subsection{レスポンスデータ}
レスポンスの処理結果を規定するデータで、コマンドごとに形式が異なります。
\section{コマンド一覧}
各コマンドの概要ならびにコマンドコードおよびレスポンスコードを以下に示します。(表\ref{table:felica-command-list})ただし、表中ではコマンドコードをCC、レスポンスコードをRCと表記します。また、まだ知られていないコマンドが存在している可能性があります。
\begin{tblr}[
long,
caption={コマンド一覧},
label={table:felica-command-list},
]{
colspec={|l|r|r|X|},
rowhead=1,
row{1}={c,m},
vlines,
hlines,
}
名称 & CC & RC & 概要 \\
Polling & 0x00 & 0x01 & カードリーダがカードを捕捉および特定する \\
Request Service & 0x02 & 0x03 & エリアやサービスの存在確認と鍵バージョンを取得する \\
Request Response & 0x04 & 0x05 & カードの存在とモードを確認する \\
{Read Without \\ Encryption} & 0x06 & 0x07 & サービス属性が認証不要のサービスからブロックデータを読み出す \\
{Write Without \\ Encryption} & 0x08 & 0x09 & サービス属性が認証不要のサービスへブロックデータを書き込む \\
Search Service Code & 0x0A & 0x0B & エリアコードとサービスコードを取得する \\
Request System Code & 0x0C & 0x0D & カード内に登録されているシステムコードを取得する \\
{Request Block \\ Information} & 0x0E & 0x0F & 指定したノードに割り当てられているブロック数を取得する \\
row{1}={c,m},
vlines,
hlines,
}
オフセット & 長さ & 項目 & 値または備考 \\
0x00 & 0x02 & システムコード & ビッグエンディアン \\
0x02 & 0x02 & Area0鍵バージョン & リトルエンディアン \\
0x04 & 0x08 & Area0鍵 & - \\
0x0C & 0x04 & 予約領域 & 0x00000000
\end{tblr}
\begin{tblr}[
long,
caption={Register Area用発行パッケージ平文(16バイト)のデータ構造},
label={table:felica-register-area-package-plain-structure},
]{
colspec={|r|r|l|X|},
rowhead=1,
row{1}={c,m},
vlines,
hlines,
}
オフセット & 長さ & 項目 & 値または備考 \\
0x00 & 0x02 & サービスコード開始 & リトルエンディアン \\
0x02 & 0x02 & サービスコード終端 & リトルエンディアン \\
0x04 & 0x02 & サイズ & リトルエンディアン \\
0x06 & 0x02 & 鍵バージョン & リトルエンディアン \\
0x08 & 0x08 & エリア鍵 & -
\end{tblr}
\begin{tblr}[
long,
caption={Register Service用発行パッケージ平文(16バイト)のデータ構造},
label={table:felica-register-service-package-plain-structure},
]{
colspec={|r|r|l|X|},
rowhead=1,
row{1}={c,m},
vlines,
hlines,
}
オフセット & 長さ & 項目 & 値または備考 \\
0x00 & 0x02 & サービスコード & リトルエンディアン \\
0x02 & 0x02 & 予約領域 & 0x0000 \\
0x04 & 0x02 & サイズ & リトルエンディアン \\
0x06 & 0x02 & 鍵バージョン & リトルエンディアン \\
0x08 & 0x08 & サービス鍵 & -
\end{tblr}
\subsection{発行パッケージ作成アルゴリズム}
パッケージ鍵を$K_{\mathrm{pkg}}$、平文パッケージを$P$とします($|P|$は8の倍数、かつ0でないことが条件です)。
\begin{itemize}
\item MAC生成鍵を
\[
K_{\mathrm{macpkg}} = K_{\mathrm{pkg}} \oplus 0xFF\ldots FF
\]
で作成します。
\item
\[
C = \mathrm{DES\mbox{-}CBC}_{IV=0,K_{\mathrm{macpkg}}}(P)
\]
を計算し、最終8バイトを$MAC_{\mathrm{pkg}}$とします。
\item
\[
Package = \mathrm{DES\mbox{-}CBC}_{IV=0,K_{\mathrm{pkg}}}(P\ \|\ MAC_{\mathrm{pkg}})
\]
を計算し、この暗号文をコマンドの「パッケージ」フィールドに格納します。
\end{itemize}
\printbibliography[title={参考文献}]
\end{document}