296 goto clean_exit;
297 }
298
299 /* Get the slot list from provider */
300 rv = prov_funcs->C_GetSlotList(FALSE, prov_slots, &slot_count);
301 if (rv != CKR_OK) {
302 cryptodebug("failed to call C_GetSlotList() from %s.",
303 libname);
304 rc = FAILURE;
305 goto clean_exit;
306 }
307
308 if (verbose) {
309 (void) printf(gettext("Number of slots: %d\n"), slot_count);
310 }
311
312 /* Get the mechanism list for each slot */
313 for (i = 0; i < slot_count; i++) {
314 if (verbose)
315 /*
316 * TRANSLATION_NOTE:
317 * In some languages, the # symbol should be
318 * converted to "no", an "n" followed by a
319 * superscript "o"..
320 */
321 (void) printf(gettext("\nSlot #%d\n"), i+1);
322
323 if ((rng_flag != NULL) && (*rng_flag == NO_RNG)) {
324 if (check_random(prov_slots[i], prov_funcs)) {
325 *rng_flag = HAS_RNG;
326 rc = SUCCESS;
327 goto clean_exit;
328 } else
329 continue;
330 }
331
332 rv = prov_funcs->C_GetSlotInfo(prov_slots[i], &slotinfo);
333 if (rv != CKR_OK) {
334 cryptodebug("failed to get slotinfo from %s", libname);
335 rc = FAILURE;
336 break;
1206
1207 if (puent == NULL) {
1208 return (FAILURE);
1209 }
1210
1211 rng_flag = NO_RNG;
1212 if (list_mechlist_for_lib(puent->name, NULL, &rng_flag, B_TRUE,
1213 B_FALSE, B_FALSE) != SUCCESS) {
1214 cryptoerror(LOG_STDERR,
1215 gettext("%s internal error."), puent->name);
1216 return (FAILURE);
1217 }
1218
1219 if (display_policy(puent) != SUCCESS) {
1220 goto failed_exit;
1221 }
1222
1223
1224 if (puent->flag_norandom == B_TRUE)
1225 /*
1226 * TRANSLATION_NOTE:
1227 * "random" is a keyword and not to be translated.
1228 */
1229 (void) printf(gettext(" %s is disabled."), "random");
1230 else {
1231 if (rng_flag == HAS_RNG)
1232 /*
1233 * TRANSLATION_NOTE:
1234 * "random" is a keyword and not to be translated.
1235 */
1236 (void) printf(gettext(" %s is enabled."), "random");
1237 }
1238 (void) printf("\n");
1239
1240 return (SUCCESS);
1241
1242 failed_exit:
1243
1244 (void) printf(gettext("\nout of memory.\n"));
1245 return (FAILURE);
1246 }
1247
1248
1249 /*
1250 * Check if the mechanism is in the mechanism list.
1251 */
1252 static boolean_t
1253 is_in_policylist(midstr_t mechname, umechlist_t *plist)
1793 * succeeds. The reason we check for CKR_RANDOM_NO_RNG also is that
1794 * this error effectively means CKR_FUNCTION_NOT_SUPPORTED.
1795 */
1796 if (rv != CKR_FUNCTION_NOT_SUPPORTED && rv != CKR_RANDOM_NO_RNG)
1797 return (B_TRUE);
1798 else
1799 return (B_FALSE);
1800 }
1801
1802 void
1803 display_verbose_mech_header()
1804 {
1805 (void) printf("%28s %s", " ", HDR1);
1806 (void) printf("%28s %s", " ", HDR2);
1807 (void) printf("%28s %s", " ", HDR3);
1808 (void) printf("%28s %s", " ", HDR4);
1809 (void) printf("%28s %s", " ", HDR5);
1810 (void) printf("%28s %s", " ", HDR6);
1811 (void) printf("%-28.28s %s", gettext("mechanism name"), HDR7);
1812 /*
1813 * TRANSLATION_NOTE:
1814 * Strictly for appearance's sake, the first header line should be
1815 * as long as the length of the translated text above. The format
1816 * lengths should all match too.
1817 */
1818 (void) printf("%28s ---- ---- "
1819 "- - - - - - - - - - - - - -\n",
1820 gettext("----------------------------"));
1821 }
|
296 goto clean_exit;
297 }
298
299 /* Get the slot list from provider */
300 rv = prov_funcs->C_GetSlotList(FALSE, prov_slots, &slot_count);
301 if (rv != CKR_OK) {
302 cryptodebug("failed to call C_GetSlotList() from %s.",
303 libname);
304 rc = FAILURE;
305 goto clean_exit;
306 }
307
308 if (verbose) {
309 (void) printf(gettext("Number of slots: %d\n"), slot_count);
310 }
311
312 /* Get the mechanism list for each slot */
313 for (i = 0; i < slot_count; i++) {
314 if (verbose)
315 /*
316 * TRANSLATION_NOTE
317 * In some languages, the # symbol should be
318 * converted to "no", an "n" followed by a
319 * superscript "o"..
320 */
321 (void) printf(gettext("\nSlot #%d\n"), i+1);
322
323 if ((rng_flag != NULL) && (*rng_flag == NO_RNG)) {
324 if (check_random(prov_slots[i], prov_funcs)) {
325 *rng_flag = HAS_RNG;
326 rc = SUCCESS;
327 goto clean_exit;
328 } else
329 continue;
330 }
331
332 rv = prov_funcs->C_GetSlotInfo(prov_slots[i], &slotinfo);
333 if (rv != CKR_OK) {
334 cryptodebug("failed to get slotinfo from %s", libname);
335 rc = FAILURE;
336 break;
1206
1207 if (puent == NULL) {
1208 return (FAILURE);
1209 }
1210
1211 rng_flag = NO_RNG;
1212 if (list_mechlist_for_lib(puent->name, NULL, &rng_flag, B_TRUE,
1213 B_FALSE, B_FALSE) != SUCCESS) {
1214 cryptoerror(LOG_STDERR,
1215 gettext("%s internal error."), puent->name);
1216 return (FAILURE);
1217 }
1218
1219 if (display_policy(puent) != SUCCESS) {
1220 goto failed_exit;
1221 }
1222
1223
1224 if (puent->flag_norandom == B_TRUE)
1225 /*
1226 * TRANSLATION_NOTE
1227 * "random" is a keyword and not to be translated.
1228 */
1229 (void) printf(gettext(" %s is disabled."), "random");
1230 else {
1231 if (rng_flag == HAS_RNG)
1232 /*
1233 * TRANSLATION_NOTE
1234 * "random" is a keyword and not to be translated.
1235 */
1236 (void) printf(gettext(" %s is enabled."), "random");
1237 }
1238 (void) printf("\n");
1239
1240 return (SUCCESS);
1241
1242 failed_exit:
1243
1244 (void) printf(gettext("\nout of memory.\n"));
1245 return (FAILURE);
1246 }
1247
1248
1249 /*
1250 * Check if the mechanism is in the mechanism list.
1251 */
1252 static boolean_t
1253 is_in_policylist(midstr_t mechname, umechlist_t *plist)
1793 * succeeds. The reason we check for CKR_RANDOM_NO_RNG also is that
1794 * this error effectively means CKR_FUNCTION_NOT_SUPPORTED.
1795 */
1796 if (rv != CKR_FUNCTION_NOT_SUPPORTED && rv != CKR_RANDOM_NO_RNG)
1797 return (B_TRUE);
1798 else
1799 return (B_FALSE);
1800 }
1801
1802 void
1803 display_verbose_mech_header()
1804 {
1805 (void) printf("%28s %s", " ", HDR1);
1806 (void) printf("%28s %s", " ", HDR2);
1807 (void) printf("%28s %s", " ", HDR3);
1808 (void) printf("%28s %s", " ", HDR4);
1809 (void) printf("%28s %s", " ", HDR5);
1810 (void) printf("%28s %s", " ", HDR6);
1811 (void) printf("%-28.28s %s", gettext("mechanism name"), HDR7);
1812 /*
1813 * TRANSLATION_NOTE
1814 * Strictly for appearance's sake, the first header line should be
1815 * as long as the length of the translated text above. The format
1816 * lengths should all match too.
1817 */
1818 (void) printf("%28s ---- ---- "
1819 "- - - - - - - - - - - - - -\n",
1820 gettext("----------------------------"));
1821 }
|