]> git.wh0rd.org - ICEs.git/blob - not-unused/des.i.0
initial import
[ICEs.git] / not-unused / des.i.0
1
2 typedef long unsigned int size_t;
3 typedef unsigned char __u_char;
4 typedef unsigned short int __u_short;
5 typedef unsigned int __u_int;
6 typedef unsigned long int __u_long;
7 typedef signed char __int8_t;
8 typedef unsigned char __uint8_t;
9 typedef signed short int __int16_t;
10 typedef unsigned short int __uint16_t;
11 typedef signed int __int32_t;
12 typedef unsigned int __uint32_t;
13 typedef signed long int __int64_t;
14 typedef unsigned long int __uint64_t;
15 typedef long int __quad_t;
16 typedef unsigned long int __u_quad_t;
17 typedef unsigned long int __dev_t;
18 typedef unsigned int __uid_t;
19 typedef unsigned int __gid_t;
20 typedef unsigned long int __ino_t;
21 typedef unsigned long int __ino64_t;
22 typedef unsigned int __mode_t;
23 typedef unsigned long int __nlink_t;
24 typedef long int __off_t;
25 typedef long int __off64_t;
26 typedef int __pid_t;
27 typedef struct { int __val[2]; } __fsid_t;
28 typedef long int __clock_t;
29 typedef unsigned long int __rlim_t;
30 typedef unsigned long int __rlim64_t;
31 typedef unsigned int __id_t;
32 typedef long int __time_t;
33 typedef unsigned int __useconds_t;
34 typedef long int __suseconds_t;
35 typedef int __daddr_t;
36 typedef long int __swblk_t;
37 typedef int __key_t;
38 typedef int __clockid_t;
39 typedef void * __timer_t;
40 typedef long int __blksize_t;
41 typedef long int __blkcnt_t;
42 typedef long int __blkcnt64_t;
43 typedef unsigned long int __fsblkcnt_t;
44 typedef unsigned long int __fsblkcnt64_t;
45 typedef unsigned long int __fsfilcnt_t;
46 typedef unsigned long int __fsfilcnt64_t;
47 typedef long int __ssize_t;
48 typedef __off64_t __loff_t;
49 typedef __quad_t *__qaddr_t;
50 typedef char *__caddr_t;
51 typedef long int __intptr_t;
52 typedef unsigned int __socklen_t;
53 typedef __u_char u_char;
54 typedef __u_short u_short;
55 typedef __u_int u_int;
56 typedef __u_long u_long;
57 typedef __quad_t quad_t;
58 typedef __u_quad_t u_quad_t;
59 typedef __fsid_t fsid_t;
60 typedef __loff_t loff_t;
61 typedef __ino_t ino_t;
62
63
64 typedef __dev_t dev_t;
65
66
67
68
69 typedef __gid_t gid_t;
70
71
72
73
74 typedef __mode_t mode_t;
75
76
77
78
79 typedef __nlink_t nlink_t;
80
81
82
83
84 typedef __uid_t uid_t;
85
86
87
88
89
90 typedef __off_t off_t;
91 typedef __pid_t pid_t;
92 typedef __id_t id_t;
93 typedef __ssize_t ssize_t;
94 typedef __daddr_t daddr_t;
95 typedef __caddr_t caddr_t;
96 typedef __key_t key_t;
97
98 typedef __time_t time_t;
99
100
101 typedef __clockid_t clockid_t;
102
103
104
105
106
107 typedef __timer_t timer_t;
108 typedef unsigned long int ulong;
109 typedef unsigned short int ushort;
110 typedef unsigned int uint;
111 typedef int int8_t __attribute__ ((__mode__ (__QI__)));
112 typedef int int16_t __attribute__ ((__mode__ (__HI__)));
113 typedef int int32_t __attribute__ ((__mode__ (__SI__)));
114 typedef int int64_t __attribute__ ((__mode__ (__DI__)));
115 typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
116 typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
117 typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
118 typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
119 typedef int register_t __attribute__ ((__mode__ (__word__)));
120 typedef int __sig_atomic_t;
121 typedef struct
122 {
123 unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
124 } __sigset_t;
125 typedef __sigset_t sigset_t;
126 struct timespec
127 {
128 __time_t tv_sec;
129 long int tv_nsec;
130 };
131 struct timeval
132 {
133 __time_t tv_sec;
134 __suseconds_t tv_usec;
135 };
136 typedef __suseconds_t suseconds_t;
137 typedef long int __fd_mask;
138 typedef struct
139 {
140 __fd_mask __fds_bits[1024 / (8 * sizeof (__fd_mask))];
141 } fd_set;
142 typedef __fd_mask fd_mask;
143
144 extern int select (int __nfds, fd_set *__restrict __readfds,
145 fd_set *__restrict __writefds,
146 fd_set *__restrict __exceptfds,
147 struct timeval *__restrict __timeout);
148 extern int pselect (int __nfds, fd_set *__restrict __readfds,
149 fd_set *__restrict __writefds,
150 fd_set *__restrict __exceptfds,
151 const struct timespec *__restrict __timeout,
152 const __sigset_t *__restrict __sigmask);
153
154 __extension__
155 extern __inline unsigned int gnu_dev_major (unsigned long long int __dev)
156 __attribute__ ((__nothrow__));
157 __extension__
158 extern __inline unsigned int gnu_dev_minor (unsigned long long int __dev)
159 __attribute__ ((__nothrow__));
160 __extension__
161 extern __inline unsigned long long int gnu_dev_makedev (unsigned int __major,
162 unsigned int __minor)
163 __attribute__ ((__nothrow__));
164 __extension__ extern __inline unsigned int
165 __attribute__ ((__nothrow__)) gnu_dev_major (unsigned long long int __dev)
166 {
167 return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
168 }
169 __extension__ extern __inline unsigned int
170 __attribute__ ((__nothrow__)) gnu_dev_minor (unsigned long long int __dev)
171 {
172 return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
173 }
174 __extension__ extern __inline unsigned long long int
175 __attribute__ ((__nothrow__)) gnu_dev_makedev (unsigned int __major, unsigned int __minor)
176 {
177 return ((__minor & 0xff) | ((__major & 0xfff) << 8)
178 | (((unsigned long long int) (__minor & ~0xff)) << 12)
179 | (((unsigned long long int) (__major & ~0xfff)) << 32));
180 }
181 typedef __blkcnt_t blkcnt_t;
182 typedef __fsblkcnt_t fsblkcnt_t;
183 typedef __fsfilcnt_t fsfilcnt_t;
184 typedef unsigned long int pthread_t;
185 typedef union
186 {
187 char __size[56];
188 long int __align;
189 } pthread_attr_t;
190 typedef struct __pthread_internal_list
191 {
192 struct __pthread_internal_list *__prev;
193 struct __pthread_internal_list *__next;
194 } __pthread_list_t;
195 typedef union
196 {
197 struct __pthread_mutex_s
198 {
199 int __lock;
200 unsigned int __count;
201 int __owner;
202 unsigned int __nusers;
203 int __kind;
204 int __spins;
205 __pthread_list_t __list;
206 } __data;
207 char __size[40];
208 long int __align;
209 } pthread_mutex_t;
210 typedef union
211 {
212 char __size[4];
213 int __align;
214 } pthread_mutexattr_t;
215 typedef union
216 {
217 struct
218 {
219 int __lock;
220 unsigned int __futex;
221 __extension__ unsigned long long int __total_seq;
222 __extension__ unsigned long long int __wakeup_seq;
223 __extension__ unsigned long long int __woken_seq;
224 void *__mutex;
225 unsigned int __nwaiters;
226 unsigned int __broadcast_seq;
227 } __data;
228 char __size[48];
229 __extension__ long long int __align;
230 } pthread_cond_t;
231 typedef union
232 {
233 char __size[4];
234 int __align;
235 } pthread_condattr_t;
236 typedef unsigned int pthread_key_t;
237 typedef int pthread_once_t;
238 typedef union
239 {
240 struct
241 {
242 int __lock;
243 unsigned int __nr_readers;
244 unsigned int __readers_wakeup;
245 unsigned int __writer_wakeup;
246 unsigned int __nr_readers_queued;
247 unsigned int __nr_writers_queued;
248 int __writer;
249 int __pad1;
250 unsigned long int __pad2;
251 unsigned long int __pad3;
252 unsigned int __flags;
253 } __data;
254 char __size[56];
255 long int __align;
256 } pthread_rwlock_t;
257 typedef union
258 {
259 char __size[8];
260 long int __align;
261 } pthread_rwlockattr_t;
262 typedef volatile int pthread_spinlock_t;
263 typedef union
264 {
265 char __size[32];
266 long int __align;
267 } pthread_barrier_t;
268 typedef union
269 {
270 char __size[4];
271 int __align;
272 } pthread_barrierattr_t;
273
274
275
276 typedef unsigned char uint8_t;
277 typedef unsigned short int uint16_t;
278 typedef unsigned int uint32_t;
279 typedef unsigned long int uint64_t;
280 typedef signed char int_least8_t;
281 typedef short int int_least16_t;
282 typedef int int_least32_t;
283 typedef long int int_least64_t;
284 typedef unsigned char uint_least8_t;
285 typedef unsigned short int uint_least16_t;
286 typedef unsigned int uint_least32_t;
287 typedef unsigned long int uint_least64_t;
288 typedef signed char int_fast8_t;
289 typedef long int int_fast16_t;
290 typedef long int int_fast32_t;
291 typedef long int int_fast64_t;
292 typedef unsigned char uint_fast8_t;
293 typedef unsigned long int uint_fast16_t;
294 typedef unsigned long int uint_fast32_t;
295 typedef unsigned long int uint_fast64_t;
296 typedef long int intptr_t;
297 typedef unsigned long int uintptr_t;
298 typedef long int intmax_t;
299 typedef unsigned long int uintmax_t;
300
301
302 struct iovec
303 {
304 void *iov_base;
305 size_t iov_len;
306 };
307 extern ssize_t readv (int __fd, __const struct iovec *__iovec, int __count);
308 extern ssize_t writev (int __fd, __const struct iovec *__iovec, int __count);
309
310 typedef __socklen_t socklen_t;
311 enum __socket_type
312 {
313 SOCK_STREAM = 1,
314 SOCK_DGRAM = 2,
315 SOCK_RAW = 3,
316 SOCK_RDM = 4,
317 SOCK_SEQPACKET = 5,
318 SOCK_PACKET = 10
319 };
320 typedef unsigned short int sa_family_t;
321 struct sockaddr
322 {
323 sa_family_t sa_family;
324 char sa_data[14];
325 };
326 struct sockaddr_storage
327 {
328 sa_family_t ss_family;
329 __uint64_t __ss_align;
330 char __ss_padding[(128 - (2 * sizeof (__uint64_t)))];
331 };
332 enum
333 {
334 MSG_OOB = 0x01,
335 MSG_PEEK = 0x02,
336 MSG_DONTROUTE = 0x04,
337 MSG_CTRUNC = 0x08,
338 MSG_PROXY = 0x10,
339 MSG_TRUNC = 0x20,
340 MSG_DONTWAIT = 0x40,
341 MSG_EOR = 0x80,
342 MSG_WAITALL = 0x100,
343 MSG_FIN = 0x200,
344 MSG_SYN = 0x400,
345 MSG_CONFIRM = 0x800,
346 MSG_RST = 0x1000,
347 MSG_ERRQUEUE = 0x2000,
348 MSG_NOSIGNAL = 0x4000,
349 MSG_MORE = 0x8000
350 };
351 struct msghdr
352 {
353 void *msg_name;
354 socklen_t msg_namelen;
355 struct iovec *msg_iov;
356 size_t msg_iovlen;
357 void *msg_control;
358 size_t msg_controllen;
359 int msg_flags;
360 };
361 struct cmsghdr
362 {
363 size_t cmsg_len;
364 int cmsg_level;
365 int cmsg_type;
366 __extension__ unsigned char __cmsg_data [];
367 };
368 extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
369 struct cmsghdr *__cmsg) __attribute__ ((__nothrow__));
370 enum
371 {
372 SCM_RIGHTS = 0x01
373 , SCM_CREDENTIALS = 0x02
374 };
375 struct ucred
376 {
377 pid_t pid;
378 uid_t uid;
379 gid_t gid;
380 };
381 struct linger
382 {
383 int l_onoff;
384 int l_linger;
385 };
386 struct osockaddr
387 {
388 unsigned short int sa_family;
389 unsigned char sa_data[14];
390 };
391 enum
392 {
393 SHUT_RD = 0,
394 SHUT_WR,
395 SHUT_RDWR
396 };
397 extern int socket (int __domain, int __type, int __protocol) __attribute__ ((__nothrow__));
398 extern int socketpair (int __domain, int __type, int __protocol,
399 int __fds[2]) __attribute__ ((__nothrow__));
400 extern int bind (int __fd, __const struct sockaddr * __addr, socklen_t __len)
401 __attribute__ ((__nothrow__));
402 extern int getsockname (int __fd, struct sockaddr *__restrict __addr,
403 socklen_t *__restrict __len) __attribute__ ((__nothrow__));
404 extern int connect (int __fd, __const struct sockaddr * __addr, socklen_t __len);
405 extern int getpeername (int __fd, struct sockaddr *__restrict __addr,
406 socklen_t *__restrict __len) __attribute__ ((__nothrow__));
407 extern ssize_t send (int __fd, __const void *__buf, size_t __n, int __flags);
408 extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);
409 extern ssize_t sendto (int __fd, __const void *__buf, size_t __n,
410 int __flags, __const struct sockaddr * __addr,
411 socklen_t __addr_len);
412 extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
413 int __flags, struct sockaddr *__restrict __addr,
414 socklen_t *__restrict __addr_len);
415 extern ssize_t sendmsg (int __fd, __const struct msghdr *__message,
416 int __flags);
417 extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
418 extern int getsockopt (int __fd, int __level, int __optname,
419 void *__restrict __optval,
420 socklen_t *__restrict __optlen) __attribute__ ((__nothrow__));
421 extern int setsockopt (int __fd, int __level, int __optname,
422 __const void *__optval, socklen_t __optlen) __attribute__ ((__nothrow__));
423 extern int listen (int __fd, int __n) __attribute__ ((__nothrow__));
424 extern int accept (int __fd, struct sockaddr *__restrict __addr,
425 socklen_t *__restrict __addr_len);
426 extern int shutdown (int __fd, int __how) __attribute__ ((__nothrow__));
427 extern int sockatmark (int __fd) __attribute__ ((__nothrow__));
428 extern int isfdtype (int __fd, int __fdtype) __attribute__ ((__nothrow__));
429
430
431 enum
432 {
433 IPPROTO_IP = 0,
434 IPPROTO_HOPOPTS = 0,
435 IPPROTO_ICMP = 1,
436 IPPROTO_IGMP = 2,
437 IPPROTO_IPIP = 4,
438 IPPROTO_TCP = 6,
439 IPPROTO_EGP = 8,
440 IPPROTO_PUP = 12,
441 IPPROTO_UDP = 17,
442 IPPROTO_IDP = 22,
443 IPPROTO_TP = 29,
444 IPPROTO_IPV6 = 41,
445 IPPROTO_ROUTING = 43,
446 IPPROTO_FRAGMENT = 44,
447 IPPROTO_RSVP = 46,
448 IPPROTO_GRE = 47,
449 IPPROTO_ESP = 50,
450 IPPROTO_AH = 51,
451 IPPROTO_ICMPV6 = 58,
452 IPPROTO_NONE = 59,
453 IPPROTO_DSTOPTS = 60,
454 IPPROTO_MTP = 92,
455 IPPROTO_ENCAP = 98,
456 IPPROTO_PIM = 103,
457 IPPROTO_COMP = 108,
458 IPPROTO_SCTP = 132,
459 IPPROTO_RAW = 255,
460 IPPROTO_MAX
461 };
462 typedef uint16_t in_port_t;
463 enum
464 {
465 IPPORT_ECHO = 7,
466 IPPORT_DISCARD = 9,
467 IPPORT_SYSTAT = 11,
468 IPPORT_DAYTIME = 13,
469 IPPORT_NETSTAT = 15,
470 IPPORT_FTP = 21,
471 IPPORT_TELNET = 23,
472 IPPORT_SMTP = 25,
473 IPPORT_TIMESERVER = 37,
474 IPPORT_NAMESERVER = 42,
475 IPPORT_WHOIS = 43,
476 IPPORT_MTP = 57,
477 IPPORT_TFTP = 69,
478 IPPORT_RJE = 77,
479 IPPORT_FINGER = 79,
480 IPPORT_TTYLINK = 87,
481 IPPORT_SUPDUP = 95,
482 IPPORT_EXECSERVER = 512,
483 IPPORT_LOGINSERVER = 513,
484 IPPORT_CMDSERVER = 514,
485 IPPORT_EFSSERVER = 520,
486 IPPORT_BIFFUDP = 512,
487 IPPORT_WHOSERVER = 513,
488 IPPORT_ROUTESERVER = 520,
489 IPPORT_RESERVED = 1024,
490 IPPORT_USERRESERVED = 5000
491 };
492 typedef uint32_t in_addr_t;
493 struct in_addr
494 {
495 in_addr_t s_addr;
496 };
497 struct in6_addr
498 {
499 union
500 {
501 uint8_t u6_addr8[16];
502 uint16_t u6_addr16[8];
503 uint32_t u6_addr32[4];
504 } in6_u;
505 };
506 extern const struct in6_addr in6addr_any;
507 extern const struct in6_addr in6addr_loopback;
508 struct sockaddr_in
509 {
510 sa_family_t sin_family;
511 in_port_t sin_port;
512 struct in_addr sin_addr;
513 unsigned char sin_zero[sizeof (struct sockaddr) -
514 (sizeof (unsigned short int)) -
515 sizeof (in_port_t) -
516 sizeof (struct in_addr)];
517 };
518 struct sockaddr_in6
519 {
520 sa_family_t sin6_family;
521 in_port_t sin6_port;
522 uint32_t sin6_flowinfo;
523 struct in6_addr sin6_addr;
524 uint32_t sin6_scope_id;
525 };
526 struct ip_mreq
527 {
528 struct in_addr imr_multiaddr;
529 struct in_addr imr_interface;
530 };
531 struct ip_mreq_source
532 {
533 struct in_addr imr_multiaddr;
534 struct in_addr imr_interface;
535 struct in_addr imr_sourceaddr;
536 };
537 struct ipv6_mreq
538 {
539 struct in6_addr ipv6mr_multiaddr;
540 unsigned int ipv6mr_interface;
541 };
542 struct group_req
543 {
544 uint32_t gr_interface;
545 struct sockaddr_storage gr_group;
546 };
547 struct group_source_req
548 {
549 uint32_t gsr_interface;
550 struct sockaddr_storage gsr_group;
551 struct sockaddr_storage gsr_source;
552 };
553 struct ip_msfilter
554 {
555 struct in_addr imsf_multiaddr;
556 struct in_addr imsf_interface;
557 uint32_t imsf_fmode;
558 uint32_t imsf_numsrc;
559 struct in_addr imsf_slist[1];
560 };
561 struct group_filter
562 {
563 uint32_t gf_interface;
564 struct sockaddr_storage gf_group;
565 uint32_t gf_fmode;
566 uint32_t gf_numsrc;
567 struct sockaddr_storage gf_slist[1];
568 };
569 struct ip_opts
570 {
571 struct in_addr ip_dst;
572 char ip_opts[40];
573 };
574 struct ip_mreqn
575 {
576 struct in_addr imr_multiaddr;
577 struct in_addr imr_address;
578 int imr_ifindex;
579 };
580 struct in_pktinfo
581 {
582 int ipi_ifindex;
583 struct in_addr ipi_spec_dst;
584 struct in_addr ipi_addr;
585 };
586 extern uint32_t ntohl (uint32_t __netlong) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
587 extern uint16_t ntohs (uint16_t __netshort)
588 __attribute__ ((__nothrow__)) __attribute__ ((__const__));
589 extern uint32_t htonl (uint32_t __hostlong)
590 __attribute__ ((__nothrow__)) __attribute__ ((__const__));
591 extern uint16_t htons (uint16_t __hostshort)
592 __attribute__ ((__nothrow__)) __attribute__ ((__const__));
593 extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __attribute__ ((__nothrow__));
594 extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
595 __attribute__ ((__nothrow__));
596 struct in6_pktinfo
597 {
598 struct in6_addr ipi6_addr;
599 unsigned int ipi6_ifindex;
600 };
601 struct ip6_mtuinfo
602 {
603 struct sockaddr_in6 ip6m_addr;
604 uint32_t ip6m_mtu;
605 };
606
607
608 struct passwd
609 {
610 char *pw_name;
611 char *pw_passwd;
612 __uid_t pw_uid;
613 __gid_t pw_gid;
614 char *pw_gecos;
615 char *pw_dir;
616 char *pw_shell;
617 };
618
619 typedef struct _IO_FILE FILE;
620
621
622 extern void setpwent (void);
623 extern void endpwent (void);
624 extern struct passwd *getpwent (void);
625 extern struct passwd *fgetpwent (FILE *__stream);
626 extern int putpwent (__const struct passwd *__restrict __p,
627 FILE *__restrict __f);
628 extern struct passwd *getpwuid (__uid_t __uid);
629 extern struct passwd *getpwnam (__const char *__name);
630 extern int getpwent_r (struct passwd *__restrict __resultbuf,
631 char *__restrict __buffer, size_t __buflen,
632 struct passwd **__restrict __result);
633 extern int getpwuid_r (__uid_t __uid,
634 struct passwd *__restrict __resultbuf,
635 char *__restrict __buffer, size_t __buflen,
636 struct passwd **__restrict __result);
637 extern int getpwnam_r (__const char *__restrict __name,
638 struct passwd *__restrict __resultbuf,
639 char *__restrict __buffer, size_t __buflen,
640 struct passwd **__restrict __result);
641 extern int fgetpwent_r (FILE *__restrict __stream,
642 struct passwd *__restrict __resultbuf,
643 char *__restrict __buffer, size_t __buflen,
644 struct passwd **__restrict __result);
645
646
647
648 extern void *memcpy (void *__restrict __dest,
649 __const void *__restrict __src, size_t __n)
650 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
651 extern void *memmove (void *__dest, __const void *__src, size_t __n)
652 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
653
654 extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
655 int __c, size_t __n)
656 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
657
658 extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
659 extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
660 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
661 extern void *memchr (__const void *__s, int __c, size_t __n)
662 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
663
664
665 extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
666 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
667 extern char *strncpy (char *__restrict __dest,
668 __const char *__restrict __src, size_t __n)
669 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
670 extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
671 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
672 extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
673 size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
674 extern int strcmp (__const char *__s1, __const char *__s2)
675 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
676 extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
677 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
678 extern int strcoll (__const char *__s1, __const char *__s2)
679 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
680 extern size_t strxfrm (char *__restrict __dest,
681 __const char *__restrict __src, size_t __n)
682 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));
683
684 extern char *strdup (__const char *__s)
685 __attribute__ ((__nothrow__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
686
687 extern char *strchr (__const char *__s, int __c)
688 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
689 extern char *strrchr (__const char *__s, int __c)
690 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
691
692
693 extern size_t strcspn (__const char *__s, __const char *__reject)
694 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
695 extern size_t strspn (__const char *__s, __const char *__accept)
696 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
697 extern char *strpbrk (__const char *__s, __const char *__accept)
698 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
699 extern char *strstr (__const char *__haystack, __const char *__needle)
700 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
701 extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
702 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));
703
704 extern char *__strtok_r (char *__restrict __s,
705 __const char *__restrict __delim,
706 char **__restrict __save_ptr)
707 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));
708 extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
709 char **__restrict __save_ptr)
710 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));
711
712 extern size_t strlen (__const char *__s)
713 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
714
715
716 extern char *strerror (int __errnum) __attribute__ ((__nothrow__));
717
718 extern int strerror_r (int __errnum, char *__buf, size_t __buflen) __asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));
719 extern void __bzero (void *__s, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
720 extern void bcopy (__const void *__src, void *__dest, size_t __n)
721 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
722 extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
723 extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
724 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
725 extern char *index (__const char *__s, int __c)
726 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
727 extern char *rindex (__const char *__s, int __c)
728 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
729 extern int ffs (int __i) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
730 extern int strcasecmp (__const char *__s1, __const char *__s2)
731 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
732 extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
733 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
734 extern char *strsep (char **__restrict __stringp,
735 __const char *__restrict __delim)
736 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
737
738
739 extern char *crypt (__const char *__key, __const char *__salt)
740 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
741 extern void setkey (__const char *__key) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
742 extern void encrypt (char *__block, int __edflag) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
743
744 extern char *__md5_crypt(const unsigned char *pw, const unsigned char *salt);
745 extern char *__des_crypt(const unsigned char *pw, const unsigned char *salt);
746 static u_char inv_key_perm[64];
747 static u_char inv_comp_perm[56];
748 static u_char u_sbox[8][64];
749 static u_char un_pbox[32];
750 static u_int32_t en_keysl[16], en_keysr[16];
751 static u_int32_t de_keysl[16], de_keysr[16];
752 static u_int32_t ip_maskl[8][256], ip_maskr[8][256];
753 static u_int32_t fp_maskl[8][256], fp_maskr[8][256];
754 static u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
755 static u_int32_t comp_maskl[8][128], comp_maskr[8][128];
756 static u_int32_t saltbits;
757 static u_int32_t old_salt;
758 static u_int32_t old_rawkey0, old_rawkey1;
759 static u_char init_perm[64], final_perm[64];
760 static u_char m_sbox[4][4096];
761 static u_int32_t psbox[4][256];
762 static const u_char ascii64[] =
763 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
764 static const u_char IP[64] = {
765 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
766 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
767 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
768 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
769 };
770 static const u_char key_perm[56] = {
771 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
772 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
773 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
774 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
775 };
776 static const u_char key_shifts[16] = {
777 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
778 };
779 static const u_char comp_perm[48] = {
780 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10,
781 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
782 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
783 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
784 };
785 static const u_char sbox[8][64] = {
786 {
787 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
788 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
789 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
790 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13},
791 {
792 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
793 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
794 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
795 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9},
796 {
797 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
798 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
799 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
800 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12},
801 {
802 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
803 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
804 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
805 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14},
806 {
807 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
808 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
809 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
810 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3},
811 {
812 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
813 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
814 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
815 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13},
816 {
817 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
818 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
819 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
820 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12},
821 {
822 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
823 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
824 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
825 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}
826 };
827 static const u_char pbox[32] = {
828 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
829 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
830 };
831 static const u_int32_t bits32[32] = {
832 0x80000000, 0x40000000, 0x20000000, 0x10000000,
833 0x08000000, 0x04000000, 0x02000000, 0x01000000,
834 0x00800000, 0x00400000, 0x00200000, 0x00100000,
835 0x00080000, 0x00040000, 0x00020000, 0x00010000,
836 0x00008000, 0x00004000, 0x00002000, 0x00001000,
837 0x00000800, 0x00000400, 0x00000200, 0x00000100,
838 0x00000080, 0x00000040, 0x00000020, 0x00000010,
839 0x00000008, 0x00000004, 0x00000002, 0x00000001
840 };
841 static const u_char bits8[8] =
842 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
843 static const u_int32_t *bits28, *bits24;
844 static int ascii_to_bin(char ch)
845 {
846 if (ch > 'z')
847 return (0);
848 if (ch >= 'a')
849 return (ch - 'a' + 38);
850 if (ch > 'Z')
851 return (0);
852 if (ch >= 'A')
853 return (ch - 'A' + 12);
854 if (ch > '9')
855 return (0);
856 if (ch >= '.')
857 return (ch - '.');
858 return (0);
859 }
860 static void des_init(void)
861 {
862 int i, j, b, k, inbit, obit;
863 u_int32_t *p, *il, *ir, *fl, *fr;
864 static int des_initialised = 0;
865 if (des_initialised == 1)
866 return;
867 old_rawkey0 = old_rawkey1 = 0L;
868 saltbits = 0L;
869 old_salt = 0L;
870 bits24 = (bits28 = bits32 + 4) + 4;
871 for (i = 0; i < 8; i++)
872 for (j = 0; j < 64; j++) {
873 b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf);
874 u_sbox[i][j] = sbox[i][b];
875 }
876 for (b = 0; b < 4; b++)
877 for (i = 0; i < 64; i++)
878 for (j = 0; j < 64; j++)
879 m_sbox[b][(i << 6) | j] =
880 (u_char) ((u_sbox[(b << 1)][i] << 4) |
881 u_sbox[(b << 1) + 1][j]);
882 for (i = 0; i < 64; i++) {
883 init_perm[final_perm[i] = IP[i] - 1] = (u_char) i;
884 inv_key_perm[i] = 255;
885 }
886 for (i = 0; i < 56; i++) {
887 inv_key_perm[key_perm[i] - 1] = (u_char) i;
888 inv_comp_perm[i] = 255;
889 }
890 for (i = 0; i < 48; i++) {
891 inv_comp_perm[comp_perm[i] - 1] = (u_char) i;
892 }
893 for (k = 0; k < 8; k++) {
894 for (i = 0; i < 256; i++) {
895 *(il = &ip_maskl[k][i]) = 0L;
896 *(ir = &ip_maskr[k][i]) = 0L;
897 *(fl = &fp_maskl[k][i]) = 0L;
898 *(fr = &fp_maskr[k][i]) = 0L;
899 for (j = 0; j < 8; j++) {
900 inbit = 8 * k + j;
901 if (i & bits8[j]) {
902 if ((obit = init_perm[inbit]) < 32)
903 *il |= bits32[obit];
904 else
905 *ir |= bits32[obit - 32];
906 if ((obit = final_perm[inbit]) < 32)
907 *fl |= bits32[obit];
908 else
909 *fr |= bits32[obit - 32];
910 }
911 }
912 }
913 for (i = 0; i < 128; i++) {
914 *(il = &key_perm_maskl[k][i]) = 0L;
915 *(ir = &key_perm_maskr[k][i]) = 0L;
916 for (j = 0; j < 7; j++) {
917 inbit = 8 * k + j;
918 if (i & bits8[j + 1]) {
919 if ((obit = inv_key_perm[inbit]) == 255)
920 continue;
921 if (obit < 28)
922 *il |= bits28[obit];
923 else
924 *ir |= bits28[obit - 28];
925 }
926 }
927 *(il = &comp_maskl[k][i]) = 0L;
928 *(ir = &comp_maskr[k][i]) = 0L;
929 for (j = 0; j < 7; j++) {
930 inbit = 7 * k + j;
931 if (i & bits8[j + 1]) {
932 if ((obit =
933 inv_comp_perm[inbit]) == 255)
934 continue;
935 if (obit < 24)
936 *il |= bits24[obit];
937 else
938 *ir |= bits24[obit - 24];
939 }
940 }
941 }
942 }
943 for (i = 0; i < 32; i++)
944 un_pbox[pbox[i] - 1] = (u_char) i;
945 for (b = 0; b < 4; b++)
946 for (i = 0; i < 256; i++) {
947 *(p = &psbox[b][i]) = 0L;
948 for (j = 0; j < 8; j++) {
949 if (i & bits8[j])
950 *p |= bits32[un_pbox[8 * b + j]];
951 }
952 }
953 des_initialised = 1;
954 }
955 static void setup_salt(u_int32_t salt)
956 {
957 u_int32_t obit, saltbit;
958 int i;
959 if (salt == old_salt)
960 return;
961 old_salt = salt;
962 saltbits = 0L;
963 saltbit = 1;
964 obit = 0x800000;
965 for (i = 0; i < 24; i++) {
966 if (salt & saltbit)
967 saltbits |= obit;
968 saltbit <<= 1;
969 obit >>= 1;
970 }
971 }
972 static int des_setkey(const char *key)
973 {
974 u_int32_t k0, k1, rawkey0, rawkey1;
975 int shifts, round;
976 des_init();
977 rawkey0 = ntohl(*(const u_int32_t *)key);
978 rawkey1 = ntohl(*(const u_int32_t *)(key + 4));
979 if ((rawkey0 | rawkey1)
980 && rawkey0 == old_rawkey0 && rawkey1 == old_rawkey1) {
981 return (0);
982 }
983 old_rawkey0 = rawkey0;
984 old_rawkey1 = rawkey1;
985 k0 = key_perm_maskl[0][rawkey0 >> 25]
986 | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f]
987 | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f]
988 | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f]
989 | key_perm_maskl[4][rawkey1 >> 25]
990 | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f]
991 | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f]
992 | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f];
993 k1 = key_perm_maskr[0][rawkey0 >> 25]
994 | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f]
995 | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f]
996 | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f]
997 | key_perm_maskr[4][rawkey1 >> 25]
998 | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f]
999 | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f]
1000 | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f];
1001 shifts = 0;
1002 for (round = 0; round < 16; round++) {
1003 u_int32_t t0, t1;
1004 shifts += key_shifts[round];
1005 t0 = (k0 << shifts) | (k0 >> (28 - shifts));
1006 t1 = (k1 << shifts) | (k1 >> (28 - shifts));
1007 de_keysl[15 - round] =
1008 en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f]
1009 | comp_maskl[1][(t0 >> 14) & 0x7f]
1010 | comp_maskl[2][(t0 >> 7) & 0x7f]
1011 | comp_maskl[3][t0 & 0x7f]
1012 | comp_maskl[4][(t1 >> 21) & 0x7f]
1013 | comp_maskl[5][(t1 >> 14) & 0x7f]
1014 | comp_maskl[6][(t1 >> 7) & 0x7f]
1015 | comp_maskl[7][t1 & 0x7f];
1016 de_keysr[15 - round] =
1017 en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f]
1018 | comp_maskr[1][(t0 >> 14) & 0x7f]
1019 | comp_maskr[2][(t0 >> 7) & 0x7f]
1020 | comp_maskr[3][t0 & 0x7f]
1021 | comp_maskr[4][(t1 >> 21) & 0x7f]
1022 | comp_maskr[5][(t1 >> 14) & 0x7f]
1023 | comp_maskr[6][(t1 >> 7) & 0x7f]
1024 | comp_maskr[7][t1 & 0x7f];
1025 }
1026 return (0);
1027 }
1028 static int
1029 do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t * l_out, u_int32_t * r_out,
1030 int count)
1031 {
1032 u_int32_t l, r, *kl, *kr, *kl1, *kr1;
1033 u_int32_t f, r48l, r48r;
1034 int round;
1035 if (count == 0) {
1036 return (1);
1037 } else if (count > 0) {
1038 kl1 = en_keysl;
1039 kr1 = en_keysr;
1040 } else {
1041 count = -count;
1042 kl1 = de_keysl;
1043 kr1 = de_keysr;
1044 }
1045 l = ip_maskl[0][l_in >> 24]
1046 | ip_maskl[1][(l_in >> 16) & 0xff]
1047 | ip_maskl[2][(l_in >> 8) & 0xff]
1048 | ip_maskl[3][l_in & 0xff]
1049 | ip_maskl[4][r_in >> 24]
1050 | ip_maskl[5][(r_in >> 16) & 0xff]
1051 | ip_maskl[6][(r_in >> 8) & 0xff]
1052 | ip_maskl[7][r_in & 0xff];
1053 r = ip_maskr[0][l_in >> 24]
1054 | ip_maskr[1][(l_in >> 16) & 0xff]
1055 | ip_maskr[2][(l_in >> 8) & 0xff]
1056 | ip_maskr[3][l_in & 0xff]
1057 | ip_maskr[4][r_in >> 24]
1058 | ip_maskr[5][(r_in >> 16) & 0xff]
1059 | ip_maskr[6][(r_in >> 8) & 0xff]
1060 | ip_maskr[7][r_in & 0xff];
1061 while (count--) {
1062 kl = kl1;
1063 kr = kr1;
1064 round = 16;
1065 while (round--) {
1066 r48l = ((r & 0x00000001) << 23)
1067 | ((r & 0xf8000000) >> 9)
1068 | ((r & 0x1f800000) >> 11)
1069 | ((r & 0x01f80000) >> 13)
1070 | ((r & 0x001f8000) >> 15);
1071 r48r = ((r & 0x0001f800) << 7)
1072 | ((r & 0x00001f80) << 5)
1073 | ((r & 0x000001f8) << 3)
1074 | ((r & 0x0000001f) << 1)
1075 | ((r & 0x80000000) >> 31);
1076 f = (r48l ^ r48r) & saltbits;
1077 r48l ^= f ^ *kl++;
1078 r48r ^= f ^ *kr++;
1079 f = psbox[0][m_sbox[0][r48l >> 12]]
1080 | psbox[1][m_sbox[1][r48l & 0xfff]]
1081 | psbox[2][m_sbox[2][r48r >> 12]]
1082 | psbox[3][m_sbox[3][r48r & 0xfff]];
1083 f ^= l;
1084 l = r;
1085 r = f;
1086 }
1087 r = l;
1088 l = f;
1089 }
1090 *l_out = fp_maskl[0][l >> 24]
1091 | fp_maskl[1][(l >> 16) & 0xff]
1092 | fp_maskl[2][(l >> 8) & 0xff]
1093 | fp_maskl[3][l & 0xff]
1094 | fp_maskl[4][r >> 24]
1095 | fp_maskl[5][(r >> 16) & 0xff]
1096 | fp_maskl[6][(r >> 8) & 0xff]
1097 | fp_maskl[7][r & 0xff];
1098 *r_out = fp_maskr[0][l >> 24]
1099 | fp_maskr[1][(l >> 16) & 0xff]
1100 | fp_maskr[2][(l >> 8) & 0xff]
1101 | fp_maskr[3][l & 0xff]
1102 | fp_maskr[4][r >> 24]
1103 | fp_maskr[5][(r >> 16) & 0xff]
1104 | fp_maskr[6][(r >> 8) & 0xff]
1105 | fp_maskr[7][r & 0xff];
1106 return (0);
1107 }
1108 void setkey(const char *key)
1109 {
1110 int i, j;
1111 u_int32_t packed_keys[2];
1112 u_char *p;
1113 p = (u_char *) packed_keys;
1114 for (i = 0; i < 8; i++) {
1115 p[i] = 0;
1116 for (j = 0; j < 8; j++)
1117 if (*key++ & 1)
1118 p[i] |= bits8[j];
1119 }
1120 des_setkey((char *)p);
1121 }
1122 void encrypt(char *block, int flag)
1123 {
1124 u_int32_t io[2];
1125 u_char *p;
1126 int i, j;
1127 des_init();
1128 setup_salt(0L);
1129 p = (u_char *) block;
1130 for (i = 0; i < 2; i++) {
1131 io[i] = 0L;
1132 for (j = 0; j < 32; j++)
1133 if (*p++ & 1)
1134 io[i] |= bits32[j];
1135 }
1136 do_des(io[0], io[1], io, io + 1, flag ? -1 : 1);
1137 for (i = 0; i < 2; i++)
1138 for (j = 0; j < 32; j++)
1139 block[(i << 5) | j] = (io[i] & bits32[j]) ? 1 : 0;
1140 }
1141 char *__des_crypt(const unsigned char *key, const unsigned char *setting)
1142 {
1143 u_int32_t count, salt, l, r0, r1, keybuf[2];
1144 u_char *p, *q;
1145 static char output[21];
1146 des_init();
1147 q = (u_char *) keybuf;
1148 while (q - (u_char *) keybuf - 8) {
1149 *q++ = *key << 1;
1150 if (*(q - 1))
1151 key++;
1152 }
1153 if (des_setkey((char *)keybuf))
1154 return (((void *)0));
1155 {
1156 count = 25;
1157 salt = (ascii_to_bin(setting[1]) << 6)
1158 | ascii_to_bin(setting[0]);
1159 output[0] = setting[0];
1160 output[1] = setting[1] ? setting[1] : output[0];
1161 p = (u_char *) output + 2;
1162 }
1163 setup_salt(salt);
1164 if (do_des(0L, 0L, &r0, &r1, (int)count))
1165 return (((void *)0));
1166 l = (r0 >> 8);
1167 *p++ = ascii64[(l >> 18) & 0x3f];
1168 *p++ = ascii64[(l >> 12) & 0x3f];
1169 *p++ = ascii64[(l >> 6) & 0x3f];
1170 *p++ = ascii64[l & 0x3f];
1171 l = (r0 << 16) | ((r1 >> 16) & 0xffff);
1172 *p++ = ascii64[(l >> 18) & 0x3f];
1173 *p++ = ascii64[(l >> 12) & 0x3f];
1174 *p++ = ascii64[(l >> 6) & 0x3f];
1175 *p++ = ascii64[l & 0x3f];
1176 l = r1 << 2;
1177 *p++ = ascii64[(l >> 12) & 0x3f];
1178 *p++ = ascii64[(l >> 6) & 0x3f];
1179 *p++ = ascii64[l & 0x3f];
1180 *p = 0;
1181 return (output);
1182 }