「Trusted Platform Module」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(→‎Using TPM 2.0: 章を入替のため追加)
(→‎PCR レジスタへのアクセス: ユニファイドカーネルイメージに変更)
 
(2人の利用者による、間の10版が非表示)
2行目: 2行目:
 
[[Category:ハードウェア]]
 
[[Category:ハードウェア]]
 
[[en:Trusted Platform Module]]
 
[[en:Trusted Platform Module]]
  +
[[pl:Trusted Platform Module]]
Trusted Platform Module (TPM) はセキュアな暗号プロセッサの国際規格です。暗号鍵をデバイスに統合することによりハードウェアを保護する専用のマイクロプロセッサとして設計されています。
 
  +
{{Related articles start}}
  +
{{Related|Rng-tools}}
  +
{{Related|自己暗号化ドライブ}}
  +
{{Related|スマートカード}}
  +
{{Related|Trusted Platform Module/1.2}}
  +
{{Related articles end}}
  +
Trusted Platform Module (TPM) は安全な暗号プロセッサの国際規格です。これは暗号鍵をデバイスに統合することによりハードウェアを保護する専用のマイクロプロセッサです。
   
実際に TPM を Secure Boot や Key Storage など様々なセキュリティアプリケーションで使うことができます。
+
実際に TPMはセキュアブート、キーストレージ、乱数生成など様々なセキュリティアプリケーションで使うことができます。
   
当然ながら TPM が使えるのは TPM ハードウェアに対応しているデバイスだけです。あなたのハードウェアが TPM をサポートしているのに認識されない場合、BIOS の設定で TPM を有効にする必要があります。
+
TPM が使えるのは TPM ハードウェアに対応しているデバイスだけです。あなたのハードウェアが TPM をサポートしているのに認識されない場合、BIOS の設定で TPM を有効にする必要があります。
   
 
== バージョン ==
 
== バージョン ==
   
TPM 仕様には、大きく分けて 2 種類あります。1.2 と 2.0 があり、それぞれ異なるソフトウェアスタックを使用しいます。
+
TPM 仕様には 2.0 と 1.2 という 2 つの非常に異なるものがあり、らも異なるソフトウェアスタックを使用します。この記事では TPM 2.0 につてのみ説明します。古い TPM 1.2 については、[[Trusted Platform Module/1.2|/1.2]] を参照してください
   
  +
