1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811
|
#!/usr/bin/perl
#
# Copyright 2005-2012 SPARTA, Inc. All rights reserved. See the COPYING
# file distributed with this software for details.
#
#
# lskrf
#
# This script lists the keyrecs in a keyrec file.
#
use strict;
use Getopt::Long qw(:config no_ignore_case_always);
use Net::DNS::SEC::Tools::conf;
use Net::DNS::SEC::Tools::defaults;
use Net::DNS::SEC::Tools::keyrec;
use Net::DNS::SEC::Tools::tooloptions;
#
# Version information.
#
my $NAME = "lskrf";
my $VERS = "$NAME version: 1.13.0";
my $DTVERS = "DNSSEC-Tools Version: 1.13";
#######################################################################
#
# Data required for command line options.
#
my %options = (); # Filled option array.
my @opts =
(
"all", # List all keyrecs.
"zones", # List zone keyrecs.
"sets", # List set keyrecs.
"keys", # List key keyrecs.
"ksk", # List KSK keyrecs.
"kcur", # List Current KSK key keyrecs.
"kpub", # List Published KSK key keyrecs.
"kobs", # List obsolete KSK key keyrecs.
"krev", # List revoked KSK key keyrecs.
"kinv", # List revoked and obs. KSK key keyrecs.
"zsk", # List ZSK keyrecs.
"cur", # List Current ZSK key keyrecs.
"new", # List New ZSK key keyrecs.
"pub", # List Published ZSK key keyrecs.
"zobs", # List obsolete ZSK key keyrecs.
"zrev", # List revoked ZSK key keyrecs.
"zinv", # List revoked and obs. ZSK key keyrecs.
"obs", # List all obsolete-key keyrecs.
"rev", # List all revoked-key keyrecs.
"invalid", # List all obs- and rev-key keyrecs.
"ref", # List referenced key keyrecs.
"unref", # List unreferenced key keyrecs.
"valid", # List unexpired zone keyrecs.
"expired", # List expired zone keyrecs.
"z-archdir", # List zone's archive directories.
"z-dirs", # Show zone's directories.
"z-dates", # Show zone's date fields.
"z-expdate", # Show zone's expiration date.
"z-kskcount", # Show zone's KSK count.
"z-ksk", # Show zone's KSK data.
"z-kskcur", # Show zone's Current KSK set.
"z-kskdir", # Show zone's KSK directory.
"z-kskpub", # Show zone's Published KSK set.
"z-sets", # Show zone's signing sets.
"z-signdate", # Show zone's signing date.
"z-signfile", # Show zone's signed zonefile.
"z-zonefile", # Show zone's zonefile.
"z-zsk", # Show zone's ZSK data.
"z-zskcount", # Show zone's ZSK count.
"z-zskcur", # Show zone's Current ZSK set.
"z-zskdir", # Show zone's ZSK directory.
"z-zsknew", # Show zone's New ZSK set.
"z-zskpub", # Show zone's Published ZSK set.
"s-keys", # Show set's keys.
"s-lastmod", # Show set's last modification.
"s-type", # Show set's types.
"s-zone", # Show set's zone.
"s-ksk", # List ZSK signing sets.
"s-kcur", # List Current KSK signing sets.
"s-kpub", # List Published KSK signing sets.
"s-kobs", # List obsolete KSK signing sets.
"s-krev", # List revoked KSK signing sets.
"s-zsk", # List ZSK signing sets.
"s-zcur", # List Current ZSK signing sets.
"s-zpub", # List Published ZSK signing sets.
"s-znew", # List New ZSK signing sets.
"s-zobs", # List obsolete ZSK signing sets.
"s-zrev", # List revoked ZSK signing sets.
"k-algorithm", # Show encryption algorithm.
"k-enddate", # Show end date.
"k-length", # Show key's length.
"k-lifespan", # Show key's lifespan.
"k-path", # Show key's path.
"k-random", # Show key's random number generator.
"k-signdate", # Show key's signing date.
"k-zone", # Show key's zonefile.
"count", # Only give a count of matching keyrecs.
"label", # Give a leading record label.
"headers", # Give column headers output.
"nodate", # Don't show the date.
"terse", # Give terse output.
"long", # Give long output.
"Version", # Display the version number.
"help", # Give a full usage message and exit.
"h-zones", # Give zone-option help message & exit.
"h-sets", # Give set-option help message & exit.
"h-keys", # Give key-option help message & exit.
);
#
# Flag values for the various options. Variable/option connection should
# be obvious.
#
my $allflag;
my $zonesflag;
my $archdirflag;
my $setsflag;
my $keysflag;
my $kskflag;
my $kcurflag;
my $kpubflag;
my $kobsflag;
my $krevflag;
my $kinvflag;
my $obsflag;
my $zskflag;
my $zcurflag;
my $zdatesflag;
my $zdirsflag;
my $zksksflag;
my $zsetsflag;
my $zzsksflag;
my $znewflag;
my $zpubflag;
my $zobsflag;
my $zrevflag;
my $zinvflag;
my $refflag;
my $unrefflag;
my $validflag;
my $expiredflag;
my $revflag;
my $invflag;
my $cntflag;
my $nodateflag;
my $headerflag;
my $terse;
my $long;
my $count = 0; # Record-match count.
my $version = 0; # Display the version number.
#########################################
#
# Data for building output.
#
my $COLSPACE = 4; # Space between columns.
my $ZONE = 'Zone'; # Hash key for zones.
my $SET = 'Set'; # Hash key for sets.
my $KEY = 'Key Name'; # Hash key for keys.
my $HEADER_KRN = "<<<header>>>"; # Name for column header "keyrec".
my %lengths = (); # Hash hash for lengths of columns;
my $prevkey; # Previous rollrec key added to output.
my $z_archdir; # Print the zone's archive directory.
my $z_expdate; # Print the zone's expiration date.
my $z_kskcount; # Print the zone's KSK count.
my $z_kskcur; # Print the zone's Current KSK set.
my $z_kskdir; # Print the zone's KSK directory.
my $z_kskpub; # Print the zone's Published KSK set.
my $z_label; # Print a leading label for zones.
my $z_signdate; # Print the zone's signing date.
my $z_signfile; # Print the zone's signed zone file.
my $z_zonefile; # Print the zone's zone file.
my $z_zskcount; # Print the zone's ZSK count.
my $z_zskcur; # Print the zone's Current ZSK set.
my $z_zskdir; # Print the zone's KSK directory.
my $z_zsknew; # Print the zone's New ZSK set.
my $z_zskpub; # Print the zone's Published ZSK set.
my $s_keys; # Print the set's key list.
my $s_label = 0; # Print a leading label for sets.
my $s_lastmod; # Print the set's last mod date.
my $s_type; # Print the set's type.
my $s_zone; # Print the set's zone.
my $k_algorithm = 0; # Key's algorithm
my $k_enddate = 0; # Key's end date.
my $k_date = 0; # Key's signing date.
my $k_label = 0; # Label for output.
my $k_length = 0; # Key's length.
my $k_life = 0; # Key's lifespan.
my $k_random = 0; # Key's random number generator.
my $k_path = 0; # Key's path.
my $k_zonename = 0; # Key's owning zone.
my $h_zone = 0; # Zone help message flag.
my $h_set = 0; # Set help message flag.
my $h_key = 0; # Key help message flag.
#######################################################################
my @krnames; # List of keyrecs in the file.
my %zones = (); # Zone keyrecs.
my %sets = (); # Set keyrecs.
my %settypes = (); # Set types to display.
my %allkeys = (); # All key keyrecs.
my %selkeys = (); # Keys selected for output.
my %kskkeys = (); # KSK keyrecs.
my %zskkeys = (); # ZSK keyrecs.
my %kcurkeys = (); # Current KSK keyrecs.
my %kpubkeys = (); # Published KSK keyrecs.
my %kobskeys = (); # Obsolete KSK keyrecs.
my %krevkeys = (); # Obsolete KSK keyrecs.
my %zcurkeys = (); # Current ZSK keyrecs.
my %znewkeys = (); # New ZSK keyrecs.
my %zpubkeys = (); # Published ZSK keyrecs.
my %zobskeys = (); # Obsolete ZSK keyrecs.
my %zrevkeys = (); # Revoked ZSK keyrecs.
my $archive; # Default archive directory.
my $ret; # Return code from main().
$ret = main();
exit($ret);
#-----------------------------------------------------------------------------
# Routine: main()
#
sub main()
{
my $argc = @ARGV; # Number of command line arguments.
my $errors = 0; # Total error count.
erraction(ERR_EXIT);
#
# Check our options.
#
doopts($argc);
#
# Read the keyrec files.
#
while($argc > 0)
{
getkeyrecs($ARGV[0]);
shift @ARGV;
$argc = @ARGV;
}
#
# Cook up the output: build a header line and calculate the maximum
# length of each field.
#
makeheaders();
maxlens();
#
# Give the output.
#
showzones() if($zonesflag);
showsets() if($setsflag);
showkeys() if($keysflag);
#
# If the matching-record count should be given, give the count in
# requested format.
#
if($cntflag)
{
if($terse)
{
print "$count\n";
}
else
{
my $plural = "s";
$plural = "" if($count == 1);
print "$count matching record$plural\n";
}
}
return(0);
}
#-----------------------------------------------------------------------------
# Routine: doopts()
#
# Purpose: This routine shakes and bakes our command line options.
# A bunch of option variables are set according to the specified
# options. Then a little massaging is done to make sure that
# the proper actions are taken. A few options imply others, so
# the implied options are set if the implying options are given.
#
sub doopts
{
my $argc = shift; # Command line argument count.
my %dtconf; # DNSSEC-Tools config values.
#
# Parse the options.
#
GetOptions(\%options,@opts) || usage();
#
# Handle a few immediate flags.
#
version() if(defined($options{'Version'}));
usage(1) if(defined($options{'help'}));
#
# Set our option variables based on the parsed options.
#
$allflag = $options{'all'} || 0;
$zonesflag = $options{'zones'} || 0;
$setsflag = $options{'sets'} || 0;
$keysflag = $options{'keys'} || 0;
$kskflag = $options{'ksk'} || 0;
$kcurflag = $options{'kcur'} || 0;
$kpubflag = $options{'kpub'} || 0;
$kobsflag = $options{'kobs'} || 0;
$krevflag = $options{'krev'} || 0;
$kinvflag = $options{'kinv'} || 0;
$zskflag = $options{'zsk'} || 0;
$zcurflag = $options{'cur'} || 0;
$znewflag = $options{'new'} || 0;
$zpubflag = $options{'pub'} || 0;
$zobsflag = $options{'zobs'} || 0;
$zrevflag = $options{'zrev'} || 0;
$zinvflag = $options{'zinv'} || 0;
$obsflag = $options{'obs'} || 0;
$revflag = $options{'rev'} || 0;
$zdatesflag = $options{'z-dates'} || 0;
$zdirsflag = $options{'z-dirs'} || 0;
$zksksflag = $options{'z-ksk'} || 0;
$zsetsflag = $options{'z-sets'} || 0;
$zzsksflag = $options{'z-zsk'} || 0;
$refflag = $options{'ref'} || 0;
$unrefflag = $options{'unref'} || 0;
$validflag = $options{'valid'} || 0;
$expiredflag = $options{'expired'} || 0;
$invflag = $options{'invalid'} || 0;
$cntflag = $options{'count'} || 0;
$nodateflag = $options{'nodate'} || 0;
$headerflag = $options{'headers'} || 0;
$terse = $options{'terse'} || 0;
$long = $options{'long'} || 0;
$h_zone = $options{'h-zones'} || 0;
$h_set = $options{'h-sets'} || 0;
$h_key = $options{'h-keys'} || 0;
#
# Set some KSK-related set-display hash fields based on options.
#
$settypes{'kskcur'} = 1 if(defined($options{'s-kcur'}));
$settypes{'kskobs'} = 1 if(defined($options{'s-kobs'}));
$settypes{'kskpub'} = 1 if(defined($options{'s-kpub'}));
$settypes{'kskrev'} = 1 if(defined($options{'s-krev'}));
if(defined($options{'s-ksk'}))
{
$settypes{'kskcur'} = 1;
$settypes{'kskobs'} = 1;
$settypes{'kskpub'} = 1;
$settypes{'kskrev'} = 1;
}
#
# Set some ZSK-related set-display hash fields based on options.
#
$settypes{'zskcur'} = 1 if(defined($options{'s-zcur'}));
$settypes{'zsknew'} = 1 if(defined($options{'s-znew'}));
$settypes{'zskobs'} = 1 if(defined($options{'s-zobs'}));
$settypes{'zskpub'} = 1 if(defined($options{'s-zpub'}));
$settypes{'zskrev'} = 1 if(defined($options{'s-zrev'}));
if(defined($options{'s-zsk'}))
{
$settypes{'zskcur'} = 1;
$settypes{'zsknew'} = 1;
$settypes{'zskobs'} = 1;
$settypes{'zskpub'} = 1;
$settypes{'zskrev'} = 1;
}
#
# If any set-types flags were given, we'll turn on the show-sets flag.
#
$setsflag = 1 if(%settypes != 0);
#
# Check for specific help messages.
#
usage(0) if($h_zone || $h_set || $h_key);
#
# Ensure we were given a keyrec file to check.
#
$argc = @ARGV;
usage(1) if($argc == 0);
#
# Get the configuration values.
#
%dtconf = parseconfig();
$archive = $dtconf{'archivedir'};
#
# If the valid-zone or the expired-zone option was given, but the
# zones specifier wasn't, we'll assume they want all the zones listed.
#
if($terse && $long)
{
print STDERR "lskrf: only one of -long and -terse may be specified\n";
exit(1);
}
#
# If both -ref and -unref were given, we'll turn off both flags.
#
if($refflag && $unrefflag)
{
$refflag = 0;
$unrefflag = 0;
}
#
# If the valid-zone or the expired-zone option was given, but the
# zones specifier wasn't, we'll assume they want all the zones listed.
#
if(($validflag || $expiredflag) && !$zonesflag)
{
$zonesflag = 1;
}
#############################################################
#
# WARNING: Code order beyond this point is critical. Do *NOT* modify
# anything in the rest of this routine if you are an idiot.
#
#
# If the -invalid option was given, convert it to -obs and -rev.
#
if($invflag)
{
$obsflag = 1;
$revflag = 1;
}
#
# If the -obs option was given, convert it to -kobs and -zobs.
#
if($obsflag)
{
$kobsflag = 1;
$zobsflag = 1;
}
#
# If the -rev option was given, convert it to -krev and -zrev.
#
if($revflag)
{
$krevflag = 1;
$zrevflag = 1;
}
#
# If none of the normal record selection flags were given but
# either the referenced or unreferenced record flags were given,
# then we'll assume the user wants all the referenced sets and keys.
#
if(!$allflag && !$zonesflag && !$setsflag && !$keysflag &&
!$kskflag && !$kcurflag && !$kpubflag &&
!$zskflag && !$zcurflag && !$zpubflag && !$znewflag &&
!$kobsflag && !$krevflag && !$zobsflag && !$zrevflag )
{
if($refflag || $unrefflag)
{
$setsflag = 1;
$keysflag = 1;
}
elsif(!$refflag && !$unrefflag)
{
print STDERR "no record-selection options were chosen\n";
exit(1);
}
#
# Turn on display of obsolete keys if the unreferenced flag
# was given.
#
if($unrefflag)
{
$kobsflag = 1;
$zobsflag = 1;
}
}
#
# Select all records if the "-all" option was given. This option
# overrides almost everything.
#
if($allflag)
{
$zonesflag = 1;
$setsflag = 1;
$keysflag = 1;
$refflag = 0;
$unrefflag = 0;
$validflag = 0;
$expiredflag = 0;
}
#
# Set the appropriate keys flags. The obsolete and revoked keys must
# be explicitly requested. The all-keys flag won't pick up either.
#
if($keysflag)
{
$kskflag = 1;
$zskflag = 1;
}
if($kskflag)
{
$kcurflag = 1;
$kpubflag = 1;
}
if($zskflag)
{
$zcurflag = 1;
$znewflag = 1;
$zpubflag = 1;
}
#
# Set up some zone output flags.
#
if($zonesflag)
{
#
# Set our defaults.
#
$z_label = 1;
$z_archdir = 0;
$z_expdate = 0;
$z_kskcount = 0;
$z_kskcur = 0;
$z_kskdir = 0;
$z_kskpub = 0;
$z_signdate = 1;
$z_signfile = 1;
$z_zonefile = 1;
$z_zskcount = 0;
$z_zskcur = 0;
$z_zskdir = 0;
$z_zsknew = 0;
$z_zskpub = 0;
#
# Set the flags for -long
#
if($long)
{
$z_archdir = 1;
$z_expdate = 1;
$z_kskcount = 1;
$z_kskcur = 1;
$z_kskdir = 1;
$z_kskpub = 1;
$z_zskcount = 1;
$z_zskcur = 1;
$z_zskdir = 1;
$z_zsknew = 1;
$z_zskpub = 1;
}
#
# Set the flags for -terse.
#
if($terse)
{
$z_archdir = 0;
$z_label = 0;
$z_signdate = 0;
$z_signfile = 0;
$z_zonefile = 0;
}
#
# Set the flags for -z-dates.
#
if($zdatesflag)
{
$z_expdate = 1;
$z_signdate = 1;
}
#
# Set the flags for -z-dirs.
#
if($zdirsflag)
{
$z_archdir = 1;
$z_kskdir = 1;
$z_zskdir = 1;
}
#
# Set the flags for -z-sets.
#
if($zsetsflag)
{
$z_kskcur = 1;
$z_kskpub = 1;
$z_zskcur = 1;
$z_zsknew = 1;
$z_zskpub = 1;
}
#
# Set the flags for -z-ksk.
#
if($zksksflag)
{
$z_kskcount = 1;
$z_kskcur = 1;
$z_kskdir = 1;
$z_kskpub = 1;
}
#
# Set the flags for -z-zsk.
#
if($zzsksflag)
{
$z_zskcount = 1;
$z_zskcur = 1;
$z_zskdir = 1;
$z_zsknew = 1;
$z_zskpub = 1;
}
#
# Set some values for flags.
#
$z_archdir = 1 if(defined($options{'z-archdir'}));
$z_expdate = 1 if(defined($options{'z-expdate'}));
$z_kskcount = 1 if(defined($options{'z-kskcount'}));
$z_kskcur = 1 if(defined($options{'z-kskcur'}));
$z_kskdir = 1 if(defined($options{'z-kskdir'}));
$z_kskpub = 1 if(defined($options{'z-kskpub'}));
$z_signdate = 1 if(defined($options{'z-signdate'}));
$z_signfile = 1 if(defined($options{'z-signfile'}));
$z_zonefile = 1 if(defined($options{'z-zonefile'}));
$z_zskcount = 1 if(defined($options{'z-zskcount'}));
$z_zskcur = 1 if(defined($options{'z-zskcur'}));
$z_zskdir = 1 if(defined($options{'z-zskdir'}));
$z_zsknew = 1 if(defined($options{'z-zsknew'}));
$z_zskpub = 1 if(defined($options{'z-zskpub'}));
$z_label = 1 if(defined($options{'label'}));
}
#
# Set up some set output flags.
#
if($setsflag)
{
#
# Set our defaults.
#
$s_label = 1;
$s_type = 1;
$s_keys = 0;
$s_lastmod = 0;
$s_zone = 1;
#
# Set the non-defaults for -long.
#
if($long)
{
$s_keys = 1;
$s_lastmod = 1;
$s_zone = 1;
}
#
# Set the non-defaults for -terse.
#
if($terse)
{
$s_label = 0;
$s_type = 0;
$s_keys = 0;
$s_zone = 0;
}
$s_label = 1 if(defined($options{'label'}));
$s_type = 1 if(defined($options{'s-type'}));
$s_keys = 1 if(defined($options{'s-keys'}));
$s_lastmod = 1 if(defined($options{'s-lastmod'}));
$s_zone = 1 if(defined($options{'s-zone'}));
}
#
# Set up some key output flags.
#
if($kskflag || $kcurflag || $kpubflag ||
$zskflag || $zcurflag || $zpubflag || $znewflag ||
$kobsflag || $krevflag || $zobsflag || $zrevflag)
{
#
# Set our defaults.
#
$k_algorithm = 0;
$k_date = 1;
$k_enddate = 0;
$k_label = 1;
$k_length = 0;
$k_life = 0;
$k_path = 0;
$k_random = 0;
$k_zonename = 1;
#
# Set the non-defaults for -long.
#
if($long)
{
$k_algorithm = 1;
$k_enddate = 1;
$k_length = 1;
$k_life = 1;
$k_path = 1;
$k_random = 1;
}
#
# Set the non-defaults for -terse.
#
if($terse)
{
$k_date = 0;
$k_label = 0;
$k_zonename = 0;
}
#
# Set some values for flags.
#
$k_algorithm = 1 if(defined($options{'k-algorithm'}));
$k_enddate = 1 if(defined($options{'k-enddate'}));
$k_date = 1 if(defined($options{'k-signdate'}));
$k_length = 1 if(defined($options{'k-length'}));
$k_life = 1 if(defined($options{'k-lifespan'}));
$k_path = 1 if(defined($options{'k-path'}));
$k_random = 1 if(defined($options{'k-random'}));
$k_zonename = 1 if(defined($options{'k-zone'}));
$k_label = 1 if(defined($options{'label'}));
#
# $keysflag isn't used any more for output selection, so we'll
# set it to indicate that some keys should be printed.
#
$keysflag = 1;
}
#
# If -headers was given, we'll turn off the label flags.
#
if($headerflag)
{
$z_label = 0 if(!defined($options{'label'}));
$s_label = 0 if(!defined($options{'label'}));
$k_label = 1;
}
}
#-----------------------------------------------------------------------------
# Routine: getkeyrecs()
#
# Purpose: This routine reads the specified keyrec file and puts each
# keyrec into the appropriate keyrec hash table. There are
# hashes for zones, KSK keys, ZSK keys, current KSKs, obsolete
# KSKs, revoked KSKs, current ZSKs, new ZSKs, published ZSKs,
# obsolete ZSKs, and revoked ZSKs.
#
sub getkeyrecs
{
my $krfile = shift; # Keyrec file.
keyrec_read($krfile);
@krnames = keyrec_names();
foreach my $krn (sort(@krnames))
{
my $kr; # Reference to keyrec.
my %keyrec; # Keyrec.
my $type; # Keyrec's type.
my $name; # Key for set hash entry.
$kr = keyrec_fullrec($krn);
%keyrec = %$kr;
$type = $keyrec{'keyrec_type'};
if($type eq 'zone')
{
my $archdir;
#
# Set the archive directory to the default if one
# isn't defined for the zone.
#
if(!defined($kr->{'archivedir'}))
{
$kr->{'archivedir'} = $archive;
}
$zones{$krn} = $kr;
}
elsif($type eq 'set')
{
$name = "$krn($kr->{'zonename'})";
$sets{$name} = $kr;
}
elsif($type eq 'kskcur')
{
$allkeys{$krn} = $kr;
$kcurkeys{$krn} = $kr;
$kskkeys{$krn} = $kr;
}
elsif($type eq 'kskpub')
{
$allkeys{$krn} = $kr;
$kpubkeys{$krn} = $kr;
$kskkeys{$krn} = $kr;
}
elsif($type eq 'kskrev')
{
$krevkeys{$krn} = $kr;
$kskkeys{$krn} = $kr;
}
elsif($type eq 'kskobs')
{
if(defined($kr->{'set_type'}))
{
$name = "$krn($kr->{'zonename'})";
$sets{$name} = $kr;
}
else
{
$kobskeys{$krn} = $kr;
$kskkeys{$krn} = $kr;
}
}
elsif($type eq 'zskcur')
{
$allkeys{$krn} = $kr;
$zcurkeys{$krn} = $kr;
$zskkeys{$krn} = $kr;
}
elsif($type eq 'zsknew')
{
$allkeys{$krn} = $kr;
$znewkeys{$krn} = $kr;
$zskkeys{$krn} = $kr;
}
elsif($type eq 'zskpub')
{
$allkeys{$krn} = $kr;
$zpubkeys{$krn} = $kr;
$zskkeys{$krn} = $kr;
}
elsif($type eq 'zskrev')
{
$zrevkeys{$krn} = $kr;
$zskkeys{$krn} = $kr;
}
elsif($type eq 'zskobs')
{
if(defined($kr->{'set_type'}))
{
$name = "$krn($kr->{'zonename'})";
$sets{$name} = $kr;
}
else
{
$zobskeys{$krn} = $kr;
$zskkeys{$krn} = $kr;
}
}
}
}
#----------------------------------------------------------------------
# Routine: makeheaders()
#
# Purpose: Build header lines as a fake keyrec.
#
sub makeheaders
{
return if(!$headerflag);
#
# Build the headers for zones.
#
if($zonesflag)
{
my %kr = ();
$kr{'keyrec_name'} = $ZONE;
$kr{'keyrec_type'} = 'Zone';
$kr{'zonefile'} = 'Zone File';
$kr{'signedzone'} = 'Signed File';
$kr{'kskcount'} = 'KSK Count';
$kr{'kskcur'} = 'Current KSK';
$kr{'kskdirectory'} = 'KSK Directory';
$kr{'kskpub'} = 'Published KSK';
$kr{'zskcount'} = 'ZSK Count';
$kr{'zskcur'} = 'Current ZSK';
$kr{'zskdirectory'} = 'ZSK Directory';
$kr{'zsknew'} = 'New ZSK';
$kr{'zskpub'} = 'Published ZSK';
$kr{'keyrec_signdate'} = 'Signing Date';
$kr{'expdate'} = 'Expiration Date';
$kr{'archivedir'} = 'Archive Directory';
$zones{$HEADER_KRN} = \%kr;
}
#
# Build the headers for signing sets.
#
if($setsflag)
{
my %kr = ();
$kr{'keyrec_name'} = $SET;
$kr{'keyrec_type'} = 'Set';
$kr{'keys'} = 'Keys';
$kr{'set_type'} = 'Set Type';
$kr{'zonename'} = 'Zone Name';
$kr{'keyrec_setdate'} = 'Last Set Modification';
$sets{$HEADER_KRN} = \%kr;
}
#
# Build the headers for keys.
#
if($keysflag)
{
my %kr = ();
$kr{'keyrec_name'} = 'Key Name';
$kr{'keyrec_type'} = 'Key Type';
$kr{'algorithm'} = 'Algorithm';
$kr{'enddate'} = 'End Date';
$kr{'keyrec_gendate'} = 'Key Generation';
$kr{'keylength'} = 'Key Length';
$kr{'keylife'} = 'Key Life';
$kr{'keypath'} = 'Key Path';
$kr{'random'} = 'Random Generator';
$kr{'zonename'} = 'Zone Name';
#
# Are these five needed?
#
$kr{'keyrec_gensecs'} = 'Key Generation';
$kr{'ksklength'} = 'Key Length';
$kr{'ksklife'} = 'Key Life';
$kr{'zsklength'} = 'Key Length';
$kr{'zsklife'} = 'Key Life';
$allkeys{$HEADER_KRN} = \%kr;
$selkeys{$HEADER_KRN} = \%kr;
}
}
#----------------------------------------------------------------------
# Routine: maxlens()
#
# Purpose: Calculate the maximum length of each keyrec field for the
# zone, signing set, and key keyrecs. Length data for each
# type of keyrec will be saved separately.
# After finding the longest length for each field, we'll
# add a little buffer space.
#
sub maxlens
{
#
# Initialize the lengths hashes.
#
%lengths = ();
#
# If we'll be printing zones, we'll calculate the maximum length
# of each field in each zone keyrec.
#
if($zonesflag)
{
#
# Loop through the zone list and get data on the desired zones.
#
foreach my $name (sort(keys(%zones)))
{
my $rref = $zones{$name};
my %kr = %$rref;
foreach my $fld (sort(keys(%kr)))
{
if(length($kr{$fld}) > $lengths{$ZONE}{$fld})
{
$lengths{$ZONE}{$fld} = length($kr{$fld});
}
}
}
#
# Hardcode the length of the expiration date string.
# Unless we change our system of time-keeping, this will be 24.
#
$lengths{$ZONE}{'expdate'} = 24;
#
# Add a little buffer space between fields.
#
foreach my $fld (sort(keys(%{$lengths{$ZONE}})))
{
my $newlen;
$newlen = $lengths{$ZONE}{$fld};
$newlen += $COLSPACE;
$lengths{$ZONE}{$fld} = $newlen;
}
}
#
# If we'll be printing signing sets, we'll calculate the maximum
# length of each field in each set keyrec.
#
if($setsflag)
{
#
# Loop through the set list and get data on the desired sets.
#
foreach my $name (sort(keys(%sets)))
{
my $rref = $sets{$name};
my %kr = %$rref;
foreach my $fld (sort(keys(%kr)))
{
if(length($kr{$fld}) > $lengths{$SET}{$fld})
{
$lengths{$SET}{$fld} = length($kr{$fld});
}
}
}
#
# Add a little buffer space between fields.
#
foreach my $fld (sort(keys(%{$lengths{$SET}})))
{
my $newlen;
$newlen = $lengths{$SET}{$fld};
$newlen += $COLSPACE;
$lengths{$SET}{$fld} = $newlen;
}
}
#
# If we'll be printing keys, we'll calculate the maximum length
# of each field in each set keyrec.
#
if($keysflag)
{
#
# Loop through the selected key list and get data on the
# desired keys.
#
foreach my $name (sort(keys(%selkeys)))
{
my $rref = $selkeys{$name};
my %kr;
#
# Skip undefined hash keys.
#
next if(!defined($rref));
%kr = %$rref;
#
# Go through the keyrec's fields and check them
# against the saved maximum lengths of key fields.
#
foreach my $fl (sort(keys(%kr)))
{
if(length($kr{$fl}) > $lengths{$KEY}{$fl})
{
$lengths{$KEY}{$fl} = length($kr{$fl});
}
}
}
#
# Add a little buffer space between fields.
#
foreach my $fld (sort(keys(%{$lengths{$KEY}})))
{
my $newlen;
$newlen = $lengths{$KEY}{$fld};
$newlen += $COLSPACE;
$lengths{$KEY}{$fld} = $newlen;
}
}
}
#-----------------------------------------------------------------------------
# Routine: showzones()
#
# Purpose: This routine displays zone data. It has three output formats:
#
# normal A zone label, the zone name, the zone file,
# and the zone's signing date are displayed.
#
# terse The zone name is displayed.
#
# long A zone label, the zone name, the zone file,
# the zone's signing date, and the zone's date
# of expiry are displayed.
#
# If one of the zone expiration flags was given then there is
# also a check made to see if the zone is expired.
#
sub showzones
{
my $out = ""; # Output string to build.
my $signdate; # Zone's signing date.
my $zonename; # Zone's name.
my $zonefile; # Zone's zonefile.
my $signfile; # Zone's signed zonefile.
my $archdir; # Zone's archive directory.
my $endtime; # Calculated expiration date.
my $expdate; # Expiration date in seconds.
my $kskcount; # KSK count.
my $kskcur; # Current KSK's signing set.
my $kskdir; # KSK's directory.
my $kskpub; # Published KSK's signing set.
my $signsecs; # Signing date in seconds.
my $zskcount; # ZSK count.
my $zskcur; # Current ZSK's signing set.
my $zskdir; # ZSK's directory.
my $zsknew; # New ZSK's signing set.
my $zskpub; # Published ZSK's signing set.
#
# Reset our previous key value.
#
$prevkey = '';
#
# Loop through the zone list and give data on the desired zones.
#
foreach my $zk (sort(keys(%zones)))
{
my $krr = $zones{$zk};
my %kr = %$krr;
#
# Check the zone-validity flags against the zone to see if
# the record should be displayed.
#
if(($validflag && expiredzone($zk)) ||
($expiredflag && !expiredzone($zk)))
{
next;
}
#
# Bump the matching-records count.
#
$count++ if($zk ne $HEADER_KRN);
#
# Stay cloaked if only the count of matching records
# should be given.
#
next if($cntflag);
#
# Get a bunch of data from the zone keyrec.
#
$archdir = $kr{'archivedir'};
$endtime = $kr{'endtime'};
$expdate = $kr{'expdate'};
$kskcount = $kr{'kskcount'};
$kskcur = $kr{'kskcur'} || "<unset>";
$kskpub = $kr{'kskpub'} || "<unset>";
$kskdir = $kr{'kskdirectory'} || ".";
$signdate = $kr{'keyrec_signdate'};
$signsecs = $kr{'keyrec_signsecs'};
$signfile = $kr{'signedzone'};
$zonefile = $kr{'zonefile'};
$zskcount = $kr{'zskcount'};
$zskcur = $kr{'zskcur'} || "<unset>";
$zsknew = $kr{'zsknew'} || "<unset>";
$zskpub = $kr{'zskpub'} || "<unset>";
$zskdir = $kr{'zskdirectory'} || ".";
#
# Do some non-header manipulations.
#
if($zk ne $HEADER_KRN)
{
#
# Get a string holding the zone's expiration date.
#
$endtime = $signsecs + $endtime;
$expdate = gmtime($endtime);
$zones{$zk}{'expdate'} = $expdate;
#
# Make sure we have numeric key counts.
#
$kskcount = '0' if($kskcount eq '');
$zskcount = '0' if($zskcount eq '');
$zones{$zk}{'kskcount'} = $kskcount;
$zones{$zk}{'zskcount'} = $zskcount;
#
# Save the current directories.
#
$zones{$zk}{'kskdir'} = $kskdir;
$zones{$zk}{'zskdir'} = $zskdir;
}
$zones{$zk}{'kskcur'} = $kskcur;
$zones{$zk}{'kskpub'} = $kskpub;
$zones{$zk}{'zskcur'} = $zskcur;
$zones{$zk}{'zsknew'} = $zsknew;
$zones{$zk}{'zskpub'} = $zskpub;
#
# Get the zone's name.
#
$zonename = $HEADER_KRN if($zonename eq "");
$zonename = $zk;
#
# Build the output string.
#
$prevkey = 'first-field';
$out = outstr($ZONE,$zk,'keyrec_type','zone',$z_label,0);
$out .= outstr($ZONE,$zk,'keyrec_name',$zonename,1,0);
$out .= outstr($ZONE,$zk,'zonefile',$zonefile,$z_zonefile,0);
$out .= outstr($ZONE,$zk,'signedzone',$signfile,$z_signfile,0);
$out .= outstr($ZONE,$zk,'kskcount',$kskcount,$z_kskcount,0);
$out .= outstr($ZONE,$zk,'kskcur',$kskcur,$z_kskcur,0);
$out .= outstr($ZONE,$zk,'kskpub',$kskpub,$z_kskpub,0);
$out .= outstr($ZONE,$zk,'kskdirectory',$kskdir,$z_kskdir,0);
$out .= outstr($ZONE,$zk,'zskcount',$zskcount,$z_zskcount,0);
$out .= outstr($ZONE,$zk,'zskcur',$zskcur,$z_zskcur,0);
$out .= outstr($ZONE,$zk,'zskpub',$zskpub,$z_zskpub,0);
$out .= outstr($ZONE,$zk,'zsknew',$zsknew,$z_zsknew,0);
$out .= outstr($ZONE,$zk,'zskdirectory',$zskdir,$z_zskdir,0);
$out .= outstr($ZONE,$zk,'keyrec_signdate',$signdate,$z_signdate,1);
$out .= outstr($ZONE,$zk,'expdate',$expdate,$z_expdate,1);
$out .= outstr($ZONE,$zk,'archivedir',$archdir,$z_archdir,0);
#
# Write the output string.
#
print "$out\n";
}
print "\n" if($headerflag && ($setsflag || $keysflag));
}
#-----------------------------------------------------------------------------
# Routine: showsets()
#
# Purpose: This routine displays set data. It has three output formats:
#
# normal A label, the set name, the set's zone, and the
# set's keys are displayed.
#
# terse The set name and the set's zone are displayed.
#
# long A label, the set name, the set's keys, the set's
# zone, the set's creation date are displayed.
#
sub showsets
{
my $out = ""; # Output string to build.
my $setname; # Set's name.
my $settype; # Set's type.
my $keylist; # Set's key list.
my $moddate; # Set's creation date.
my $zone; # Set's zonename.
my $checktypes = 0; # Flag for checking types.
my $endtime; # Calculated expiration date.
my $setsecs; # Signing date in seconds.
#
# Reset our previous key value.
#
$prevkey = '';
#
# Set our check-types flag.
#
$checktypes = 1 if(%settypes != 0);
#
# Loop through the set list and give data on the desired sets.
#
foreach my $sk (sort(keys(%sets)))
{
my $krr = $sets{$sk}; # Reference to set's keyrec.
my %kr = %$krr; # Set's keyrec.
#
# Check this set's reference state against the command options.
#
if($sk ne $HEADER_KRN)
{
my $sn; # Set name.
#
# Get just the set name.
#
$sk =~ /(.*)\(.*\)/;
$sn = $1;
#
# Skip this keyrec if we should.
# (Nice and obscure, no?)
#
if(($refflag && !refdkeyrec($sn)) ||
($unrefflag && refdkeyrec($sn)))
{
next;
}
}
#
# Get a bunch of data from the set keyrec.
#
$zone = $kr{'zonename'};
$settype = $kr{'set_type'};
$keylist = $kr{'keys'};
$moddate = $kr{'keyrec_setdate'};
#
# Skip this record if we aren't supposed to show this set type.
#
next if($checktypes && !defined($settypes{$settype}));
#
# Bump the matching-records count.
#
$count++ if($sk ne $HEADER_KRN);
#
# Stay cloaked if only the count of matching records
# should be given.
#
next if($cntflag);
#
# Get the set's name (stripping off the zone.)
#
$sk =~ /(.*)\(.*\)/;
$setname = $1;
$setname = $HEADER_KRN if($setname eq "");
#
# Convert the set's type into a pretty version.
#
if($settype ne 'Set Type')
{
$settype =~ /^([kz]sk)(.+)$/i;
my $type1 = uc($1);
my $type2 = $2;
$settype = "$type1-$type2";
$sets{$sk}{'set_type'} = $settype;
}
else
{
if($setname ne $HEADER_KRN)
{
$settype = '(unknown set type)';
}
}
#
# If this is the active "super" set of revoked KSKs, we'll
# capitalize the suffix.
#
if($settype eq 'KSK-rev')
{
my $zkr = $zones{$zone};
if($zkr->{'kskrev'} eq $setname)
{
$settype = "KSK-REV";
}
}
#
# Build the output string.
#
$prevkey = 'first-field';
$out = outstr($SET,$sk,'keyrec_type','set',$s_label,0);
$out .= outstr($SET,$sk,'keyrec_name',$setname,1,0);
$out .= outstr($SET,$sk,'zonename',$zone,$s_zone,0);
$out .= outstr($SET,$sk,'set_type',$settype,$s_type,0);
$out .= outstr($SET,$sk,'keyrec_setdate',$moddate,$s_lastmod,1);
$out .= outstr($SET,$sk,'keys',$keylist,$s_keys,0);
#
# Write the output string.
#
print "$out\n";
}
print "\n" if($headerflag && ($keysflag));
}
#-----------------------------------------------------------------------------
# Routine: showkeys()
#
# Purpose: This routine goes through the key-related hashes and prints
# output for them. It's only done if the appropriate option
# has been given, blah blah blah.
#
sub showkeys
{
my $krr; # Reference to a key's keyrec.
#
# Select a header line.
#
if($headerflag)
{
$krr = $selkeys{$HEADER_KRN};
selkey($HEADER_KRN,$krr,'');
}
#
# Select the information about the Current KSK keys.
#
if($kcurflag)
{
foreach my $k (sort(keys(%kcurkeys)))
{
$krr = $kcurkeys{$k};
selkey($k,$krr,"KSK-cur");
}
}
#
# Select the information about the Published KSK keys.
#
if($kpubflag)
{
foreach my $k (sort(keys(%kpubkeys)))
{
$krr = $kpubkeys{$k};
selkey($k,$krr,"KSK-pub");
}
}
#
# Select the information about the revoked KSK keys.
#
if($krevflag)
{
foreach my $k (sort(keys(%krevkeys)))
{
$krr = $krevkeys{$k};
selkey($k,$krr,"KSK-rev");
}
}
#
# Select the information about the obsolete KSK keys.
#
if($kobsflag)
{
foreach my $k (sort(keys(%kobskeys)))
{
$krr = $kobskeys{$k};
selkey($k,$krr,"KSK-obs");
}
}
#
# Select the information about the Current ZSK keys.
#
if($zcurflag)
{
foreach my $k (sort(keys(%zcurkeys)))
{
$krr = $zcurkeys{$k};
selkey($k,$krr,"ZSK-cur");
}
}
#
# Select the information about the Published ZSK keys.
#
if($zpubflag)
{
foreach my $k (sort(keys(%zpubkeys)))
{
$krr = $zpubkeys{$k};
selkey($k,$krr,"ZSK-pub");
}
}
#
# Select the information about the New ZSK keys.
#
if($znewflag)
{
foreach my $k (sort(keys(%znewkeys)))
{
$krr = $znewkeys{$k};
selkey($k,$krr,"ZSK-new");
}
}
#
# Select the information about the obsolete ZSK keys.
#
if($zobsflag)
{
foreach my $k (sort(keys(%zobskeys)))
{
$krr = $zobskeys{$k};
selkey($k,$krr,"ZSK-obs");
}
}
#
# Select the information about the revoked ZSK keys.
#
if($zrevflag)
{
foreach my $k (sort(keys(%zrevkeys)))
{
$krr = $zrevkeys{$k};
selkey($k,$krr,"ZSK-rev");
}
}
#
# Write the selected key data.
#
writekeys();
}
#-----------------------------------------------------------------------------
# Routine: expiredzone()
#
# Purpose: This routine determines if a specified zone has expired or
# if it's still valid.
#
# Return Values:
# 1 - the zone has expired
# 0 - the zone has not expired
#
sub expiredzone
{
my $zn = shift; # Zone name to be checked.
my %zkr; # Zone keyrec.
my $zkrref; # Reference to zone keyrec.
my $endtime; # Zone's end-time.
my $signsecs; # Zone's signing date.
my $curtime = time(); # Current time.
my $secs; # Seconds in "+nnn" endtime.
my $finaltime; # Time zone expires.
#
# Get the zone's keyrec.
#
$zkrref = $zones{$zn};
%zkr = %$zkrref;
#
# Pull some data from the keyrec.
#
$endtime = $zkr{'endtime'};
$signsecs = $zkr{'keyrec_signsecs'};
#
# Get the number of seconds until the zone's end time.
#
if($endtime =~ /^+/)
{
$endtime =~ /\+([0-9]+)/;
$secs = $1;
}
#
# Calculate the zone's expiration date.
#
$finaltime = $signsecs + $secs;
#
# If the zone has expired, we'll return success. If not, we'll
# return failure.
#
if($finaltime <= $curtime)
{
return(1);
}
return(0);
}
#-----------------------------------------------------------------------------
# Routine: refdkeyrec()
#
# Purpose: This routine determines if a named keyrec is referenced.
# Zones reference signing sets, signing sets reference zones.
# For a set keyrec to be referenced, it must be listed in a
# zone keyrec. For a key keyrec to be referenced, it must be
# listed in a set keyrec which is listed in a zone.
#
# Return Values:
# 1 - the keyrec is referenced
# 0 - the keyrec is not referenced
#
sub refdkeyrec
{
my $kn = shift; # Keyrec name to be checked.
my $krtype; # Type of specified keyrec.
#
# Get the key's type and return false if this is a zone.
#
$krtype = keyrec_recval($kn,'keyrec_type');
return(0) if($krtype eq 'zone');
#
# If this is a signing set, we'll see if any of the zones has it
# as an active set.
#
if($krtype eq 'set')
{
#
# Check each zone to see if this signing set is one of the
# zone's active sets. If so, return true.
#
foreach my $zn (keys(%zones))
{
my %zkr; # Zone keyrec.
my $zkrref; # Ref. to zone keyrec.
$zkrref = $zones{$zn};
%zkr = %$zkrref;
if(($zkr{'kskcur'} eq $kn) ||
($zkr{'kskpub'} eq $kn) ||
($zkr{'zskcur'} eq $kn) ||
($zkr{'zskpub'} eq $kn) ||
($zkr{'zsknew'} eq $kn))
{
return(1);
}
}
#
# The signing set wasn't found in any of the zones so
# we'll return false.
#
return(0);
}
#
# Check each signing set to see if it's using this key.
#
foreach my $sn (keys(%sets))
{
my %skr; # Set keyrec.
my $skrref; # Ref. to set keyrec.
$sn =~ /(.*)\(.*\)/;
$sn = $1;
#
# If this signing set holds this key, we'll see if it
# is referenced by a zone.
#
if(keyrec_signset_haskey($sn,$kn))
{
return(1) if(refdkeyrec($sn));
}
}
#
# Didn't find a reference to the key, so we'll return failure.
#
return(0);
}
#-----------------------------------------------------------------------------
# Routine: selkey()
#
# Purpose: This routine selects the keys whose data will be displayed.
# It is called for several types of KSKs and of ZSK. It handles
# the referenced-key options, depending on whether or not the
# specified key is actually referenced.
#
sub selkey
{
my $key = shift; # Key name.
my $kkr = shift; # Reference to key's keyrec.
my $lbl = shift; # Output label.
my %kr = %$kkr; # Key's keyrec.
my $algorithm; # Key's algorithm.
my $ender; # Key's lifespan date (in seconds.)
my $gendate = ""; # Key's date.
my $enddate = ""; # Key's end-date (in text.)
my $length; # Key's length.
my $life; # Key's lifespan.
my $path; # Key's path.
my $random; # Key's random number generator.
my $zonename; # Name of key's owning zone.
my $out = ""; # Output string.
#
# Check this key's reference state against the command options.
#
if($key ne $HEADER_KRN)
{
if(($refflag && !refdkeyrec($key)) ||
($unrefflag && refdkeyrec($key)))
{
return;
}
}
#
# Bump the matching-records count.
#
$count++ if($key ne $HEADER_KRN);
#
# Run silent if only the count of matching records should be given.
#
return if($cntflag);
#
# Set up some -long specific stuff.
#
if($long)
{
$lbl .= "-key";
}
#
# Get the key's data.
#
$algorithm = $kr{'algorithm'};
$path = $kr{'keypath'};
$random = $kr{'random'};
$zonename = $kr{'zonename'};
$gendate = "$kr{'keyrec_gendate'}" if(!$nodateflag);
#
# Set some key-type-specific values.
#
if($kr{'keyrec_type'} =~ /^ksk/)
{
$lbl .= "\t" if($long);
$length = $kr{'ksklength'};
$life = $kr{'ksklife'};
}
else
{
$length = $kr{'zsklength'};
$life = $kr{'zsklife'}
}
#
# Do some field-specific data majigulations.
#
if($key eq $HEADER_KRN)
{
$enddate = $kr{'enddate'};
}
else
{
#
# Calculate the key's end-date.
#
$ender = $kr{'keyrec_gensecs'} + $life;
$enddate = gmtime($ender);
#
# Set a dummy value if the lifetime wasn't set yet.
#
$life = "unset" if($life eq "");
}
#
# Save the calculated end date.
#
$allkeys{$key}{'enddate'} = $enddate;
#
# Save the key data to the selected-keys hash.
#
$selkeys{$key}{'keyrec_name'} = $key;
$selkeys{$key}{'keyrec_type'} = $kr{'keyrec_type'};
$selkeys{$key}{'algorithm'} = $algorithm;
$selkeys{$key}{'enddate'} = $enddate;
$selkeys{$key}{'gendate'} = $gendate;
$selkeys{$key}{'keylength'} = $length;
$selkeys{$key}{'keylife'} = $life;
$selkeys{$key}{'keypath'} = $path;
$selkeys{$key}{'random'} = $random;
$selkeys{$key}{'zonename'} = $zonename;
}
#----------------------------------------------------------------------
# Routine: writekeys()
#
# Purpose: This routine is the master routine for writing key data.
# It does a but of final data massage and then writes the
# data in order key-type-specific order.
#
sub writekeys
{
#
# Adjust the key's type a bit.
#
foreach my $key (sort(keys(%selkeys)))
{
my $keytype; # Key's type.
$keytype = $selkeys{$key}{'keyrec_type'};
$keytype =~ s/^ksk/KSK-/;
$keytype =~ s/^zsk/ZSK-/;
$selkeys{$key}{'keyrec_type'} = $keytype;
}
#
# Now that we have the actual keys, recalculate the maximum lengths.
#
$zonesflag = $setsflag = 0;
maxlens();
#
# Write each of the key types in a nice orderly fashion.
#
foreach my $kt ('Key Type',
'KSK-cur', 'KSK-pub', 'KSK-rev', 'KSK-obs',
'ZSK-cur', 'ZSK-pub', 'ZSK-new', 'ZSK-rev', 'ZSK-obs' )
{
writekeytype($kt);
}
}
#----------------------------------------------------------------------
# Routine: writekeytype()
#
# Purpose: This routine performs the actual output operations for key
# data. It creates an output string for each of the keys saved
# in the %selkeys hash. However, it only works for a specific,
# caller-specified type of key.
#
sub writekeytype
{
my $keytype = shift; # Type of key to write.
#
# Write the selected keys.
#
foreach my $key (sort(keys(%selkeys)))
{
my $out = ''; # Output string.
my $algorithm; # Key's algorithm.
my $enddate; # Key's expiration date.
my $gendate; # Key's generation date.
my $length; # Key's length.
my $life; # Key's lifespan.
my $path; # Key's path.
my $random; # Key's randomizer.
my $type; # Key's type.
my $zonename; # Key's zone.
#
# Make sure we're only looking at the requested key type.
#
$type = $selkeys{$key}{'keyrec_type'};
next if($type ne $keytype);
#
# Set-up for output line.
#
$prevkey = 'first-field';
#
# Save the key data to the selected-keys hash.
#
$algorithm = $selkeys{$key}{'algorithm'};
$enddate = $selkeys{$key}{'enddate'};
$gendate = $selkeys{$key}{'gendate'};
$length = $selkeys{$key}{'keylength'};
$life = $selkeys{$key}{'keylife'};
$path = $selkeys{$key}{'keypath'};
$random = $selkeys{$key}{'random'};
$zonename = $selkeys{$key}{'zonename'};
#
# Build the output string.
#
$out = outstr($KEY,$key,'keyrec_type',$type,$k_label,0);
$out .= outstr($KEY,$key,'keyrec_name',$key,1,0);
$out .= outstr($KEY,$key,'zonename',$zonename,$k_zonename,0);
$out .= outstr($KEY,$key,'algorithm',$algorithm,$k_algorithm,0);
$out .= outstr($KEY,$key,'keylength',$length,$k_length,0);
$out .= outstr($KEY,$key,'gendate',$gendate,$k_date,1);
$out .= outstr($KEY,$key,'keylife',$life,$k_life,0);
$out .= outstr($KEY,$key,'enddate',$enddate,$k_enddate,1);
$out .= outstr($KEY,$key,'keypath',$path,$k_path,0);
$out .= outstr($KEY,$key,'random',$random,$k_random,0);
#
# Write the output string.
#
print "$out\n";
}
}
#----------------------------------------------------------------------
# Routine: outstr()
#
# Purpose: Build an output line. We'll do whatever spacing is required
# so that each type's records line up nicely. The built output
# line is returned to the caller.
#
sub outstr
{
my $dtype = shift; # Type of these data.
my $krname = shift; # Zone/set/key name.
my $key = shift; # Hashkey.
my $val = shift; # Value to print.
my $flag = shift; # Output flag.
my $usequotes = shift; # Quotes flag.
my $ret; # Return string.
my $krgroup; # Keyrec group to consult.
my $maxcollen; # Max field length of previous field.
my $prevcollen; # Length of previous field's value.
my $numspaces = 0; # Spaces to add to previous field.
my $spaces = ''; # Spaces to add.
#
# Return if the given flag isn't set and -long wasn't given.
#
return('') if(!$flag);
#
# Figure out which group of keyrecs to use. We're intentionally
# not using a default for this and will thus allow things to die
# horrible death if this routine is improperly used.
#
if($dtype eq $ZONE)
{
$krgroup = \%zones;
}
elsif($dtype eq $SET)
{
$krgroup = \%sets;
}
elsif($dtype eq $KEY)
{
$krgroup = \%selkeys;
}
#
# Use the data's type as the name field for the header line.
#
if(($key eq 'keyrec_name') && ($val eq $HEADER_KRN))
{
$val = $dtype;
$krgroup->{$krname}{$key} = $dtype;
}
#
# Add in the appropriate header for zone and set data.
# (Key keyrecs have their type header pre-set.)
#
if((($key eq 'keyrec_type') &&
($krname eq $HEADER_KRN)) &&
(($val eq 'zone') || ($val eq 'set')))
{
$val = "Type";
$krgroup->{$krname}{$key} = $val;
}
#
# Figure out spacing for this column.
#
$maxcollen = $lengths{$dtype}{$prevkey};
$prevcollen = length($krgroup->{$krname}{$prevkey});
$numspaces = $maxcollen - $prevcollen;
#
# Build the spacing.
#
$spaces = ' ' x $numspaces if($numspaces > 0);
#
# Build the output line.
#
$ret = $spaces . $val;
#
# For some fields we'll add quotes around the value.
# We won't add quotes if we're printing headers.
#
$usequotes = 0 if($headerflag);
if($usequotes && ($krname ne $HEADER_KRN))
{
$ret =~ s/$spaces$val/$spaces\"$val\"/;
}
#
# Save the hash key and return the output string to the caller.
#
$prevkey = $key;
return($ret);
}
#----------------------------------------------------------------------
# Routine: version()
#
# Purpose: Print the version number(s) and exit.
#
sub version
{
print STDERR "$VERS\n";
print STDERR "$DTVERS\n";
exit(0);
}
#-----------------------------------------------------------------------------
# Routine: usage()
#
sub usage
{
my $allflag = shift; # Show-all flag.
if($allflag)
{
$h_zone = 1;
$h_set = 1;
$h_key = 1;
}
print STDERR "usage: lskrf [options] <keyrec-file>\n";
if($allflag)
{
print STDERR "\trecord-selection options:\n";
print STDERR "\t\t-all list all records\n";
print STDERR "\t\t-zones\t list all zones\n";
print STDERR "\t\t-sets list all signing sets\n";
print STDERR "\t\t-keys list all keys\n";
print STDERR "\t\t-ksk list KSK keys\n";
print STDERR "\t\t -kcur list Current KSK keys\n";
print STDERR "\t\t -kpub list Published KSK keys\n";
print STDERR "\t\t -kobs list obsolete KSK keys\n";
print STDERR "\t\t -krev list revoked KSK keys\n";
print STDERR "\t\t-zsk list ZSK keys\n";
print STDERR "\t\t -cur list Current ZSK keys\n";
print STDERR "\t\t -pub list Published ZSK keys\n";
print STDERR "\t\t -new list New ZSK keys\n";
print STDERR "\t\t -zobs list obsolete ZSK keys\n";
print STDERR "\t\t -zrev list revoked ZSK keys\n";
print STDERR "\t\t-obs list obsolete KSK and ZSK keys\n";
print STDERR "\t\t-rev list revoked KSK and ZSK keys\n";
print STDERR "\t\t-invalid list obsolete and revoked KSK and ZSK keys\n";
print STDERR "\trecord-attribute options:\n";
print STDERR "\t\t-valid\t show keyrecs of unexpired zones\n";
print STDERR "\t\t-expired show keyrecs of expired zones\n";
print STDERR "\t\t-ref show referenced key keyrecs\n";
print STDERR "\t\t-unref\t show unreferenced key keyrecs\n";
print STDERR "\toutput-format options:\n";
print STDERR "\t\t-count only give count of matching keyrecs\n";
print STDERR "\t\t-label show record-type label\n";
print STDERR "\t\t-headers give explanatory column headers\n";
print STDERR "\t\t-life display date\n";
print STDERR "\t\t-long long output\n";
print STDERR "\t\t-nodate do not display date\n";
print STDERR "\t\t-terse\t terse output\n";
print STDERR "\t\t-Version Show version information\n";
}
if($h_zone)
{
print STDERR "\tzone-attribute options:\n";
print STDERR "\t\t-z-archdir show zone's key-archive directory\n";
print STDERR "\t\t-z-dates show zone's time-stamps\n";
print STDERR "\t\t-z-dirs show zone's directories\n";
print STDERR "\t\t-z-expdate show zone's expiration date\n";
print STDERR "\t\t-z-ksk show zone's KSK data\n";
print STDERR "\t\t-z-kskcount show zone's KSK count\n";
print STDERR "\t\t-z-kskcur show zone's Current KSK signing set\n";
print STDERR "\t\t-z-kskdir show zone's KSK directory\n";
print STDERR "\t\t-z-kskpub show zone's Published KSK signing set\n";
print STDERR "\t\t-z-sets show zone's signing sets\n";
print STDERR "\t\t-z-signdate show zone's signing date\n";
print STDERR "\t\t-z-signfile show zone's signed zonefile\n";
print STDERR "\t\t-z-zonefile show zone's zonefile\n";
print STDERR "\t\t-z-zsk show zone's ZSK data\n";
print STDERR "\t\t-z-zskcount show zone's ZSK count\n";
print STDERR "\t\t-z-zskcur show zone's Current ZSK signing set\n";
print STDERR "\t\t-z-zskdir show zone's ZSK directory\n";
print STDERR "\t\t-z-zsknew show zone's New ZSK signing set\n";
print STDERR "\t\t-z-zskpub show zone's Published ZSK signing set\n";
}
if($h_set)
{
print STDERR "\tset-attribute options:\n";
print STDERR "\t\t-s-keys show set's keys\n";
print STDERR "\t\t-s-lastmod show set's last modification date\n";
print STDERR "\t\t-s-type show set's type\n";
print STDERR "\t\t-s-zone show set's zone\n";
}
if($h_key)
{
print STDERR "\tkey-attribute options:\n";
print STDERR "\t\t-k-algorithm show key's algorithm\n";
print STDERR "\t\t-k-enddate show key's end-date\n";
print STDERR "\t\t-k-length show key's length\n";
print STDERR "\t\t-k-lifespan show key's lifespan\n";
print STDERR "\t\t-k-path show key's path\n";
print STDERR "\t\t-k-random show key's random number generator\n";
print STDERR "\t\t-k-signdate show key's signing date\n";
print STDERR "\t\t-k-zone show key's zonefile\n";
}
if($allflag)
{
print STDERR "\thelp options:\n";
print STDERR "\t\t-help full help message\n";
print STDERR "\t\t-h-zones zone-options help message \n";
print STDERR "\t\t-h-sets set-options help message \n";
print STDERR "\t\t-h-keys key-options help message \n";
}
exit(0);
}
1;
##############################################################################
#
=pod
=head1 NAME
lskrf - List the I<keyrec>s in a DNSSEC-Tools I<keyrec> file
=head1 SYNOPSIS
lskrf [options] <keyrec-files>
=head1 DESCRIPTION
B<lskrf> lists the contents of the specified I<keyrec> files. All
I<keyrec> files are loaded before the output is displayed. If any I<keyrec>s
have duplicated names, whether within one file or across multiple files, the
later I<keyrec> will be the one whose data are displayed.
B<lskrf> has three base output formats. In ascending levels of detail, these
formats are terse output, default format, and long format. Terse output is
given when the B<-terse> option is specified; long output is given when the
B<-long> option is specified.
The output displayed for each record in a I<keyrec> file depends on the
selected records, the selected attributes, and the selected output format.
Each option in these option groups is described in detail in the OPTIONS
section; the three basic output formats are described in the OUTPUT FORMATS
section.
=head1 OUTPUT FORMATS
I<keyrec> files hold three types of I<keyrec> records: zone records, signing
set records, and key records. Each type of I<keyrec> record contains
I<keyrec> fields related to that type. Zone I<keyrec> records contain data
about all the keys associated with a particular zone; set I<keyrec> records
contain data about all the keys associated with a particular signing set; key
I<keyrec> records contain key lengths and algorithms for each particular key.
(There is the case of subordinate revoked and obsolete signing sets. These
are stored in key I<keyrec> records, but they contain the I<set_type> entry
which key I<keyrec>s do not.)
The data to be printed must be specified by selecting some combination of the
B<-zone>, B<-sets>, B<-keys>, and B<-all> options. There are also options
for specifying specific types of keys to be printed.
The three base output formats are the default format, the terse format, and
the long format. The B<-terse> option indicates that a minimal amount of
output is desired; the B<-long> option indicates that a great deal of output
is desired. The record-selection and attribute-selection options may be used
in conjunction with B<-terse> to display exactly the set of I<keyrec> fields
needed. The default output format is a middle ground between terse and long
output and is that used when neither B<-terse> nor B<-long> is given.
=head2 Zone I<keyrec> Output
The table below shows the zone I<keyrec> fields displayed for each output
format.
keyrec field default terse long
------------ ------- ----- ----
keyrec type yes no yes
zone name yes yes yes
zone file yes no yes
signed zonefile yes no yes
signing date yes no yes
expiration date no no yes
archive directory no no yes
KSK count no no yes
KSK directory no no yes
current KSK set no no yes
published KSK set no no yes
ZSK count no no yes
ZSK directory no no yes
current ZSK set no no yes
published ZSK set no no yes
new ZSK set no no yes
=head2 Set I<keyrec> Output
The table below shows the signing set I<keyrec> fields displayed for each
output format.
keyrec field default terse long
------------ ------- ----- ----
keyrec type yes no yes
set name yes yes yes
zone name yes no yes
type yes no yes
keys no no yes
last modification date no no yes
=head2 Key I<keyrec> Output
The table below shows the key I<keyrec> fields displayed for each
output format.
keyrec field default terse long
------------ ------- ----- ----
keyrec type yes no yes
key name yes yes yes
algorithm no no yes
end date no no yes
generation date yes no yes
key length no no yes
key life no no yes
key path no no yes
keys no no yes
random number generator no no yes
zone name yes no yes
=head1 OPTIONS
B<lskrf> takes three types of options: record-selection options,
record-attribute options, and output-style options. These option
sets are detailed below.
Record-selection options are required options; at least one record-selection
option B<must> be selected. Record-attribute options and output-style options
are optional options; any number of these option I<may> be selected.
=head2 Record-Selection Options
These options select the types of I<keyrec> that will be displayed.
=over 4
=item B<-all>
This option displays all the records in a I<keyrec> file.
=item B<-zones>
This option displays the zones in a I<keyrec> file.
=item B<-sets>
This option displays the signing sets in a I<keyrec> file.
=item B<-keys>
This option displays the keys in a I<keyrec> file.
The key data are sorted by key type in the following order: Current KSKs,
Published KSKs, Current ZSKs, Published ZSKs, New ZSKs, Obsolete KSKs, and
Obsolete ZSKs.
=item B<-ksk>
This option displays the KSK keys in a I<keyrec> file.
=item B<-kcur>
This option displays the Current KSK keys in a I<keyrec> file.
=item B<-kpub>
This option displays the Published KSK keys in a I<keyrec> file.
=item B<-kobs>
This option displays the obsolete KSK keys in a I<keyrec> file. This option
must be give if obsolete KSK keys are to be displayed.
=item B<-krev>
This option displays the revoked KSK keys in a I<keyrec> file. This option
must be give if revoked KSK keys are to be displayed.
=item B<-zsk>
This option displays the ZSK keys in a I<keyrec> file. It does not include
obsolete ZSK keys; the B<-obs> option must be specified to display obsolete
keys.
=item B<-cur>
This option displays the Current ZSK keys in a I<keyrec> file.
=item B<-new>
This option displays the New ZSK keys in a I<keyrec> file.
=item B<-pub>
This option displays the Published ZSK keys in a I<keyrec> file.
=item B<-zobs>
This option displays the obsolete ZSK keys in a I<keyrec> file. This option
must be give if obsolete ZSK keys are to be displayed.
=item B<-zrev>
This option displays the revoked ZSK keys in a I<keyrec> file. This option
must be give if revoked ZSK keys are to be displayed.
=item B<-obs>
This option displays the obsolete KSK and ZSK keys in a I<keyrec> file.
This option is a shorthand method specifying the B<-kobs> and B<-zobs> options.
=item B<-rev>
This option displays the revoked KSK and ZSK keys in a I<keyrec> file.
This option is a shorthand method specifying the B<-krev> and B<-zrev> options.
=item B<-invalid>
This option displays the obsolete and revoked KSK and ZSK keys in a I<keyrec>
file. This option is a shorthand method specifying the B<-obs> and B<-rev>
options.
=back
=head2 Record-Attribute Options
These options select subsets of the I<keyrec>s chosen by the
record-selection options.
=over 4
=item B<-valid>
This option displays the valid zones in a I<keyrec> file.
It implies the B<-zones> option.
=item B<-expired>>
This option displays the expired zones in a I<keyrec> file.
It implies the B<-zones> option.
=item B<-ref>
This option displays the referenced signing set I<keyrec>s and the referenced
key I<keyrec>s in a I<keyrec> file, depending upon other selected options.
Referenced state depends on the following:
* Signing sets are considered to be referenced if they
are listed in a zone keyrec.
* KSKs are considered to be referenced if they are listed
in a signing set keyrec that is listed in a zone keyrec.
* ZSKs are considered to be referenced if they are listed
in a signing set keyrec that is listed in a zone keyrec.
This option may be used with either the B<-sets> or B<-keys> options. If it
isn't used with any record-selection options, then it is assumed that both
B<-sets> and B<-keys> have been specified.
=item B<-unref>
This option displays the unreferenced signing set I<keyrec>s or the
unreferenced key I<keyrec>s in a I<keyrec> file, depending upon other
selected options.
Unreferenced state depends on the following:
* Signing sets are considered to be unreferenced if they
are not listed in a zone keyrec.
* KSKs are considered to be unreferenced if they are not listed
in a signing set keyrec that is listed in a zone keyrec.
* ZSKs are considered to be unreferenced if they are not listed
in a signing set keyrec that is listed in a zone keyrec.
* Obsolete ZSKs are checked, whether or not the -obs flag
was specified.
This option may be used with either the B<-sets> or B<-keys> options. If it
isn't used with any record-selection options, then it is assumed that both
B<-sets> and B<-keys> have been specified.
=back
=head2 Zone-Attribute Options
These options allow specific zone fields to be included in the output. If
combined with the B<-terse> option, only those fields specifically desired
will be printed. These options must be used with the B<-zone> option.
=over 4
=item B<-z-archdir>
Display the zone's archive directory. If an archive directory is not
explicitly set for the zone, the default directory will be listed.
=item B<-z-dates>
Display the zone's time-stamps. These are the signing date and the
expiration date.
=item B<-z-dirs>
Display the zone's directories. These directories are the KSK directory,
the ZSK directory, and the key archive directory.
=item B<-z-expdate>
Display the zone's expiration date.
=item B<-z-ksk>
Display the zone's KSK data. This is the equivalent of specifying the
B<-z-kskcount>, B<-z-kskcur>, B<-z-kskdir>, and B<-z-kskpub> options.
=item B<-z-kskcount>
Display the zone's KSK count.
=item B<-z-kskcur>
Display the zone's Current KSK signing set.
If this is not defined, then "<unset>" will be given.
=item B<-z-kskdir>
Display the zone's KSK directory.
If this is not defined, then "." will be given.
=item B<-z-kskpub>
Display the zone's Published KSK signing set.
If this is not defined, then "<unset>" will be given.
=item B<-z-sets>
Display the zone's signing sets. This is the equivalent of specifying the
B<-z-kskcur>, B<-z-kskpub>, B<-z-zskcur>, B<-z-zsknew>, and B<-z-zskpub>
options.
=item B<-z-signdate>
Display the zone's signing date.
=item B<-z-signfile>
Display the zone's signed zonefile.
=item B<-z-zonefile>
Display the zone's zonefile.
=item B<-z-zsk>
Display the zone's ZSK data. This is the equivalent of specifying the
B<-z-zskcount>, B<-z-zskcur>, B<-z-zskdir>, B<-z-zsknew>, and B<-z-zskpub>
options.
=item B<-z-zskcount>
Display the zone's ZSK count.
=item B<-z-zskcur>
Display the zone's Current ZSK signing set.
If this is not defined, then "<unset>" will be given.
=item B<-z-zskdir>
Display the zone's ZSK directory.
If this is not defined, then "." will be given.
=item B<-z-zsknew>
Display the zone's New ZSK signing set.
If this is not defined, then "<unset>" will be given.
=item B<-z-zskpub>
Display the zone's Published ZSK signing set.
If this is not defined, then "<unset>" will be given.
=back
=head2 Set-Attribute Options
These options allow specific set fields to be included in the output. If
combined with the B<-terse> option, only those fields specifically desired
will be printed. These options must be used with the B<-sets> option.
If RFC5011 processing is enabled, there is special handling of the zone's set
I<keyrec> of revoked KSK keys. The "kskrev" field in the zone's I<keyrec>
points to a set I<keyrec>, marked as being of type "kskrev". This set
I<keyrec>, in turn, points to a number of other set I<keyrec>s, all of which
are also marked as being of type "kskrev". The group of all revoked KSK keys
is found by consulting that subsidiary set of "kskrev" set I<keyrec>s. When
the ages of these revoked keys exceeds their revocation periods, they are
marked as being obsolete ("kskobs"). If this happens as part of normal
rollover, these revoked key and set I<keyrec>s are all removed from the chain
of active, revoked I<keyrec>s. If this happens to a key that's part of a
larger set of keys, it is removed from that signing set and put in its own
new signing set. B<lskrf> displays the type of the "kskrev" set (listed in
the zone I<keyrec>) as "KSK-REV", and all other revoked KSK I<keyrec>s are
listed as "KSK-rev".
=over 4
=item B<-s-keys>
Display the set's keys.
=item B<-s-lastmod>
Display the set's date of last modification.
=item B<-s-type>
Display the set's type.
=item B<-s-zone>
Display the set's zone name.
=item B<-s-ksk>
Display KSK signing sets. This option implies the B<-sets> option.
=item B<-s-kcur>
Display current KSK signing sets. This option implies the B<-sets> option.
=item B<-s-kobs>
Display obsolete KSK signing sets. This option implies the B<-sets> option.
=item B<-s-kpub>
Display published KSK signing sets. This option implies the B<-sets> option.
=item B<-s-krev>
Display revoked KSK signing sets. This option implies the B<-sets> option.
=item B<-s-zsk>
Display ZSK signing sets. This option implies the B<-sets> option.
=item B<-s-zcur>
Display current ZSK signing sets. This option implies the B<-sets> option.
=item B<-s-znew>
Display new ZSK signing sets. This option implies the B<-sets> option.
=item B<-s-zobs>
Display obsolete ZSK signing sets. This option implies the B<-sets> option.
=item B<-s-zpub>
Display published ZSK signing sets. This option implies the B<-sets> option.
=item B<-s-zrev>
Display revoked ZSK signing sets. This option implies the B<-sets> option.
=back
=head2 Key-Attribute Options
These options allow specific key fields to be included in the output. If
combined with the B<-terse> option, only those fields specifically desired
will be printed. These options must be used with the B<-key> option.
=over 4
=item B<-k-algorithm>
Display the key's encryption algorithm.
=item B<-k-enddate>
Display the key's end-date, calculated by adding the key's lifespan to its
signing date.
=item B<-k-length>
Display the key's length.
=item B<-k-lifespan>
Display the key's lifespan (in seconds.) This lifespan is B<only> related to
the time between key rollover. There is no other lifespan associated with a
key.
=item B<-k-path>
Display the key's path.
=item B<-k-random>
Display the key's random number generator.
=item B<-k-signdate>
Display the key's signing date.
=item B<-k-zone>
Display the key's zonefile.
=back
=head2 Output-Format Options
These options define how the I<keyrec> information will be displayed.
Without any of these options, the zone name, zone file, zone-signing date,
and a label will be displayed for zones. For types, the key name, the key's
zone, the key's generation date, and a label will be displayed if these
options aren't given.
=over 4
=item B<-count>
The count of matching records will be displayed, but the matching records
will not be.
=item B<-nodate>
The key's generation date will not be printed if this flag is given.
=item B<-headers>
Display explanatory column headers. If this flag is given, then entry labels
will not be printed unless explicitly requested by use of the B<-label>
option.
=item B<-label>
A label for the I<keyrec>'s type will be given.
=item B<-long>
The long form of output will be given. See the OUTPUT FORMATS section for
details on data printed for each type of I<keyrec> record.
Long zone output can get I<very> wide, depending on the data.
=item B<-terse>
This options displays only the name of the zones or keys selected by other
options.
=item B<-Version>
Displays the version information for B<lskrf> and the DNSSEC-Tools package.
=item B<-help>
Display a usage message and exit.
=item B<-h-zones>
Display the zone-attribute options and exit.
=item B<-h-sets>
Display the set-attribute options and exit.
=item B<-h-keys>
Display the key-attribute options and exit.
=back
=head1 COPYRIGHT
Copyright 2005-2012 SPARTA, Inc. All rights reserved.
See the COPYING file included with the DNSSEC-Tools package for details.
=head1 AUTHOR
Wayne Morrison, tewok@tislabs.com
=head1 SEE ALSO
B<zonesigner(8)>
B<Net::DNS::SEC::Tools::keyrec.pm(3)>
B<file-keyrec(5)>
=cut
|