aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_dnsparser_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-06 21:57:50 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-06 21:57:50 +0000
commit7918527acf021ad8753ead08334d6a6ac71084c4 (patch)
tree5157211fc30fce830fd9b1e96e7f83681b351b70 /src/include/gnunet_dnsparser_lib.h
parent6332c8ffbc8f63a8006a3283b95f3e3abae1e8db (diff)
downloadgnunet-7918527acf021ad8753ead08334d6a6ac71084c4.tar.gz
gnunet-7918527acf021ad8753ead08334d6a6ac71084c4.zip
-adding CERT record support to dnsparser
Diffstat (limited to 'src/include/gnunet_dnsparser_lib.h')
-rw-r--r--src/include/gnunet_dnsparser_lib.h215
1 files changed, 215 insertions, 0 deletions
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h
index b6b9bcea9..68d0a5ebd 100644
--- a/src/include/gnunet_dnsparser_lib.h
+++ b/src/include/gnunet_dnsparser_lib.h
@@ -53,6 +53,7 @@
53#define GNUNET_DNSPARSER_TYPE_TXT 16 53#define GNUNET_DNSPARSER_TYPE_TXT 16
54#define GNUNET_DNSPARSER_TYPE_AAAA 28 54#define GNUNET_DNSPARSER_TYPE_AAAA 28
55#define GNUNET_DNSPARSER_TYPE_SRV 33 55#define GNUNET_DNSPARSER_TYPE_SRV 33
56#define GNUNET_DNSPARSER_TYPE_CERT 37
56#define GNUNET_DNSPARSER_TYPE_TLSA 52 57#define GNUNET_DNSPARSER_TYPE_TLSA 52
57 58
58 59
@@ -178,6 +179,171 @@ struct GNUNET_DNSPARSER_SrvRecord
178 179
179 180
180/** 181/**
182 * DNS CERT types as defined in RFC 4398.
183 */
184enum GNUNET_DNSPARSER_CertType
185{
186 /**
187 * Reserved value
188 */
189 GNUNET_DNSPARSER_CERTTYPE_RESERVED = 0,
190
191 /**
192 * An x509 PKIX certificate
193 */
194 GNUNET_DNSPARSER_CERTTYPE_PKIX = 1,
195
196 /**
197 * A SKPI certificate
198 */
199 GNUNET_DNSPARSER_CERTTYPE_SKPI = 2,
200
201 /**
202 * A PGP certificate
203 */
204 GNUNET_DNSPARSER_CERTTYPE_PGP = 3,
205
206 /**
207 * An x509 PKIX cert URL
208 */
209 GNUNET_DNSPARSER_CERTTYPE_IPKIX = 4,
210
211 /**
212 * A SKPI cert URL
213 */
214 GNUNET_DNSPARSER_CERTTYPE_ISKPI = 5,
215
216 /**
217 * A PGP cert fingerprint and URL
218 */
219 GNUNET_DNSPARSER_CERTTYPE_IPGP = 6,
220
221 /**
222 * An attribute Certificate
223 */
224 GNUNET_DNSPARSER_CERTTYPE_ACPKIX = 7,
225
226 /**
227 * An attribute cert URL
228 */
229 GNUNET_DNSPARSER_CERTTYPE_IACKPIX = 8
230};
231
232
233/**
234 * DNSCERT algorithms as defined in http://www.iana.org/assignments/
235 * dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml#dns-sec-alg-numbers-1
236 */
237enum GNUNET_DNSPARSER_CertAlgorithm
238{
239 /**
240 * No defined
241 */
242 GNUNET_DNSPARSER_CERTALGO_UNDEFINED = 0,
243
244 /**
245 * RSA/MD5
246 */
247 GNUNET_DNSPARSER_CERTALGO_RSAMD5 = 1,
248
249 /**
250 * Diffie-Hellman
251 */
252 GNUNET_DNSPARSER_CERTALGO_DH = 2,
253
254 /**
255 * DSA/SHA1
256 */
257 GNUNET_DNSPARSER_CERTALGO_DSASHA = 3,
258
259 /**
260 * Reserved
261 */
262 GNUNET_DNSPARSER_CERTALGO_RSRVD4 = 4,
263
264 /**
265 * RSA/SHA1
266 */
267 GNUNET_DNSPARSER_CERTALGO_RSASHA = 5,
268
269 /**
270 * DSA/NSEC3/SHA
271 */
272 GNUNET_DNSPARSER_CERTALGO_DSANSEC3 = 6,
273
274 /**
275 * RSA/NSEC3/SHA
276 */
277 GNUNET_DNSPARSER_CERTALGO_RSANSEC3 = 7,
278
279 /**
280 * RSA/SHA256
281 */
282 GNUNET_DNSPARSER_CERTALGO_RSASHA256 = 8,
283
284 /**
285 * Reserved
286 */
287 GNUNET_DNSPARSER_CERTALGO_RSRVD9 = 9,
288
289 /**
290 * RSA/SHA512
291 */
292 GNUNET_DNSPARSER_CERTALGO_RSASHA512 = 10,
293
294 /**
295 * GOST R 34.10-2001
296 */
297 GNUNET_DNSPARSER_CERTALGO_GOST_R34 = 12,
298
299 /**
300 * ECDSA Curve P-256/SHA256
301 */
302 GNUNET_DNSPARSER_CERTALGO_ECDSA_P256SHA256 = 13,
303
304 /**
305 * ECDSA Curve P-384/SHA384
306 */
307 GNUNET_DNSPARSER_CERTALGO_ECDSA_P384SHA384 = 14
308
309};
310
311
312/**
313 * Information from CERT records (RFC 4034).
314 */
315struct GNUNET_DNSPARSER_CertRecord
316{
317
318 /**
319 * Certificate type
320 */
321 enum GNUNET_DNSPARSER_CertType cert_type;
322
323 /**
324 * Certificate KeyTag
325 */
326 uint16_t cert_tag;
327
328 /**
329 * Algorithm
330 */
331 enum GNUNET_DNSPARSER_CertAlgorithm algorithm;
332
333 /**
334 * Number of bytes in @e certificate_data
335 */
336 size_t certificate_size;
337
338 /**
339 * Data of the certificate.
340 */
341 char *certificate_data;
342
343};
344
345
346/**
181 * Information from SOA records (RFC 1035). 347 * Information from SOA records (RFC 1035).
182 */ 348 */
183struct GNUNET_DNSPARSER_SoaRecord 349struct GNUNET_DNSPARSER_SoaRecord
@@ -288,6 +454,11 @@ struct GNUNET_DNSPARSER_Record
288 struct GNUNET_DNSPARSER_SoaRecord *soa; 454 struct GNUNET_DNSPARSER_SoaRecord *soa;
289 455
290 /** 456 /**
457 * CERT data for CERT records.
458 */
459 struct GNUNET_DNSPARSER_CertRecord *cert;
460
461 /**
291 * MX data for MX records. 462 * MX data for MX records.
292 */ 463 */
293 struct GNUNET_DNSPARSER_MxRecord *mx; 464 struct GNUNET_DNSPARSER_MxRecord *mx;
@@ -528,6 +699,25 @@ GNUNET_DNSPARSER_builder_add_soa (char *dst,
528 699
529 700
530/** 701/**
702 * Add CERT record to the UDP packet at the given location.
703 *
704 * @param dst where to write the CERT record
705 * @param dst_len number of bytes in @a dst
706 * @param off pointer to offset where to write the CERT information (increment by bytes used)
707 * can also change if there was an error
708 * @param cert CERT information to write
709 * @return #GNUNET_SYSERR if @a soa is invalid
710 * #GNUNET_NO if @a soa did not fit
711 * #GNUNET_OK if @a soa was added to @a dst
712 */
713int
714GNUNET_DNSPARSER_builder_add_cert (char *dst,
715 size_t dst_len,
716 size_t *off,
717 const struct GNUNET_DNSPARSER_CertRecord *cert);
718
719
720/**
531 * Add an SRV record to the UDP packet at the given location. 721 * Add an SRV record to the UDP packet at the given location.
532 * 722 *
533 * @param dst where to write the SRV record 723 * @param dst where to write the SRV record
@@ -595,6 +785,7 @@ GNUNET_DNSPARSER_parse_query (const char *udp_payload,
595 size_t *off, 785 size_t *off,
596 struct GNUNET_DNSPARSER_Query *q); 786 struct GNUNET_DNSPARSER_Query *q);
597 787
788
598/** 789/**
599 * Parse a DNS SOA record. 790 * Parse a DNS SOA record.
600 * 791 *
@@ -611,6 +802,21 @@ GNUNET_DNSPARSER_parse_soa (const char *udp_payload,
611 802
612 803
613/** 804/**
805 * Parse a DNS CERT record.
806 *
807 * @param udp_payload reference to UDP packet
808 * @param udp_payload_length length of @a udp_payload
809 * @param off pointer to the offset of the query to parse in the CERT record (to be
810 * incremented by the size of the record), unchanged on error
811 * @return the parsed CERT record, NULL on error
812 */
813struct GNUNET_DNSPARSER_CertRecord *
814GNUNET_DNSPARSER_parse_cert (const char *udp_payload,
815 size_t udp_payload_length,
816 size_t *off);
817
818
819/**
614 * Parse a DNS MX record. 820 * Parse a DNS MX record.
615 * 821 *
616 * @param udp_payload reference to UDP packet 822 * @param udp_payload reference to UDP packet
@@ -679,4 +885,13 @@ void
679GNUNET_DNSPARSER_free_soa (struct GNUNET_DNSPARSER_SoaRecord *soa); 885GNUNET_DNSPARSER_free_soa (struct GNUNET_DNSPARSER_SoaRecord *soa);
680 886
681 887
888/**
889 * Free CERT information record.
890 *
891 * @param cert record to free
892 */
893void
894GNUNET_DNSPARSER_free_cert (struct GNUNET_DNSPARSER_CertRecord *cert);
895
896
682#endif 897#endif