TPM 2.0 では、{{ic|/dev/tpm0}} による直接アクセスが可能である。(一度に1クライアント)、{{ic|/dev/tpmrm0}} 経由のカーネル管理アクセス、{{Pkg|tpm2-abrmd}} リソースマネージャーデーモンによる管理アクセスが可能です。[https://groups.google.com/g/linux.debian.bugs.dist/c/OWBHw40g6Vk/m/rnwwkVapDAAJ systemd プロジェクトメンバーによると]、{{Pkg|tpm2-abrmd}} の使用はもはや推奨されていません。ユーザ空間ツールには Intel の {{Pkg|tpm2-tools}} と IBM の {{AUR|ibm-tss}} の2つの選択肢があります。
* TPM 1.2 は IBM の "TrouSerS" TSS (TCG ソフトウェアスタック) を使用しており、{{AUR|trousers}} (''tcsd'') と {{AUR|tpm-tools}} (ユーザースペース) としてパッケージ化されている。すべてのソフトウェアは、''tcsd'' デーモンを介して TPM にアクセスする。
 
   
  +
TPM 2.0 には [[UEFI]] ブートが必要です。BIOS またはレガシーブートシステムは TPM 1.2 のみを使用できます。
* TPM 2.0 では、{{ic|/dev/tpm0}} を介した直接アクセス (一度に 1 クライアント)、{{Pkg|tpm2-abrmd}} リソースマネージャデーモンを介したマネージドアクセス、または {{ic|/dev/tpmrm0}} を介したカーネルマネージドアクセスが可能です。ユーザースペースツールには Intel の {{Pkg|tpm2-tools}} と IBM の {{AUR|ibm-tss}} の2種類があります。
 
   
  +
一部の TPM チップは、ファームウェアアップグレードを通じて 2.0 と 1.2 の間で切り替えることができます (限られた回数のみ実行可能)
TPM 2.0 は [[UEFI]] ブートを必要とします。BIOS やレガシーブートシステムは TPM 1.2 しか使えません。
 
   
  +
== 使い方 ==
TPM チップの中には、ファームウェアのアップグレードによって 1.2 と 2.0 を切り替えられるものがあります(回数に限りがあります)。
 
   
  +
日常のアプリケーションで TPM 2.0 サービスを設定および利用する方法を学習するための多くの有益なリソースが、[https://tpm2-software.github.io/tpm2-software コミュニティ] から入手できます。
== Using TPM 2.0 ==
 
   
  +
=== サポートの確認 ===
{{Expansion|This section is a stub. You can help by expanding it with information on how to set up and use a TPM 2.0 device.}}
 
   
  +
TPM 2.0 チップは、2016 年 7 月 28 日以降、Windows 10 を実行することが認定されたコンピューターの要件となっています。[https://www.computerworld.com/article/3101427/microsoft-mandates-windows-10-hardware-change-for-pc-security.html] Linux はバージョン 3.20 以降 TPM 2.0 をサポートしています [https://www.phoronix.com/scan.php?page=news_item&px=Linux-3.20-TPM-2.0-Security] 他の手順は、デフォルトの Arch インストールで有効になります。
Many informative resources to learn how to configure and make use of TPM 2.0 services in daily applications are available from the [https://tpm2-software.github.io/ tpm2-software community].
 
   
  +
特定のソフトウェアを使用せずに TPM 2.0 がセットアップされているかどうかを確認する 2 つの方法:
=== Checking support ===
 
   
  +
* ログを確認します。たとえば、root として {{ic|1=journalctl -k --grep=tpm}} を実行します。
A TPM 2.0 chip has been a requirement for computers certified to run Windows 10 since 2016-07-28.[https://www.computerworld.com/article/3101427/microsoft-mandates-windows-10-hardware-change-for-pc-security.html] Linux has support for TPM 2.0 since version 3.20[https://www.phoronix.com/scan.php?page=news_item&px=Linux-3.20-TPM-2.0-Security] and should not require any other steps to be enabled on a default Arch install.
 
  +
* {{ic|/sys/class/tpm/tpm0/device/description}} [https://github.com/tpm2-software/tpm2-tools/issues/604#issuecomment-342784674] または {{ic|/sys/class/tpm/tpm0/tpm_version_major}} の値を読み取ります。
   
  +
=== LUKS による保存データの暗号化 ===
Two ways to verify whether TPM 2.0 is setup without specific software:
 
   
  +
TPM を使用して LUKS ボリュームのロックを解除するには、2 つの方法があります。[[Clevis]] または [[Trusted Platform Module#systemd-cryptenroll|systemd-cryptenroll]] を使用できます。
* checking the logs, e.g., by running {{ic|1=journalctl -k --grep=tpm}} as root
 
* read the value of {{ic|/sys/class/tpm/tpm0/device/description}}[https://github.com/tpm2-software/tpm2-tools/issues/604#issuecomment-342784674] or {{ic|/sys/class/tpm/tpm0/tpm_version_major}}
 
   
  +
どちらの方法を使用しても、TPM に保存されているキーを使用して、起動時に自動的に、または後で手動で、暗号化されたボリュームのロックを解除できます。この目的で TPM を使用すると、ファームウェアが変更されていない、[[セキュアブート]] が無効になっていないなど、特定の条件が満たされない限り、ドライブのロックが解除されなくなります ([[Trusted Platform Module#PCR レジスタへのアクセス|PCR レジスタへのアクセス]] を参照)
=== Data-at-rest encryption with LUKS ===
 
   
  +
{{Warning|この方法をルートボリュームで使用すると、先に述べた一定の条件が満たされている限り、暗号化パスワードを入力することなく、コンピュータの起動時に ''自動的にロックが解除される'' ことを意味します。
There are two methods for unlocking a LUKS volume using a TPM. An older method using {{Pkg|clevis}}, and a newer method using ''systemd-cryptenroll''. The newer method will be detailed first.
 
  +
* つまり、暗号化されたディスクだけが盗まれてもデータへのアクセスは保護されますが、PC全体が盗まれた場合保護されません。
 
  +
* なぜなら、たとえコンピュータの電源が長い間オフになっていたとしても(メモリが完全にクリアされていることを保証するために)、攻撃者は単に電源を入れ、TPMが自動的にキーをロードするのを待つことができるからです。これは、価値の高いターゲットにとっては懸念事項になります。
Using either method, an encrypted volume or volumes may be unlocked using keys stored in a TPM, either automatically at boot or manually at a later time. Using a TPM for this purpose ensures that your drives will not unlock unless certain conditions are met, such as your firmware not having been modified and [[Secure Boot]] not having been disabled (see [[#Accessing PCR registers]]).
 
 
{{Warning|If you use this method on your root volume, this means that, as long as the previously mentioned certain conditions are met, your computer will '''unlock automatically''' at boot without needing to enter an encryption password.
 
* This means that access to data is not protected in case the hardware gets stolen.
 
* Be aware that this method makes you more vulnerable to [[Wikipedia:Cold boot attack|cold boot attacks]], because even if your computer has been powered off for a long time (ensuring the memory is completely cleared), an attacker could simply turn it on and wait for the TPM to load the key automatically. This may be a concern for high-value targets.
 
 
}}
 
}}
   
 
==== systemd-cryptenroll ====
 
==== systemd-cryptenroll ====
   
  +
[[systemd-cryptenroll#Trusted Platform Module]] を参照してください。
Since version 248, [[systemd]] has had native support for enrolling LUKS keys in TPMs. This functionality is managed through the ''systemd-cryptenroll'' command. This method requires the following:
 
   
  +
=== SSH ===
* A LUKS2 device (currently the default type used by [[Dm-crypt/Device_encryption#Encryption_options_with_dm-crypt|cryptsetup]]),
 
* If you intend to use this method on your root partition, use of the {{ic|systemd}} and {{ic|sd-encrypt}} hooks in the initramfs. See [[Mkinitcpio#HOOKS]] and [[Dm-crypt/System_configuration#Using_sd-encrypt_hook|Using sd-encrypt hook]].
 
   
  +
TPM でシールされた SSH キーには、次の 2 つのオプションがあります:
To begin, run the following command to list your installed TPMs:
 
   
  +
* {{App|ssh-tpm-agent|TPM でサポートされたキーを使用する ssh-agent 互換エージェント。|https://github.com/Foxboron/ssh-tpm-agent|{{AUR|ssh-tpm-agent-git}}}}
$ systemd-cryptenroll --tpm2-device=list
 
   
  +
:参照 [https://linderud.dev/blog/store-ssh-keys-inside-the-tpm-ssh-tpm-agent/ SSH キーを TPM 内に保存します: ssh-tpm-agent]
A key may be enrolled in both the TPM and the LUKS volume using only one command. The following example binds the key to PCRs 0 and 7 (the system firmware and [[Secure Boot]] state):
 
   
  +
* {{App|tpm2-pkcs11|Trusted Platform Module 2.0 ハードウェア用の PKCS#11 インターフェイス。|https://github.com/tpm2-software/tpm2-pkcs11|{{Pkg|tpm2-pkcs11}}}}
# systemd-cryptenroll --tpm2-device=''/path/to/tpm2_device'' --tpm2-pcrs=0,7 /dev/sdX
 
  +
:参照 [https://github.com/tpm2-software/tpm2-pkcs11/blob/master/docs/SSH.md SSH 設定] それと [https://incenp.org/notes/2020/tpm-based-ssh-key.html SSH 認証に TPM を使用する] (2020-01)
   
  +
=== GnuPG ===
where {{ic|/dev/sdX}} is the full path to the encrypted LUKS volume and {{ic|''/path/to/tpm2_device''}} is the full path to the TPM as given in the output of the first command.
 
   
  +
[[GnuPG]] はバージョン 2.3 以降、互換性のあるキーの TPM への移動をサポートしています。手順については、[https://gnupg.org/blog/20210315-using-tpm-with-gnupg-2.3.html GnuPG 2.3 での TPM の使用] を参照してください。
{{Tip|If your computer has only one TPM installed, which is usually the case, you may instead specify {{ic|1=--tpm2-device=auto}} to automatically select the only available TPM.}}
 
   
  +
=== TPM 2.0 のその他の使用例 ===
To test that the key works, run the following command while the LUKS volume is closed:
 
   
  +
* [https://threat.tevora.com/secure-boot-tpm-2/ セキュアブート + TPM 2 の設定] (2018-06, Debian)
# /usr/lib/systemd/systemd-cryptsetup attach ''mapping_name'' /dev/sdX - tpm2-device=''/path/to/tpm2_device''
 
  +
* [https://www.youtube.com/watch?v=XwaSyHJIos8 Using the TPM - It's Not Rocket Science (Anymore)] - Johannes Holland & Peter Huewe (2020-11、Youtube): {{Pkg|tpm2-tss-engine}} を使用した OpenSSL の例
   
  +
== PCR レジスタへのアクセス ==
where {{ic|''mapping_name''}} is your chosen name for the volume once opened. If the volume successfully unlocks, you are ready to add the required information to the [[crypttab]] so that [[systemd]] can automatically unlock the device at boot.
 
   
  +
Platform Configuration Registers (PCR) には、いつでも読み取ることができるハッシュが含まれていますが、以前のハッシュ値に依存する拡張操作を介してのみ書き込むことができるため、一種のブロックチェーンが形成されます。これらは、ブート間のプラットフォームのハードウェアおよびソフトウェアの整合性チェックに使用することを目的としています (たとえば、[[Wikipedia:ja:悪意あるメイド攻撃|悪意のある Maid 攻撃]] に対する保護) これらは、暗号化キーのロックを解除し、正しい OS が起動されたことを証明するために使用できます。
{{hc|/etc/crypttab|2=
 
# Example crypttab file. Fields are: name, underlying device, passphrase, cryptsetup options.
 
   
  +
[https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/ TCG PC クライアント固有プラットフォームファームウェアプロファイル仕様] では、使用中のレジスタが定義されており、[https://uapi-group.org/specifications/specs/linux_tpm_pcr_registry/ Linux TPM PCR レジストリ] は、これらを使用して Linux システムコンポーネントを割り当てます。
# Unlock /dev/sdX using the only available TPM, naming it myvolume
 
myvolume /dev/sdX - tpm2-device=auto
 
}}
 
   
  +
レジスタは次のとおりです:
{{Note|While you may specify the UUID of your LUKS volume in place of the pathname {{ic|/etc/crypttab}}, the ''systemd-cryptenroll'' command itself currently only supports pathnames.}}
 
  +
:
   
  +
{| class="wikitable"
If the volume you wish to unlock contains your root filesystem, you must take the following additional steps:
 
  +
|-
  +
! scope="col"| PCR
  +
! scope="col"| 使用
  +
! scope="col"| ノート
  +
|-
  +
|PCR0
  +
|コアシステムファームウェアの実行可能コード (別名ファームウェア)
  +
|UEFIをアップグレードすると変更される可能性があります
  +
|-
  +
|PCR1
  +
|コアシステムファームウェア データ (別名 UEFI 設定)
  +
|
  +
|-
  +
|PCR2
  +
|拡張またはプラグイン可能な実行可能コード
  +
|
  +
|-
  +
|PCR3
  +
|拡張またはプラグイン可能なファームウェアデータ
  +
|ブートデバイス選択 UEFI ブートフェーズ中に設定
  +
|-
  +
|PCR4
  +
|ブートマネージャーコードとブート試行
  +
|ブートマネージャーとファームウェアがブートしようとしたデバイスを測定します。
  +
|-
  +
|PCR5
  +
|ブートマネージャーの設定とデータ
  +
|ブートローダーの設定を測定できます。GPT パーティションテーブルが含まれます
  +
|-
  +
|PCR6
  +
|S4 および S5 の電源状態イベントから再開
  +
|
  +
|-
  +
|PCR7
  +
|セキュアブート状態
  +
|PK/KEK/db の完全な内容と、各ブートアプリケーションの検証に使用される特定の証明書が含まれます。 [https://superuser.com/questions/1640985/how-to-enable-bitlocker-when-booting-windows-10-from-a-non-microsoft-boot-manage]
  +
|-
  +
|PCR8<sup>1</sup>
  +
|カーネルコマンドラインのハッシュ
  +
|[https://lists.gnu.org/archive/html/grub-devel/2017-07/msg00003.html grub] それと [https://github.com/systemd/systemd/pull/2587 systemd-boot] によってサポートされています
  +
|-
  +
|PCR9<sup>1</sup>
  +
|initrd および EFI ロードオプションのハッシュ
  +
|Linux は、initrd および EFI ロードオプション、つまりカーネルコマンドラインオプションを測定します。
  +
|-
  +
|PCR10<sup>1</sup>
  +
|将来の使用のために予約されています
  +
|
  +
|-
  +
|PCR11<sup>1</sup>
  +
|[[ユニファイドカーネルイメージ]]のハッシュ
  +
|{{man|7|systemd-stub}} を参照してください。
  +
|-
  +
|PCR12<sup>1</sup>
  +
|オーバーライドされたカーネルコマンドライン、資格情報
  +
|{{man|7|systemd-stub}} を参照してください。
  +
|-
  +
|PCR13<sup>1</sup>
  +
|システム拡張機能
  +
|{{man|7|systemd-stub}} を参照してください。
  +
|-
  +
|PCR14<sup>1</sup>
  +
|shim の MokList、MokListX、および MokSBState。
  +
|[https://github.com/rhboot/shim/blob/main/README.tpm]
  +
|-
  +
|PCR15<sup>1</sup>
  +
|
  +
|未使用
  +
|-
  +
|PCR16<sup>1</sup>
  +
|デバッグ
  +
|いつでも使用およびリセットできます。公式ファームウェアのリリースには含まれていない可能性があります。
  +
|-
  +
|PCR23
  +
|アプリケーションのサポート
  +
|OS はこの PCR を設定およびリセットできます。
  +
|}
   
  +
# ユースケースは OS によって定義されており、さまざまな Linux ディストリビューションと Windows デバイス間で異なる場合があります。
* Ensure you are using {{ic|systemd}} and {{ic|sd-encrypt}} in the {{ic|HOOKS}} array of {{ic|/etc/mkinitcpio.conf}}
 
* Configure your initramfs to unlock the root volume with one of the following methods:
 
** Specifying the root volume using the configuration outlined above in {{ic|/etc/crypttab.initramfs}} (see tip at the top of [[Dm-crypt/System_configuration#Using_sd-encrypt_hook|Using sd-encrypt hook]])
 
** Setting {{ic|1=rd.luks.options=''XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX''=tpm2-device=auto}} in addition to {{ic|rd.luks.uuid}} or {{ic|rd.luks.name}} in the kernel command line
 
   
  +
Windows では、BitLocker は独自の目的で PCR8-11 (レガシー) または PCR11-14 (UEFI) を使用します。
To remove a key enrolled using this method, run:
 
  +
tianocore のドキュメント [https://github.com/tianocore-docs/edk2-TrustedBootChain/blob/main/4_Other_Trusted_Boot_Chains.md]
   
  +
{{Pkg|tpm2-totp}} は、オブザーバーと専用の信頼できるデバイスを使用してこのチェックを容易にします。
# systemd-cryptenroll /dev/sdX --wipe-slot=''slot_number''
 
   
  +
現在の PCR 値は、{{man|1|systemd-analyze}} で一覧表示できます:
where {{ic|''slot_number''}} is the numeric LUKS slot number in which your TPM key is stored.
 
   
  +
$ systemd-analyze pcrs
Alternatively, run:
 
   
  +
または、{{Pkg|tpm2-tools}} の {{man|1|tpm2_pcrread}} を使用します:
# systemd-cryptenroll /dev/sdX --wipe-slot=tpm2
 
   
  +
# tpm2_pcrread
to remove all TPM-associated keys from your LUKS volume.
 
 
See {{man|1|systemd-cryptenroll}} and {{man|5|crypttab}} for more information and examples.
 
 
==== Clevis ====
 
 
{{Pkg|clevis}} allows binding a LUKS volume to a system by creating a key and encrypting it using the TPM, and sealing the key using PCR values which represent the system state at the time of the Clevis pin creation.
 
 
{{Warning|Set a strong backup password in case the TPM unsealing fails, using:
 
 
{{bc|# cryptsetup luksAddKey /dev/sdX}}
 
}}
 
 
To bind a LUKS volume to the TPM, use:
 
 
# clevis luks bind -d /dev/sdX tpm2 '{}'
 
 
where {{ic|'{}'|}} contains the configuration. Even with no parameters, the drive cannot be decrypted from another computer (unless the attacker knows the backup password).
 
 
To seal the LUKS key against, for example, the UEFI settings and the [[Secure Boot]] policy, use:
 
 
{{bc|'{"pcr_ids":"1,7"}'}}
 
 
If the UEFI or Secure Boot settings are modified, the TPM will compute different PCR values and decryption will fail. This gives protection against [[wikipedia:Evil maid attack|evil maid attacks]].
 
 
For a list of parameters, see {{man|1|clevis-encrypt-tpm2|CONFIG}}.
 
 
For a full explanation of the meanings of PCRs, see the [https://trustedcomputinggroup.org/wp-content/uploads/PC-ClientSpecific_Platform_Profile_for_TPM_2p0_Systems_v51.pdf TCG specification] (§ 2.3.4).
 
 
To generate a new Clevis pin after changes in system configuration that result in different PCR values, for example updating the UEFI when PCR 0 is used, run
 
 
{{hc|# cryptsetup luksDump /dev/sdX|output=
 
Tokens:
 
''token slot'': clevis
 
Keyslot: ''keyslot''
 
}}
 
 
to find the slot used for the Clevis pin, then
 
 
# clevis luks regen -d /dev/sdX -s ''keyslot''
 
 
To remove the Clevis binding, run:
 
 
# clevis luks unbind -d /dev/sdX -s ''keyslot''
 
 
{{Warning|Double check you have chosen the right slot, or you might lose access to your volume.}}
 
 
You can unlock a TPM-bound volume using:
 
 
# clevis luks unlock -d /dev/sdX
 
 
For automated decryption of volumes in [[Dm-crypt/System_configuration#crypttab|/etc/crypttab]], [[enable]] {{ic|clevis-luks-askpass.path}}.
 
 
For automated decryption of the root volume, use [[Booster]], [[Dracut]] or [https://github.com/kishorv06/arch-mkinitcpio-clevis-hook mkinitcpio-clevis-hook]. Booster automatically decrypts LUKS volumes bound using Clevis out of the box. Dracut and mkinitcpio-clevis-hook needs the following extra packages:
 
 
* {{Pkg|libpwquality}}
 
* {{Pkg|luksmeta}}
 
* {{Pkg|nmap}} (For Dracut)
 
* {{Pkg|tpm2-tools}} (For mkinitcpio-clevis-hook)
 
 
followed by an initramfs regeneration:
 
 
Dracut:
 
# dracut -f
 
 
mkinitcpio-clevis-hook:
 
# mkinitcpio -P
 
 
=== Other good examples of TPM 2.0 usage ===
 
 
* SSH: {{Pkg|tpm2-pkcs11}}'s [https://github.com/tpm2-software/tpm2-pkcs11/blob/master/docs/SSH.md SSH configuration] and [https://incenp.org/notes/2020/tpm-based-ssh-key.html Using a TPM for SSH authentication] (2020-01)
 
* [https://threat.tevora.com/secure-boot-tpm-2/ Configuring Secure Boot + TPM 2] (2018-06, Debian)
 
* [https://www.youtube.com/watch?v=XwaSyHJIos8 Using the TPM - It's Not Rocket Science (Anymore)] - Johannes Holland & Peter Huewe (2020-11, Youtube): examples for OpenSSL with {{Pkg|tpm2-tss-engine}}
 
 
== Using TPM 1.2 ==
 
=== ドライバー ===
 
 
TPM ドライバーは新しいカーネルならネイティブで含まれていますが、ロードする必要があります:
 
 
# modprobe tpm
 
 
さらに、使用しているチップセットにあわせて、以下のモジュールのどれかをロードしてください:
 
 
# modprobe tpm_{atmel,bios,infineon,nsc,tis,crb}
 
 
=== 使用方法 ===
 
 
TPM は {{ic|tcsd}} によって管理します。Trusted Computing リソースを管理するユーザー空間のデーモンで、(TSS の仕様によれば) TPM デバイスドライバーの唯一の表玄関です。{{ic|tcsd}} は AUR パッケージの {{AUR|trousers}} に含まれています。IBM によって開発・リリースされており、{{ic|/etc/tcsd.conf}} で設定することが可能です。
 
 
tcsd を起動して出力を監視するには、次を実行:
 
 
# tcsd -f
 
 
もしくは {{ic|tcsd.service}} を起動・有効化してください。
 
 
{{ic|tcsd}} を実行したら、{{AUR|tpm-tools}} もインストールすると良いでしょう。TPM を管理するためのコマンドラインツールが多数入っています。
 
 
他の便利なツール:
 
 
* {{App|tpmmanager|tpm-tools の Qt フロントエンド。|https://sourceforge.net/projects/tpmmanager|{{AUR|tpmmanager}}}}
 
* {{App|openssl_tpm_engine|TSS API と対話する OpenSSL エンジン。|https://sourceforge.net/projects/trousers|{{AUR|openssl_tpm_engine}}{{Broken package link|{{aur-mirror|openssl_tpm_engine}}}}}}
 
* {{App|tpm_keyring2|TPM ベースの eCryptfs 鍵を管理するキーマネージャ。|https://sourceforge.net/projects/trousers|{{AUR|tpm_keyring2}}{{Broken package link|{{aur-mirror|tpm_keyring2}}}}}}
 
* {{App|opencryptoki|Linux の PKCS#11 実装。IBM の暗号ハードウェアを使用するためのドライバーやライブラリ、テスト用のソフトウェアトークンが含まれています。|https://sourceforge.net/projects/opencryptoki|{{AUR|opencryptoki}}}}
 
 
=== 基本 ===
 
 
まずは基本的なバージョン情報を確認してください:
 
 
$ tpm_version
 
 
そしてセルフテストを実行:
 
 
$ tpm_selftest -l info
 
TPM Test Results: 00000000 ...
 
tpm_selftest succeeded
 
 
=== SSH 鍵のセキュア化 ===
 
 
TPM を使って鍵を保護する方法は複数存在しますが、以下では {{aur|simple-tpm-pk11-git}} を使用する簡単な方法を説明します。
 
 
まず、新しいディレクトリを作成して鍵を生成してください:
 
 
$ mkdir ~/.simple-tpm-pk11
 
$ stpm-keygen -o ~/.simple-tpm-pk11/my.key
 
 
鍵を設定:
 
 
{{hc|~/.simple-tpm-pk11/config|
 
key my.key
 
}}
 
 
SSH を設定して適切な PKCS11 プロバイダを使用する:
 
 
{{hc|~/.ssh/config|
 
Host *
 
PKCS11Provider /usr/lib/libsimple-tpm-pk11.so
 
}}
 
 
これで PKCS11 プロバイダで鍵を生成することができます:
 
 
$ ssh-keygen -D /usr/lib/libsimple-tpm-pk11.so
 
 
{{Note|上記の方法では複数の鍵を生成・使用することはできません。}}
 
   
 
== トラブルシューティング ==
 
== トラブルシューティング ==
   
  +
=== TPM2 LUKS2 のロック解除でパスワードを要求される ===
=== tcsd.service が起動しない ===
 
 
パーミッションの問題が原因で {{ic|tcsd.service}} サービスが起動できないのかもしれません [https://bugs.launchpad.net/ubuntu/+source/trousers/+bug/963587/comments/3]。以下のコマンドで解決できる可能性があります:
 
   
  +
TPM2 ハードウェアモジュールに登録された鍵で luks2 デバイスのロックを自動的に解除する [[Trusted Platform Module# LUKS による保存データの暗号化|上記の指示]] に従ったにもかかわらず、initramfs のブートステージでパスワードを入力するプロンプトが表示される場合。特定の TPM2 モジュールを扱うカーネルモジュール ({{ic|1= systemd-cryptenroll --tpm2-device=list}} でその名前を取得できます) を [[カーネルモジュール#モジュールの早期ロード|早期ロード]] する必要があるかもしれません。
# chown tss:tss /dev/tpm*
 
# chown -R tss:tss /var/lib/tpm
 
   
==参照==
+
== 参照 ==
   
  +
* [[Gentoo:Trusted Platform Module]]
* [https://lwn.net/Articles/674751/ Protecting systems with the TPM]
 
  +
* TPM-JS テストツール:: [https://github.com/google/tpm-js source] - [https://google.github.io/tpm-js/ live web version].
* [https://www.thinkwiki.org/wiki/Embedded_Security_Subsystem Embedded Security Subsystem on Thinkwiki]
 
* [https://www.cs.unh.edu/~it666/reading_list/Hardware/tpm_fundamentals.pdf TPM Fundamentals (PDF)]
 
* [https://www.lorier.net/docs/tpm Using a TPM]
 

2024年4月24日 (水) 20:26時点における最新版

関連記事

Trusted Platform Module (TPM) は安全な暗号プロセッサの国際規格です。これは暗号鍵をデバイスに統合することによりハードウェアを保護する専用のマイクロプロセッサです。

実際には TPMはセキュアブート、キーストレージ、乱数生成など様々なセキュリティアプリケーションで使うことができます。

TPM が使えるのは TPM ハードウェアに対応しているデバイスだけです。あなたのハードウェアが TPM をサポートしているのに認識されない場合、BIOS の設定で TPM を有効にする必要があります。

バージョン

TPM 仕様には 2.0 と 1.2 という 2 つの非常に異なるものがあり、これらも異なるソフトウェアスタックを使用します。この記事では TPM 2.0 についてのみ説明します。古い TPM 1.2 については、/1.2 を参照してください。

TPM 2.0 では、/dev/tpm0 による直接アクセスが可能である。(一度に1クライアント)、/dev/tpmrm0 経由のカーネル管理アクセス、tpm2-abrmd リソースマネージャーデーモンによる管理アクセスが可能です。systemd プロジェクトメンバーによるとtpm2-abrmd の使用はもはや推奨されていません。ユーザ空間ツールには Intel の tpm2-tools と IBM の ibm-tssAUR の2つの選択肢があります。

TPM 2.0 には UEFI ブートが必要です。BIOS またはレガシーブートシステムは TPM 1.2 のみを使用できます。

一部の TPM チップは、ファームウェアアップグレードを通じて 2.0 と 1.2 の間で切り替えることができます (限られた回数のみ実行可能)

使い方

日常のアプリケーションで TPM 2.0 サービスを設定および利用する方法を学習するための多くの有益なリソースが、コミュニティ から入手できます。

サポートの確認

TPM 2.0 チップは、2016 年 7 月 28 日以降、Windows 10 を実行することが認定されたコンピューターの要件となっています。[1] Linux はバージョン 3.20 以降 TPM 2.0 をサポートしています [2] 他の手順は、デフォルトの Arch インストールで有効になります。

特定のソフトウェアを使用せずに TPM 2.0 がセットアップされているかどうかを確認する 2 つの方法:

  • ログを確認します。たとえば、root として journalctl -k --grep=tpm を実行します。
  • /sys/class/tpm/tpm0/device/description [3] または /sys/class/tpm/tpm0/tpm_version_major の値を読み取ります。

LUKS による保存データの暗号化

TPM を使用して LUKS ボリュームのロックを解除するには、2 つの方法があります。Clevis または systemd-cryptenroll を使用できます。

どちらの方法を使用しても、TPM に保存されているキーを使用して、起動時に自動的に、または後で手動で、暗号化されたボリュームのロックを解除できます。この目的で TPM を使用すると、ファームウェアが変更されていない、セキュアブート が無効になっていないなど、特定の条件が満たされない限り、ドライブのロックが解除されなくなります (PCR レジスタへのアクセス を参照)

警告: この方法をルートボリュームで使用すると、先に述べた一定の条件が満たされている限り、暗号化パスワードを入力することなく、コンピュータの起動時に 自動的にロックが解除される ことを意味します。
  • つまり、暗号化されたディスクだけが盗まれてもデータへのアクセスは保護されますが、PC全体が盗まれた場合保護されません。
  • なぜなら、たとえコンピュータの電源が長い間オフになっていたとしても(メモリが完全にクリアされていることを保証するために)、攻撃者は単に電源を入れ、TPMが自動的にキーをロードするのを待つことができるからです。これは、価値の高いターゲットにとっては懸念事項になります。

systemd-cryptenroll

systemd-cryptenroll#Trusted Platform Module を参照してください。

SSH

TPM でシールされた SSH キーには、次の 2 つのオプションがあります:

  • ssh-tpm-agent — TPM でサポートされたキーを使用する ssh-agent 互換エージェント。
https://github.com/Foxboron/ssh-tpm-agent || ssh-tpm-agent-gitAUR
参照 SSH キーを TPM 内に保存します: ssh-tpm-agent
  • tpm2-pkcs11 — Trusted Platform Module 2.0 ハードウェア用の PKCS#11 インターフェイス。
https://github.com/tpm2-software/tpm2-pkcs11 || tpm2-pkcs11
参照 SSH 設定 それと SSH 認証に TPM を使用する (2020-01)

GnuPG

GnuPG はバージョン 2.3 以降、互換性のあるキーの TPM への移動をサポートしています。手順については、GnuPG 2.3 での TPM の使用 を参照してください。

TPM 2.0 のその他の使用例

PCR レジスタへのアクセス

Platform Configuration Registers (PCR) には、いつでも読み取ることができるハッシュが含まれていますが、以前のハッシュ値に依存する拡張操作を介してのみ書き込むことができるため、一種のブロックチェーンが形成されます。これらは、ブート間のプラットフォームのハードウェアおよびソフトウェアの整合性チェックに使用することを目的としています (たとえば、悪意のある Maid 攻撃 に対する保護) これらは、暗号化キーのロックを解除し、正しい OS が起動されたことを証明するために使用できます。

TCG PC クライアント固有プラットフォームファームウェアプロファイル仕様 では、使用中のレジスタが定義されており、Linux TPM PCR レジストリ は、これらを使用して Linux システムコンポーネントを割り当てます。

レジスタは次のとおりです:

PCR 使用 ノート
PCR0 コアシステムファームウェアの実行可能コード (別名ファームウェア) UEFIをアップグレードすると変更される可能性があります
PCR1 コアシステムファームウェア データ (別名 UEFI 設定)
PCR2 拡張またはプラグイン可能な実行可能コード
PCR3 拡張またはプラグイン可能なファームウェアデータ ブートデバイス選択 UEFI ブートフェーズ中に設定
PCR4 ブートマネージャーコードとブート試行 ブートマネージャーとファームウェアがブートしようとしたデバイスを測定します。
PCR5 ブートマネージャーの設定とデータ ブートローダーの設定を測定できます。GPT パーティションテーブルが含まれます
PCR6 S4 および S5 の電源状態イベントから再開
PCR7 セキュアブート状態 PK/KEK/db の完全な内容と、各ブートアプリケーションの検証に使用される特定の証明書が含まれます。 [4]
PCR81 カーネルコマンドラインのハッシュ grub それと systemd-boot によってサポートされています
PCR91 initrd および EFI ロードオプションのハッシュ Linux は、initrd および EFI ロードオプション、つまりカーネルコマンドラインオプションを測定します。
PCR101 将来の使用のために予約されています
PCR111 ユニファイドカーネルイメージのハッシュ systemd-stub(7) を参照してください。
PCR121 オーバーライドされたカーネルコマンドライン、資格情報 systemd-stub(7) を参照してください。
PCR131 システム拡張機能 systemd-stub(7) を参照してください。
PCR141 shim の MokList、MokListX、および MokSBState。 [5]
PCR151 未使用
PCR161 デバッグ いつでも使用およびリセットできます。公式ファームウェアのリリースには含まれていない可能性があります。
PCR23 アプリケーションのサポート OS はこの PCR を設定およびリセットできます。
  1. ユースケースは OS によって定義されており、さまざまな Linux ディストリビューションと Windows デバイス間で異なる場合があります。

Windows では、BitLocker は独自の目的で PCR8-11 (レガシー) または PCR11-14 (UEFI) を使用します。 tianocore のドキュメント [6]

tpm2-totp は、オブザーバーと専用の信頼できるデバイスを使用してこのチェックを容易にします。

現在の PCR 値は、systemd-analyze(1) で一覧表示できます:

$ systemd-analyze pcrs

または、tpm2-toolstpm2_pcrread(1) を使用します:

# tpm2_pcrread

トラブルシューティング

TPM2 LUKS2 のロック解除でパスワードを要求される

TPM2 ハードウェアモジュールに登録された鍵で luks2 デバイスのロックを自動的に解除する 上記の指示 に従ったにもかかわらず、initramfs のブートステージでパスワードを入力するプロンプトが表示される場合。特定の TPM2 モジュールを扱うカーネルモジュール (systemd-cryptenroll --tpm2-device=list でその名前を取得できます) を 早期ロード する必要があるかもしれません。

参照