20 for (i = 0; i < 12; i++)
34 if (
len < 68)
return 0;
35 if (byte_diff(
buf + pos,8,
"Q6fnvWj8"))
return 0;
48 byte_copy((
char *)nonce,12,
buf + pos);
54 if (pos >=
len)
return 0;
55 byte_copy((
char *)cryptobox,
len - pos,
buf + pos);
75char curvetxtq[10] = {
'\x00',
'\x00',
'\x00',
'\x01',
'\x00',
'\x00',
'\x00',
'\x00',
'\x00',
'\x00' };
81 if (
buf[pos] & 0xfe)
return 0;
88 for (i = 12; i <
len; i++) {
89 if (*(
buf + i) == 54 && (*(
buf + i + 1) & ~0x20) ==
'X' &&
90 *(
buf + i + 2) ==
'1' && (*(
buf + i + 3) & ~0x20) ==
'A')
return i;
98static unsigned char *qname;
103 unsigned int boxlen = 0;
112 lablen = *(qname + i);
113 if (lablen == 54)
break;
114 else if (lablen > 50)
return 0;
115 else if (lablen == 0)
return 0;
117 byte_copy((
char *)box + boxlen,lablen,qname + i + 1);
136 byte_copy((
char *)nonce,12,(
char *)base32box);
148static uint8 cryptobox[4099];
149static uint8 fullnonce[24];
155 byte_copy((
char *)fullnonce,12,(
char *)nonce);
157 byte_zero((
char *)cryptobox,
KEY_LEN);
195 const unsigned char *
query,
const unsigned int len,
const int rd)
198 unsigned int rrdatalen;
203 byte_copy((
char *)fullnonce,12,(
char *)nonce);
206 byte_zero((
char *)cryptobox,
KEY_LEN);
210 byte_copy((
char *)cryptobox + 4,12,(
char *)fullnonce + 12);
220 rrdatalen = boxlen + ((boxlen + 254) /
FQDN_LEN);
221 uint16_pack_big(rdlen,rrdatalen);
230 if (boxlen <
FQDN_LEN) lablen = boxlen;
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