FAQ
Hello list,

I'm trying to create a working wrapper for pkcs#11. And I got a bunch of stuff working, however
the more important stuff like pkcs#11's attributes is giving me a headache. These hold a
void* and a length so the can point to arbitrary data. From the Go side I convert a []byte
to void* and the length, so it can be used in pkcs#11. For testing I use a modified softhsm
implementation which prints lots of debugging. But for some reason it is
not working as intended...

The code to make an attribute is:
https://github.com/miekg/pkcs11/blob/new/types.go#L118

The code converting from Go to C is:
https://github.com/miekg/pkcs11/blob/new/types.go#L170

When using a small example program
(https://github.com/miekg/pkcs11/blob/new/example1/example.go), I try to
generate keys with CKA_MODULUS_BITS set to 1024 and the CKA_PUBLIC_EXPONENT to 257

Running this against softHSM results in failure, and I'm not sure what
to do next...?

  SoftHSM: C_GetFunctionList: Calling
  SoftHSM: C_GetFunctionList: OK
  SoftHSM: C_Initialize: Calling
  SoftHSM: C_Initialize: OK
  SoftHSM: C_GetSlotList: Calling
  SoftHSM: C_GetSlotList: OK, returning list length
  SoftHSM: C_GetSlotList: Calling
  SoftHSM: C_GetSlotList: OK, returning list
  2013/08/06 07:23:31 slots [0]
  SoftHSM: C_OpenSession: Calling
  SoftHSM: C_OpenSession: OK
  2013/08/06 07:23:31 [0] 1
  SoftHSM: C_Login: Calling
  SoftHSM: C_Login: OK
  pointee 121 c200000080 1024 <--- [Go land] CKA_MODULUS_BITS is set to 1024
  pointee 100 c200000088 2
  pointee 1 c200000090 1
  pointee 104 c200000098 1
  pointee 122 c2000000a0 257 <--- [Go land] CKA_PUBLIC_EXPONENT is set to 257
  pointee 3 c20005f1d0 5437097585372723533
  pointee 100 c2000000a8 3
  pointee 1 c2000000b0 1
  pointee 2 c2000000b8 1
  pointee 108 c2000000c0 1
  pointee 3 c20005f1f0 5437097585372723533
  SoftHSM: C_GenerateKeyPair: Calling
  (point 0xc20008a080) 0 attribute type 0)x100 len 8
  (point 0xc20008a098) 1 attribute type 0)x1 len 1
  CKA_TOKEN 1
  (point 0xc20008a0b0) 2 attribute type 0)x2 len 1
  CKA_PRIVATE 1
  (point 0xc20008a0c8) 3 attribute type 0)x108 len 1
  (point 0xc20008a0e0) 4 attribute type 0)x3 len 10
  (point 0xc20008c000) pub 0x0 attribute type 121 len 8
  CKA_MODULUS_BITS 128 <-- [C land] HUH, 128??? seems to be staticly set to 128
  CKA_MODULUS_BITS 128
  CKA_MODULUS_BITS 0xc200000080 <-- [C land] Same address though
  (point 0xc20008c018) pub 0x1 attribute type 100 len 8
  (point 0xc20008c030) pub 0x2 attribute type 1 len 1
  (point 0xc20008c048) pub 0x3 attribute type 104 len 1
  (point 0xc20008c060) pub 0x4 attribute type 122 len 8
  CKA_PUBLIC_EXPONENT 0xc2000000a0
  CKA_PUBLIC_EXPONENT 36356064 0x22abfe0 <-- [C land] HUH, not 257, but some random number... (changes every run)
  (point 0xc20008c078) pub 0x5 attribute type 3 len 10
  SoftHSM: C_GenerateKeyPair: Could not generate key pair
  2013/08/06 07:23:31 pkcs11: 0x5

Thanks for any help.

- Grtz,

  ---
    Miek Gieben

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 7, '13 at 5:18p
activeAug 7, '13 at 5:18p
posts1
users1
websitegolang.org

1 user in discussion

Miek Gieben: 1 post

People

Translate

site design / logo © 2022 Grokbase