]> git.wh0rd.org - ICEs.git/blame - not-unused/des.i.0
initial import
[ICEs.git] / not-unused / des.i.0
CommitLineData
45516216 1
2typedef long unsigned int size_t;
3typedef unsigned char __u_char;
4typedef unsigned short int __u_short;
5typedef unsigned int __u_int;
6typedef unsigned long int __u_long;
7typedef signed char __int8_t;
8typedef unsigned char __uint8_t;
9typedef signed short int __int16_t;
10typedef unsigned short int __uint16_t;
11typedef signed int __int32_t;
12typedef unsigned int __uint32_t;
13typedef signed long int __int64_t;
14typedef unsigned long int __uint64_t;
15typedef long int __quad_t;
16typedef unsigned long int __u_quad_t;
17typedef unsigned long int __dev_t;
18typedef unsigned int __uid_t;
19typedef unsigned int __gid_t;
20typedef unsigned long int __ino_t;
21typedef unsigned long int __ino64_t;
22typedef unsigned int __mode_t;
23typedef unsigned long int __nlink_t;
24typedef long int __off_t;
25typedef long int __off64_t;
26typedef int __pid_t;
27typedef struct { int __val[2]; } __fsid_t;
28typedef long int __clock_t;
29typedef unsigned long int __rlim_t;
30typedef unsigned long int __rlim64_t;
31typedef unsigned int __id_t;
32typedef long int __time_t;
33typedef unsigned int __useconds_t;
34typedef long int __suseconds_t;
35typedef int __daddr_t;
36typedef long int __swblk_t;
37typedef int __key_t;
38typedef int __clockid_t;
39typedef void * __timer_t;
40typedef long int __blksize_t;
41typedef long int __blkcnt_t;
42typedef long int __blkcnt64_t;
43typedef unsigned long int __fsblkcnt_t;
44typedef unsigned long int __fsblkcnt64_t;
45typedef unsigned long int __fsfilcnt_t;
46typedef unsigned long int __fsfilcnt64_t;
47typedef long int __ssize_t;
48typedef __off64_t __loff_t;
49typedef __quad_t *__qaddr_t;
50typedef char *__caddr_t;
51typedef long int __intptr_t;
52typedef unsigned int __socklen_t;
53typedef __u_char u_char;
54typedef __u_short u_short;
55typedef __u_int u_int;
56typedef __u_long u_long;
57typedef __quad_t quad_t;
58typedef __u_quad_t u_quad_t;
59typedef __fsid_t fsid_t;
60typedef __loff_t loff_t;
61typedef __ino_t ino_t;
62
63
64typedef __dev_t dev_t;
65
66
67
68
69typedef __gid_t gid_t;
70
71
72
73
74typedef __mode_t mode_t;
75
76
77
78
79typedef __nlink_t nlink_t;
80
81
82
83
84typedef __uid_t uid_t;
85
86
87
88
89
90typedef __off_t off_t;
91typedef __pid_t pid_t;
92typedef __id_t id_t;
93typedef __ssize_t ssize_t;
94typedef __daddr_t daddr_t;
95typedef __caddr_t caddr_t;
96typedef __key_t key_t;
97
98typedef __time_t time_t;
99
100
101typedef __clockid_t clockid_t;
102
103
104
105
106
107typedef __timer_t timer_t;
108typedef unsigned long int ulong;
109typedef unsigned short int ushort;
110typedef unsigned int uint;
111typedef int int8_t __attribute__ ((__mode__ (__QI__)));
112typedef int int16_t __attribute__ ((__mode__ (__HI__)));
113typedef int int32_t __attribute__ ((__mode__ (__SI__)));
114typedef int int64_t __attribute__ ((__mode__ (__DI__)));
115typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
116typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
117typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
118typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
119typedef int register_t __attribute__ ((__mode__ (__word__)));
120typedef int __sig_atomic_t;
121typedef struct
122 {
123 unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
124 } __sigset_t;
125typedef __sigset_t sigset_t;
126struct timespec
127 {
128 __time_t tv_sec;
129 long int tv_nsec;
130 };
131struct timeval
132 {
133 __time_t tv_sec;
134 __suseconds_t tv_usec;
135 };
136typedef __suseconds_t suseconds_t;
137typedef long int __fd_mask;
138typedef struct
139 {
140 __fd_mask __fds_bits[1024 / (8 * sizeof (__fd_mask))];
141 } fd_set;
142typedef __fd_mask fd_mask;
143
144extern int select (int __nfds, fd_set *__restrict __readfds,
145 fd_set *__restrict __writefds,
146 fd_set *__restrict __exceptfds,
147 struct timeval *__restrict __timeout);
148extern 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__
155extern __inline unsigned int gnu_dev_major (unsigned long long int __dev)
156 __attribute__ ((__nothrow__));
157__extension__
158extern __inline unsigned int gnu_dev_minor (unsigned long long int __dev)
159 __attribute__ ((__nothrow__));
160__extension__
161extern __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}
181typedef __blkcnt_t blkcnt_t;
182typedef __fsblkcnt_t fsblkcnt_t;
183typedef __fsfilcnt_t fsfilcnt_t;
184typedef unsigned long int pthread_t;
185typedef union
186{
187 char __size[56];
188 long int __align;
189} pthread_attr_t;
190typedef struct __pthread_internal_list
191{
192 struct __pthread_internal_list *__prev;
193 struct __pthread_internal_list *__next;
194} __pthread_list_t;
195typedef 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;
210typedef union
211{
212 char __size[4];
213 int __align;
214} pthread_mutexattr_t;
215typedef 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;
231typedef union
232{
233 char __size[4];
234 int __align;
235} pthread_condattr_t;
236typedef unsigned int pthread_key_t;
237typedef int pthread_once_t;
238typedef 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;
257typedef union
258{
259 char __size[8];
260 long int __align;
261} pthread_rwlockattr_t;
262typedef volatile int pthread_spinlock_t;
263typedef union
264{
265 char __size[32];
266 long int __align;
267} pthread_barrier_t;
268typedef union
269{
270 char __size[4];
271 int __align;
272} pthread_barrierattr_t;
273
274
275
276typedef unsigned char uint8_t;
277typedef unsigned short int uint16_t;
278typedef unsigned int uint32_t;
279typedef unsigned long int uint64_t;
280typedef signed char int_least8_t;
281typedef short int int_least16_t;
282typedef int int_least32_t;
283typedef long int int_least64_t;
284typedef unsigned char uint_least8_t;
285typedef unsigned short int uint_least16_t;
286typedef unsigned int uint_least32_t;
287typedef unsigned long int uint_least64_t;
288typedef signed char int_fast8_t;
289typedef long int int_fast16_t;
290typedef long int int_fast32_t;
291typedef long int int_fast64_t;
292typedef unsigned char uint_fast8_t;
293typedef unsigned long int uint_fast16_t;
294typedef unsigned long int uint_fast32_t;
295typedef unsigned long int uint_fast64_t;
296typedef long int intptr_t;
297typedef unsigned long int uintptr_t;
298typedef long int intmax_t;
299typedef unsigned long int uintmax_t;
300
301
302struct iovec
303 {
304 void *iov_base;
305 size_t iov_len;
306 };
307extern ssize_t readv (int __fd, __const struct iovec *__iovec, int __count);
308extern ssize_t writev (int __fd, __const struct iovec *__iovec, int __count);
309
310typedef __socklen_t socklen_t;
311enum __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};
320typedef unsigned short int sa_family_t;
321struct sockaddr
322 {
323 sa_family_t sa_family;
324 char sa_data[14];
325 };
326struct sockaddr_storage
327 {
328 sa_family_t ss_family;
329 __uint64_t __ss_align;
330 char __ss_padding[(128 - (2 * sizeof (__uint64_t)))];
331 };
332enum
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 };
351struct 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 };
361struct cmsghdr
362 {
363 size_t cmsg_len;
364 int cmsg_level;
365 int cmsg_type;
366 __extension__ unsigned char __cmsg_data [];
367 };
368extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
369 struct cmsghdr *__cmsg) __attribute__ ((__nothrow__));
370enum
371 {
372 SCM_RIGHTS = 0x01
373 , SCM_CREDENTIALS = 0x02
374 };
375struct ucred
376{
377 pid_t pid;
378 uid_t uid;
379 gid_t gid;
380};
381struct linger
382 {
383 int l_onoff;
384 int l_linger;
385 };
386struct osockaddr
387 {
388 unsigned short int sa_family;
389 unsigned char sa_data[14];
390 };
391enum
392{
393 SHUT_RD = 0,
394 SHUT_WR,
395 SHUT_RDWR
396};
397extern int socket (int __domain, int __type, int __protocol) __attribute__ ((__nothrow__));
398extern int socketpair (int __domain, int __type, int __protocol,
399 int __fds[2]) __attribute__ ((__nothrow__));
400extern int bind (int __fd, __const struct sockaddr * __addr, socklen_t __len)
401 __attribute__ ((__nothrow__));
402extern int getsockname (int __fd, struct sockaddr *__restrict __addr,
403 socklen_t *__restrict __len) __attribute__ ((__nothrow__));
404extern int connect (int __fd, __const struct sockaddr * __addr, socklen_t __len);
405extern int getpeername (int __fd, struct sockaddr *__restrict __addr,
406 socklen_t *__restrict __len) __attribute__ ((__nothrow__));
407extern ssize_t send (int __fd, __const void *__buf, size_t __n, int __flags);
408extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);
409extern ssize_t sendto (int __fd, __const void *__buf, size_t __n,
410 int __flags, __const struct sockaddr * __addr,
411 socklen_t __addr_len);
412extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
413 int __flags, struct sockaddr *__restrict __addr,
414 socklen_t *__restrict __addr_len);
415extern ssize_t sendmsg (int __fd, __const struct msghdr *__message,
416 int __flags);
417extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
418extern int getsockopt (int __fd, int __level, int __optname,
419 void *__restrict __optval,
420 socklen_t *__restrict __optlen) __attribute__ ((__nothrow__));
421extern int setsockopt (int __fd, int __level, int __optname,
422 __const void *__optval, socklen_t __optlen) __attribute__ ((__nothrow__));
423extern int listen (int __fd, int __n) __attribute__ ((__nothrow__));
424extern int accept (int __fd, struct sockaddr *__restrict __addr,
425 socklen_t *__restrict __addr_len);
426extern int shutdown (int __fd, int __how) __attribute__ ((__nothrow__));
427extern int sockatmark (int __fd) __attribute__ ((__nothrow__));
428extern int isfdtype (int __fd, int __fdtype) __attribute__ ((__nothrow__));
429
430
431enum
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 };
462typedef uint16_t in_port_t;
463enum
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 };
492typedef uint32_t in_addr_t;
493struct in_addr
494 {
495 in_addr_t s_addr;
496 };
497struct 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 };
506extern const struct in6_addr in6addr_any;
507extern const struct in6_addr in6addr_loopback;
508struct 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 };
518struct 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 };
526struct ip_mreq
527 {
528 struct in_addr imr_multiaddr;
529 struct in_addr imr_interface;
530 };
531struct ip_mreq_source
532 {
533 struct in_addr imr_multiaddr;
534 struct in_addr imr_interface;
535 struct in_addr imr_sourceaddr;
536 };
537struct ipv6_mreq
538 {
539 struct in6_addr ipv6mr_multiaddr;
540 unsigned int ipv6mr_interface;
541 };
542struct group_req
543 {
544 uint32_t gr_interface;
545 struct sockaddr_storage gr_group;
546 };
547struct group_source_req
548 {
549 uint32_t gsr_interface;
550 struct sockaddr_storage gsr_group;
551 struct sockaddr_storage gsr_source;
552 };
553struct 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 };
561struct 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};
569struct ip_opts
570 {
571 struct in_addr ip_dst;
572 char ip_opts[40];
573 };
574struct ip_mreqn
575 {
576 struct in_addr imr_multiaddr;
577 struct in_addr imr_address;
578 int imr_ifindex;
579 };
580struct in_pktinfo
581 {
582 int ipi_ifindex;
583 struct in_addr ipi_spec_dst;
584 struct in_addr ipi_addr;
585 };
586extern uint32_t ntohl (uint32_t __netlong) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
587extern uint16_t ntohs (uint16_t __netshort)
588 __attribute__ ((__nothrow__)) __attribute__ ((__const__));
589extern uint32_t htonl (uint32_t __hostlong)
590 __attribute__ ((__nothrow__)) __attribute__ ((__const__));
591extern uint16_t htons (uint16_t __hostshort)
592 __attribute__ ((__nothrow__)) __attribute__ ((__const__));
593extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __attribute__ ((__nothrow__));
594extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
595 __attribute__ ((__nothrow__));
596struct in6_pktinfo
597 {
598 struct in6_addr ipi6_addr;
599 unsigned int ipi6_ifindex;
600 };
601struct ip6_mtuinfo
602 {
603 struct sockaddr_in6 ip6m_addr;
604 uint32_t ip6m_mtu;
605 };
606
607
608struct 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
619typedef struct _IO_FILE FILE;
620
621
622extern void setpwent (void);
623extern void endpwent (void);
624extern struct passwd *getpwent (void);
625extern struct passwd *fgetpwent (FILE *__stream);
626extern int putpwent (__const struct passwd *__restrict __p,
627 FILE *__restrict __f);
628extern struct passwd *getpwuid (__uid_t __uid);
629extern struct passwd *getpwnam (__const char *__name);
630extern int getpwent_r (struct passwd *__restrict __resultbuf,
631 char *__restrict __buffer, size_t __buflen,
632 struct passwd **__restrict __result);
633extern int getpwuid_r (__uid_t __uid,
634 struct passwd *__restrict __resultbuf,
635 char *__restrict __buffer, size_t __buflen,
636 struct passwd **__restrict __result);
637extern int getpwnam_r (__const char *__restrict __name,
638 struct passwd *__restrict __resultbuf,
639 char *__restrict __buffer, size_t __buflen,
640 struct passwd **__restrict __result);
641extern 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
648extern void *memcpy (void *__restrict __dest,
649 __const void *__restrict __src, size_t __n)
650 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
651extern void *memmove (void *__dest, __const void *__src, size_t __n)
652 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
653
654extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
655 int __c, size_t __n)
656 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
657
658extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
659extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
660 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
661extern void *memchr (__const void *__s, int __c, size_t __n)
662 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
663
664
665extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
666 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
667extern char *strncpy (char *__restrict __dest,
668 __const char *__restrict __src, size_t __n)
669 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
670extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
671 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
672extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
673 size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
674extern int strcmp (__const char *__s1, __const char *__s2)
675 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
676extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
677 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
678extern int strcoll (__const char *__s1, __const char *__s2)
679 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
680extern size_t strxfrm (char *__restrict __dest,
681 __const char *__restrict __src, size_t __n)
682 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));
683
684extern char *strdup (__const char *__s)
685 __attribute__ ((__nothrow__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
686
687extern char *strchr (__const char *__s, int __c)
688 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
689extern char *strrchr (__const char *__s, int __c)
690 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
691
692
693extern size_t strcspn (__const char *__s, __const char *__reject)
694 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
695extern size_t strspn (__const char *__s, __const char *__accept)
696 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
697extern char *strpbrk (__const char *__s, __const char *__accept)
698 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
699extern char *strstr (__const char *__haystack, __const char *__needle)
700 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
701extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
702 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));
703
704extern char *__strtok_r (char *__restrict __s,
705 __const char *__restrict __delim,
706 char **__restrict __save_ptr)
707 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));
708extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
709 char **__restrict __save_ptr)
710 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));
711
712extern size_t strlen (__const char *__s)
713 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
714
715
716extern char *strerror (int __errnum) __attribute__ ((__nothrow__));
717
718extern int strerror_r (int __errnum, char *__buf, size_t __buflen) __asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));
719extern void __bzero (void *__s, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
720extern void bcopy (__const void *__src, void *__dest, size_t __n)
721 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
722extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
723extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
724 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
725extern char *index (__const char *__s, int __c)
726 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
727extern char *rindex (__const char *__s, int __c)
728 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
729extern int ffs (int __i) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
730extern int strcasecmp (__const char *__s1, __const char *__s2)
731 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
732extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
733 __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
734extern char *strsep (char **__restrict __stringp,
735 __const char *__restrict __delim)
736 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
737
738
739extern char *crypt (__const char *__key, __const char *__salt)
740 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
741extern void setkey (__const char *__key) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
742extern void encrypt (char *__block, int __edflag) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
743
744extern char *__md5_crypt(const unsigned char *pw, const unsigned char *salt);
745extern char *__des_crypt(const unsigned char *pw, const unsigned char *salt);
746static u_char inv_key_perm[64];
747static u_char inv_comp_perm[56];
748static u_char u_sbox[8][64];
749static u_char un_pbox[32];
750static u_int32_t en_keysl[16], en_keysr[16];
751static u_int32_t de_keysl[16], de_keysr[16];
752static u_int32_t ip_maskl[8][256], ip_maskr[8][256];
753static u_int32_t fp_maskl[8][256], fp_maskr[8][256];
754static u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
755static u_int32_t comp_maskl[8][128], comp_maskr[8][128];
756static u_int32_t saltbits;
757static u_int32_t old_salt;
758static u_int32_t old_rawkey0, old_rawkey1;
759static u_char init_perm[64], final_perm[64];
760static u_char m_sbox[4][4096];
761static u_int32_t psbox[4][256];
762static const u_char ascii64[] =
763 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
764static 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};
770static 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};
776static const u_char key_shifts[16] = {
777 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
778};
779static 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};
785static 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};
827static 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};
831static 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};
841static const u_char bits8[8] =
842 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
843static const u_int32_t *bits28, *bits24;
844static 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}
860static 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}
955static 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}
972static 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}
1028static int
1029do_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}
1108void 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}
1122void 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}
1141char *__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}