What Should I Push On?

Douglas E. Engert deengert at anl.gov
Mon May 7 10:45:55 EDT 2012



On 5/5/2012 12:58 PM, Henry B. Hotz wrote:
> Thanks for the info.  I may have issues to deal with afer this one.  *sigh*
>
> Since the specific problem shows with a PKCS12 credential as well, I'm thinking I should get a real RedHat 6.2 instance to test with first.
>

This morning, after using the pcscd -d -f -a to look at the
APDU commands sent to the card and the responses:

It looks like the PIVApplet_signDecrypt routine in cky_applet.c
is sending a short command without the data (RSA padded data)
to be signed, and it is only requesting the first 128 bytes of
the response.

The response includes a header that the PIV will return with
the signature.

The PIV card is taking this as the data to be signed is all zero
or whatever is in some buffer on the card, and the header plus the
first 122 bytes of the signature is returned as requested, and
status of "90 00" Success is returned.

The header returned is 6 bytes for a RSA 1024 bit key.

The coolkey parses the header, skips the 6 bytes and only
returns the 122 bytes, even though the header says there should
be 128 signature.

Attached is pcscd output showing what Coolkey and OpenSC do
with a sign operation. (Note some data bytes changed to XX XX
to not expose a valid signature.)


> On May 4, 2012, at 1:40 PM, Douglas E. Engert wrote:
>
>> On 5/4/2012 8:57 AM, Douglas E. Engert wrote:
>>>
>>>
>>> On 5/3/2012 11:18 PM, Greg Hudson wrote:
>>>> On 05/03/2012 08:52 PM, Henry B. Hotz wrote:
>>>>> [5571] 1336088306.8828: Selected etype info: etype aes256-cts, salt "SC.JPL.NASA.GOVhotz", params "
>>>>> CoolKey PIN:
>>>>> [5571] 1336088310.707006: Preauth module pkinit (16) (flags=1) returned: 12/Cannot allocate memory
>>>>> [5571] 1336088310.708361: Preauth module pkinit (15) (flags=1) returned: 12/Cannot allocate memory
>>>>
>>>> That almost certainly indicates a bug--either in our code, the
>>>> Scientific Linux packaging of it, or the PKCS11 library invoked for the
>>>> PIV card.
>>>
>>>
>>> What version of coolkey are you running? In the past coolkey only supported
>>> the CAC cards. DOD has been moving to dual CAC and PIV cards. NASA cards may
>>> be PIV only, thus may not work with some versions of coolkey.
>>>
>>> To test if it is a PKCS#11 issue, OpenSC has a pkcs11-spy module
>>> that could be used to trace the PKCS#11 calls and results.
>>>
>>> export PKCS11SPY=/usr/lib64/pkcs11/libcoolkeypk11.so
>>> kinit -X X509_user_identity=PKCS11:/path/to/pkcs11-spy.so hotz at SC.JPL.NASA.GOV
>>>
>>> OpenSC also has PKCS#11 and supports PIV.
>>>
>>
>> I got coolkey-1.1.0-19 to build on Solaris 10 in 32 bit mode. (although
>> some of the patches from the rpm to the 1.1.0 source did
>> not apply cleanly and I have to make a minor modification for Solaris.)
>>
>> Using krb5-1.10.1 and the OpenSC pkcs11spy and a PIV card,
>> I can see it reads the certificates, prompted for PIN and did a C_Sign operation
>> but coolkey only returns 122 bytes rather then 128 bytes as expected for the signature.
>>
>> I then get a kinit: Message stream modified while getting initial credentials.
>>
>> So it looks like there are some problems in the coolkey code in processing the
>> returned signature.
>>
>> Using the same card, with krb5-1.10.1 and OpenSC pkcs11 works.
>>
>>>
>>>>
>>>> Unfortunately, I think the next step is to grab the SRPM for krb5 and
>>>> either (a) build with debugging symbols (and without optimization) and
>>>> start poking around in gdb, or (b) build with the PKINIT debugging
>>>> defines turned on and collect more information.  Either is pretty
>>>> time-consuming.
>>>> _______________________________________________
>>>> krbdev mailing list             krbdev at mit.edu
>>>> https://mailman.mit.edu/mailman/listinfo/krbdev
>>>>
>>>>
>>>
>>
>> --
>>
>> Douglas E. Engert<DEEngert at anl.gov>
>> Argonne National Laboratory
>> 9700 South Cass Avenue
>> Argonne, Illinois  60439
>> (630) 252-5444
>
> ------------------------------------------------------
> The opinions expressed in this message are mine,
> not those of Caltech, JPL, NASA, or the US Government.
> Henry.B.Hotz at jpl.nasa.gov, or hbhotz at oxy.edu
>
>

-- 

  Douglas E. Engert  <DEEngert at anl.gov>
  Argonne National Laboratory
  9700 South Cass Avenue
  Argonne, Illinois  60439
  (630) 252-5444
-------------- next part --------------


Coolkey does this:

APDU: 00 87 06 9A 08 7C 81 85 82 00 81 81 80 80

SW: 7C 81 83 82 81 80 67 ED 10 F7 0B E4 44 DC 9B 4A 03 35 F0 76 D5 AA D5 8E F5 BA 42 EE EE 5B EF 64 6B F9 58 B0 53 74 16 49 78 32 3B EE 95 E4 A7 36 2B 2A FE 94 91 90 1E 23 A3 9F 21 DF 79 BF 4D 89 C7 CA F6 8E 89 D8 58 55 16 4A 90 7B 71 94 16 A1 BA D5 AD AB B5 E1 2D 06 92 91 06 B9 13 55 63 B6 D3 C2 3D EC 55 70 36 2C FF 36 67 FA 26 76 49 04 F7 39 4D 2F 00 58 CE CA 17 CF 66 E3 78 62 72 6E 90 00

OpenSC does this:

APDU: 00 87 06 9A 88 7C 81 85 82 00 81 81 80 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 30 1F 30 07 06 05 2B XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 13 5B 5E 18 19 CE 00

(Some data replaced with XX's above)

SW: 7C 81 83 82 81 80 97 10 BB 60 E7 D2 6B 4B A8 30 C5 6B C2 27 37 E0 D6 AC 1D 5D 64 88 24 48 3E 36 51 70 AA FE F3 DC 72 20 1C E9 FA E1 65 4F 5A 95 79 01 DE 2F 3F B5 73 7B 26 CA 77 3F 82 54 16 6A ED 7D 6B CC D6 D5 CB 0E 23 B8 A6 84 EE 94 26 0F 6F 24 04 E0 EA 22 75 18 06 02 A6 33 CA 68 CB F4 6F 13 1A BB 2C 50 0F AA EE 0B D9 B0 46 77 8F BE 74 85 DA 7E CA 9E BC 23 62 2E 80 34 69 5A EF A7 58 A9 2A 13 01 2C 90 00


More information about the krbdev mailing list