Тогда вот последовательность действий:
1. Инициализировал токен:
pkcs15-init --erase-card
pkcs15-init --create-pkcs15 --so-pin 87654321 --so-puk ""
pkcs15-init --store-pin --label "User PIN" --auth-id 02 --pin 12345678 --so-pin 87654321 --finalize
2. Сгенерировал закрытый ключ:
pkcs15-init --generate-key GOST2001 --auth-id 02
3. Проверил, что ключ есть на карте:
Выдало:
Using reader with a card: Aktiv Rutoken ECP 00 00
Private GOSTR3410 Key [Private Key]
Object Flags : [0x3], private, modifiable
Usage : [0x4], sign
Access Flags : [0x1D], sensitive, alwaysSensitive, neverExtract, local
ModLength : 256
Key ref : 1 (0x1)
Native : yes
Path : 3f001000100060020001
Auth ID : 02
ID : 11abc3d0047e1af0c3b7824afb75046d5512920d
GUID : {11abc3d0-047e-1af0-c3b7-824afb75046d}
3. Пытаюсь подписать тестовый файл (файл существует):
pkcs15-crypt -s -i ./test.txt
Выдает:
Using reader with a card: Aktiv Rutoken ECP 00 00
Enter PIN [User PIN]:
Compute signature failed: Invalid arguments
При включенной отладке:
pkcs15-crypt -s -vvv -i ./test.txt
фрагмент выдачи с ошибкой:
...
PIN code correct.
0x7fa822ae0720 09:08:54.465 [pkcs15-crypt] apdu.c:524:sc_transmit_apdu: called
0x7fa822ae0720 09:08:54.475 [pkcs15-crypt] iso7816.c:479:iso7816_select_file: returning with: 0 (Success)
0x7fa822ae0720 09:08:54.475 [pkcs15-crypt] card-rtecp.c:268:rtecp_select_file: returning with: 0 (Success)
0x7fa822ae0720 09:08:54.475 [pkcs15-crypt] apdu.c:524:sc_transmit_apdu: called
0x7fa822ae0720 09:08:54.483 [pkcs15-crypt] sec.c:70:sc_set_security_env: returning with: 0 (Success)
0x7fa822ae0720 09:08:54.483 [pkcs15-crypt] apdu.c:524:sc_transmit_apdu: called
0x7fa822ae0720 09:08:54.483 [pkcs15-crypt] card-rtecp.c:400:rtecp_cipher: returning with: -1300 (Invalid arguments)
0x7fa822ae0720 09:08:54.483 [pkcs15-crypt] card-rtecp.c:423:rtecp_compute_signature: returning with: -1300 (Invalid arguments)
0x7fa822ae0720 09:08:54.483 [pkcs15-crypt] sec.c:56:sc_compute_signature: returning with: -1300 (Invalid arguments)
Compute signature failed: Invalid arguments
0x7fa822ae0720 09:08:54.499 [pkcs15-crypt] ctx.c:737:sc_release_context: called
Не подскажете, что я делаю не так?