<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Google-Cloud-Kms on Tarragon</title><link>https://tarrragon.github.io/blog/tags/google-cloud-kms/</link><description>Recent content in Google-Cloud-Kms on Tarragon</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Tarragon (CC BY 4.0)</copyright><lastBuildDate>Mon, 18 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tarrragon.github.io/blog/tags/google-cloud-kms/index.xml" rel="self" type="application/rss+xml"/><item><title>Google Cloud KMS</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-cloud-kms/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-cloud-kms/</guid><description>&lt;p>Google Cloud KMS 是 GCP 原生的 key management service、把 envelope encryption、asymmetric signing 與 MAC 等密碼運算集中在受控的 key custodian 內、key material 不離保護邊界。應用端只持 &lt;em>KMS resource name + IAM 權限&lt;/em>、用 &lt;code>Encrypt&lt;/code> / &lt;code>Decrypt&lt;/code> / &lt;code>AsymmetricSign&lt;/code> API 把 plaintext 或 hash 送進 Cloud KMS、key 永遠在 Google 管理的 software 模組或 HSM 內運算完才把結果送回。整個 GCP 的 CMEK（Customer Managed Encryption Key）生態都以 Cloud KMS 為錨點 — GCS bucket、BigQuery dataset、Persistent Disk、Cloud SQL、GKE etcd 都可指定一把 Cloud KMS key 做加密、跟 cloud-native 預設加密（GCP 自管 key、客戶看不到）拉出邊界。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>Cloud KMS 的核心定位是 &lt;em>GCP-native envelope encryption + signing 控制面&lt;/em>、用 KeyRing 作為 organizational + locational grouping、CryptoKey + CryptoKeyVersion 作為 key material 的版本軸。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/aws-kms/" data-link-title="AWS KMS" data-link-desc="AWS 原生 key management service、envelope encryption / digital signing / Multi-Region Key、Key Policy &amp;#43; Grant 雙軌授權">AWS KMS&lt;/a> 相比、最大差異是 &lt;em>沒有獨立的 Key Policy&lt;/em>：權限完全走 GCP IAM（Role Binding 綁到 KeyRing 或 CryptoKey resource）、好處是跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM&lt;/a> 統一治理（同一份 IAM audit、同一套 conditional binding）、代價是少了 AWS KMS Key Policy 那種 &lt;em>key-level 的獨立 deny override&lt;/em>。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/azure-key-vault/" data-link-title="Azure Key Vault" data-link-desc="Azure 三合一 service（Secret &amp;#43; Key &amp;#43; Certificate）、整合 Managed Identity &amp;#43; Entra ID RBAC、Premium tier 走 HSM">Azure Key Vault&lt;/a> 相比、Cloud KMS 拆得更細：Azure 把 secret + key + certificate 合在同一個 Key Vault service、Google 拆成 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-secret-manager/" data-link-title="Google Secret Manager" data-link-desc="GCP 原生 secret store、CMEK &amp;#43; Workload Identity Federation 整合、rotation 走自寫 Cloud Function 而非 built-in Lambda">Google Secret Manager&lt;/a>（secret）+ Cloud KMS（key）+ Certificate Authority Service（PKI），各 service IAM、quota、audit 獨立。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/cloudhsm/" data-link-title="AWS CloudHSM" data-link-desc="Single-tenant dedicated HSM（FIPS 140-2 Level 3）、AWS 不持 Crypto User credential、合規 &amp;#43; 資料主權場景的 key custody">CloudHSM&lt;/a> 相比、Cloud KMS Protection Level=HSM 是 &lt;em>managed HSM&lt;/em>（FIPS 140-2 Level 3、Google 顧 cluster）、CloudHSM 是 &lt;em>single-tenant 專屬 HSM&lt;/em>（客戶顧 cluster、合規隔離更強）。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault transit&lt;/a> 相比、Cloud KMS 綁 GCP、Vault transit 可跨雲；但 Vault 自己常用 Cloud KMS 當 auto-unseal master key custodian。&lt;/p></description><content:encoded><![CDATA[<p>Google Cloud KMS 是 GCP 原生的 key management service、把 envelope encryption、asymmetric signing 與 MAC 等密碼運算集中在受控的 key custodian 內、key material 不離保護邊界。應用端只持 <em>KMS resource name + IAM 權限</em>、用 <code>Encrypt</code> / <code>Decrypt</code> / <code>AsymmetricSign</code> API 把 plaintext 或 hash 送進 Cloud KMS、key 永遠在 Google 管理的 software 模組或 HSM 內運算完才把結果送回。整個 GCP 的 CMEK（Customer Managed Encryption Key）生態都以 Cloud KMS 為錨點 — GCS bucket、BigQuery dataset、Persistent Disk、Cloud SQL、GKE etcd 都可指定一把 Cloud KMS key 做加密、跟 cloud-native 預設加密（GCP 自管 key、客戶看不到）拉出邊界。</p>
<h2 id="服務定位">服務定位</h2>
<p>Cloud KMS 的核心定位是 <em>GCP-native envelope encryption + signing 控制面</em>、用 KeyRing 作為 organizational + locational grouping、CryptoKey + CryptoKeyVersion 作為 key material 的版本軸。跟 <a href="/blog/backend/07-security-data-protection/vendors/aws-kms/" data-link-title="AWS KMS" data-link-desc="AWS 原生 key management service、envelope encryption / digital signing / Multi-Region Key、Key Policy &#43; Grant 雙軌授權">AWS KMS</a> 相比、最大差異是 <em>沒有獨立的 Key Policy</em>：權限完全走 GCP IAM（Role Binding 綁到 KeyRing 或 CryptoKey resource）、好處是跟 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM</a> 統一治理（同一份 IAM audit、同一套 conditional binding）、代價是少了 AWS KMS Key Policy 那種 <em>key-level 的獨立 deny override</em>。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/azure-key-vault/" data-link-title="Azure Key Vault" data-link-desc="Azure 三合一 service（Secret &#43; Key &#43; Certificate）、整合 Managed Identity &#43; Entra ID RBAC、Premium tier 走 HSM">Azure Key Vault</a> 相比、Cloud KMS 拆得更細：Azure 把 secret + key + certificate 合在同一個 Key Vault service、Google 拆成 <a href="/blog/backend/07-security-data-protection/vendors/google-secret-manager/" data-link-title="Google Secret Manager" data-link-desc="GCP 原生 secret store、CMEK &#43; Workload Identity Federation 整合、rotation 走自寫 Cloud Function 而非 built-in Lambda">Google Secret Manager</a>（secret）+ Cloud KMS（key）+ Certificate Authority Service（PKI），各 service IAM、quota、audit 獨立。跟 <a href="/blog/backend/07-security-data-protection/vendors/cloudhsm/" data-link-title="AWS CloudHSM" data-link-desc="Single-tenant dedicated HSM（FIPS 140-2 Level 3）、AWS 不持 Crypto User credential、合規 &#43; 資料主權場景的 key custody">CloudHSM</a> 相比、Cloud KMS Protection Level=HSM 是 <em>managed HSM</em>（FIPS 140-2 Level 3、Google 顧 cluster）、CloudHSM 是 <em>single-tenant 專屬 HSM</em>（客戶顧 cluster、合規隔離更強）。跟 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault transit</a> 相比、Cloud KMS 綁 GCP、Vault transit 可跨雲；但 Vault 自己常用 Cloud KMS 當 auto-unseal master key custodian。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>KeyRing 該放哪個 location（global / regional / dual-regional / multi-regional）、為何一旦決定無法搬遷</li>
<li>CryptoKey Version + Primary 版本軸怎麼支撐 rotation、何時該 disable / destroy 舊 version</li>
<li>Protection Level（SOFTWARE / HSM / EXTERNAL）跟 Cloud HSM、External Key Manager 的取捨</li>
<li>CMEK 整合 GCS / BigQuery / Persistent Disk 跟 cloud-native default encryption 的邊界差異</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷一份 Cloud KMS 部署是否健康、最少看四件事：</p>
<ul>
<li><strong>KeyRing location 對不對</strong>：production sensitive key 用 region / multi-region、避免不必要的 <code>global</code> KeyRing；location 一旦設定 <em>不能改</em>、key 也搬不出原 KeyRing — 設錯只能建新 KeyRing + 重新加密所有 ciphertext</li>
<li><strong>IAM Conditions 跟 least privilege</strong>：<code>roles/cloudkms.cryptoKeyEncrypterDecrypter</code> 不該綁到 KeyRing level（會放大爆炸半徑）、應綁到具體 CryptoKey；admin 跟 use 角色分離（<code>roles/cloudkms.admin</code> ≠ <code>roles/cloudkms.signer</code>）；敏感 key 加 IAM Condition（時間窗、resource attribute）</li>
<li><strong>Cloud Audit Logs 開到對的層級</strong>：Admin Activity（建 key、改 IAM、destroy version）預設開、Data Access（每次 Encrypt / Decrypt / Sign）<em>預設關</em> — production sensitive key 必須在 IAM audit config 把 Data Access 開、否則「誰用 key 做了什麼」查不到</li>
<li><strong>Protection Level 對齊合規</strong>：production 跟 PII / 金融 / 醫療資料的 key 應走 HSM 或 EXTERNAL、SOFTWARE 只給 dev / 低敏感場景；EKM 對應 <em>資料主權</em>（key 物理上不在 GCP）</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/knowledge-cards/audit-log/" data-link-title="Audit Log" data-link-desc="說明高風險操作如何留下可追溯、可稽核的紀錄">Audit Log</a> 與 KMS 邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>KeyRing 設計</strong>：KeyRing 是 <em>組織單位 + 位置鎖</em>。建議切法：依 <em>環境 + 用途</em> 拆（<code>prod-data-encryption-asia-east1</code>、<code>prod-signing-global</code>、<code>dev-data-encryption-asia-east1</code>），不要全公司一個 KeyRing。Location 選擇：跟資料 colocate（GCS bucket 在 <code>asia-east1</code> 的 key 也放 <code>asia-east1</code> KeyRing、避免跨區延遲與資料主權問題）；signing key 多半放 <code>global</code> 或 multi-region 提高可用性；CMEK 給 BigQuery 時 KeyRing location 必須跟 dataset location 一致、否則綁不上。一個原則：<em>KeyRing location 是一次性決策</em>、上線前確認跟 cloud resource location + 法規要求對齊。</p>
<p><strong>CryptoKey Version 與 Primary</strong>：CryptoKey 有多個 version（<code>projects/.../cryptoKeys/k/cryptoKeyVersions/1</code>、<code>v2</code>、<code>v3</code>）、其中一個是 Primary — 所有 <code>Encrypt</code> API 預設用 Primary version 加密、<code>Decrypt</code> 自動依 ciphertext 內嵌的 version ID 找對應 version 解。Rotation 不是「換 key」、是 <em>建立新 version 並 promote 為 Primary</em>；舊 version 仍可 decrypt 既有 ciphertext（除非手動 disable / destroy）。Destroy 是 24 小時延遲（可在期內 restore）、destroy 之後 ciphertext 永久不可解 — 排程 destroy 前必須確認沒有遺留 ciphertext 還在用該 version。</p>
<p><strong>Auto Rotation</strong>：CryptoKey 可設 <code>rotationPeriod</code>（最短 1 天、預設 90 天）、KMS 在到期時自動建立新 version + promote 為 Primary、app 不需要改 code。Auto rotation 只對 <em>symmetric encryption key</em> 有效；asymmetric key（signing / decryption）不支援 auto rotation、需要手動建 version + 通知 consumer 更新 public key。注意 auto rotation 是 <em>key version 換</em>、不會 re-encrypt 既有資料 — 真正的 <em>資料 re-encryption</em> 是另一條工作流（讀回 ciphertext + 用新 Primary 重加密寫回）、要依 CMEK-integrated resource 各自規劃。</p>
<p><strong>Protection Level</strong>：SOFTWARE（軟體運算、最便宜、FIPS 140-2 Level 1）/ HSM（Cloud HSM 後端、FIPS 140-2 Level 3、key 物理上在 Google 管理的 HSM cluster）/ EXTERNAL（External Key Manager、key 在客戶自管的外部 HSM、Cloud KMS 把運算委派出去）。Production sensitive key 應走 HSM、SOFTWARE 給 dev / 低敏感場景。Protection Level 是 <em>CryptoKey 建立時決定</em>、不能改 — 要升等只能建新 CryptoKey + 遷移 ciphertext。</p>
<p><strong>CMEK 整合</strong>：CMEK 把 Cloud KMS key 綁到 GCS bucket / BigQuery dataset / Persistent Disk / Cloud SQL / GKE etcd / Pub/Sub topic / Dataflow job 等 resource。設定方式：cloud service 的 service account（如 <code>service-PROJECT_NUMBER@gs-project-accounts.iam.gserviceaccount.com</code>）取得該 CryptoKey 的 <code>cryptoKeyEncrypterDecrypter</code> 權限、resource 在加密時自動呼叫 KMS。跟 cloud-native default encryption（GCP 自己管 key）的差異：CMEK 下 <em>客戶可隨時 disable key 讓整個 bucket / dataset 立刻無法解</em>（compliance kill switch）、default encryption 沒這個能力。代價是 KMS 故障 = CMEK-integrated resource 全部讀寫卡住、所以 production KMS 自身 SLA 跟 monitoring 是 cluster-level dependency。</p>
<p><strong>External Key Manager (EKM)</strong>：GCP 把 encryption / decryption operation <em>委派</em> 給客戶自管的外部 HSM（Thales、Equinix SmartKey、Fortanix 等）、key 物理上不在 GCP、Cloud KMS 只是個 proxy。適合 <em>資料主權</em> 嚴格的場景（歐盟金融、政府機密、跨境法規）— 客戶撤銷外部 HSM 的存取、GCP 立刻無法解密、達成「Google 看不到資料」的合規承諾。代價：每次 Encrypt / Decrypt 都打外部 HSM、延遲跟可用性受外部 HSM 影響、運維複雜度大幅上升。</p>
<p><strong>IAM 整合</strong>：用 Role Binding 控制存取（綁在 KeyRing 或 CryptoKey resource）— <code>roles/cloudkms.cryptoKeyEncrypterDecrypter</code>（Encrypt + Decrypt）/ <code>roles/cloudkms.signer</code>（AsymmetricSign）/ <code>roles/cloudkms.signerVerifier</code>（含 public key 取得）/ <code>roles/cloudkms.admin</code>（建 key、改 IAM）。對應 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM</a> 的 conditional binding、可加時間窗、resource attribute、access level 條件。跟 AWS KMS 的關鍵差異：<em>沒有 Key Policy</em> — 所有授權都在 IAM、好處是統一治理、代價是少了 key-level 的獨立 deny override（AWS KMS Key Policy 可寫「即使 IAM 給了 admin、仍 deny destroy」、Cloud KMS 要用 Organization Policy 或 IAM Deny 達成類似效果）。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>Google Cloud KMS</th>
          <th>AWS KMS</th>
          <th>Azure Key Vault</th>
          <th>Vault transit</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>部署模型</td>
          <td>GCP managed</td>
          <td>AWS managed</td>
          <td>Azure managed</td>
          <td>self-hosted 或 HCP</td>
      </tr>
      <tr>
          <td>跨雲</td>
          <td>弱 — 綁 GCP</td>
          <td>弱 — 綁 AWS</td>
          <td>弱 — 綁 Azure</td>
          <td>強 — 同介面跨雲</td>
      </tr>
      <tr>
          <td>Multi-region key</td>
          <td>用 multi-region KeyRing（key material 在多 region 鏡像）</td>
          <td>Multi-Region Key 較直接（單一 key ID、跨 region 自動同步）</td>
          <td>支援 geo-replication</td>
          <td>跨雲、需自行設計 replication</td>
      </tr>
      <tr>
          <td>Key 權限模型</td>
          <td>純 IAM Role Binding、無 Key Policy</td>
          <td>IAM + 獨立 Key Policy（雙層授權）</td>
          <td>RBAC + Access Policy 雙模式</td>
          <td>Vault policy（path-based）</td>
      </tr>
      <tr>
          <td>HSM 選項</td>
          <td>Protection Level=HSM（managed、FIPS 140-2 L3）</td>
          <td>AWS KMS HSM-backed（預設）+ CloudHSM（專屬）</td>
          <td>Premium tier + Managed HSM</td>
          <td>依賴後端 KMS / HSM</td>
      </tr>
      <tr>
          <td>外部 key 託管</td>
          <td>External Key Manager (EKM)</td>
          <td>XKS (External Key Store)</td>
          <td>BYOK + Managed HSM</td>
          <td>自管 HSM unseal</td>
      </tr>
      <tr>
          <td>Audit</td>
          <td>Cloud Audit Logs（Data Access 需手動開）</td>
          <td>CloudTrail（KMS event 自動進）</td>
          <td>Azure Monitor / Activity Log</td>
          <td>Vault audit device</td>
      </tr>
      <tr>
          <td>CMEK 整合廣度</td>
          <td>GCS / BQ / PD / Cloud SQL / GKE etcd / Pub/Sub / Dataflow</td>
          <td>S3 / EBS / RDS / DynamoDB / Lambda env</td>
          <td>Storage / SQL / Cosmos / Disk</td>
          <td>不適用（app-level）</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>GCP-heavy、需 CMEK 整合、Workload Identity Federation 已主導</td>
          <td>AWS-heavy、需 Multi-Region Key + Key Policy 精細控制</td>
          <td>Azure-heavy、需要 secret + key 統一治理</td>
          <td>跨雲、需要 app-level encryption-as-a-service</td>
      </tr>
  </tbody>
