Omnikey 6121: OpenPGP スマートカードに書き込めません

Omnikey 6121: OpenPGP スマートカードに書き込めません

私はOmnikey 6121スマートカードリーダーをOpenPGPv2スマートカードで使用しようとしています。リーダーは認識されており、gpg --card-statusURL、名前などのカードの詳細を編集することができました。

ただし、「keytocard」コマンドを発行しようとすると、次のメッセージが表示されます。

gpg: writing new key
gpg: 3 Admin PIN attempts remaining before card is permanently locked

Please enter the Admin PIN
gpg: ccid_transceive failed: (0x10002)
gpg: apdu_send_simple(0) failed: invalid value
gpg: failed to store the key: invalid argument
gpg: error writing key to card: invalid argument

--debug-ccid-driver でも同じエラーが発生します。

同様に、「generate」を発行すると次のようになります。

gpg/card> generate
Make off-card backup of encryption key? (Y/n) n

Please enter the PIN
What keysize do you want for the Signature key? (2048) 
What keysize do you want for the Encryption key? (2048) 
What keysize do you want for the Authentication key? (2048) 
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

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and E-mail Address in this form:
    "Heinrich Heine (Der Dichter) <[email protected]>"

Real name: Deim0s Anomaly
E-mail address: [email protected]
Comment: 
You selected this USER-ID:
    "Deim0s Anomaly <[email protected]>"

Change (N)ame, (C)omment, (E)-mail or (O)kay/(Q)uit? O
gpg: generating new key
gpg: 3 Admin PIN attempts remaining before card is permanently locked

Please enter the Admin PIN
gpg: please wait while key is being generated ...
gpg: generating key failed
gpg: key generation failed: general error
Key generation failed: general error

gpg/card> 

何が起こっているのですか?誰か助けてくれませんか?

答え1

奇妙だが、私はついにこの設定を機能させることができた(オムニキー6121+OpenGPG v2 カード)。凡人同じことが達成できます:

  1. /etc/X11/Xsession.d/で無効にして90gpg-agent-mine90ssh-agent-minegpg-agentまたはssh-agentを起動しないようにします。
  2. で説明したように、新しいgpg-agent-wrapperを作成します。https://blog.flameeyes.eu/2010/08/smart-cards-and-secret-agents

(1) でそこから gpg-agent を起動しない理由は、私が望んでいた --enable-ssh-support が有効にならないためです。

を発行するとgpg --card-status、わずかな遅延が発生し、その後次のようになります。

gpg: detected reader `OMNIKEY CardMan (076B:6622) 6121 00 00'
Application ID ...: ......

つまり、カードは書き込み操作にも使えるようになるということです! やった! そして私のはkeytocard成功しました :)

関連情報