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