</table>
<p>選 Cloud KMS 的核心訴求：<em>GCP 是主力雲</em> + 需要 CMEK 把 GCS / BigQuery / PD / Cloud SQL 的加密 key custody 拉回客戶手上 + 接受 IAM-only 授權模型。需要 <em>跨雲統一 key custody</em> 走 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault transit</a> 或 EKM；需要 <em>單一專屬 HSM 隔離</em> 走 <a href="/blog/backend/07-security-data-protection/vendors/cloudhsm/" data-link-title="AWS CloudHSM" data-link-desc="Single-tenant dedicated HSM（FIPS 140-2 Level 3）、AWS 不持 Crypto User credential、合規 &#43; 資料主權場景的 key custody">CloudHSM</a> 或 EKM 接 on-prem HSM。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>External Key Manager (EKM) 與資料主權</strong>：EKM 讓 key 物理上不在 GCP、Cloud KMS 變成 proxy 把 cryptographic operation 委派給客戶自管 HSM。常見部署：金融 / 政府用 <em>EKM via VPC</em>（外部 HSM 在客戶 VPC 內、Cloud KMS 走 PSC 連線、延遲較低）、跨境合規用 <em>EKM via Internet</em>（HSM 在第三方 KMS provider、延遲較高但治理邊界更乾淨）。代價：每次 Encrypt / Decrypt = 一次外部呼叫、CMEK-integrated resource 的讀寫吞吐量受外部 HSM 限制、外部 HSM 故障 = 整個 GCP 端讀寫卡住。</p>
<p><strong>Cloud HSM（Protection Level=HSM）</strong>：把 CryptoKey 物理上鎖在 Google 託管的 FIPS 140-2 Level 3 HSM cluster 內、key 不可 export、所有 cryptographic operation 在 HSM 邊界內完成。對應 <a href="/blog/backend/07-security-data-protection/cases/microsoft-storm-0558-signing-key-2023/" data-link-title="7.C4 Microsoft：Storm-0558 簽章金鑰事件" data-link-desc="簽章金鑰事件如何回寫 identity 信任邊界與觀測證據鏈。">Microsoft Storm-0558 Signing Key 2023</a> 的對照啟示：signing key 一旦能被 export 或從 memory crash dump 撈出、整個信任鏈崩 — HSM-bound key 從設計上斷掉這條路徑。代價：HSM 後端比 SOFTWARE 貴、operation 延遲略高（典型多 &lt; 10ms）、quota 也獨立計算。</p>
<p><strong>Asymmetric Key 做 JWT signing</strong>：CryptoKey purpose=<code>ASYMMETRIC_SIGN</code> 配 algorithm（RSA / EC）、app 透過 <code>AsymmetricSign</code> API 把 JWT header+payload 的 hash 送進 KMS、KMS 回 signature。Public key 走 <code>GetPublicKey</code> API 取得、給 JWKS endpoint 對外發布。優勢：private key 不離 KMS、即使 app server compromise 也無法搬走 signing key；劣勢：每次簽名都 round-trip 一次 KMS、高 QPS 場景要算 quota 跟延遲（典型 ~10-30ms / sign）。</p>
<p><strong>跟 Google Secret Manager 的 CMEK 整合</strong>：<a href="/blog/backend/07-security-data-protection/vendors/google-secret-manager/" data-link-title="Google Secret Manager" data-link-desc="GCP 原生 secret store、CMEK &#43; Workload Identity Federation 整合、rotation 走自寫 Cloud Function 而非 built-in Lambda">Google Secret Manager</a> 預設用 GCP 管的 key 加密 secret、若要 <em>客戶管 key</em>、可設 CMEK 把 GSM 的 secret 用客戶 Cloud KMS key 加密。意義：disable Cloud KMS key 立刻讓 GSM secret 不可讀（compliance kill switch）— 但代價是 KMS 故障 = GSM 也卡住、是強耦合 dependency。</p>
<p><strong>Multi-region key</strong>：Cloud KMS 的 multi-region KeyRing（如 <code>us</code>、<code>europe</code>、<code>asia</code>）讓 key material 在多 region 鏡像、提高可用性但加密 / 解密延遲較高。AWS KMS 的 Multi-Region Key 設計不同（單一 key ID 跨 region 同步、有獨立的 primary / replica 角色）— 跨雲遷移 / 多雲 active-active 設計時要留意這個差異、Cloud KMS multi-region 比較像 <em>單一邏輯 key 多 region 可用</em>、不是 <em>多 region 各自獨立可寫</em>。</p>
<p><strong>Import 自有 key material（BYOK）</strong>：Cloud KMS 可 import 客戶自產的 key material（透過 wrapping key 包覆後上傳）、適合需要 <em>客戶端 key generation 證據鏈</em> 的合規場景。代價：import 的 key 不能 auto rotate（rotation 必須客戶端重新產 key 再 import），且 SOFTWARE / HSM Protection Level 都支援、EXTERNAL 不適用（EXTERNAL 本來就在外部 HSM、不走 import 路徑）。</p>
<p><strong>Organization Policy 與防護欄</strong>：跟 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM</a> 整合的 Org Policy 可在 organization-level 強制 <em>只允許 HSM / EXTERNAL key</em>（<code>constraints/gcp.restrictNonCmekServices</code>）、防止工程師建出 SOFTWARE key 處理敏感資料。這層防護欄比依賴 reviewer 紀律有效、屬於 <a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a> 同類「規約靠系統而非紀律」的設計。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>KeyRing location 設錯</strong>：KeyRing 建在 <code>global</code>、要綁 <code>asia-east1</code> 的 BigQuery dataset CMEK — 綁不上、location 不能改、只能建新 KeyRing + 重新加密 — 上線前 review KeyRing location 跟 resource location 對齊</li>
<li><strong>Data Access audit 沒開</strong>：production 用 Cloud KMS 做 signing、事故時要查 <em>誰用 key 簽了什麼</em>、發現只有 Admin Activity log、沒有 Decrypt / Sign 記錄 — IAM audit config 加 <code>dataAccess</code> log type、留意 audit log 自己會增加成本與 quota</li>
<li><strong>CMEK key disable 後 resource 全卡</strong>：disable CryptoKey 想做 compliance 演練、整個 GCS bucket 讀寫立刻 503 — disable 是 <em>全或無</em>、要演練得排維護窗、有 rollback 計畫（re-enable 後恢復）</li>
<li><strong>Auto rotation 設定 + asymmetric key</strong>：以為 asymmetric signing key 也會 auto rotate、上線數月後發現 version 1 還在用 — asymmetric key 不支援 auto rotation、要手動建 version + 通知 JWKS consumer</li>
<li><strong>IAM Role 過寬</strong>：給整個 KeyRing <code>cryptoKeyEncrypterDecrypter</code>、單一 service account 可以解所有 key — 改綁到具體 CryptoKey、加 IAM Condition</li>
<li><strong>EKM 外部 HSM 故障</strong>：外部 HSM 連線中斷、Cloud KMS 端 Encrypt / Decrypt 全 fail、所有 CMEK-integrated resource 讀寫卡住 — EKM 需要 dual HSM redundancy + Cloud KMS 端 monitoring alert</li>
<li><strong>Destroy 後資料不可解</strong>：CryptoKeyVersion destroy 後 24 小時 grace period 過了、發現某個 backup 還是用該 version 加密 — destroy 前必須跑 inventory 確認沒有 ciphertext 還掛在該 version</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>AWS-only 加密 + 需 Key Policy 精細控制</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/aws-kms/" data-link-title="AWS KMS" data-link-desc="AWS 原生 key management service、envelope encryption / digital signing / Multi-Region Key、Key Policy &#43; Grant 雙軌授權">AWS KMS</a></td>
      </tr>
      <tr>
          <td>Azure-only 加密 + 需 secret + key 同治理</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/azure-key-vault/" data-link-title="Azure Key Vault" data-link-desc="Azure 三合一 service（Secret &#43; Key &#43; Certificate）、整合 Managed Identity &#43; Entra ID RBAC、Premium tier 走 HSM">Azure Key Vault</a></td>
      </tr>
      <tr>
          <td>跨雲統一 encryption-as-a-service</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a> transit engine</td>
      </tr>
      <tr>
          <td>單一專屬 HSM 隔離 / 跨雲合規</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/cloudhsm/" data-link-title="AWS CloudHSM" data-link-desc="Single-tenant dedicated HSM（FIPS 140-2 Level 3）、AWS 不持 Crypto User credential、合規 &#43; 資料主權場景的 key custody">CloudHSM</a></td>
      </tr>
      <tr>
          <td>GCP secret 管理（非 key）</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/google-secret-manager/" data-link-title="Google Secret Manager" data-link-desc="GCP 原生 secret store、CMEK &#43; Workload Identity Federation 整合、rotation 走自寫 Cloud Function 而非 built-in Lambda">Google Secret Manager</a></td>
      </tr>
      <tr>
          <td>GCP IAM 治理基底</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM</a></td>
      </tr>
      <tr>
          <td>公開憑證 / PKI</td>
          <td>Certificate Authority Service（GCP）或 <a href="/blog/backend/07-security-data-protection/vendors/letsencrypt/" data-link-title="Let&#39;s Encrypt" data-link-desc="免費 &#43; 自動化的公共 ACME CA、90 天 TTL 強制自動化、跨雲跨平台 public TLS cert 的事實基礎">Let&rsquo;s Encrypt</a></td>
      </tr>
      <tr>
          <td>Secret rotation 證據鏈</td>
          <td><a href="/blog/backend/07-security-data-protection/credential-rotation-scoped-evidence/" data-link-title="7.27 Credential Rotation with Scoped Evidence 實作示範" data-link-desc="以 webhook/API credential 輪替示範 scope map、證據欄位與回退窗口如何一起設計。">7.5 Credential Rotation Scoped Evidence</a></td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>Cloud KMS 完整 API reference 跟 <code>gcloud kms</code> CLI 詳盡用法</li>
