Skip to content

CKR_BUFFER_TOO_SMALL bulk attribute fetch fails to retrieve object attributes #221

@a1bert01

Description

@a1bert01

bulk attribute fetch introduced in #209 fails to load attributes from Starcos 3.7 card with CKR_BUFFER_TOO_SMALL error. it looks like the card is returning CK_UNAVAILABLE_INFORMATION only for the first unavailable attribute per C_GetAttributeValue call so the one pass filtering is not enough to filter all unaavalable attributes out

Object returned by get_objects() is then missing valid methods ie:

AttributeError: 'Object' object has no attribute 'sign'

0x00368880 : 0x00007b11f3c64080 : ******************************************************************************************************************************
0x00368880 : 0x00007b11f3c64080 : 2025-12-06 17:22:16.619843 - Entered C_GetAttributeValue
0x00368880 : 0x00007b11f3c64080 : Input
0x00368880 : 0x00007b11f3c64080 :  hSession: 1
0x00368880 : 0x00007b11f3c64080 :  hObject: 3
0x00368880 : 0x00007b11f3c64080 :  pTemplate: 0x7b11efa81bf0
0x00368880 : 0x00007b11f3c64080 :  ulCount: 8
0x00368880 : 0x00007b11f3c64080 :   *** Begin attribute template ***
0x00368880 : 0x00007b11f3c64080 :   Attribute 0
0x00368880 : 0x00007b11f3c64080 :    Attribute: 0 (CKA_CLASS)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 1
0x00368880 : 0x00007b11f3c64080 :    Attribute: 260 (CKA_ENCRYPT)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 2
0x00368880 : 0x00007b11f3c64080 :    Attribute: 261 (CKA_DECRYPT)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 3
0x00368880 : 0x00007b11f3c64080 :    Attribute: 264 (CKA_SIGN)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 4
0x00368880 : 0x00007b11f3c64080 :    Attribute: 266 (CKA_VERIFY)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 5
0x00368880 : 0x00007b11f3c64080 :    Attribute: 262 (CKA_WRAP)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 6
0x00368880 : 0x00007b11f3c64080 :    Attribute: 263 (CKA_UNWRAP)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 7
0x00368880 : 0x00007b11f3c64080 :    Attribute: 268 (CKA_DERIVE)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   *** End attribute template ***
0x00368880 : 0x00007b11f3c64080 : 2025-12-06 17:22:16.619997 - Calling C_GetAttributeValue
0x00368880 : 0x00007b11f3c64080 : 2025-12-06 17:22:16.620005 - Received response from C_GetAttributeValue
0x00368880 : 0x00007b11f3c64080 : Output
0x00368880 : 0x00007b11f3c64080 :  pTemplate: 0x7b11efa81bf0
0x00368880 : 0x00007b11f3c64080 :  ulCount: 8
0x00368880 : 0x00007b11f3c64080 :   *** Begin attribute template ***
0x00368880 : 0x00007b11f3c64080 :   Attribute 0
0x00368880 : 0x00007b11f3c64080 :    Attribute: 0 (CKA_CLASS)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 8
0x00368880 : 0x00007b11f3c64080 :   Attribute 1
0x00368880 : 0x00007b11f3c64080 :    Attribute: 260 (CKA_ENCRYPT)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 18446744073709551615
0x00368880 : 0x00007b11f3c64080 :   Attribute 2
0x00368880 : 0x00007b11f3c64080 :    Attribute: 261 (CKA_DECRYPT)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 3
0x00368880 : 0x00007b11f3c64080 :    Attribute: 264 (CKA_SIGN)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 4
0x00368880 : 0x00007b11f3c64080 :    Attribute: 266 (CKA_VERIFY)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 5
0x00368880 : 0x00007b11f3c64080 :    Attribute: 262 (CKA_WRAP)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 6
0x00368880 : 0x00007b11f3c64080 :    Attribute: 263 (CKA_UNWRAP)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   Attribute 7
0x00368880 : 0x00007b11f3c64080 :    Attribute: 268 (CKA_DERIVE)
0x00368880 : 0x00007b11f3c64080 :    pValue: (nil)
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :   *** End attribute template ***
0x00368880 : 0x00007b11f3c64080 : 2025-12-06 17:22:16.620133 - Returning 18 (CKR_ATTRIBUTE_TYPE_INVALID)
0x00368880 : 0x00007b11f3c64080 : ******************************************************************************************************************************
0x00368880 : 0x00007b11f3c64080 : 2025-12-06 17:22:16.620142 - Entered C_GetAttributeValue
0x00368880 : 0x00007b11f3c64080 : Input
0x00368880 : 0x00007b11f3c64080 :  hSession: 1
0x00368880 : 0x00007b11f3c64080 :  hObject: 3
0x00368880 : 0x00007b11f3c64080 :  pTemplate: 0x7b11efa81bf0
0x00368880 : 0x00007b11f3c64080 :  ulCount: 7
0x00368880 : 0x00007b11f3c64080 :   *** Begin attribute template ***
0x00368880 : 0x00007b11f3c64080 :   Attribute 0
0x00368880 : 0x00007b11f3c64080 :    Attribute: 0 (CKA_CLASS)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x7b11f3922e10
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 8
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX(202E92F3117B0000)
0x00368880 : 0x00007b11f3c64080 :   Attribute 1
0x00368880 : 0x00007b11f3c64080 :    Attribute: 261 (CKA_DECRYPT)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b772c90
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 2
0x00368880 : 0x00007b11f3c64080 :    Attribute: 264 (CKA_SIGN)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b360300
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 3
0x00368880 : 0x00007b11f3c64080 :    Attribute: 266 (CKA_VERIFY)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b6e7b40
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 4
0x00368880 : 0x00007b11f3c64080 :    Attribute: 262 (CKA_WRAP)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b772c70
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 5
0x00368880 : 0x00007b11f3c64080 :    Attribute: 263 (CKA_UNWRAP)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b772b40
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 6
0x00368880 : 0x00007b11f3c64080 :    Attribute: 268 (CKA_DERIVE)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b772cb0
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   *** End attribute template ***
0x00368880 : 0x00007b11f3c64080 : 2025-12-06 17:22:16.620284 - Calling C_GetAttributeValue
0x00368880 : 0x00007b11f3c64080 : 2025-12-06 17:22:16.620289 - Received response from C_GetAttributeValue
0x00368880 : 0x00007b11f3c64080 : Output
0x00368880 : 0x00007b11f3c64080 :  pTemplate: 0x7b11efa81bf0
0x00368880 : 0x00007b11f3c64080 :  ulCount: 7
0x00368880 : 0x00007b11f3c64080 :   *** Begin attribute template ***
0x00368880 : 0x00007b11f3c64080 :   Attribute 0
0x00368880 : 0x00007b11f3c64080 :    Attribute: 0 (CKA_CLASS)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x7b11f3922e10
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 8
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX(0300000000000000)
0x00368880 : 0x00007b11f3c64080 :   Attribute 1
0x00368880 : 0x00007b11f3c64080 :    Attribute: 261 (CKA_DECRYPT)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b772c90
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 18446744073709551615
0x00368880 : 0x00007b11f3c64080 :   Attribute 2
0x00368880 : 0x00007b11f3c64080 :    Attribute: 264 (CKA_SIGN)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b360300
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 3
0x00368880 : 0x00007b11f3c64080 :    Attribute: 266 (CKA_VERIFY)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b6e7b40
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 4
0x00368880 : 0x00007b11f3c64080 :    Attribute: 262 (CKA_WRAP)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b772c70
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 5
0x00368880 : 0x00007b11f3c64080 :    Attribute: 263 (CKA_UNWRAP)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b772b40
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   Attribute 6
0x00368880 : 0x00007b11f3c64080 :    Attribute: 268 (CKA_DERIVE)
0x00368880 : 0x00007b11f3c64080 :    pValue: 0x1b772cb0
0x00368880 : 0x00007b11f3c64080 :    ulValueLen: 0
0x00368880 : 0x00007b11f3c64080 :    *pValue: HEX()
0x00368880 : 0x00007b11f3c64080 :   *** End attribute template ***
0x00368880 : 0x00007b11f3c64080 : 2025-12-06 17:22:16.620428 - Returning 336 (CKR_BUFFER_TOO_SMALL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions