Ticket #124: pkcs11-tool-test.patch

File pkcs11-tool-test.patch, 1.5 KB (added by harning@…, 2 years ago)
  • src/tools/pkcs11-tool.c

    === src/tools/pkcs11-tool.c
    ==================================================================
     
    22822282                        printf(" -- can't be used for signature, skipping\n"); 
    22832283                        continue; 
    22842284                } 
     2285                modLenBytes = (get_private_key_length(sess, privKeyObject) + 7) / 8; 
     2286                if(modLenBytes <= 0) { 
     2287                        printf(" -- can't be used for signature, skipping: can't obtain modulus\n"); 
     2288                        continue; 
     2289                } 
    22852290                printf("\n"); 
    22862291                break; 
    22872292        } 
     
    22922297 
    22932298        data[0] = 0; 
    22942299        data[1] = 1; 
    2295         modLenBytes = (get_private_key_length(sess, privKeyObject) + 7) / 8; 
    22962300 
    22972301        /* 1st test */ 
    22982302 
     
    24242428                label = getLABEL(sess, privKeyObject, NULL); 
    24252429                modLenBits = get_private_key_length(sess, privKeyObject); 
    24262430                modLenBytes = (modLenBits + 7) / 8; 
    2427  
     2431                 
    24282432                printf("  testing key %d (%u bits%s%s) with 1 signature mechanism", 
    24292433                                (int) (j-1), 
    24302434                                (int) modLenBits, 
     
    24362440                if (!getSIGN(sess, privKeyObject)) { 
    24372441                        printf(" -- can't be used to sign/verify, skipping\n"); 
    24382442                        continue; 
     2443                } else if(modLenBytes <= 0) { 
     2444                        printf(" -- can't be used to sign/verify, skipping: can't obtain modulus\n"); 
     2445                        continue; 
    24392446                } 
    24402447                else 
    24412448                        printf("\n"); 
     
    25902597                } 
    25912598 
    25922599                key_len = (get_private_key_length(sess, priv_key) + 7) / 8; 
     2600                if(key_len <= 0) { 
     2601                        printf(" -- can't get the modulus length, skipping\n"); 
     2602                        continue; 
     2603                } 
    25932604 
    25942605                errors += sign_verify(slot, sess, priv_key, key_len, pub_key, i != 0); 
    25952606        }