<li>Cloud HSM partition 內部架構、FIPS 140-2 Level 3 驗證細節</li>
<li>EKM 各 partner（Thales / Fortanix / Equinix）的整合步驟與 API 對照</li>
<li>BigQuery / GCS / Cloud SQL 各自 CMEK 設定的完整教學</li>
<li>Cloud KMS pricing 詳盡計算（key version 數、operation 次數、HSM 加成）</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>Cloud KMS 在 07 案例庫沒有直接 vendor-level 事件、以下案例採對照引用：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 Cloud KMS 的關係（對照）</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/cases/microsoft-storm-0558-signing-key-2023/" data-link-title="7.C4 Microsoft：Storm-0558 簽章金鑰事件" data-link-desc="簽章金鑰事件如何回寫 identity 信任邊界與觀測證據鏈。">Microsoft Storm-0558 Signing Key 2023</a></td>
          <td>Cloud KMS Protection Level=HSM 把 signing key 鎖在硬體、不可 export、跟 HSM-bound mindset 同源 — signing key 一旦能 export 整條信任鏈崩</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/identity-access/microsoft-storm-0558-2023-signing-key-chain/" data-link-title="7.R7.1.5 Microsoft Storm-0558 2023：簽章金鑰鏈與郵件存取" data-link-desc="從簽章金鑰保護失效到雲端郵件存取，拆解身分信任鏈的關鍵控制點">Microsoft Storm-0558 Signing Key Chain (red-team)</a></td>
          <td>Asymmetric Key + Cloud Audit Data Access 是 <em>誰用 key 簽什麼</em> 的稽核基礎、預設關閉的 Data Access log 在 production 必須開、否則事故時無證據</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a></td>
          <td>Auto Rotation 是 vendor-controlled、但 CMEK 整合的 GCS bucket / BQ dataset 的 <em>re-encryption schedule</em> 還是要自己管、否則 rotation 只換 key version、舊資料還是用舊 version</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/secrets-and-machine-credential-governance/" data-link-title="7.6 秘密管理與機器憑證治理" data-link-desc="以問題驅動方式整理 secret、token、key 與機器身份治理">7.6 秘密管理與機器憑證治理</a>、<a href="/blog/backend/07-security-data-protection/transport-trust-and-certificate-lifecycle/" data-link-title="7.5 傳輸信任與憑證生命週期" data-link-desc="以問題驅動方式整理傳輸信任鏈、會話完整性與憑證節奏">7.5 傳輸信任與憑證生命週期</a>（KMS 為 TLS / signing key 的 root custodian）、<a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">7.13 偵測覆蓋率與訊號治理</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/aws-kms/" data-link-title="AWS KMS" data-link-desc="AWS 原生 key management service、envelope encryption / digital signing / Multi-Region Key、Key Policy &#43; Grant 雙軌授權">AWS KMS</a>、<a href="/blog/backend/07-security-data-protection/vendors/azure-key-vault/" data-link-title="Azure Key Vault" data-link-desc="Azure 三合一 service（Secret &#43; Key &#43; Certificate）、整合 Managed Identity &#43; Entra ID RBAC、Premium tier 走 HSM">Azure Key Vault</a>、<a href="/blog/backend/07-security-data-protection/vendors/cloudhsm/" data-link-title="AWS CloudHSM" data-link-desc="Single-tenant dedicated HSM（FIPS 140-2 Level 3）、AWS 不持 Crypto User credential、合規 &#43; 資料主權場景的 key custody">CloudHSM</a></li>
<li>平行（secret）：<a href="/blog/backend/07-security-data-protection/vendors/google-secret-manager/" data-link-title="Google Secret Manager" data-link-desc="GCP 原生 secret store、CMEK &#43; Workload Identity Federation 整合、rotation 走自寫 Cloud Function 而非 built-in Lambda">Google Secret Manager</a>、<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a></li>
<li>上游（IAM）：<a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM</a>（Cloud KMS 權限完全走 IAM Role Binding）</li>
<li>跨模組：<a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a>（KMS 事件如何 routing 進 IR 流程）</li>
<li>官方：<a href="https://cloud.google.com/kms/docs">Cloud KMS Documentation</a></li>
</ul>
]]></content:encoded></item></channel></rss>