21 for (i = 0; i < 12; i++)
35 if (
len < 68)
return 0;
36 if (byte_diff(
buf + pos,8,
"Q6fnvWj8"))
return 0;
43 byte_copy(pubkey,32,
buf + pos);
49 byte_copy(nonce,12,
buf + pos);
55 if (pos >=
len)
return 0;
56 byte_copy(cryptobox,
len - pos,
buf + pos);
76char curvetxtq[10] = {
'\x00',
'\x00',
'\x00',
'\x01',
'\x00',
'\x00',
'\x00',
'\x00',
'\x00',
'\x00' };
82 if (
buf[pos] & 0xfe)
return 0;
89 for (i = 12; i <
len; i++) {
90 if (*(
buf + i) == 54 && (*(
buf + i + 1) & ~0x20) ==
'X' &&
91 *(
buf + i + 2) ==
'1' && (*(
buf + i + 3) & ~0x20) ==
'A')
return i;
99static unsigned char *qname;
104 unsigned int boxlen = 0;
113 lablen = *(qname + i);
114 if (lablen == 54)
break;
115 else if (lablen > 50)
return 0;
116 else if (lablen == 0)
return 0;
118 byte_copy(box + boxlen,lablen,qname + i + 1);
137 byte_copy(nonce,12,base32box);
149static uint8 cryptobox[4099];
150static uint8 fullnonce[24];
156 byte_copy(fullnonce,12,nonce);
158 byte_zero(cryptobox,32);
195int response_alttxt(
const uint8 *secret,
const uint8 *nonce,
const char id[2],
const unsigned char *
query,
const unsigned int len,
const int rd)
198 unsigned int rrdatalen;
203 byte_copy(fullnonce,12,nonce);
206 byte_zero(cryptobox,32);
210 byte_copy(cryptobox + 4,12,fullnonce + 12);
220 rrdatalen = boxlen + ((boxlen + 254) /
TXT_LABLEN);
221 uint16_pack_big(rdlen,rrdatalen);
231 uint16_pack_big(rdlen,lablen);
unsigned int base32_decode(uint8 *out, const char *in, unsigned int len, int mode)
int dns_curve_txtquery(const char *buf, const unsigned int len, const unsigned int pos)
int dns_curve_txtpubkey(uint8 *pubkey, const char *buf, const unsigned int pos)
int dns_curve_cryptobox(uint8 *cryptobox, const char *buf, const unsigned int len, const unsigned int pos)
int dns_curve_pubkey(uint8 *pubkey, const char *buf, const unsigned int pos)
int dns_curve_query(const char *buf, const unsigned int len, const unsigned int pos)
int response_alttxt(const uint8 *secret, const uint8 *nonce, const char id[2], const unsigned char *query, const unsigned int len, const int rd)
int dns_curve_nonce(uint8 *nonce, const char *buf, const unsigned int pos)
int dns_curve_txtqname(uint8 *base32box, const char *buf, const unsigned int len)
void curve_nonce(uint8 nonce[12])
int dns_curve_txtnonce(uint8 *nonce, const uint8 *base32box)
int response_stream(const uint8 *secret, const uint8 *nonce)
#define crypto_box_afternm
unsigned int dns_packet_getname(const char *buf, unsigned int len, unsigned int pos, char **d)
unsigned int dns_random(unsigned int n)
int response_addbytes(const char *, unsigned int)
unsigned int response_len