pkcs11-tool does PSO without MSE

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

pkcs11-tool does PSO without MSE

Peter Koch

Hello all!

Andreas Heinemann asked me for some advice on how to
use his TCOS card with OpenSC.

pkcs11-tool --login --test

fails and Andreas sent me level-5 debug output
which I analysed.

My impression is, that no "Manage Security Environment"
command is send to Andreas card before a
"Perform Security Operation" command is executed.
And therefore PSO fails with 6A88

I looked at the sourcecode:

sc_pkcs15_compute_signature calls:
  r = sc_set_security_env(p15card->card, &senv, 0);
and
  r = sc_compute_signature(p15card->card, tmpin, inlen, out, outlen);

sc_set_security_env returns with 0 but did not
sent something to the card.

If MSE was not implemented with TCOS cards then
sc_set_security should fail.

If sc_set_security_env does not work with TCOS-cards
what else IS working???

Did it make any sense that I wrote the Netkey emulation
for TCOS cards?

Peter (confused !!)

Here's the relevant part from the debug output

> Selected flags 1. Now computing signature for 128 bytes. 1024 bytes reserved.
> pkcs15-sec.c:162:: called
> called; type=2, path=41015103
> card.c:247:: called
> Sending 10 bytes (resp. 258 bytes):
> 00 A4 08 00 04 41 01 51 03 FF .....A.Q..
> Received 43 bytes (SW1=90 SW2=00)
> 6F 29 83 02 51 03 81 02 01 92 82 03 03 41 43 85 o)..Q........AC.
> 06 01 C4 03 90 00 00 86 12 EE 00 00 00 FF FF E4 ................
> 10 00 00 FF FF 2A 10 00 00 FF FF                .....*.....
> card-tcos.c:490:: returning with: 0
> card.c:756:: returning with: 0
> sec.c:63:: called
> sec.c:67:: returning with: 0
> sec.c:49:: called
> card.c:247:: called
> Sending 134 bytes (resp. 258 bytes, sensitive):
> 00 2a 9e 9a [sensitive data]
> Received 0 bytes (SW1=6A SW2=88)
> card.c:531:: called
> Calling card logout function
> called; type=2, path=3f00
> card.c:247:: called
> Sending 8 bytes (resp. 258 bytes):
> 00 A4 00 00 02 3F 00 FF .....?..
> Received 33 bytes (SW1=90 SW2=00)
> 6F 1F 83 02 3F 00 82 01 38 85 01 01 84 05 D2 76 o...?...8......v
> 00 00 03 86 0C 60 00 00 00 FF FF A4 00 00 00 FF .....`..........
> FF                                              .
> card-tcos.c:490:: returning with: 0
> card.c:756:: returning with: 0
> Sign complete. Result -1216.
> opensc error: Data object not found (-1216)
> C_SignFinal returns 5

_________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179



_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: pkcs11-tool does PSO without MSE

Nils Larsch
Peter Koch wrote:

> Hello all!
>
> Andreas Heinemann asked me for some advice on how to
> use his TCOS card with OpenSC.
>
> pkcs11-tool --login --test
>
> fails and Andreas sent me level-5 debug output
> which I analysed.
>
> My impression is, that no "Manage Security Environment"
> command is send to Andreas card before a
> "Perform Security Operation" command is executed.
> And therefore PSO fails with 6A88
>
> I looked at the sourcecode:
>
> sc_pkcs15_compute_signature calls:
>   r = sc_set_security_env(p15card->card, &senv, 0);
> and
>   r = sc_compute_signature(p15card->card, tmpin, inlen, out, outlen);
>
> sc_set_security_env returns with 0 but did not
> sent something to the card.

yep, in case of a signatur operations it just returns without
doing something (the ratio for this seems to be that there's
only one security environment for signing and hence the call
is superfluous).

>
> If MSE was not implemented with TCOS cards then
> sc_set_security should fail.

it's implemented

...

>>Selected flags 1. Now computing signature for 128 bytes. 1024 bytes reserved.
>>pkcs15-sec.c:162:: called
>>called; type=2, path=41015103
>>card.c:247:: called
>>Sending 10 bytes (resp. 258 bytes):
>>00 A4 08 00 04 41 01 51 03 FF .....A.Q..
>>Received 43 bytes (SW1=90 SW2=00)
>>6F 29 83 02 51 03 81 02 01 92 82 03 03 41 43 85 o)..Q........AC.
>>06 01 C4 03 90 00 00 86 12 EE 00 00 00 FF FF E4 ................
>>10 00 00 FF FF 2A 10 00 00 FF FF                .....*.....
>>card-tcos.c:490:: returning with: 0
>>card.c:756:: returning with: 0
>>sec.c:63:: called
>>sec.c:67:: returning with: 0
>>sec.c:49:: called
>>card.c:247:: called
>>Sending 134 bytes (resp. 258 bytes, sensitive):
>>00 2a 9e 9a [sensitive data]
>>Received 0 bytes (SW1=6A SW2=88)

one could change tcos_set_security_env to see if this helps here

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: pkcs11-tool does PSO without MSE

Peter Koch
In reply to this post by Peter Koch


Nils Larsch <[hidden email]> wrote:

> Peter Koch wrote:
>
> > My impression is, that no "Manage Security Environment"
> > command is send to Andreas card before a
> > "Perform Security Operation" command is executed.
> > And therefore PSO fails with 6A88
> >
> > I looked at the sourcecode:
> >
> > sc_pkcs15_compute_signature calls:
> >   r = sc_set_security_env(p15card->card, &senv, 0);
> > and
> >   r = sc_compute_signature(p15card->card, tmpin, inlen, out, outlen);
> >
> > sc_set_security_env returns with 0 but did not
> > sent something to the card.
>
> yep, in case of a signatur operations it just returns without
> doing something (the ratio for this seems to be that there's
> only one security environment for signing and hence the call
> is superfluous).

Is that correct? If there are multiple keys on the card
how could OpenSC pcik the right one.

In this TCOS-case (and I guess this is similar with other
cards) a PSO without MSE will have the consequence that
the default-MSE is used.

This could have the consequence that the wrong will be
used or - as with Andreas card - a non-existant key.

Maybe that explains some problems I had with pkcs15-crypt.

What must I do to fix this? change TCOS-related stuff
or change sc_compute_signature such that a MSE is
send before every PSO?

Peter
_________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179



_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: pkcs11-tool does PSO without MSE

Nils Larsch
Peter Koch wrote:
...
> Is that correct?

as you already noticed this is somewhat problematic if there's
more than one signature key

> If there are multiple keys on the card
> how could OpenSC pcik the right one.
>
> In this TCOS-case (and I guess this is similar with other
> cards) a PSO without MSE will have the consequence that
> the default-MSE is used.
>
> This could have the consequence that the wrong will be
> used or - as with Andreas card - a non-existant key.
>
> Maybe that explains some problems I had with pkcs15-crypt.
>
> What must I do to fix this? change TCOS-related stuff
> or change sc_compute_signature such that a MSE is
> send before every PSO?

sc_set_security_env is called before a signature generation but
the current implementation of tcos_set_security_env simply does
nothing in case of a signature operation. So I guess you should
modify card-tcos.c and see if this helps.

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel