etc/protocols - sync with NetBSD-8
[minix.git] / external / bsd / dhcpcd / dist / auth.h
blob32408fc2453888e5e1d3d4456f381e91ef545fdd
1 /* $NetBSD: auth.h,v 1.9 2015/05/16 23:31:32 roy Exp $ */
3 /*
4 * dhcpcd - DHCP client daemon
5 * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
6 * All rights reserved
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
30 #ifndef AUTH_H
31 #define AUTH_H
33 #include "config.h"
35 #ifdef HAVE_SYS_QUEUE_H
36 #include <sys/queue.h>
37 #endif
39 #define DHCPCD_AUTH_SEND (1 << 0)
40 #define DHCPCD_AUTH_REQUIRE (1 << 1)
41 #define DHCPCD_AUTH_RDM_COUNTER (1 << 2)
43 #define DHCPCD_AUTH_SENDREQUIRE (DHCPCD_AUTH_SEND | DHCPCD_AUTH_REQUIRE)
45 #define AUTH_PROTO_TOKEN 0
46 #define AUTH_PROTO_DELAYED 1
47 #define AUTH_PROTO_DELAYEDREALM 2
48 #define AUTH_PROTO_RECONFKEY 3
50 #define AUTH_ALG_HMAC_MD5 1
52 #define AUTH_RDM_MONOTONIC 0
54 struct token {
55 TAILQ_ENTRY(token) next;
56 uint32_t secretid;
57 size_t realm_len;
58 unsigned char *realm;
59 size_t key_len;
60 unsigned char *key;
61 time_t expire;
64 TAILQ_HEAD(token_head, token);
66 struct auth {
67 int options;
68 uint8_t protocol;
69 uint8_t algorithm;
70 uint8_t rdm;
71 uint64_t last_replay;
72 uint8_t last_replay_set;
73 struct token_head tokens;
76 struct authstate {
77 uint64_t replay;
78 struct token *token;
79 struct token *reconf;
82 void dhcp_auth_reset(struct authstate *);
84 const struct token * dhcp_auth_validate(struct authstate *,
85 const struct auth *,
86 const uint8_t *, size_t, int, int,
87 const uint8_t *, size_t);
89 ssize_t dhcp_auth_encode(struct auth *, const struct token *,
90 uint8_t *, size_t, int, int,
91 uint8_t *, size_t);
92 #endif