はじめに
Renesas DLM Serverは、HRKによりUFPKを暗号化し、UFPKのEncrypted Keyを得ることのできるサービスです。
このサービスにより、UFPKのEncrypted Keyを取得します。
DLM Serverへの新規登録
Renesas DLM Serverにアクセスし、メールアドレスで新規アカウントを登録します。
登録確認メールが届くので、メール内リンクから必要事項を入力してアカウントを作ります。
PGP鍵交換
DLM ServerにUFPKを直接送ることは、セキュリティ上好ましくありません。それで、鍵のやり取りのためにPGPによる暗号化ができるよう、登録したメールアドレスのPGP鍵を作り登録する必要があります。
PGP鍵作成
gpgなどのソフトウェアで、PGP鍵(RSA必須;4096bit推奨)を作成する必要があります。メールアドレスはDLM Server に登録したのと同じものを使います。
gpgの場合、以下のコマンドで作成を行います。
C:\Users\xxx>gpg --full-generate-key --expert
gpg (GnuPG) 2.4.3; Copyright (C) 2023 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
(7) DSA (set your own capabilities)
(8) RSA (set your own capabilities)
(9) ECC (sign and encrypt) *default*
(10) ECC (sign only)
(11) ECC (set your own capabilities)
(13) Existing key
(14) Existing key from card
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (3072) 4096
Requested keysize is 4096 bits
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want for the subkey? (3072) 4096
Requested keysize is 4096 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
GnuPG needs to construct a user ID to identify your key.
Real name: [自分の名前]
Email address: [登録したメールアドレス]
Comment: [任意のコメント(省略可)]
You selected this USER-ID:
"[自分の名前] ([コメント]) <メールアドレス>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: revocation certificate stored as 'C:\\Users\\xxx\\AppData\\Roaming\\gnupg\\openpgp-revocs.d\\[PGPキーID].rev'
public and secret key created and signed.
pub rsa4096 2024-xx-xx [SC]
[PGPキーID]
uid [自分の名前] ([コメント]) <メールアドレス>
sub rsa4096 2024-xx-xx [E]
PGP鍵のエクスポート
作成したPGP鍵の公開鍵をエクスポートします。
C:\Users\xxx>gpg --export [PGPキーID] > [PGPキーID].key
PGP鍵をDLM Serverへの登録
DLM Server メニューから「PGP鍵交換」をクリックし、エクスポートした公開鍵を登録します。
メールがDLM Serverから送信され、DLM ServerのPGP鍵が送られてきます(keywrap-pub.keyという添付がついています)。
DLM Serverの公開鍵をキーリング(鍵束)に追加
送られてきたDLM ServerのPGP鍵を追加することで、DLM Server との安全な送受信ができるようになります。
gpg の場合以下のように行います。
C:\Users\xxx>gpg --import keywrap-pub.key
gpg: key F517189C1EA5E55D: public key "keywrap <customer-key-encryption-system@lm.renesas.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
追加したキーを表示してみます。
C:\Users\xxx>gpg -k
gpg: checking the trustdb
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
[keyboxd]
---------
pub rsa4096 2024-xx-xx [SC]
[PGPキーID]
uid [自分の名前] ([コメント]) <メールアドレス>
sub rsa4096 2024-xx-xx [E]
pub rsa4096 2018-10-24 [SC]
FB18EB661F6120E996138DF7F517189C1EA5E55D
uid [ unknown] keywrap <customer-key-encryption-system@lm.renesas.com>
sub rsa4096 2018-10-24 [E]
pub キーのFingerprintが DLM Server上に表示されているものと同じであることを確認したら、このPGPキーをローカルで信頼します。
C:\Users\taniz>gpg --lsign-key FB18EB661F6120E996138DF7F517189C1EA5E55D
pub rsa4096/F517189C1EA5E55D
created: 2018-10-24 expires: never usage: SC
trust: unknown validity: unknown
sub rsa4096/8420039B5F4E4F5E
created: 2018-10-24 expires: never usage: E
[ unknown] (1). keywrap <customer-key-encryption-system@lm.renesas.com>
pub rsa4096/F517189C1EA5E55D
created: 2018-10-24 expires: never usage: SC
trust: unknown validity: unknown
Primary key fingerprint: FB18 EB66 1F61 20E9 9613 8DF7 F517 189C 1EA5 E55D
keywrap <customer-key-encryption-system@lm.renesas.com>
Are you sure that you want to sign this key with your
key "[自分の名前] ([コメント]) <メールアドレス>" ([自分のキー])
The signature will be marked as non-exportable.
Really sign? (y/N) y
再びキーを表示してみます。DLM Serverのキーを信頼しているはずです。
C:\Users\xxx>gpg -k
gpg: checking the trustdb
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: depth: 0 valid: 1 signed: 1 trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: depth: 1 valid: 1 signed: 0 trust: 1-, 0q, 0n, 0m, 0f, 0u
[keyboxd]
---------
pub rsa4096 2024-xx-xx [SC]
[PGPキーID]
uid [自分の名前] ([コメント]) <メールアドレス>
sub rsa4096 2024-xx-xx [E]
pub rsa4096 2018-10-24 [SC]
FB18EB661F6120E996138DF7F517189C1EA5E55D
uid [ full ] keywrap <customer-key-encryption-system@lm.renesas.com>
sub rsa4096 2018-10-24 [E]
UFPKのEncrypted Key作成
UFPKのEncrypted Keyを作成するためには、Security Key Management Tool で作成したUFPKをDLM ServerのPGP鍵で暗号化してアップロードします。
DLM Serverからはメールで、UFPKのEncryted Key(HRKで暗号化されている)が、自分のPGP鍵で暗号化された添付ファイルとして届きます。
自分のPGP鍵でこれを復号化することでUFPKのEncrypted Keyを取得できます。
UFPKをDLM ServerのPGP鍵で暗号化
以下のコマンドで、PGPによりUFPKを暗号化します。
UFPKはufpk.keyというファイルに保存されているとすると、同じフォルダにufpk.key.gpg が作成されます。
C:\Users\xxx>gpg -r customer-key-encryption-system@lm.renesas.com --encrypt ufpk.key
PGPで暗号化したUFPKをDLM Serverにアップロード
DLM ServerでRX65N/RX651お客様データ暗号化 > 製品用暗号化サービス とたどり、ufpk.key.gpg をアップロードします。
しばらくすると、DLM Serverからメールが届き、UFPK のEncrypted KeyがPGPで暗号化されたものが添付されてきます。
ufpk.key.gpg をアップロードしたとすると、ufpk.key_enc.key.pgp が添付されてくるはずです。
PGPで暗号化されたUFPKのEncrypted Keyを復号化
以下のコマンドで、自分のPGP鍵により受信データを復号化します。
C:\Users\xxx>gpg --decrypt ufpk.key_enc.key.pgp
DLM Serverからufpk.key_enc.key.pgpを受け取ったとすると、ufpk.key_enc.key が作成され、これがUFPKのEncrypted Keyになります。
なお、作成されたファイルは36バイトになるはずです。
- 先頭4byte:0x00000001(おそらくキーの種別)
- 残り32byte:UFPKのEncrypted Key