Changeset 3405 for trunk/src/tools/pkcs15-init.c
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 Makefile 2 Makefile.in 3 core 4 archive 5 acinclude.m4 6 aclocal.m4 7 autom4te.cache 8 compile 9 confdefs.h 10 config.* 11 configure 12 conftest 13 conftest.c 14 depcomp 15 install-sh 16 libtool 17 libtool.m4 18 ltmain.sh 19 missing 20 mkinstalldirs 21 so_locations 22 stamp-h* 23 1 24 .deps 2 25 .libs … … 19 42 *.rej 20 43 *.u 44 *.rc 45 *.pc 21 46 *~ 22 Makefile 23 Makefile.in 24 core 25 gmon.out 26 archive 27 acinclude.m4 28 aclocal.m4 29 autom4te.cache 30 compile 31 confdefs.h 32 config.cache 33 config.guess 34 config.h 35 config.h.in 36 config.log 37 config.status 38 config.sub 39 configure 40 conftest 41 conftest.c 42 depcomp 43 install-sh 44 libtool 45 libtool.m4 46 ltmain.sh 47 missing 48 mkinstalldirs 49 so_locations 50 stamp-h* 47 *.gz 48 *.bz2 49 *.[0-9] 50 *.html 51 *.gif 52 *.css 53 *.out 54 55 ChangeLog 56 opensc.conf 57 xsl-stylesheets 58 opensc-config 59 test-conf 60 pkcs15-tool 61 pkcs15-crypt 62 pkcs15-init 63 piv-tool 64 eidenv 65 opensc-explorer 66 opensc-tool 67 rutoken-tool 68 cardos-info 69 cryptoflex-tool 70 netkey-tool 71 pkcs11-tool 72 pintest 73 p15dump 74 prngtest 75 base64 76 lottery 77
-
- Property svn:ignore
-
trunk/src
- Property svn:ignore
-
old new 1 Makefile 2 Makefile.in 3 core 4 archive 5 acinclude.m4 6 aclocal.m4 7 autom4te.cache 8 compile 9 confdefs.h 10 config.* 11 configure 12 conftest 13 conftest.c 14 depcomp 15 install-sh 16 libtool 17 libtool.m4 18 ltmain.sh 19 missing 20 mkinstalldirs 21 so_locations 22 stamp-h* 23 1 24 .deps 2 25 .libs … … 19 42 *.rej 20 43 *.u 44 *.rc 45 *.pc 21 46 *~ 22 Makefile 23 Makefile.in 24 core 25 gmon.out 47 *.gz 48 *.bz2 49 *.[0-9] 50 *.html 51 *.gif 52 *.css 53 *.out 54 55 ChangeLog 56 opensc.conf 57 xsl-stylesheets 58 opensc-config 59 test-conf 60 pkcs15-tool 61 pkcs15-crypt 62 pkcs15-init 63 piv-tool 64 eidenv 65 opensc-explorer 66 opensc-tool 67 rutoken-tool 68 cardos-info 69 cryptoflex-tool 70 netkey-tool 71 pkcs11-tool 72 pintest 73 p15dump 74 prngtest 75 base64 76 lottery 77
-
- Property svn:ignore
-
trunk/src/tools
- Property svn:ignore
-
old new 1 Makefile 2 Makefile.in 3 core 4 archive 5 acinclude.m4 6 aclocal.m4 7 autom4te.cache 8 compile 9 confdefs.h 10 config.* 11 configure 12 conftest 13 conftest.c 14 depcomp 15 install-sh 16 libtool 17 libtool.m4 18 ltmain.sh 19 missing 20 mkinstalldirs 21 so_locations 22 stamp-h* 23 1 24 .deps 2 25 .libs … … 19 42 *.rej 20 43 *.u 44 *.rc 45 *.pc 21 46 *~ 22 Makefile 23 Makefile.in 24 core 25 gmon.out 26 cryptoflex-tool 27 cardos-info 47 *.gz 48 *.bz2 49 *.[0-9] 50 *.html 51 *.gif 52 *.css 53 *.out 54 55 ChangeLog 56 opensc.conf 57 xsl-stylesheets 58 opensc-config 59 test-conf 60 pkcs15-tool 61 pkcs15-crypt 62 pkcs15-init 63 piv-tool 28 64 eidenv 29 piv-tool30 netkey-tool31 65 opensc-explorer 32 66 opensc-tool 67 rutoken-tool 68 cardos-info 69 cryptoflex-tool 70 netkey-tool 33 71 pkcs11-tool 34 pkcs15-crypt 35 pkcs15-init 36 pkcs15-tool 72 pintest 73 p15dump 74 prngtest 75 base64 76 lottery 77
-
- Property svn:ignore
-
trunk/src/tools/pkcs15-init.c
r3403 r3405 53 53 #include <opensc/ui.h> 54 54 #include <opensc/cards.h> 55 #include <compat_getpass.h> 55 56 #include "util.h" 56 #include "strlcpy.h"57 #include <compat_strlcpy.h> 57 58 58 59 … … 348 349 #ifdef RANDOM_POOL 349 350 if (!RAND_load_file(RANDOM_POOL, 32)) 350 fatal("Unable to seed random number pool for key generation");351 util_fatal("Unable to seed random number pool for key generation"); 351 352 #endif 352 353 … … 354 355 355 356 if (optind != argc) 356 print_usage_and_die(app_name, options, option_help);357 util_print_usage_and_die(app_name, options, option_help); 357 358 if (opt_actions == 0) { 358 359 fprintf(stderr, "No action specified.\n"); 359 print_usage_and_die(app_name, options, option_help);360 util_print_usage_and_die(app_name, options, option_help); 360 361 } 361 362 if (!opt_profile) { 362 363 fprintf(stderr, "No profile specified.\n"); 363 print_usage_and_die(app_name, options, option_help);364 util_print_usage_and_die(app_name, options, option_help); 364 365 } 365 366 … … 465 466 break; 466 467 default: 467 fatal("Action not yet implemented\n");468 util_fatal("Action not yet implemented\n"); 468 469 } 469 470 … … 502 503 r = sc_context_create(&ctx, &ctx_param); 503 504 if (r) { 504 error("Failed to establish context: %s\n", sc_strerror(r));505 util_error("Failed to establish context: %s\n", sc_strerror(r)); 505 506 return 0; 506 507 } … … 510 511 } 511 512 512 if ( connect_card(ctx, &card, reader, 0, opt_wait, verbose))513 if (util_connect_card(ctx, &card, reader, 0, opt_wait, verbose)) 513 514 return 0; 514 515 … … 681 682 682 683 if (!pin_id) { 683 error("No pin id specified\n");684 util_error("No pin id specified\n"); 684 685 return SC_ERROR_INVALID_ARGUMENTS; 685 686 } … … 693 694 } 694 695 if (*opt_pins[0] == '\0') { 695 error("You must specify a PIN\n");696 util_error("You must specify a PIN\n"); 696 697 return SC_ERROR_INVALID_ARGUMENTS; 697 698 } … … 1003 1004 r = do_convert_cert(newcert_raw, newcert); 1004 1005 else 1005 error("the public keys in the old and new certificate differ");1006 util_error("the public keys in the old and new certificate differ"); 1006 1007 1007 1008 X509_free(newcert); … … 1027 1028 1028 1029 if (opt_objectid == NULL) { 1029 error("no ID given for the cert: use --id");1030 util_error("no ID given for the cert: use --id"); 1030 1031 return SC_ERROR_INVALID_ARGUMENTS; 1031 1032 } 1032 1033 sc_pkcs15_format_id(opt_objectid, &id); 1033 1034 if (sc_pkcs15_find_cert_by_id(p15card, &id, &obj) != 0) { 1034 error("Couldn't find the cert with ID %s\n", opt_objectid);1035 util_error("Couldn't find the cert with ID %s\n", opt_objectid); 1035 1036 return SC_ERROR_OBJECT_NOT_FOUND; 1036 1037 } … … 1234 1235 sc_pkcs15_object_t *obj; 1235 1236 if (opt_application_id == NULL) 1236 fatal("Specify the --application-id for the data object to be deleted\n");1237 util_fatal("Specify the --application-id for the data object to be deleted\n"); 1237 1238 sc_format_oid(&app_oid, opt_application_id); 1238 1239 … … 1248 1249 sc_pkcs15_id_t id; 1249 1250 if (opt_objectid == NULL) 1250 fatal("Specify the --id for key(s) or cert(s) to be deleted\n");1251 util_fatal("Specify the --id for key(s) or cert(s) to be deleted\n"); 1251 1252 sc_pkcs15_format_id(opt_objectid, &id); 1252 1253 … … 1342 1343 spec += 3; 1343 1344 } else { 1344 error("Unknown algorithm \"%s\"", spec);1345 util_error("Unknown algorithm \"%s\"", spec); 1345 1346 return SC_ERROR_INVALID_ARGUMENTS; 1346 1347 } … … 1353 1354 keybits = strtoul(spec, &end, 10); 1354 1355 if (*end) { 1355 error("Invalid number of key bits \"%s\"", spec);1356 util_error("Invalid number of key bits \"%s\"", spec); 1356 1357 return SC_ERROR_INVALID_ARGUMENTS; 1357 1358 } … … 1408 1409 sc_pkcs15_format_id(opt_authid, &args->auth_id); 1409 1410 } else if (!opt_unprotected) { 1410 error("no PIN given for key - either use --insecure or \n"1411 util_error("no PIN given for key - either use --insecure or \n" 1411 1412 "specify a PIN using --auth-id"); 1412 1413 return SC_ERROR_INVALID_ARGUMENTS; … … 1418 1419 } else { 1419 1420 if (!opt_unprotected) { 1420 error("no pass phrase given for key - "1421 util_error("no pass phrase given for key - " 1421 1422 "either use --insecure or\n" 1422 1423 "specify a pass phrase using " … … 1478 1479 1479 1480 parse_err: 1480 fatal("Cannot parse secret \"%s\"\n", arg);1481 util_fatal("Cannot parse secret \"%s\"\n", arg); 1481 1482 } 1482 1483 … … 1728 1729 BIO_free(err); 1729 1730 if (rsa == 0) 1730 fatal("RSA key generation error");1731 util_fatal("RSA key generation error"); 1731 1732 EVP_PKEY_assign_RSA(*res, rsa); 1732 1733 break; … … 1742 1743 r = DSA_generate_key(dsa); 1743 1744 if (r == 0 || dsa == 0) 1744 fatal("DSA key generation error");1745 util_fatal("DSA key generation error"); 1745 1746 EVP_PKEY_assign_DSA(*res, dsa); 1746 1747 break; 1747 1748 } 1748 1749 default: 1749 fatal("Unable to generate key: unsupported algorithm");1750 util_fatal("Unable to generate key: unsupported algorithm"); 1750 1751 } 1751 1752 return 0; … … 1783 1784 bio = BIO_new(BIO_s_file()); 1784 1785 if (BIO_read_filename(bio, filename) <= 0) 1785 fatal("Unable to open %s: %m", filename);1786 util_fatal("Unable to open %s: %m", filename); 1786 1787 *key = PEM_read_bio_PrivateKey(bio, NULL, pass_cb, (char *) passphrase); 1787 1788 BIO_free(bio); … … 1808 1809 bio = BIO_new(BIO_s_file()); 1809 1810 if (BIO_read_filename(bio, filename) <= 0) 1810 fatal("Unable to open %s: %m", filename);1811 util_fatal("Unable to open %s: %m", filename); 1811 1812 p12 = d2i_PKCS12_bio(bio, NULL); 1812 1813 BIO_free(bio); … … 1817 1818 1818 1819 if (!user_key) { 1819 error("No key in pkcs12 file?!\n");1820 util_error("No key in pkcs12 file?!\n"); 1820 1821 return SC_ERROR_CANNOT_LOAD_KEY; 1821 1822 } … … 1874 1875 } 1875 1876 } else { 1876 error("Error when reading private key. "1877 util_error("Error when reading private key. " 1877 1878 "Key file format \"%s\" not supported.\n", format); 1878 1879 return SC_ERROR_NOT_SUPPORTED; … … 1880 1881 1881 1882 if (r < 0) 1882 fatal("Unable to read private key from %s\n", filename);1883 util_fatal("Unable to read private key from %s\n", filename); 1883 1884 return r; 1884 1885 } … … 1895 1896 bio = BIO_new(BIO_s_file()); 1896 1897 if (BIO_read_filename(bio, filename) <= 0) 1897 fatal("Unable to open %s: %m", filename);1898 util_fatal("Unable to open %s: %m", filename); 1898 1899 pk = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL); 1899 1900 BIO_free(bio); … … 1911 1912 bio = BIO_new(BIO_s_file()); 1912 1913 if (BIO_read_filename(bio, filename) <= 0) 1913 fatal("Unable to open %s: %m", filename);1914 util_fatal("Unable to open %s: %m", filename); 1914 1915 pk = d2i_PUBKEY_bio(bio, NULL); 1915 1916 BIO_free(bio); … … 1927 1928 *out = do_read_der_public_key(name); 1928 1929 } else { 1929 fatal("Error when reading public key. "1930 util_fatal("Error when reading public key. " 1930 1931 "File format \"%s\" not supported.\n", 1931 1932 format); … … 1933 1934 1934 1935 if (!*out) 1935 fatal("Unable to read public key from %s\n", name);1936 util_fatal("Unable to read public key from %s\n", name); 1936 1937 return 0; 1937 1938 } … … 1949 1950 bio = BIO_new(BIO_s_file()); 1950 1951 if (BIO_write_filename(bio, (char *) filename) < 0) 1951 fatal("Unable to open %s: %m", filename);1952 util_fatal("Unable to open %s: %m", filename); 1952 1953 r = PEM_write_bio_PUBKEY(bio, pk); 1953 1954 BIO_free(bio); … … 1987 1988 bio = BIO_new(BIO_s_file()); 1988 1989 if (BIO_read_filename(bio, filename) <= 0) 1989 fatal("Unable to open %s: %m", filename);1990 util_fatal("Unable to open %s: %m", filename); 1990 1991 xp = PEM_read_bio_X509(bio, NULL, NULL, NULL); 1991 1992 BIO_free(bio); … … 2003 2004 bio = BIO_new(BIO_s_file()); 2004 2005 if (BIO_read_filename(bio, filename) <= 0) 2005 fatal("Unable to open %s: %m", filename);2006 util_fatal("Unable to open %s: %m", filename); 2006 2007 xp = d2i_X509_bio(bio, NULL); 2007 2008 BIO_free(bio); … … 2019 2020 *out = do_read_der_certificate(name); 2020 2021 } else { 2021 fatal("Error when reading certificate. "2022 util_fatal("Error when reading certificate. " 2022 2023 "File format \"%s\" not supported.\n", 2023 2024 format); … … 2025 2026 2026 2027 if (!*out) 2027 fatal("Unable to read certificate from %s\n", name);2028 util_fatal("Unable to read certificate from %s\n", name); 2028 2029 return 0; 2029 2030 } … … 2034 2035 2035 2036 if ((fp = fopen(filename,"rb")) == NULL) { 2036 fatal("Unable to open %s: %m", filename);2037 util_fatal("Unable to open %s: %m", filename); 2037 2038 } 2038 2039 fseek(fp,0L,SEEK_END); … … 2094 2095 || !do_convert_bignum(&dst->p, src->p) 2095 2096 || !do_convert_bignum(&dst->q, src->q)) 2096 fatal("Invalid/incomplete RSA key.\n");2097 util_fatal("Invalid/incomplete RSA key.\n"); 2097 2098 if (src->iqmp && src->dmp1 && src->dmq1) { 2098 2099 do_convert_bignum(&dst->iqmp, src->iqmp); … … 2117 2118 } 2118 2119 default: 2119 fatal("Unsupported key algorithm\n");2120 util_fatal("Unsupported key algorithm\n"); 2120 2121 } 2121 2122 … … 2133 2134 if (!do_convert_bignum(&dst->modulus, src->n) 2134 2135 || !do_convert_bignum(&dst->exponent, src->e)) 2135 fatal("Invalid/incomplete RSA key.\n");2136 util_fatal("Invalid/incomplete RSA key.\n"); 2136 2137 RSA_free(src); 2137 2138 break; … … 2150 2151 } 2151 2152 default: 2152 fatal("Unsupported key algorithm\n");2153 util_fatal("Unsupported key algorithm\n"); 2153 2154 } 2154 2155 … … 2238 2239 r = sc_pkcs15_find_pin_by_auth_id(p15card, &auth_id, &pinobj); 2239 2240 if (r < 0) 2240 fatal("Searching for user PIN %d failed: %s\n", opt_authid, sc_strerror(r));2241 util_fatal("Searching for user PIN %d failed: %s\n", opt_authid, sc_strerror(r)); 2241 2242 pin_info = (sc_pkcs15_pin_info_t *) pinobj->data; 2242 2243 sc_keycache_set_pin_name(&path, pin_info->reference, SC_PKCS15INIT_USER_PIN); … … 2376 2377 break; 2377 2378 case 'h': 2378 print_usage_and_die(app_name, options, option_help);2379 util_print_usage_and_die(app_name, options, option_help); 2379 2380 case 'i': 2380 2381 opt_objectid = optarg; … … 2465 2466 break; 2466 2467 default: 2467 print_usage_and_die(app_name, options, option_help);2468 util_print_usage_and_die(app_name, options, option_help); 2468 2469 } 2469 2470 … … 2475 2476 fprintf(stderr, " -%c", opt->val); 2476 2477 fprintf(stderr, " more than once.\n"); 2477 print_usage_and_die(app_name, options, option_help);2478 util_print_usage_and_die(app_name, options, option_help); 2478 2479 } 2479 2480 if (this_action) … … 2484 2485 "The --no-so-pin option and --so-pin/--so-puk are mutually\n" 2485 2486 "exclusive.\n"); 2486 print_usage_and_die(app_name, options, option_help);2487 util_print_usage_and_die(app_name, options, option_help); 2487 2488 } 2488 2489 } … … 2512 2513 break; 2513 2514 default: 2514 fatal("Internal: bad has_arg value");2515 util_fatal("Internal: bad has_arg value");
