Annotation of embedaddon/bird2/nest/password.c, revision 1.1.1.1
1.1 misho 1: /*
2: * BIRD -- Password handling
3: *
4: * (c) 1999 Pavel Machek <pavel@ucw.cz>
5: * (c) 2004 Ondrej Filip <feela@network.cz>
6: *
7: * Can be freely distributed and used under the terms of the GNU GPL.
8: */
9:
10: #include "nest/bird.h"
11: #include "nest/password.h"
12: #include "lib/string.h"
13: #include "lib/timer.h"
14: #include "lib/mac.h"
15:
16: struct password_item *last_password_item = NULL;
17:
18: struct password_item *
19: password_find(list *l, int first_fit)
20: {
21: struct password_item *pi;
22: struct password_item *pf = NULL;
23: btime now_ = current_real_time();
24:
25: if (l)
26: {
27: WALK_LIST(pi, *l)
28: {
29: if ((pi->genfrom < now_) && (pi->gento > now_))
30: {
31: if (first_fit)
32: return pi;
33:
34: if (!pf || pf->genfrom < pi->genfrom)
35: pf = pi;
36: }
37: }
38: }
39: return pf;
40: }
41:
42: struct password_item *
43: password_find_by_id(list *l, uint id)
44: {
45: struct password_item *pi;
46: btime now_ = current_real_time();
47:
48: if (!l)
49: return NULL;
50:
51: WALK_LIST(pi, *l)
52: if ((pi->id == id) && (pi->accfrom <= now_) && (now_ < pi->accto))
53: return pi;
54:
55: return NULL;
56: }
57:
58: struct password_item *
59: password_find_by_value(list *l, char *pass, uint size)
60: {
61: struct password_item *pi;
62: btime now_ = current_real_time();
63:
64: if (!l)
65: return NULL;
66:
67: WALK_LIST(pi, *l)
68: if (password_verify(pi, pass, size) && (pi->accfrom <= now_) && (now_ < pi->accto))
69: return pi;
70:
71: return NULL;
72: }
73:
74: uint
75: max_mac_length(list *l)
76: {
77: struct password_item *pi;
78: uint val = 0;
79:
80: if (!l)
81: return 0;
82:
83: WALK_LIST(pi, *l)
84: val = MAX(val, mac_type_length(pi->alg));
85:
86: return val;
87: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>