]>
Commit | Line | Data |
---|---|---|
870a0fe4 AT |
1 | #ifdef HAVE_CONFIG_H |
2 | #include "config.h" | |
3 | #endif | |
9feed75b BH |
4 | #include "dnsparser.hh" |
5 | #include "dnswriter.hh" | |
6 | #include "sstuff.hh" | |
7 | #include "misc.hh" | |
8 | #include "dnswriter.hh" | |
9 | #include "dnsrecords.hh" | |
10 | #include "statbag.hh" | |
bfcdbc13 | 11 | #include "digests.hh" |
9feed75b | 12 | #include "base64.hh" |
01cb2fe2 | 13 | #include "dnssecinfra.hh" |
0dd42dbb | 14 | #include "axfr-retriever.hh" |
8e041630 BH |
15 | #include "arguments.hh" |
16 | #include "dns_random.hh" | |
20829585 | 17 | #include "query-local-address.hh" |
9feed75b BH |
18 | |
19 | StatBag S; | |
20 | ||
8e041630 BH |
21 | ArgvMap& arg() |
22 | { | |
23 | static ArgvMap theArg; | |
24 | return theArg; | |
25 | } | |
9feed75b BH |
26 | |
27 | int main(int argc, char** argv) | |
28 | try | |
29 | { | |
20829585 | 30 | pdns::parseQueryLocalAddress(":: 0.0.0.0"); |
8e041630 | 31 | |
9feed75b BH |
32 | reportAllTypes(); |
33 | ||
34 | if(argc < 4) { | |
35 | cerr<<"tsig-tests: ask a TSIG signed question, verify the TSIG signed answer"<<endl; | |
36 | cerr<<"Syntax: tsig IP-address port question question-type\n"; | |
37 | exit(EXIT_FAILURE); | |
38 | } | |
39 | ||
40 | vector<uint8_t> packet; | |
41 | ||
eaedd091 | 42 | DNSPacketWriter pw(packet, DNSName(argv[3]), DNSRecordContent::TypeToNumber(argv[4])); |
9feed75b BH |
43 | |
44 | pw.getHeader()->id=htons(0x4831); | |
01cb2fe2 | 45 | |
9feed75b | 46 | string key; |
8e041630 BH |
47 | B64Decode("Syq9L9WrBWdxBC+HxKok2g==", key); |
48 | ||
2e16c059 | 49 | DNSName keyname("pdns-b-aa"); |
9feed75b | 50 | |
9feed75b | 51 | TSIGRecordContent trc; |
eaedd091 | 52 | trc.d_algoName=DNSName("hmac-md5.sig-alg.reg.int"); |
01cb2fe2 | 53 | trc.d_time=time(0); |
9feed75b | 54 | trc.d_fudge=300; |
9feed75b BH |
55 | trc.d_origID=ntohs(pw.getHeader()->id); |
56 | trc.d_eRcode=0; | |
57 | ||
ea3816cf | 58 | addTSIG(pw, trc, keyname, key, "", false); |
9feed75b | 59 | |
0131659f | 60 | Socket sock(AF_INET, SOCK_DGRAM); |
9feed75b | 61 | ComboAddress dest(argv[1] + (*argv[1]=='@'), atoi(argv[2])); |
317f7521 | 62 | cerr<<"Keyname: '"<<keyname<<"', algo: '"<<trc.d_algoName<<"', key: '"<<Base64Encode(key)<<"'\n"; |
0f578389 | 63 | TSIGTriplet tt; |
64 | tt.name=keyname; | |
65 | tt.algo=DNSName("hmac-md5"); | |
66 | tt.secret=key; | |
67 | AXFRRetriever axfr(dest, DNSName("b.aa"), tt); | |
8e041630 BH |
68 | vector<DNSResourceRecord> res; |
69 | while(axfr.getChunk(res)) { | |
70 | } | |
71 | return 0; | |
9feed75b BH |
72 | } |
73 | catch(std::exception &e) | |
74 | { | |
75 | cerr<<"Fatal: "<<e.what()<<endl; | |
8e041630 BH |
76 | return 1; |
77 | } | |
3f81d239 | 78 | catch(PDNSException& ae) |
8e041630 BH |
79 | { |
80 | cerr<<"Fatal 2: "<<ae.reason<<endl; | |
81 | return 1; | |
9feed75b | 82 | } |