]> git.wh0rd.org - ICEs.git/blob - 505182/ssh-keygen.i.0
more
[ICEs.git] / 505182 / ssh-keygen.i.0
1 typedef unsigned char __u_char;
2 typedef unsigned short int __u_short;
3 typedef unsigned int __u_int;
4 typedef unsigned long int __u_long;
5 typedef signed char __int8_t;
6 typedef unsigned char __uint8_t;
7 typedef signed short int __int16_t;
8 typedef unsigned short int __uint16_t;
9 typedef signed int __int32_t;
10 typedef unsigned int __uint32_t;
11 __extension__ typedef signed long long int __int64_t;
12 __extension__ typedef unsigned long long int __uint64_t;
13 __extension__ typedef long long int __quad_t;
14 __extension__ typedef unsigned long long int __u_quad_t;
15 __extension__ typedef __u_quad_t __dev_t;
16 __extension__ typedef unsigned int __uid_t;
17 __extension__ typedef unsigned int __gid_t;
18 __extension__ typedef unsigned long int __ino_t;
19 __extension__ typedef __u_quad_t __ino64_t;
20 __extension__ typedef unsigned int __mode_t;
21 __extension__ typedef unsigned int __nlink_t;
22 __extension__ typedef long int __off_t;
23 __extension__ typedef __quad_t __off64_t;
24 __extension__ typedef int __pid_t;
25 __extension__ typedef struct { int __val[2]; } __fsid_t;
26 __extension__ typedef long int __clock_t;
27 __extension__ typedef unsigned long int __rlim_t;
28 __extension__ typedef __u_quad_t __rlim64_t;
29 __extension__ typedef unsigned int __id_t;
30 __extension__ typedef long int __time_t;
31 __extension__ typedef unsigned int __useconds_t;
32 __extension__ typedef long int __suseconds_t;
33 __extension__ typedef int __daddr_t;
34 __extension__ typedef int __key_t;
35 __extension__ typedef int __clockid_t;
36 __extension__ typedef void * __timer_t;
37 __extension__ typedef long int __blksize_t;
38 __extension__ typedef long int __blkcnt_t;
39 __extension__ typedef __quad_t __blkcnt64_t;
40 __extension__ typedef unsigned long int __fsblkcnt_t;
41 __extension__ typedef __u_quad_t __fsblkcnt64_t;
42 __extension__ typedef unsigned long int __fsfilcnt_t;
43 __extension__ typedef __u_quad_t __fsfilcnt64_t;
44 __extension__ typedef int __fsword_t;
45 __extension__ typedef int __ssize_t;
46 __extension__ typedef long int __syscall_slong_t;
47 __extension__ typedef unsigned long int __syscall_ulong_t;
48 typedef __off64_t __loff_t;
49 typedef __quad_t *__qaddr_t;
50 typedef char *__caddr_t;
51 __extension__ typedef int __intptr_t;
52 __extension__ 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 __ino64_t ino_t;
62 typedef __ino64_t ino64_t;
63 typedef __dev_t dev_t;
64 typedef __gid_t gid_t;
65 typedef __mode_t mode_t;
66 typedef __nlink_t nlink_t;
67 typedef __uid_t uid_t;
68 typedef __off64_t off_t;
69 typedef __off64_t off64_t;
70 typedef __pid_t pid_t;
71 typedef __id_t id_t;
72 typedef __ssize_t ssize_t;
73 typedef __daddr_t daddr_t;
74 typedef __caddr_t caddr_t;
75 typedef __key_t key_t;
76 typedef __clock_t clock_t;
77 typedef __time_t time_t;
78 typedef __clockid_t clockid_t;
79 typedef __timer_t timer_t;
80 typedef __useconds_t useconds_t;
81 typedef __suseconds_t suseconds_t;
82 typedef unsigned int size_t;
83 typedef unsigned long int ulong;
84 typedef unsigned short int ushort;
85 typedef unsigned int uint;
86 typedef int int8_t __attribute__ ((__mode__ (__QI__)));
87 typedef int int16_t __attribute__ ((__mode__ (__HI__)));
88 typedef int int32_t __attribute__ ((__mode__ (__SI__)));
89 typedef int int64_t __attribute__ ((__mode__ (__DI__)));
90 typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
91 typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
92 typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
93 typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
94 typedef int register_t __attribute__ ((__mode__ (__word__)));
95 static __inline unsigned int
96 __bswap_32 (unsigned int __bsx)
97 {
98 return __builtin_bswap32 (__bsx);
99 }
100 static __inline __uint64_t
101 __bswap_64 (__uint64_t __bsx)
102 {
103 return __builtin_bswap64 (__bsx);
104 }
105 typedef int __sig_atomic_t;
106 typedef struct
107 {
108 unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
109 } __sigset_t;
110 typedef __sigset_t sigset_t;
111 struct timespec
112 {
113 __time_t tv_sec;
114 __syscall_slong_t tv_nsec;
115 };
116 struct timeval
117 {
118 __time_t tv_sec;
119 __suseconds_t tv_usec;
120 };
121 typedef long int __fd_mask;
122 typedef struct
123 {
124 __fd_mask fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];
125 } fd_set;
126 typedef __fd_mask fd_mask;
127 extern int select (int __nfds, fd_set *__restrict __readfds,
128 fd_set *__restrict __writefds,
129 fd_set *__restrict __exceptfds,
130 struct timeval *__restrict __timeout);
131 extern int pselect (int __nfds, fd_set *__restrict __readfds,
132 fd_set *__restrict __writefds,
133 fd_set *__restrict __exceptfds,
134 const struct timespec *__restrict __timeout,
135 const __sigset_t *__restrict __sigmask);
136 extern long int __fdelt_chk (long int __d);
137 extern long int __fdelt_warn (long int __d)
138 __attribute__((__warning__ ("bit outside of fd_set selected")));
139 __extension__
140 extern unsigned int gnu_dev_major (unsigned long long int __dev)
141 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
142 __extension__
143 extern unsigned int gnu_dev_minor (unsigned long long int __dev)
144 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
145 __extension__
146 extern unsigned long long int gnu_dev_makedev (unsigned int __major,
147 unsigned int __minor)
148 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
149 __extension__ extern __inline __attribute__ ((__const__)) unsigned int
150 __attribute__ ((__nothrow__ , __leaf__)) gnu_dev_major (unsigned long long int __dev)
151 {
152 return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
153 }
154 __extension__ extern __inline __attribute__ ((__const__)) unsigned int
155 __attribute__ ((__nothrow__ , __leaf__)) gnu_dev_minor (unsigned long long int __dev)
156 {
157 return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
158 }
159 __extension__ extern __inline __attribute__ ((__const__)) unsigned long long int
160 __attribute__ ((__nothrow__ , __leaf__)) gnu_dev_makedev (unsigned int __major, unsigned int __minor)
161 {
162 return ((__minor & 0xff) | ((__major & 0xfff) << 8)
163 | (((unsigned long long int) (__minor & ~0xff)) << 12)
164 | (((unsigned long long int) (__major & ~0xfff)) << 32));
165 }
166 typedef __blksize_t blksize_t;
167 typedef __blkcnt64_t blkcnt_t;
168 typedef __fsblkcnt64_t fsblkcnt_t;
169 typedef __fsfilcnt64_t fsfilcnt_t;
170 typedef __blkcnt64_t blkcnt64_t;
171 typedef __fsblkcnt64_t fsblkcnt64_t;
172 typedef __fsfilcnt64_t fsfilcnt64_t;
173 typedef unsigned long int pthread_t;
174 union pthread_attr_t
175 {
176 char __size[36];
177 long int __align;
178 };
179 typedef union pthread_attr_t pthread_attr_t;
180 typedef struct __pthread_internal_slist
181 {
182 struct __pthread_internal_slist *__next;
183 } __pthread_slist_t;
184 typedef union
185 {
186 struct __pthread_mutex_s
187 {
188 int __lock __attribute__ ((aligned(16)));
189 unsigned int __count;
190 int __owner;
191 int __kind;
192 int __compat_padding[4];
193 unsigned int __nusers;
194 __extension__ union
195 {
196 int __spins;
197 __pthread_slist_t __list;
198 };
199 int __reserved1;
200 int __reserved2;
201 } __data;
202 char __size[48];
203 long int __align;
204 } pthread_mutex_t;
205 typedef union
206 {
207 char __size[4];
208 long int __align;
209 } pthread_mutexattr_t;
210 typedef union
211 {
212 struct
213 {
214 int __lock __attribute__ ((aligned(16)));
215 int __initializer;
216 unsigned int __futex;
217 void *__mutex;
218 __extension__ unsigned long long int __total_seq;
219 __extension__ unsigned long long int __wakeup_seq;
220 __extension__ unsigned long long int __woken_seq;
221 unsigned int __nwaiters;
222 unsigned int __broadcast_seq;
223 } __data;
224 char __size[48];
225 __extension__ long long int __align;
226 } pthread_cond_t;
227 typedef union
228 {
229 char __size[4];
230 long int __align;
231 } pthread_condattr_t;
232 typedef unsigned int pthread_key_t;
233 typedef int pthread_once_t;
234 typedef union
235 {
236 struct
237 {
238 int __compat_padding[4] __attribute__ ((aligned(16)));
239 int __lock;
240 unsigned int __nr_readers;
241 unsigned int __readers_wakeup;
242 unsigned int __writer_wakeup;
243 unsigned int __nr_readers_queued;
244 unsigned int __nr_writers_queued;
245 int __writer;
246 int __reserved1;
247 unsigned char __pad2;
248 unsigned char __pad1;
249 unsigned char __shared;
250 unsigned char __flags;
251 int __reserved2;
252 int __reserved3;
253 int __reserved4;
254 } __data;
255 char __size[64];
256 long int __align;
257 } pthread_rwlock_t;
258 typedef union
259 {
260 char __size[8];
261 long int __align;
262 } pthread_rwlockattr_t;
263 typedef volatile int pthread_spinlock_t;
264 typedef union
265 {
266 char __size[48];
267 long int __align;
268 } pthread_barrier_t;
269 typedef union
270 {
271 char __size[4];
272 int __align;
273 } pthread_barrierattr_t;
274 struct iovec
275 {
276 void *iov_base;
277 size_t iov_len;
278 };
279 extern ssize_t process_vm_readv (pid_t __pid, const struct iovec *__lvec,
280 unsigned long int __liovcnt,
281 const struct iovec *__rvec,
282 unsigned long int __riovcnt,
283 unsigned long int __flags)
284 __attribute__ ((__nothrow__ , __leaf__));
285 extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec,
286 unsigned long int __liovcnt,
287 const struct iovec *__rvec,
288 unsigned long int __riovcnt,
289 unsigned long int __flags)
290 __attribute__ ((__nothrow__ , __leaf__));
291 extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count)
292 __attribute__ ((__warn_unused_result__));
293 extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count)
294 __attribute__ ((__warn_unused_result__));
295 extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __asm__ ("" "preadv64")
296 __attribute__ ((__warn_unused_result__));
297 extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __asm__ ("" "pwritev64")
298 __attribute__ ((__warn_unused_result__));
299 extern ssize_t preadv64 (int __fd, const struct iovec *__iovec, int __count,
300 __off64_t __offset) __attribute__ ((__warn_unused_result__));
301 extern ssize_t pwritev64 (int __fd, const struct iovec *__iovec, int __count,
302 __off64_t __offset) __attribute__ ((__warn_unused_result__));
303 typedef __socklen_t socklen_t;
304 enum __socket_type
305 {
306 SOCK_STREAM = 1,
307 SOCK_DGRAM = 2,
308 SOCK_RAW = 3,
309 SOCK_RDM = 4,
310 SOCK_SEQPACKET = 5,
311 SOCK_DCCP = 6,
312 SOCK_PACKET = 10,
313 SOCK_CLOEXEC = 010000000,
314 SOCK_NONBLOCK = 0x40000000
315 };
316 typedef unsigned short int sa_family_t;
317 struct sockaddr
318 {
319 sa_family_t sa_family;
320 char sa_data[14];
321 };
322 struct sockaddr_storage
323 {
324 sa_family_t ss_family;
325 unsigned long int __ss_align;
326 char __ss_padding[(128 - (2 * sizeof (unsigned long int)))];
327 };
328 enum
329 {
330 MSG_OOB = 0x01,
331 MSG_PEEK = 0x02,
332 MSG_DONTROUTE = 0x04,
333 MSG_TRYHARD = MSG_DONTROUTE,
334 MSG_CTRUNC = 0x08,
335 MSG_PROXY = 0x10,
336 MSG_TRUNC = 0x20,
337 MSG_DONTWAIT = 0x40,
338 MSG_EOR = 0x80,
339 MSG_WAITALL = 0x100,
340 MSG_FIN = 0x200,
341 MSG_SYN = 0x400,
342 MSG_CONFIRM = 0x800,
343 MSG_RST = 0x1000,
344 MSG_ERRQUEUE = 0x2000,
345 MSG_NOSIGNAL = 0x4000,
346 MSG_MORE = 0x8000,
347 MSG_WAITFORONE = 0x10000,
348 MSG_CMSG_CLOEXEC = 0x40000000
349 };
350 struct msghdr
351 {
352 void *msg_name;
353 socklen_t msg_namelen;
354 struct iovec *msg_iov;
355 size_t msg_iovlen;
356 void *msg_control;
357 size_t msg_controllen;
358 int msg_flags;
359 };
360 struct cmsghdr
361 {
362 size_t cmsg_len;
363 int cmsg_level;
364 int cmsg_type;
365 __extension__ unsigned char __cmsg_data [];
366 };
367 extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
368 struct cmsghdr *__cmsg) __attribute__ ((__nothrow__ , __leaf__));
369 extern __inline struct cmsghdr *
370 __attribute__ ((__nothrow__ , __leaf__)) __cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg)
371 {
372 if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
373 return (struct cmsghdr *) 0;
374 __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
375 + (((__cmsg->cmsg_len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)));
376 if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
377 + __mhdr->msg_controllen)
378 || ((unsigned char *) __cmsg + (((__cmsg->cmsg_len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
379 > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
380 return (struct cmsghdr *) 0;
381 return __cmsg;
382 }
383 enum
384 {
385 SCM_RIGHTS = 0x01
386 , SCM_CREDENTIALS = 0x02
387 };
388 struct ucred
389 {
390 pid_t pid;
391 uid_t uid;
392 gid_t gid;
393 };
394 struct linger
395 {
396 int l_onoff;
397 int l_linger;
398 };
399 struct osockaddr
400 {
401 unsigned short int sa_family;
402 unsigned char sa_data[14];
403 };
404 enum
405 {
406 SHUT_RD = 0,
407 SHUT_WR,
408 SHUT_RDWR
409 };
410 typedef union { struct sockaddr *__restrict __sockaddr__; struct sockaddr_at *__restrict __sockaddr_at__; struct sockaddr_ax25 *__restrict __sockaddr_ax25__; struct sockaddr_dl *__restrict __sockaddr_dl__; struct sockaddr_eon *__restrict __sockaddr_eon__; struct sockaddr_in *__restrict __sockaddr_in__; struct sockaddr_in6 *__restrict __sockaddr_in6__; struct sockaddr_inarp *__restrict __sockaddr_inarp__; struct sockaddr_ipx *__restrict __sockaddr_ipx__; struct sockaddr_iso *__restrict __sockaddr_iso__; struct sockaddr_ns *__restrict __sockaddr_ns__; struct sockaddr_un *__restrict __sockaddr_un__; struct sockaddr_x25 *__restrict __sockaddr_x25__;
411 } __SOCKADDR_ARG __attribute__ ((__transparent_union__));
412 typedef union { const struct sockaddr *__restrict __sockaddr__; const struct sockaddr_at *__restrict __sockaddr_at__; const struct sockaddr_ax25 *__restrict __sockaddr_ax25__; const struct sockaddr_dl *__restrict __sockaddr_dl__; const struct sockaddr_eon *__restrict __sockaddr_eon__; const struct sockaddr_in *__restrict __sockaddr_in__; const struct sockaddr_in6 *__restrict __sockaddr_in6__; const struct sockaddr_inarp *__restrict __sockaddr_inarp__; const struct sockaddr_ipx *__restrict __sockaddr_ipx__; const struct sockaddr_iso *__restrict __sockaddr_iso__; const struct sockaddr_ns *__restrict __sockaddr_ns__; const struct sockaddr_un *__restrict __sockaddr_un__; const struct sockaddr_x25 *__restrict __sockaddr_x25__;
413 } __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));
414 struct mmsghdr
415 {
416 struct msghdr msg_hdr;
417 unsigned int msg_len;
418 };
419 extern int socket (int __domain, int __type, int __protocol) __attribute__ ((__nothrow__ , __leaf__));
420 extern int socketpair (int __domain, int __type, int __protocol,
421 int __fds[2]) __attribute__ ((__nothrow__ , __leaf__));
422 extern int bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
423 __attribute__ ((__nothrow__ , __leaf__));
424 extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
425 socklen_t *__restrict __len) __attribute__ ((__nothrow__ , __leaf__));
426 extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
427 extern int getpeername (int __fd, __SOCKADDR_ARG __addr,
428 socklen_t *__restrict __len) __attribute__ ((__nothrow__ , __leaf__));
429 extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags);
430 extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);
431 extern ssize_t sendto (int __fd, const void *__buf, size_t __n,
432 int __flags, __CONST_SOCKADDR_ARG __addr,
433 socklen_t __addr_len);
434 extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
435 int __flags, __SOCKADDR_ARG __addr,
436 socklen_t *__restrict __addr_len);
437 extern ssize_t sendmsg (int __fd, const struct msghdr *__message,
438 int __flags);
439 extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
440 unsigned int __vlen, int __flags);
441 extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
442 extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
443 unsigned int __vlen, int __flags,
444 const struct timespec *__tmo);
445 extern int getsockopt (int __fd, int __level, int __optname,
446 void *__restrict __optval,
447 socklen_t *__restrict __optlen) __attribute__ ((__nothrow__ , __leaf__));
448 extern int setsockopt (int __fd, int __level, int __optname,
449 const void *__optval, socklen_t __optlen) __attribute__ ((__nothrow__ , __leaf__));
450 extern int listen (int __fd, int __n) __attribute__ ((__nothrow__ , __leaf__));
451 extern int accept (int __fd, __SOCKADDR_ARG __addr,
452 socklen_t *__restrict __addr_len);
453 extern int accept4 (int __fd, __SOCKADDR_ARG __addr,
454 socklen_t *__restrict __addr_len, int __flags);
455 extern int shutdown (int __fd, int __how) __attribute__ ((__nothrow__ , __leaf__));
456 extern int sockatmark (int __fd) __attribute__ ((__nothrow__ , __leaf__));
457 extern int isfdtype (int __fd, int __fdtype) __attribute__ ((__nothrow__ , __leaf__));
458 extern ssize_t __recv_chk (int __fd, void *__buf, size_t __n, size_t __buflen,
459 int __flags);
460 extern ssize_t __recv_alias (int __fd, void *__buf, size_t __n, int __flags) __asm__ ("" "recv")
461 ;
462 extern ssize_t __recv_chk_warn (int __fd, void *__buf, size_t __n, size_t __buflen, int __flags) __asm__ ("" "__recv_chk")
463 __attribute__((__warning__ ("recv called with bigger length than size of destination " "buffer")))
464 ;
465 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) ssize_t
466 recv (int __fd, void *__buf, size_t __n, int __flags)
467 {
468 if (__builtin_object_size (__buf, 0) != (size_t) -1)
469 {
470 if (!__builtin_constant_p (__n))
471 return __recv_chk (__fd, __buf, __n, __builtin_object_size (__buf, 0), __flags);
472 if (__n > __builtin_object_size (__buf, 0))
473 return __recv_chk_warn (__fd, __buf, __n, __builtin_object_size (__buf, 0), __flags);
474 }
475 return __recv_alias (__fd, __buf, __n, __flags);
476 }
477 extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n,
478 size_t __buflen, int __flags,
479 __SOCKADDR_ARG __addr,
480 socklen_t *__restrict __addr_len);
481 extern ssize_t __recvfrom_alias (int __fd, void *__restrict __buf, size_t __n, int __flags, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len) __asm__ ("" "recvfrom")
482 ;
483 extern ssize_t __recvfrom_chk_warn (int __fd, void *__restrict __buf, size_t __n, size_t __buflen, int __flags, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len) __asm__ ("" "__recvfrom_chk")
484 __attribute__((__warning__ ("recvfrom called with bigger length than size of " "destination buffer")))
485 ;
486 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) ssize_t
487 recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
488 __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len)
489 {
490 if (__builtin_object_size (__buf, 0) != (size_t) -1)
491 {
492 if (!__builtin_constant_p (__n))
493 return __recvfrom_chk (__fd, __buf, __n, __builtin_object_size (__buf, 0), __flags,
494 __addr, __addr_len);
495 if (__n > __builtin_object_size (__buf, 0))
496 return __recvfrom_chk_warn (__fd, __buf, __n, __builtin_object_size (__buf, 0), __flags,
497 __addr, __addr_len);
498 }
499 return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len);
500 }
501 struct ttyent {
502 char *ty_name;
503 char *ty_getty;
504 char *ty_type;
505 int ty_status;
506 char *ty_window;
507 char *ty_comment;
508 };
509 extern struct ttyent *getttyent (void) __attribute__ ((__nothrow__ , __leaf__));
510 extern struct ttyent *getttynam (const char *__tty) __attribute__ ((__nothrow__ , __leaf__));
511 extern int setttyent (void) __attribute__ ((__nothrow__ , __leaf__));
512 extern int endttyent (void) __attribute__ ((__nothrow__ , __leaf__));
513 struct utimbuf
514 {
515 __time_t actime;
516 __time_t modtime;
517 };
518 extern int utime (const char *__file,
519 const struct utimbuf *__file_times)
520 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
521 extern int bcmp (const void *__s1, const void *__s2, size_t __n)
522 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__));
523 extern void bcopy (const void *__src, void *__dest, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
524 extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
525 extern char *index (const char *__s, int __c)
526 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
527 extern char *rindex (const char *__s, int __c)
528 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
529 extern int ffs (int __i) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((const));
530 extern int strcasecmp (const char *__s1, const char *__s2)
531 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__));
532 extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
533 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__));
534 typedef struct __locale_struct
535 {
536 struct __locale_data *__locales[13];
537 const unsigned short int *__ctype_b;
538 const int *__ctype_tolower;
539 const int *__ctype_toupper;
540 const char *__names[13];
541 } *__locale_t;
542 typedef __locale_t locale_t;
543 extern int strcasecmp_l (const char *__s1, const char *__s2, __locale_t __loc)
544 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
545 extern int strncasecmp_l (const char *__s1, const char *__s2,
546 size_t __n, __locale_t __loc)
547 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4)));
548 struct timezone
549 {
550 int tz_minuteswest;
551 int tz_dsttime;
552 };
553 typedef struct timezone *__restrict __timezone_ptr_t;
554 extern int gettimeofday (struct timeval *__restrict __tv,
555 __timezone_ptr_t __tz) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
556 extern int settimeofday (const struct timeval *__tv,
557 const struct timezone *__tz)
558 __attribute__ ((__nothrow__ , __leaf__));
559 extern int adjtime (const struct timeval *__delta,
560 struct timeval *__olddelta) __attribute__ ((__nothrow__ , __leaf__));
561 enum __itimer_which
562 {
563 ITIMER_REAL = 0,
564 ITIMER_VIRTUAL = 1,
565 ITIMER_PROF = 2
566 };
567 struct itimerval
568 {
569 struct timeval it_interval;
570 struct timeval it_value;
571 };
572 typedef enum __itimer_which __itimer_which_t;
573 extern int getitimer (__itimer_which_t __which,
574 struct itimerval *__value) __attribute__ ((__nothrow__ , __leaf__));
575 extern int setitimer (__itimer_which_t __which,
576 const struct itimerval *__restrict __new,
577 struct itimerval *__restrict __old) __attribute__ ((__nothrow__ , __leaf__));
578 extern int utimes (const char *__file, const struct timeval __tvp[2])
579 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
580 extern int lutimes (const char *__file, const struct timeval __tvp[2])
581 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
582 extern int futimes (int __fd, const struct timeval __tvp[2]) __attribute__ ((__nothrow__ , __leaf__));
583 extern int futimesat (int __fd, const char *__file,
584 const struct timeval __tvp[2]) __attribute__ ((__nothrow__ , __leaf__));
585 struct lastlog
586 {
587 __time_t ll_time;
588 char ll_line[32];
589 char ll_host[256];
590 };
591 struct exit_status
592 {
593 short int e_termination;
594 short int e_exit;
595 };
596 struct utmp
597 {
598 short int ut_type;
599 pid_t ut_pid;
600 char ut_line[32];
601 char ut_id[4];
602 char ut_user[32];
603 char ut_host[256];
604 struct exit_status ut_exit;
605 long int ut_session;
606 struct timeval ut_tv;
607 int32_t ut_addr_v6[4];
608 char __unused[20];
609 };
610 extern int login_tty (int __fd) __attribute__ ((__nothrow__ , __leaf__));
611 extern void login (const struct utmp *__entry) __attribute__ ((__nothrow__ , __leaf__));
612 extern int logout (const char *__ut_line) __attribute__ ((__nothrow__ , __leaf__));
613 extern void logwtmp (const char *__ut_line, const char *__ut_name,
614 const char *__ut_host) __attribute__ ((__nothrow__ , __leaf__));
615 extern void updwtmp (const char *__wtmp_file, const struct utmp *__utmp)
616 __attribute__ ((__nothrow__ , __leaf__));
617 extern int utmpname (const char *__file) __attribute__ ((__nothrow__ , __leaf__));
618 extern struct utmp *getutent (void) __attribute__ ((__nothrow__ , __leaf__));
619 extern void setutent (void) __attribute__ ((__nothrow__ , __leaf__));
620 extern void endutent (void) __attribute__ ((__nothrow__ , __leaf__));
621 extern struct utmp *getutid (const struct utmp *__id) __attribute__ ((__nothrow__ , __leaf__));
622 extern struct utmp *getutline (const struct utmp *__line) __attribute__ ((__nothrow__ , __leaf__));
623 extern struct utmp *pututline (const struct utmp *__utmp_ptr) __attribute__ ((__nothrow__ , __leaf__));
624 extern int getutent_r (struct utmp *__buffer, struct utmp **__result) __attribute__ ((__nothrow__ , __leaf__));
625 extern int getutid_r (const struct utmp *__id, struct utmp *__buffer,
626 struct utmp **__result) __attribute__ ((__nothrow__ , __leaf__));
627 extern int getutline_r (const struct utmp *__line,
628 struct utmp *__buffer, struct utmp **__result) __attribute__ ((__nothrow__ , __leaf__));
629 struct __exit_status
630 {
631 short int e_termination;
632 short int e_exit;
633 };
634 struct utmpx
635 {
636 short int ut_type;
637 __pid_t ut_pid;
638 char ut_line[32];
639 char ut_id[4];
640 char ut_user[32];
641 char ut_host[256];
642 struct __exit_status ut_exit;
643 long int ut_session;
644 struct timeval ut_tv;
645 __int32_t ut_addr_v6[4];
646 char __unused[20];
647 };
648 struct utmp;
649 extern void setutxent (void);
650 extern void endutxent (void);
651 extern struct utmpx *getutxent (void);
652 extern struct utmpx *getutxid (const struct utmpx *__id);
653 extern struct utmpx *getutxline (const struct utmpx *__line);
654 extern struct utmpx *pututxline (const struct utmpx *__utmpx);
655 extern int utmpxname (const char *__file);
656 extern void updwtmpx (const char *__wtmpx_file,
657 const struct utmpx *__utmpx);
658 extern void getutmp (const struct utmpx *__utmpx,
659 struct utmp *__utmp);
660 extern void getutmpx (const struct utmp *__utmp, struct utmpx *__utmpx);
661 typedef unsigned char uint8_t;
662 typedef unsigned short int uint16_t;
663 typedef unsigned int uint32_t;
664 __extension__
665 typedef unsigned long long int uint64_t;
666 typedef signed char int_least8_t;
667 typedef short int int_least16_t;
668 typedef int int_least32_t;
669 __extension__
670 typedef long long int int_least64_t;
671 typedef unsigned char uint_least8_t;
672 typedef unsigned short int uint_least16_t;
673 typedef unsigned int uint_least32_t;
674 __extension__
675 typedef unsigned long long int uint_least64_t;
676 typedef signed char int_fast8_t;
677 typedef int int_fast16_t;
678 typedef int int_fast32_t;
679 __extension__
680 typedef long long int int_fast64_t;
681 typedef unsigned char uint_fast8_t;
682 typedef unsigned int uint_fast16_t;
683 typedef unsigned int uint_fast32_t;
684 __extension__
685 typedef unsigned long long int uint_fast64_t;
686 typedef int intptr_t;
687 typedef unsigned int uintptr_t;
688 __extension__
689 typedef long long int intmax_t;
690 __extension__
691 typedef unsigned long long int uintmax_t;
692 typedef unsigned char cc_t;
693 typedef unsigned int speed_t;
694 typedef unsigned int tcflag_t;
695 struct termios
696 {
697 tcflag_t c_iflag;
698 tcflag_t c_oflag;
699 tcflag_t c_cflag;
700 tcflag_t c_lflag;
701 cc_t c_line;
702 cc_t c_cc[32];
703 speed_t c_ispeed;
704 speed_t c_ospeed;
705 };
706 extern speed_t cfgetospeed (const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
707 extern speed_t cfgetispeed (const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
708 extern int cfsetospeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));
709 extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));
710 extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));
711 extern int tcgetattr (int __fd, struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
712 extern int tcsetattr (int __fd, int __optional_actions,
713 const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
714 extern void cfmakeraw (struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
715 extern int tcsendbreak (int __fd, int __duration) __attribute__ ((__nothrow__ , __leaf__));
716 extern int tcdrain (int __fd);
717 extern int tcflush (int __fd, int __queue_selector) __attribute__ ((__nothrow__ , __leaf__));
718 extern int tcflow (int __fd, int __action) __attribute__ ((__nothrow__ , __leaf__));
719 extern __pid_t tcgetsid (int __fd) __attribute__ ((__nothrow__ , __leaf__));
720 struct stat
721 {
722 __dev_t st_dev;
723 unsigned short int __pad1;
724 __ino_t __st_ino;
725 __mode_t st_mode;
726 __nlink_t st_nlink;
727 __uid_t st_uid;
728 __gid_t st_gid;
729 __dev_t st_rdev;
730 unsigned short int __pad2;
731 __off64_t st_size;
732 __blksize_t st_blksize;
733 __blkcnt64_t st_blocks;
734 struct timespec st_atim;
735 struct timespec st_mtim;
736 struct timespec st_ctim;
737 __ino64_t st_ino;
738 };
739 struct stat64
740 {
741 __dev_t st_dev;
742 unsigned int __pad1;
743 __ino_t __st_ino;
744 __mode_t st_mode;
745 __nlink_t st_nlink;
746 __uid_t st_uid;
747 __gid_t st_gid;
748 __dev_t st_rdev;
749 unsigned int __pad2;
750 __off64_t st_size;
751 __blksize_t st_blksize;
752 __blkcnt64_t st_blocks;
753 struct timespec st_atim;
754 struct timespec st_mtim;
755 struct timespec st_ctim;
756 __ino64_t st_ino;
757 };
758 extern int stat (const char *__restrict __file, struct stat *__restrict __buf) __asm__ ("" "stat64") __attribute__ ((__nothrow__ , __leaf__))
759 __attribute__ ((__nonnull__ (1, 2)));
760 extern int fstat (int __fd, struct stat *__buf) __asm__ ("" "fstat64") __attribute__ ((__nothrow__ , __leaf__))
761 __attribute__ ((__nonnull__ (2)));
762 extern int stat64 (const char *__restrict __file,
763 struct stat64 *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
764 extern int fstat64 (int __fd, struct stat64 *__buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
765 extern int fstatat (int __fd, const char *__restrict __file, struct stat *__restrict __buf, int __flag) __asm__ ("" "fstatat64") __attribute__ ((__nothrow__ , __leaf__))
766 __attribute__ ((__nonnull__ (2, 3)));
767 extern int fstatat64 (int __fd, const char *__restrict __file,
768 struct stat64 *__restrict __buf, int __flag)
769 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
770 extern int lstat (const char *__restrict __file, struct stat *__restrict __buf) __asm__ ("" "lstat64") __attribute__ ((__nothrow__ , __leaf__))
771 __attribute__ ((__nonnull__ (1, 2)));
772 extern int lstat64 (const char *__restrict __file,
773 struct stat64 *__restrict __buf)
774 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
775 extern int chmod (const char *__file, __mode_t __mode)
776 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
777 extern int lchmod (const char *__file, __mode_t __mode)
778 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
779 extern int fchmod (int __fd, __mode_t __mode) __attribute__ ((__nothrow__ , __leaf__));
780 extern int fchmodat (int __fd, const char *__file, __mode_t __mode,
781 int __flag)
782 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
783 extern __mode_t umask (__mode_t __mask) __attribute__ ((__nothrow__ , __leaf__));
784 extern __mode_t getumask (void) __attribute__ ((__nothrow__ , __leaf__));
785 extern int mkdir (const char *__path, __mode_t __mode)
786 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
787 extern int mkdirat (int __fd, const char *__path, __mode_t __mode)
788 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
789 extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev)
790 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
791 extern int mknodat (int __fd, const char *__path, __mode_t __mode,
792 __dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
793 extern int mkfifo (const char *__path, __mode_t __mode)
794 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
795 extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
796 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
797 extern int utimensat (int __fd, const char *__path,
798 const struct timespec __times[2],
799 int __flags)
800 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
801 extern int futimens (int __fd, const struct timespec __times[2]) __attribute__ ((__nothrow__ , __leaf__));
802 extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf) __asm__ ("" "__fxstat64") __attribute__ ((__nothrow__ , __leaf__))
803 __attribute__ ((__nonnull__ (3)));
804 extern int __xstat (int __ver, const char *__filename, struct stat *__stat_buf) __asm__ ("" "__xstat64") __attribute__ ((__nothrow__ , __leaf__))
805 __attribute__ ((__nonnull__ (2, 3)));
806 extern int __lxstat (int __ver, const char *__filename, struct stat *__stat_buf) __asm__ ("" "__lxstat64") __attribute__ ((__nothrow__ , __leaf__))
807 __attribute__ ((__nonnull__ (2, 3)));
808 extern int __fxstatat (int __ver, int __fildes, const char *__filename, struct stat *__stat_buf, int __flag) __asm__ ("" "__fxstatat64") __attribute__ ((__nothrow__ , __leaf__))
809 __attribute__ ((__nonnull__ (3, 4)));
810 extern int __fxstat64 (int __ver, int __fildes, struct stat64 *__stat_buf)
811 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3)));
812 extern int __xstat64 (int __ver, const char *__filename,
813 struct stat64 *__stat_buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
814 extern int __lxstat64 (int __ver, const char *__filename,
815 struct stat64 *__stat_buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
816 extern int __fxstatat64 (int __ver, int __fildes, const char *__filename,
817 struct stat64 *__stat_buf, int __flag)
818 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4)));
819 extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
820 __dev_t *__dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));
821 extern int __xmknodat (int __ver, int __fd, const char *__path,
822 __mode_t __mode, __dev_t *__dev)
823 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 5)));
824 extern __inline int
825 __attribute__ ((__nothrow__ , __leaf__)) stat (const char *__path, struct stat *__statbuf)
826 {
827 return __xstat (3, __path, __statbuf);
828 }
829 extern __inline int
830 __attribute__ ((__nothrow__ , __leaf__)) lstat (const char *__path, struct stat *__statbuf)
831 {
832 return __lxstat (3, __path, __statbuf);
833 }
834 extern __inline int
835 __attribute__ ((__nothrow__ , __leaf__)) fstat (int __fd, struct stat *__statbuf)
836 {
837 return __fxstat (3, __fd, __statbuf);
838 }
839 extern __inline int
840 __attribute__ ((__nothrow__ , __leaf__)) fstatat (int __fd, const char *__filename, struct stat *__statbuf, int __flag)
841 {
842 return __fxstatat (3, __fd, __filename, __statbuf, __flag);
843 }
844 extern __inline int
845 __attribute__ ((__nothrow__ , __leaf__)) mknod (const char *__path, __mode_t __mode, __dev_t __dev)
846 {
847 return __xmknod (1, __path, __mode, &__dev);
848 }
849 extern __inline int
850 __attribute__ ((__nothrow__ , __leaf__)) mknodat (int __fd, const char *__path, __mode_t __mode, __dev_t __dev)
851 {
852 return __xmknodat (1, __fd, __path, __mode, &__dev);
853 }
854 extern __inline int
855 __attribute__ ((__nothrow__ , __leaf__)) stat64 (const char *__path, struct stat64 *__statbuf)
856 {
857 return __xstat64 (3, __path, __statbuf);
858 }
859 extern __inline int
860 __attribute__ ((__nothrow__ , __leaf__)) lstat64 (const char *__path, struct stat64 *__statbuf)
861 {
862 return __lxstat64 (3, __path, __statbuf);
863 }
864 extern __inline int
865 __attribute__ ((__nothrow__ , __leaf__)) fstat64 (int __fd, struct stat64 *__statbuf)
866 {
867 return __fxstat64 (3, __fd, __statbuf);
868 }
869 extern __inline int
870 __attribute__ ((__nothrow__ , __leaf__)) fstatat64 (int __fd, const char *__filename, struct stat64 *__statbuf, int __flag)
871 {
872 return __fxstatat64 (3, __fd, __filename, __statbuf, __flag);
873 }
874 extern void * mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset) __asm__ ("" "mmap64") __attribute__ ((__nothrow__ , __leaf__))
875 ;
876 extern void *mmap64 (void *__addr, size_t __len, int __prot,
877 int __flags, int __fd, __off64_t __offset) __attribute__ ((__nothrow__ , __leaf__));
878 extern int munmap (void *__addr, size_t __len) __attribute__ ((__nothrow__ , __leaf__));
879 extern int mprotect (void *__addr, size_t __len, int __prot) __attribute__ ((__nothrow__ , __leaf__));
880 extern int msync (void *__addr, size_t __len, int __flags);
881 extern int madvise (void *__addr, size_t __len, int __advice) __attribute__ ((__nothrow__ , __leaf__));
882 extern int posix_madvise (void *__addr, size_t __len, int __advice) __attribute__ ((__nothrow__ , __leaf__));
883 extern int mlock (const void *__addr, size_t __len) __attribute__ ((__nothrow__ , __leaf__));
884 extern int munlock (const void *__addr, size_t __len) __attribute__ ((__nothrow__ , __leaf__));
885 extern int mlockall (int __flags) __attribute__ ((__nothrow__ , __leaf__));
886 extern int munlockall (void) __attribute__ ((__nothrow__ , __leaf__));
887 extern int mincore (void *__start, size_t __len, unsigned char *__vec)
888 __attribute__ ((__nothrow__ , __leaf__));
889 extern void *mremap (void *__addr, size_t __old_len, size_t __new_len,
890 int __flags, ...) __attribute__ ((__nothrow__ , __leaf__));
891 extern int remap_file_pages (void *__start, size_t __size, int __prot,
892 size_t __pgoff, int __flags) __attribute__ ((__nothrow__ , __leaf__));
893 extern int shm_open (const char *__name, int __oflag, mode_t __mode);
894 extern int shm_unlink (const char *__name);
895 enum
896 {
897 IPPROTO_IP = 0,
898 IPPROTO_HOPOPTS = 0,
899 IPPROTO_ICMP = 1,
900 IPPROTO_IGMP = 2,
901 IPPROTO_IPIP = 4,
902 IPPROTO_TCP = 6,
903 IPPROTO_EGP = 8,
904 IPPROTO_PUP = 12,
905 IPPROTO_UDP = 17,
906 IPPROTO_IDP = 22,
907 IPPROTO_TP = 29,
908 IPPROTO_DCCP = 33,
909 IPPROTO_IPV6 = 41,
910 IPPROTO_ROUTING = 43,
911 IPPROTO_FRAGMENT = 44,
912 IPPROTO_RSVP = 46,
913 IPPROTO_GRE = 47,
914 IPPROTO_ESP = 50,
915 IPPROTO_AH = 51,
916 IPPROTO_ICMPV6 = 58,
917 IPPROTO_NONE = 59,
918 IPPROTO_DSTOPTS = 60,
919 IPPROTO_MTP = 92,
920 IPPROTO_ENCAP = 98,
921 IPPROTO_PIM = 103,
922 IPPROTO_COMP = 108,
923 IPPROTO_SCTP = 132,
924 IPPROTO_UDPLITE = 136,
925 IPPROTO_RAW = 255,
926 IPPROTO_MAX
927 };
928 typedef uint16_t in_port_t;
929 enum
930 {
931 IPPORT_ECHO = 7,
932 IPPORT_DISCARD = 9,
933 IPPORT_SYSTAT = 11,
934 IPPORT_DAYTIME = 13,
935 IPPORT_NETSTAT = 15,
936 IPPORT_FTP = 21,
937 IPPORT_TELNET = 23,
938 IPPORT_SMTP = 25,
939 IPPORT_TIMESERVER = 37,
940 IPPORT_NAMESERVER = 42,
941 IPPORT_WHOIS = 43,
942 IPPORT_MTP = 57,
943 IPPORT_TFTP = 69,
944 IPPORT_RJE = 77,
945 IPPORT_FINGER = 79,
946 IPPORT_TTYLINK = 87,
947 IPPORT_SUPDUP = 95,
948 IPPORT_EXECSERVER = 512,
949 IPPORT_LOGINSERVER = 513,
950 IPPORT_CMDSERVER = 514,
951 IPPORT_EFSSERVER = 520,
952 IPPORT_BIFFUDP = 512,
953 IPPORT_WHOSERVER = 513,
954 IPPORT_ROUTESERVER = 520,
955 IPPORT_RESERVED = 1024,
956 IPPORT_USERRESERVED = 5000
957 };
958 typedef uint32_t in_addr_t;
959 struct in_addr
960 {
961 in_addr_t s_addr;
962 };
963 struct in6_addr
964 {
965 union
966 {
967 uint8_t __u6_addr8[16];
968 uint16_t __u6_addr16[8];
969 uint32_t __u6_addr32[4];
970 } __in6_u;
971 };
972 extern const struct in6_addr in6addr_any;
973 extern const struct in6_addr in6addr_loopback;
974 struct sockaddr_in
975 {
976 sa_family_t sin_family;
977 in_port_t sin_port;
978 struct in_addr sin_addr;
979 unsigned char sin_zero[sizeof (struct sockaddr) -
980 (sizeof (unsigned short int)) -
981 sizeof (in_port_t) -
982 sizeof (struct in_addr)];
983 };
984 struct sockaddr_in6
985 {
986 sa_family_t sin6_family;
987 in_port_t sin6_port;
988 uint32_t sin6_flowinfo;
989 struct in6_addr sin6_addr;
990 uint32_t sin6_scope_id;
991 };
992 struct ip_mreq
993 {
994 struct in_addr imr_multiaddr;
995 struct in_addr imr_interface;
996 };
997 struct ip_mreq_source
998 {
999 struct in_addr imr_multiaddr;
1000 struct in_addr imr_interface;
1001 struct in_addr imr_sourceaddr;
1002 };
1003 struct ipv6_mreq
1004 {
1005 struct in6_addr ipv6mr_multiaddr;
1006 unsigned int ipv6mr_interface;
1007 };
1008 struct group_req
1009 {
1010 uint32_t gr_interface;
1011 struct sockaddr_storage gr_group;
1012 };
1013 struct group_source_req
1014 {
1015 uint32_t gsr_interface;
1016 struct sockaddr_storage gsr_group;
1017 struct sockaddr_storage gsr_source;
1018 };
1019 struct ip_msfilter
1020 {
1021 struct in_addr imsf_multiaddr;
1022 struct in_addr imsf_interface;
1023 uint32_t imsf_fmode;
1024 uint32_t imsf_numsrc;
1025 struct in_addr imsf_slist[1];
1026 };
1027 struct group_filter
1028 {
1029 uint32_t gf_interface;
1030 struct sockaddr_storage gf_group;
1031 uint32_t gf_fmode;
1032 uint32_t gf_numsrc;
1033 struct sockaddr_storage gf_slist[1];
1034 };
1035 struct ip_opts
1036 {
1037 struct in_addr ip_dst;
1038 char ip_opts[40];
1039 };
1040 struct ip_mreqn
1041 {
1042 struct in_addr imr_multiaddr;
1043 struct in_addr imr_address;
1044 int imr_ifindex;
1045 };
1046 struct in_pktinfo
1047 {
1048 int ipi_ifindex;
1049 struct in_addr ipi_spec_dst;
1050 struct in_addr ipi_addr;
1051 };
1052 extern uint32_t ntohl (uint32_t __netlong) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1053 extern uint16_t ntohs (uint16_t __netshort)
1054 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1055 extern uint32_t htonl (uint32_t __hostlong)
1056 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1057 extern uint16_t htons (uint16_t __hostshort)
1058 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1059 extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __attribute__ ((__nothrow__ , __leaf__));
1060 extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
1061 __attribute__ ((__nothrow__ , __leaf__));
1062 struct cmsghdr;
1063 struct in6_pktinfo
1064 {
1065 struct in6_addr ipi6_addr;
1066 unsigned int ipi6_ifindex;
1067 };
1068 struct ip6_mtuinfo
1069 {
1070 struct sockaddr_in6 ip6m_addr;
1071 uint32_t ip6m_mtu;
1072 };
1073 extern int inet6_option_space (int __nbytes)
1074 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1075 extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp,
1076 int __type) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1077 extern int inet6_option_append (struct cmsghdr *__cmsg,
1078 const uint8_t *__typep, int __multx,
1079 int __plusy) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1080 extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen,
1081 int __multx, int __plusy)
1082 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1083 extern int inet6_option_next (const struct cmsghdr *__cmsg,
1084 uint8_t **__tptrp)
1085 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1086 extern int inet6_option_find (const struct cmsghdr *__cmsg,
1087 uint8_t **__tptrp, int __type)
1088 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1089 extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __attribute__ ((__nothrow__ , __leaf__));
1090 extern int inet6_opt_append (void *__extbuf, socklen_t __extlen, int __offset,
1091 uint8_t __type, socklen_t __len, uint8_t __align,
1092 void **__databufp) __attribute__ ((__nothrow__ , __leaf__));
1093 extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __offset)
1094 __attribute__ ((__nothrow__ , __leaf__));
1095 extern int inet6_opt_set_val (void *__databuf, int __offset, void *__val,
1096 socklen_t __vallen) __attribute__ ((__nothrow__ , __leaf__));
1097 extern int inet6_opt_next (void *__extbuf, socklen_t __extlen, int __offset,
1098 uint8_t *__typep, socklen_t *__lenp,
1099 void **__databufp) __attribute__ ((__nothrow__ , __leaf__));
1100 extern int inet6_opt_find (void *__extbuf, socklen_t __extlen, int __offset,
1101 uint8_t __type, socklen_t *__lenp,
1102 void **__databufp) __attribute__ ((__nothrow__ , __leaf__));
1103 extern int inet6_opt_get_val (void *__databuf, int __offset, void *__val,
1104 socklen_t __vallen) __attribute__ ((__nothrow__ , __leaf__));
1105 extern socklen_t inet6_rth_space (int __type, int __segments) __attribute__ ((__nothrow__ , __leaf__));
1106 extern void *inet6_rth_init (void *__bp, socklen_t __bp_len, int __type,
1107 int __segments) __attribute__ ((__nothrow__ , __leaf__));
1108 extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __attribute__ ((__nothrow__ , __leaf__));
1109 extern int inet6_rth_reverse (const void *__in, void *__out) __attribute__ ((__nothrow__ , __leaf__));
1110 extern int inet6_rth_segments (const void *__bp) __attribute__ ((__nothrow__ , __leaf__));
1111 extern struct in6_addr *inet6_rth_getaddr (const void *__bp, int __index)
1112 __attribute__ ((__nothrow__ , __leaf__));
1113 extern int getipv4sourcefilter (int __s, struct in_addr __interface_addr,
1114 struct in_addr __group, uint32_t *__fmode,
1115 uint32_t *__numsrc, struct in_addr *__slist)
1116 __attribute__ ((__nothrow__ , __leaf__));
1117 extern int setipv4sourcefilter (int __s, struct in_addr __interface_addr,
1118 struct in_addr __group, uint32_t __fmode,
1119 uint32_t __numsrc,
1120 const struct in_addr *__slist)
1121 __attribute__ ((__nothrow__ , __leaf__));
1122 extern int getsourcefilter (int __s, uint32_t __interface_addr,
1123 const struct sockaddr *__group,
1124 socklen_t __grouplen, uint32_t *__fmode,
1125 uint32_t *__numsrc,
1126 struct sockaddr_storage *__slist) __attribute__ ((__nothrow__ , __leaf__));
1127 extern int setsourcefilter (int __s, uint32_t __interface_addr,
1128 const struct sockaddr *__group,
1129 socklen_t __grouplen, uint32_t __fmode,
1130 uint32_t __numsrc,
1131 const struct sockaddr_storage *__slist) __attribute__ ((__nothrow__ , __leaf__));
1132 typedef u_int16_t n_short;
1133 typedef u_int32_t n_long;
1134 typedef u_int32_t n_time;
1135 typedef int bool_t;
1136 typedef int enum_t;
1137 typedef unsigned long rpcprog_t;
1138 typedef unsigned long rpcvers_t;
1139 typedef unsigned long rpcproc_t;
1140 typedef unsigned long rpcprot_t;
1141 typedef unsigned long rpcport_t;
1142 typedef long int wchar_t;
1143 union wait
1144 {
1145 int w_status;
1146 struct
1147 {
1148 unsigned int:16;
1149 unsigned int __w_retcode:8;
1150 unsigned int __w_coredump:1;
1151 unsigned int __w_termsig:7;
1152 } __wait_terminated;
1153 struct
1154 {
1155 unsigned int:16;
1156 unsigned int __w_stopsig:8;
1157 unsigned int __w_stopval:8;
1158 } __wait_stopped;
1159 };
1160 typedef union
1161 {
1162 union wait *__uptr;
1163 int *__iptr;
1164 } __WAIT_STATUS __attribute__ ((__transparent_union__));
1165 typedef struct
1166 {
1167 int quot;
1168 int rem;
1169 } div_t;
1170 typedef struct
1171 {
1172 long int quot;
1173 long int rem;
1174 } ldiv_t;
1175 __extension__ typedef struct
1176 {
1177 long long int quot;
1178 long long int rem;
1179 } lldiv_t;
1180 extern size_t __ctype_get_mb_cur_max (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1181 extern double atof (const char *__nptr)
1182 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1183 extern int atoi (const char *__nptr)
1184 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1185 extern long int atol (const char *__nptr)
1186 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1187 __extension__ extern long long int atoll (const char *__nptr)
1188 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1189 extern double strtod (const char *__restrict __nptr,
1190 char **__restrict __endptr)
1191 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1192 extern float strtof (const char *__restrict __nptr,
1193 char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1194 extern long double strtold (const char *__restrict __nptr,
1195 char **__restrict __endptr)
1196 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1197 extern long int strtol (const char *__restrict __nptr,
1198 char **__restrict __endptr, int __base)
1199 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1200 extern unsigned long int strtoul (const char *__restrict __nptr,
1201 char **__restrict __endptr, int __base)
1202 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1203 __extension__
1204 extern long long int strtoq (const char *__restrict __nptr,
1205 char **__restrict __endptr, int __base)
1206 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1207 __extension__
1208 extern unsigned long long int strtouq (const char *__restrict __nptr,
1209 char **__restrict __endptr, int __base)
1210 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1211 __extension__
1212 extern long long int strtoll (const char *__restrict __nptr,
1213 char **__restrict __endptr, int __base)
1214 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1215 __extension__
1216 extern unsigned long long int strtoull (const char *__restrict __nptr,
1217 char **__restrict __endptr, int __base)
1218 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1219 extern long int strtol_l (const char *__restrict __nptr,
1220 char **__restrict __endptr, int __base,
1221 __locale_t __loc) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 4)));
1222 extern unsigned long int strtoul_l (const char *__restrict __nptr,
1223 char **__restrict __endptr,
1224 int __base, __locale_t __loc)
1225 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 4)));
1226 __extension__
1227 extern long long int strtoll_l (const char *__restrict __nptr,
1228 char **__restrict __endptr, int __base,
1229 __locale_t __loc)
1230 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 4)));
1231 __extension__
1232 extern unsigned long long int strtoull_l (const char *__restrict __nptr,
1233 char **__restrict __endptr,
1234 int __base, __locale_t __loc)
1235 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 4)));
1236 extern double strtod_l (const char *__restrict __nptr,
1237 char **__restrict __endptr, __locale_t __loc)
1238 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3)));
1239 extern float strtof_l (const char *__restrict __nptr,
1240 char **__restrict __endptr, __locale_t __loc)
1241 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3)));
1242 extern long double strtold_l (const char *__restrict __nptr,
1243 char **__restrict __endptr,
1244 __locale_t __loc)
1245 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3)));
1246 extern __inline int
1247 __attribute__ ((__nothrow__ , __leaf__)) atoi (const char *__nptr)
1248 {
1249 return (int) strtol (__nptr, (char **) ((void *)0), 10);
1250 }
1251 extern __inline long int
1252 __attribute__ ((__nothrow__ , __leaf__)) atol (const char *__nptr)
1253 {
1254 return strtol (__nptr, (char **) ((void *)0), 10);
1255 }
1256 __extension__ extern __inline long long int
1257 __attribute__ ((__nothrow__ , __leaf__)) atoll (const char *__nptr)
1258 {
1259 return strtoll (__nptr, (char **) ((void *)0), 10);
1260 }
1261 extern char *l64a (long int __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1262 extern long int a64l (const char *__s)
1263 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1264 extern long int random (void) __attribute__ ((__nothrow__ , __leaf__));
1265 extern void srandom (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));
1266 extern char *initstate (unsigned int __seed, char *__statebuf,
1267 size_t __statelen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1268 extern char *setstate (char *__statebuf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1269 struct random_data
1270 {
1271 int32_t *fptr;
1272 int32_t *rptr;
1273 int32_t *state;
1274 int rand_type;
1275 int rand_deg;
1276 int rand_sep;
1277 int32_t *end_ptr;
1278 };
1279 extern int random_r (struct random_data *__restrict __buf,
1280 int32_t *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1281 extern int srandom_r (unsigned int __seed, struct random_data *__buf)
1282 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1283 extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
1284 size_t __statelen,
1285 struct random_data *__restrict __buf)
1286 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));
1287 extern int setstate_r (char *__restrict __statebuf,
1288 struct random_data *__restrict __buf)
1289 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1290 extern int rand (void) __attribute__ ((__nothrow__ , __leaf__));
1291 extern void srand (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));
1292 extern int rand_r (unsigned int *__seed) __attribute__ ((__nothrow__ , __leaf__));
1293 extern double drand48 (void) __attribute__ ((__nothrow__ , __leaf__));
1294 extern double erand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1295 extern long int lrand48 (void) __attribute__ ((__nothrow__ , __leaf__));
1296 extern long int nrand48 (unsigned short int __xsubi[3])
1297 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1298 extern long int mrand48 (void) __attribute__ ((__nothrow__ , __leaf__));
1299 extern long int jrand48 (unsigned short int __xsubi[3])
1300 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1301 extern void srand48 (long int __seedval) __attribute__ ((__nothrow__ , __leaf__));
1302 extern unsigned short int *seed48 (unsigned short int __seed16v[3])
1303 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1304 extern void lcong48 (unsigned short int __param[7]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1305 struct drand48_data
1306 {
1307 unsigned short int __x[3];
1308 unsigned short int __old_x[3];
1309 unsigned short int __c;
1310 unsigned short int __init;
1311 unsigned long long int __a;
1312 };
1313 extern int drand48_r (struct drand48_data *__restrict __buffer,
1314 double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1315 extern int erand48_r (unsigned short int __xsubi[3],
1316 struct drand48_data *__restrict __buffer,
1317 double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1318 extern int lrand48_r (struct drand48_data *__restrict __buffer,
1319 long int *__restrict __result)
1320 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1321 extern int nrand48_r (unsigned short int __xsubi[3],
1322 struct drand48_data *__restrict __buffer,
1323 long int *__restrict __result)
1324 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1325 extern int mrand48_r (struct drand48_data *__restrict __buffer,
1326 long int *__restrict __result)
1327 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1328 extern int jrand48_r (unsigned short int __xsubi[3],
1329 struct drand48_data *__restrict __buffer,
1330 long int *__restrict __result)
1331 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1332 extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
1333 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1334 extern int seed48_r (unsigned short int __seed16v[3],
1335 struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1336 extern int lcong48_r (unsigned short int __param[7],
1337 struct drand48_data *__buffer)
1338 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1339 extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
1340 extern void *calloc (size_t __nmemb, size_t __size)
1341 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
1342 extern void *realloc (void *__ptr, size_t __size)
1343 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1344 extern void free (void *__ptr) __attribute__ ((__nothrow__ , __leaf__));
1345 extern void cfree (void *__ptr) __attribute__ ((__nothrow__ , __leaf__));
1346 extern void *alloca (size_t __size) __attribute__ ((__nothrow__ , __leaf__));
1347 extern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
1348 extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
1349 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1350 extern void *aligned_alloc (size_t __alignment, size_t __size)
1351 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__)) __attribute__ ((__malloc__, __alloc_size__ (2)));
1352 extern void abort (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
1353 extern int atexit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1354 extern int at_quick_exit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1355 extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
1356 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1357 extern void exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
1358 extern void quick_exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
1359 extern void _Exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
1360 extern char *getenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1361 extern char *secure_getenv (const char *__name)
1362 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1363 extern int putenv (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1364 extern int setenv (const char *__name, const char *__value, int __replace)
1365 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1366 extern int unsetenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1367 extern int clearenv (void) __attribute__ ((__nothrow__ , __leaf__));
1368 extern char *mktemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1369 extern int mkstemp (char *__template) __asm__ ("" "mkstemp64")
1370 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1371 extern int mkstemp64 (char *__template) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1372 extern int mkstemps (char *__template, int __suffixlen) __asm__ ("" "mkstemps64")
1373 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1374 extern int mkstemps64 (char *__template, int __suffixlen)
1375 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1376 extern char *mkdtemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1377 extern int mkostemp (char *__template, int __flags) __asm__ ("" "mkostemp64")
1378 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1379 extern int mkostemp64 (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1380 extern int mkostemps (char *__template, int __suffixlen, int __flags) __asm__ ("" "mkostemps64")
1381 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1382 extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
1383 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1384 extern int system (const char *__command) __attribute__ ((__warn_unused_result__));
1385 extern char *canonicalize_file_name (const char *__name)
1386 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1387 extern char *realpath (const char *__restrict __name,
1388 char *__restrict __resolved) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1389 typedef int (*__compar_fn_t) (const void *, const void *);
1390 typedef __compar_fn_t comparison_fn_t;
1391 typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
1392 extern void *bsearch (const void *__key, const void *__base,
1393 size_t __nmemb, size_t __size, __compar_fn_t __compar)
1394 __attribute__ ((__nonnull__ (1, 2, 5))) __attribute__ ((__warn_unused_result__));
1395 extern void qsort (void *__base, size_t __nmemb, size_t __size,
1396 __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
1397 extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
1398 __compar_d_fn_t __compar, void *__arg)
1399 __attribute__ ((__nonnull__ (1, 4)));
1400 extern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
1401 extern long int labs (long int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
1402 __extension__ extern long long int llabs (long long int __x)
1403 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
1404 extern div_t div (int __numer, int __denom)
1405 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
1406 extern ldiv_t ldiv (long int __numer, long int __denom)
1407 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
1408 __extension__ extern lldiv_t lldiv (long long int __numer,
1409 long long int __denom)
1410 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
1411 extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
1412 int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
1413 extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
1414 int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
1415 extern char *gcvt (double __value, int __ndigit, char *__buf)
1416 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) __attribute__ ((__warn_unused_result__));
1417 extern char *qecvt (long double __value, int __ndigit,
1418 int *__restrict __decpt, int *__restrict __sign)
1419 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
1420 extern char *qfcvt (long double __value, int __ndigit,
1421 int *__restrict __decpt, int *__restrict __sign)
1422 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
1423 extern char *qgcvt (long double __value, int __ndigit, char *__buf)
1424 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) __attribute__ ((__warn_unused_result__));
1425 extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
1426 int *__restrict __sign, char *__restrict __buf,
1427 size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
1428 extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
1429 int *__restrict __sign, char *__restrict __buf,
1430 size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
1431 extern int qecvt_r (long double __value, int __ndigit,
1432 int *__restrict __decpt, int *__restrict __sign,
1433 char *__restrict __buf, size_t __len)
1434 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
1435 extern int qfcvt_r (long double __value, int __ndigit,
1436 int *__restrict __decpt, int *__restrict __sign,
1437 char *__restrict __buf, size_t __len)
1438 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
1439 extern int mblen (const char *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1440 extern int mbtowc (wchar_t *__restrict __pwc,
1441 const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1442 extern int wctomb (char *__s, wchar_t __wchar) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1443 extern size_t mbstowcs (wchar_t *__restrict __pwcs,
1444 const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
1445 extern size_t wcstombs (char *__restrict __s,
1446 const wchar_t *__restrict __pwcs, size_t __n)
1447 __attribute__ ((__nothrow__ , __leaf__));
1448 extern int rpmatch (const char *__response) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1449 extern int getsubopt (char **__restrict __optionp,
1450 char *const *__restrict __tokens,
1451 char **__restrict __valuep)
1452 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3))) __attribute__ ((__warn_unused_result__));
1453 extern void setkey (const char *__key) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1454 extern int posix_openpt (int __oflag) __attribute__ ((__warn_unused_result__));
1455 extern int grantpt (int __fd) __attribute__ ((__nothrow__ , __leaf__));
1456 extern int unlockpt (int __fd) __attribute__ ((__nothrow__ , __leaf__));
1457 extern char *ptsname (int __fd) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1458 extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
1459 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1460 extern int getpt (void);
1461 extern int getloadavg (double __loadavg[], int __nelem)
1462 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1463 extern __inline double
1464 __attribute__ ((__nothrow__ , __leaf__)) atof (const char *__nptr)
1465 {
1466 return strtod (__nptr, (char **) ((void *)0));
1467 }
1468 extern char *__realpath_chk (const char *__restrict __name,
1469 char *__restrict __resolved,
1470 size_t __resolvedlen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1471 extern char *__realpath_alias (const char *__restrict __name, char *__restrict __resolved) __asm__ ("" "realpath") __attribute__ ((__nothrow__ , __leaf__))
1472 __attribute__ ((__warn_unused_result__));
1473 extern char *__realpath_chk_warn (const char *__restrict __name, char *__restrict __resolved, size_t __resolvedlen) __asm__ ("" "__realpath_chk") __attribute__ ((__nothrow__ , __leaf__))
1474 __attribute__ ((__warn_unused_result__))
1475 __attribute__((__warning__ ("second argument of realpath must be either NULL or at " "least PATH_MAX bytes long buffer")))
1476 ;
1477 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
1478 __attribute__ ((__nothrow__ , __leaf__)) realpath (const char *__restrict __name, char *__restrict __resolved)
1479 {
1480 if (__builtin_object_size (__resolved, 2 > 1) != (size_t) -1)
1481 {
1482 if (__builtin_object_size (__resolved, 2 > 1) < 4096)
1483 return __realpath_chk_warn (__name, __resolved, __builtin_object_size (__resolved, 2 > 1));
1484 return __realpath_chk (__name, __resolved, __builtin_object_size (__resolved, 2 > 1));
1485 }
1486 return __realpath_alias (__name, __resolved);
1487 }
1488 extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen,
1489 size_t __nreal) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1490 extern int __ptsname_r_alias (int __fd, char *__buf, size_t __buflen) __asm__ ("" "ptsname_r") __attribute__ ((__nothrow__ , __leaf__))
1491 __attribute__ ((__nonnull__ (2)));
1492 extern int __ptsname_r_chk_warn (int __fd, char *__buf, size_t __buflen, size_t __nreal) __asm__ ("" "__ptsname_r_chk") __attribute__ ((__nothrow__ , __leaf__))
1493 __attribute__ ((__nonnull__ (2))) __attribute__((__warning__ ("ptsname_r called with buflen bigger than " "size of buf")))
1494 ;
1495 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
1496 __attribute__ ((__nothrow__ , __leaf__)) ptsname_r (int __fd, char *__buf, size_t __buflen)
1497 {
1498 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
1499 {
1500 if (!__builtin_constant_p (__buflen))
1501 return __ptsname_r_chk (__fd, __buf, __buflen, __builtin_object_size (__buf, 2 > 1));
1502 if (__buflen > __builtin_object_size (__buf, 2 > 1))
1503 return __ptsname_r_chk_warn (__fd, __buf, __buflen, __builtin_object_size (__buf, 2 > 1));
1504 }
1505 return __ptsname_r_alias (__fd, __buf, __buflen);
1506 }
1507 extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen)
1508 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1509 extern int __wctomb_alias (char *__s, wchar_t __wchar) __asm__ ("" "wctomb") __attribute__ ((__nothrow__ , __leaf__))
1510 __attribute__ ((__warn_unused_result__));
1511 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) int
1512 __attribute__ ((__nothrow__ , __leaf__)) wctomb (char *__s, wchar_t __wchar)
1513 {
1514 if (__builtin_object_size (__s, 2 > 1) != (size_t) -1 && 16 > __builtin_object_size (__s, 2 > 1))
1515 return __wctomb_chk (__s, __wchar, __builtin_object_size (__s, 2 > 1));
1516 return __wctomb_alias (__s, __wchar);
1517 }
1518 extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
1519 const char *__restrict __src,
1520 size_t __len, size_t __dstlen) __attribute__ ((__nothrow__ , __leaf__));
1521 extern size_t __mbstowcs_alias (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len) __asm__ ("" "mbstowcs") __attribute__ ((__nothrow__ , __leaf__))
1522 ;
1523 extern size_t __mbstowcs_chk_warn (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len, size_t __dstlen) __asm__ ("" "__mbstowcs_chk") __attribute__ ((__nothrow__ , __leaf__))
1524 __attribute__((__warning__ ("mbstowcs called with dst buffer smaller than len " "* sizeof (wchar_t)")))
1525 ;
1526 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) size_t
1527 __attribute__ ((__nothrow__ , __leaf__)) mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len)
1528 {
1529 if (__builtin_object_size (__dst, 2 > 1) != (size_t) -1)
1530 {
1531 if (!__builtin_constant_p (__len))
1532 return __mbstowcs_chk (__dst, __src, __len,
1533 __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t));
1534 if (__len > __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t))
1535 return __mbstowcs_chk_warn (__dst, __src, __len,
1536 __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t));
1537 }
1538 return __mbstowcs_alias (__dst, __src, __len);
1539 }
1540 extern size_t __wcstombs_chk (char *__restrict __dst,
1541 const wchar_t *__restrict __src,
1542 size_t __len, size_t __dstlen) __attribute__ ((__nothrow__ , __leaf__));
1543 extern size_t __wcstombs_alias (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len) __asm__ ("" "wcstombs") __attribute__ ((__nothrow__ , __leaf__))
1544 ;
1545 extern size_t __wcstombs_chk_warn (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len, size_t __dstlen) __asm__ ("" "__wcstombs_chk") __attribute__ ((__nothrow__ , __leaf__))
1546 __attribute__((__warning__ ("wcstombs called with dst buffer smaller than len")));
1547 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) size_t
1548 __attribute__ ((__nothrow__ , __leaf__)) wcstombs (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len)
1549 {
1550 if (__builtin_object_size (__dst, 2 > 1) != (size_t) -1)
1551 {
1552 if (!__builtin_constant_p (__len))
1553 return __wcstombs_chk (__dst, __src, __len, __builtin_object_size (__dst, 2 > 1));
1554 if (__len > __builtin_object_size (__dst, 2 > 1))
1555 return __wcstombs_chk_warn (__dst, __src, __len, __builtin_object_size (__dst, 2 > 1));
1556 }
1557 return __wcstombs_alias (__dst, __src, __len);
1558 }
1559 extern int __sigismember (const __sigset_t *, int);
1560 extern int __sigaddset (__sigset_t *, int);
1561 extern int __sigdelset (__sigset_t *, int);
1562 extern __inline int __sigismember (const __sigset_t *__set, int __sig) { unsigned long int __mask = (((unsigned long int) 1) << (((__sig) - 1) % (8 * sizeof (unsigned long int)))); unsigned long int __word = (((__sig) - 1) / (8 * sizeof (unsigned long int))); return (__set->__val[__word] & __mask) ? 1 : 0; }
1563 extern __inline int __sigaddset ( __sigset_t *__set, int __sig) { unsigned long int __mask = (((unsigned long int) 1) << (((__sig) - 1) % (8 * sizeof (unsigned long int)))); unsigned long int __word = (((__sig) - 1) / (8 * sizeof (unsigned long int))); return ((__set->__val[__word] |= __mask), 0); }
1564 extern __inline int __sigdelset ( __sigset_t *__set, int __sig) { unsigned long int __mask = (((unsigned long int) 1) << (((__sig) - 1) % (8 * sizeof (unsigned long int)))); unsigned long int __word = (((__sig) - 1) / (8 * sizeof (unsigned long int))); return ((__set->__val[__word] &= ~__mask), 0); }
1565 typedef __sig_atomic_t sig_atomic_t;
1566 typedef union sigval
1567 {
1568 int sival_int;
1569 void *sival_ptr;
1570 } sigval_t;
1571 typedef struct
1572 {
1573 int si_signo;
1574 int si_errno;
1575 int si_code;
1576 union
1577 {
1578 int _pad[((128 / sizeof (int)) - 3)];
1579 struct
1580 {
1581 __pid_t si_pid;
1582 __uid_t si_uid;
1583 } _kill;
1584 struct
1585 {
1586 int si_tid;
1587 int si_overrun;
1588 sigval_t si_sigval;
1589 } _timer;
1590 struct
1591 {
1592 __pid_t si_pid;
1593 __uid_t si_uid;
1594 sigval_t si_sigval;
1595 } _rt;
1596 struct
1597 {
1598 __pid_t si_pid;
1599 __uid_t si_uid;
1600 int si_status;
1601 __clock_t si_utime;
1602 __clock_t si_stime;
1603 } _sigchld;
1604 struct
1605 {
1606 void *si_addr;
1607 } _sigfault;
1608 struct
1609 {
1610 long int si_band;
1611 int si_fd;
1612 } _sigpoll;
1613 struct
1614 {
1615 void *_call_addr;
1616 int _syscall;
1617 unsigned int _arch;
1618 } _sigsys;
1619 } _sifields;
1620 } siginfo_t;
1621 enum
1622 {
1623 SI_ASYNCNL = -60,
1624 SI_TKILL = -6,
1625 SI_SIGIO,
1626 SI_ASYNCIO,
1627 SI_MESGQ,
1628 SI_TIMER,
1629 SI_QUEUE,
1630 SI_USER,
1631 SI_KERNEL = 0x80
1632 };
1633 enum
1634 {
1635 ILL_ILLOPC = 1,
1636 ILL_ILLOPN,
1637 ILL_ILLADR,
1638 ILL_ILLTRP,
1639 ILL_PRVOPC,
1640 ILL_PRVREG,
1641 ILL_COPROC,
1642 ILL_BADSTK
1643 };
1644 enum
1645 {
1646 FPE_INTDIV = 1,
1647 FPE_INTOVF,
1648 FPE_FLTDIV,
1649 FPE_FLTOVF,
1650 FPE_FLTUND,
1651 FPE_FLTRES,
1652 FPE_FLTINV,
1653 FPE_FLTSUB
1654 };
1655 enum
1656 {
1657 SEGV_MAPERR = 1,
1658 SEGV_ACCERR
1659 };
1660 enum
1661 {
1662 BUS_ADRALN = 1,
1663 BUS_ADRERR,
1664 BUS_OBJERR
1665 };
1666 enum
1667 {
1668 TRAP_BRKPT = 1,
1669 TRAP_TRACE
1670 };
1671 enum
1672 {
1673 CLD_EXITED = 1,
1674 CLD_KILLED,
1675 CLD_DUMPED,
1676 CLD_TRAPPED,
1677 CLD_STOPPED,
1678 CLD_CONTINUED
1679 };
1680 enum
1681 {
1682 POLL_IN = 1,
1683 POLL_OUT,
1684 POLL_MSG,
1685 POLL_ERR,
1686 POLL_PRI,
1687 POLL_HUP
1688 };
1689 typedef struct sigevent
1690 {
1691 sigval_t sigev_value;
1692 int sigev_signo;
1693 int sigev_notify;
1694 union
1695 {
1696 int _pad[((64 / sizeof (int)) - 3)];
1697 __pid_t _tid;
1698 struct
1699 {
1700 void (*_function) (sigval_t);
1701 pthread_attr_t *_attribute;
1702 } _sigev_thread;
1703 } _sigev_un;
1704 } sigevent_t;
1705 enum
1706 {
1707 SIGEV_SIGNAL = 0,
1708 SIGEV_NONE,
1709 SIGEV_THREAD,
1710 SIGEV_THREAD_ID = 4
1711 };
1712 typedef void (*__sighandler_t) (int);
1713 extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
1714 __attribute__ ((__nothrow__ , __leaf__));
1715 extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
1716 __attribute__ ((__nothrow__ , __leaf__));
1717 extern __sighandler_t signal (int __sig, __sighandler_t __handler)
1718 __attribute__ ((__nothrow__ , __leaf__));
1719 extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
1720 __attribute__ ((__nothrow__ , __leaf__));
1721 extern int kill (__pid_t __pid, int __sig) __attribute__ ((__nothrow__ , __leaf__));
1722 extern int killpg (__pid_t __pgrp, int __sig) __attribute__ ((__nothrow__ , __leaf__));
1723 extern int raise (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1724 extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
1725 __attribute__ ((__nothrow__ , __leaf__));
1726 extern int gsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1727 extern void psignal (int __sig, const char *__s);
1728 extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
1729 extern int __sigpause (int __sig_or_mask, int __is_sig);
1730 extern int sigpause (int __sig) __asm__ ("__xpg_sigpause");
1731 extern int sigblock (int __mask) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1732 extern int sigsetmask (int __mask) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1733 extern int siggetmask (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1734 typedef __sighandler_t sighandler_t;
1735 typedef __sighandler_t sig_t;
1736 extern int sigemptyset (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1737 extern int sigfillset (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1738 extern int sigaddset (sigset_t *__set, int __signo) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1739 extern int sigdelset (sigset_t *__set, int __signo) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1740 extern int sigismember (const sigset_t *__set, int __signo)
1741 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1742 extern int sigisemptyset (const sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1743 extern int sigandset (sigset_t *__set, const sigset_t *__left,
1744 const sigset_t *__right) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3)));
1745 extern int sigorset (sigset_t *__set, const sigset_t *__left,
1746 const sigset_t *__right) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3)));
1747 struct sigaction
1748 {
1749 union
1750 {
1751 __sighandler_t sa_handler;
1752 void (*sa_sigaction) (int, siginfo_t *, void *);
1753 }
1754 __sigaction_handler;
1755 unsigned long int sa_flags;
1756 __sigset_t sa_mask;
1757 };
1758 extern int sigprocmask (int __how, const sigset_t *__restrict __set,
1759 sigset_t *__restrict __oset) __attribute__ ((__nothrow__ , __leaf__));
1760 extern int sigsuspend (const sigset_t *__set) __attribute__ ((__nonnull__ (1)));
1761 extern int sigaction (int __sig, const struct sigaction *__restrict __act,
1762 struct sigaction *__restrict __oact) __attribute__ ((__nothrow__ , __leaf__));
1763 extern int sigpending (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1764 extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
1765 __attribute__ ((__nonnull__ (1, 2)));
1766 extern int sigwaitinfo (const sigset_t *__restrict __set,
1767 siginfo_t *__restrict __info) __attribute__ ((__nonnull__ (1)));
1768 extern int sigtimedwait (const sigset_t *__restrict __set,
1769 siginfo_t *__restrict __info,
1770 const struct timespec *__restrict __timeout)
1771 __attribute__ ((__nonnull__ (1)));
1772 extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
1773 __attribute__ ((__nothrow__ , __leaf__));
1774 extern const char *const _sys_siglist[65];
1775 extern const char *const sys_siglist[65];
1776 struct sigvec
1777 {
1778 __sighandler_t sv_handler;
1779 int sv_mask;
1780 int sv_flags;
1781 };
1782 extern int sigvec (int __sig, const struct sigvec *__vec,
1783 struct sigvec *__ovec) __attribute__ ((__nothrow__ , __leaf__));
1784 struct sigcontext {
1785 unsigned long sc_flags;
1786 unsigned long sc_gr[32];
1787 unsigned long long sc_fr[32];
1788 unsigned long sc_iasq[2];
1789 unsigned long sc_iaoq[2];
1790 unsigned long sc_sar;
1791 };
1792 extern int sigreturn (struct sigcontext *__scp) __attribute__ ((__nothrow__ , __leaf__));
1793 extern int siginterrupt (int __sig, int __interrupt) __attribute__ ((__nothrow__ , __leaf__));
1794 struct sigstack
1795 {
1796 void *ss_sp;
1797 int ss_onstack;
1798 };
1799 enum
1800 {
1801 SS_ONSTACK = 1,
1802 SS_DISABLE
1803 };
1804 typedef struct sigaltstack
1805 {
1806 void *ss_sp;
1807 int ss_flags;
1808 size_t ss_size;
1809 } stack_t;
1810 typedef unsigned long int greg_t;
1811 typedef struct gregset
1812 {
1813 greg_t g_regs[32];
1814 greg_t sr_regs[8];
1815 greg_t cr_regs[24];
1816 greg_t g_pad[16];
1817 } gregset_t;
1818 typedef struct fpregset
1819 {
1820 double fp_dregs[32];
1821 } fpregset_t;
1822 typedef struct sigcontext mcontext_t;
1823 typedef struct ucontext
1824 {
1825 unsigned long int uc_flags;
1826 struct ucontext *uc_link;
1827 stack_t uc_stack;
1828 mcontext_t uc_mcontext;
1829 __sigset_t uc_sigmask;
1830 } ucontext_t;
1831 extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
1832 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1833 extern int sigaltstack (const struct sigaltstack *__restrict __ss,
1834 struct sigaltstack *__restrict __oss) __attribute__ ((__nothrow__ , __leaf__));
1835 extern int sighold (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1836 extern int sigrelse (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1837 extern int sigignore (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1838 extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __attribute__ ((__nothrow__ , __leaf__));
1839 extern int pthread_sigmask (int __how,
1840 const __sigset_t *__restrict __newmask,
1841 __sigset_t *__restrict __oldmask)__attribute__ ((__nothrow__ , __leaf__));
1842 extern int pthread_kill (pthread_t __threadid, int __signo) __attribute__ ((__nothrow__ , __leaf__));
1843 extern int pthread_sigqueue (pthread_t __threadid, int __signo,
1844 const union sigval __value) __attribute__ ((__nothrow__ , __leaf__));
1845 extern int __libc_current_sigrtmin (void) __attribute__ ((__nothrow__ , __leaf__));
1846 extern int __libc_current_sigrtmax (void) __attribute__ ((__nothrow__ , __leaf__));
1847 extern int *__errno_location (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1848 extern char *program_invocation_name, *program_invocation_short_name;
1849 typedef int error_t;
1850 struct timestamp
1851 {
1852 u_int8_t len;
1853 u_int8_t ptr;
1854 unsigned int overflow:4;
1855 unsigned int flags:4;
1856 u_int32_t data[9];
1857 };
1858 struct iphdr
1859 {
1860 unsigned int version:4;
1861 unsigned int ihl:4;
1862 u_int8_t tos;
1863 u_int16_t tot_len;
1864 u_int16_t id;
1865 u_int16_t frag_off;
1866 u_int8_t ttl;
1867 u_int8_t protocol;
1868 u_int16_t check;
1869 u_int32_t saddr;
1870 u_int32_t daddr;
1871 };
1872 struct ip
1873 {
1874 unsigned int ip_v:4;
1875 unsigned int ip_hl:4;
1876 u_int8_t ip_tos;
1877 u_short ip_len;
1878 u_short ip_id;
1879 u_short ip_off;
1880 u_int8_t ip_ttl;
1881 u_int8_t ip_p;
1882 u_short ip_sum;
1883 struct in_addr ip_src, ip_dst;
1884 };
1885 struct ip_timestamp
1886 {
1887 u_int8_t ipt_code;
1888 u_int8_t ipt_len;
1889 u_int8_t ipt_ptr;
1890 unsigned int ipt_oflw:4;
1891 unsigned int ipt_flg:4;
1892 u_int32_t data[9];
1893 };
1894 struct passwd
1895 {
1896 char *pw_name;
1897 char *pw_passwd;
1898 __uid_t pw_uid;
1899 __gid_t pw_gid;
1900 char *pw_gecos;
1901 char *pw_dir;
1902 char *pw_shell;
1903 };
1904 struct _IO_FILE;
1905 typedef struct _IO_FILE FILE;
1906 extern void setpwent (void);
1907 extern void endpwent (void);
1908 extern struct passwd *getpwent (void);
1909 extern struct passwd *fgetpwent (FILE *__stream);
1910 extern int putpwent (const struct passwd *__restrict __p,
1911 FILE *__restrict __f);
1912 extern struct passwd *getpwuid (__uid_t __uid);
1913 extern struct passwd *getpwnam (const char *__name);
1914 extern int getpwent_r (struct passwd *__restrict __resultbuf,
1915 char *__restrict __buffer, size_t __buflen,
1916 struct passwd **__restrict __result);
1917 extern int getpwuid_r (__uid_t __uid,
1918 struct passwd *__restrict __resultbuf,
1919 char *__restrict __buffer, size_t __buflen,
1920 struct passwd **__restrict __result);
1921 extern int getpwnam_r (const char *__restrict __name,
1922 struct passwd *__restrict __resultbuf,
1923 char *__restrict __buffer, size_t __buflen,
1924 struct passwd **__restrict __result);
1925 extern int fgetpwent_r (FILE *__restrict __stream,
1926 struct passwd *__restrict __resultbuf,
1927 char *__restrict __buffer, size_t __buflen,
1928 struct passwd **__restrict __result);
1929 extern int getpw (__uid_t __uid, char *__buffer);
1930 void platform_pre_listen(void);
1931 void platform_pre_fork(void);
1932 void platform_pre_restart(void);
1933 void platform_post_fork_parent(pid_t child_pid);
1934 void platform_post_fork_child(void);
1935 int platform_privileged_uidswap(void);
1936 void platform_setusercontext(struct passwd *);
1937 void platform_setusercontext_post_groups(struct passwd *);
1938 char *platform_get_krb5_client(const char *);
1939 char *platform_krb5_get_principal_name(const char *);
1940 int platform_sys_dir_uid(uid_t);
1941 int b64_ntop(u_char const *src, size_t srclength, char *target,
1942 size_t targsize);
1943 int b64_pton(char const *src, u_char *target, size_t targsize);
1944 struct stat;
1945 typedef struct {
1946 int gl_pathc;
1947 int gl_matchc;
1948 int gl_offs;
1949 int gl_flags;
1950 char **gl_pathv;
1951 struct stat **gl_statv;
1952 int (*gl_errfunc)(const char *, int);
1953 void (*gl_closedir)(void *);
1954 struct dirent *(*gl_readdir)(void *);
1955 void *(*gl_opendir)(const char *);
1956 int (*gl_lstat)(const char *, struct stat *);
1957 int (*gl_stat)(const char *, struct stat *);
1958 } glob_t;
1959 int glob(const char *, int, int (*)(const char *, int), glob_t *);
1960 void globfree(glob_t *);
1961 char * readpassphrase(const char *, char *, size_t, int);
1962 char *vis(char *, int, int, int);
1963 int strvis(char *, const char *, int);
1964 int strnvis(char *, const char *, size_t, int)
1965 __attribute__ (());
1966 int strvisx(char *, const char *, size_t, int)
1967 __attribute__ (());
1968 int strunvis(char *, const char *);
1969 int unvis(char *, char, int *, int);
1970 ssize_t strnunvis(char *, const char *, size_t)
1971 __attribute__ (());
1972 typedef enum __ns_sect {
1973 ns_s_qd = 0,
1974 ns_s_zn = 0,
1975 ns_s_an = 1,
1976 ns_s_pr = 1,
1977 ns_s_ns = 2,
1978 ns_s_ud = 2,
1979 ns_s_ar = 3,
1980 ns_s_max = 4
1981 } ns_sect;
1982 typedef struct __ns_msg {
1983 const u_char *_msg, *_eom;
1984 u_int16_t _id, _flags, _counts[ns_s_max];
1985 const u_char *_sections[ns_s_max];
1986 ns_sect _sect;
1987 int _rrnum;
1988 const u_char *_msg_ptr;
1989 } ns_msg;
1990 struct _ns_flagdata { int mask, shift; };
1991 extern const struct _ns_flagdata _ns_flagdata[];
1992 typedef struct __ns_rr {
1993 char name[1025];
1994 u_int16_t type;
1995 u_int16_t rr_class;
1996 u_int32_t ttl;
1997 u_int16_t rdlength;
1998 const u_char * rdata;
1999 } ns_rr;
2000 typedef enum __ns_flag {
2001 ns_f_qr,
2002 ns_f_opcode,
2003 ns_f_aa,
2004 ns_f_tc,
2005 ns_f_rd,
2006 ns_f_ra,
2007 ns_f_z,
2008 ns_f_ad,
2009 ns_f_cd,
2010 ns_f_rcode,
2011 ns_f_max
2012 } ns_flag;
2013 typedef enum __ns_opcode {
2014 ns_o_query = 0,
2015 ns_o_iquery = 1,
2016 ns_o_status = 2,
2017 ns_o_notify = 4,
2018 ns_o_update = 5,
2019 ns_o_max = 6
2020 } ns_opcode;
2021 typedef enum __ns_rcode {
2022 ns_r_noerror = 0,
2023 ns_r_formerr = 1,
2024 ns_r_servfail = 2,
2025 ns_r_nxdomain = 3,
2026 ns_r_notimpl = 4,
2027 ns_r_refused = 5,
2028 ns_r_yxdomain = 6,
2029 ns_r_yxrrset = 7,
2030 ns_r_nxrrset = 8,
2031 ns_r_notauth = 9,
2032 ns_r_notzone = 10,
2033 ns_r_max = 11,
2034 ns_r_badvers = 16,
2035 ns_r_badsig = 16,
2036 ns_r_badkey = 17,
2037 ns_r_badtime = 18
2038 } ns_rcode;
2039 typedef enum __ns_update_operation {
2040 ns_uop_delete = 0,
2041 ns_uop_add = 1,
2042 ns_uop_max = 2
2043 } ns_update_operation;
2044 struct ns_tsig_key {
2045 char name[1025], alg[1025];
2046 unsigned char *data;
2047 int len;
2048 };
2049 typedef struct ns_tsig_key ns_tsig_key;
2050 struct ns_tcp_tsig_state {
2051 int counter;
2052 struct dst_key *key;
2053 void *ctx;
2054 unsigned char sig[512];
2055 int siglen;
2056 };
2057 typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
2058 typedef enum __ns_type {
2059 ns_t_invalid = 0,
2060 ns_t_a = 1,
2061 ns_t_ns = 2,
2062 ns_t_md = 3,
2063 ns_t_mf = 4,
2064 ns_t_cname = 5,
2065 ns_t_soa = 6,
2066 ns_t_mb = 7,
2067 ns_t_mg = 8,
2068 ns_t_mr = 9,
2069 ns_t_null = 10,
2070 ns_t_wks = 11,
2071 ns_t_ptr = 12,
2072 ns_t_hinfo = 13,
2073 ns_t_minfo = 14,
2074 ns_t_mx = 15,
2075 ns_t_txt = 16,
2076 ns_t_rp = 17,
2077 ns_t_afsdb = 18,
2078 ns_t_x25 = 19,
2079 ns_t_isdn = 20,
2080 ns_t_rt = 21,
2081 ns_t_nsap = 22,
2082 ns_t_nsap_ptr = 23,
2083 ns_t_sig = 24,
2084 ns_t_key = 25,
2085 ns_t_px = 26,
2086 ns_t_gpos = 27,
2087 ns_t_aaaa = 28,
2088 ns_t_loc = 29,
2089 ns_t_nxt = 30,
2090 ns_t_eid = 31,
2091 ns_t_nimloc = 32,
2092 ns_t_srv = 33,
2093 ns_t_atma = 34,
2094 ns_t_naptr = 35,
2095 ns_t_kx = 36,
2096 ns_t_cert = 37,
2097 ns_t_a6 = 38,
2098 ns_t_dname = 39,
2099 ns_t_sink = 40,
2100 ns_t_opt = 41,
2101 ns_t_apl = 42,
2102 ns_t_tkey = 249,
2103 ns_t_tsig = 250,
2104 ns_t_ixfr = 251,
2105 ns_t_axfr = 252,
2106 ns_t_mailb = 253,
2107 ns_t_maila = 254,
2108 ns_t_any = 255,
2109 ns_t_zxfr = 256,
2110 ns_t_max = 65536
2111 } ns_type;
2112 typedef enum __ns_class {
2113 ns_c_invalid = 0,
2114 ns_c_in = 1,
2115 ns_c_2 = 2,
2116 ns_c_chaos = 3,
2117 ns_c_hs = 4,
2118 ns_c_none = 254,
2119 ns_c_any = 255,
2120 ns_c_max = 65536
2121 } ns_class;
2122 typedef enum __ns_key_types {
2123 ns_kt_rsa = 1,
2124 ns_kt_dh = 2,
2125 ns_kt_dsa = 3,
2126 ns_kt_private = 254
2127 } ns_key_types;
2128 typedef enum __ns_cert_types {
2129 cert_t_pkix = 1,
2130 cert_t_spki = 2,
2131 cert_t_pgp = 3,
2132 cert_t_url = 253,
2133 cert_t_oid = 254
2134 } ns_cert_types;
2135 int ns_msg_getflag (ns_msg, int) __attribute__ ((__nothrow__ , __leaf__));
2136 u_int ns_get16 (const u_char *) __attribute__ ((__nothrow__ , __leaf__));
2137 u_long ns_get32 (const u_char *) __attribute__ ((__nothrow__ , __leaf__));
2138 void ns_put16 (u_int, u_char *) __attribute__ ((__nothrow__ , __leaf__));
2139 void ns_put32 (u_long, u_char *) __attribute__ ((__nothrow__ , __leaf__));
2140 int ns_initparse (const u_char *, int, ns_msg *) __attribute__ ((__nothrow__ , __leaf__));
2141 int ns_skiprr (const u_char *, const u_char *, ns_sect, int)
2142 __attribute__ ((__nothrow__ , __leaf__));
2143 int ns_parserr (ns_msg *, ns_sect, int, ns_rr *) __attribute__ ((__nothrow__ , __leaf__));
2144 int ns_sprintrr (const ns_msg *, const ns_rr *,
2145 const char *, const char *, char *, size_t)
2146 __attribute__ ((__nothrow__ , __leaf__));
2147 int ns_sprintrrf (const u_char *, size_t, const char *,
2148 ns_class, ns_type, u_long, const u_char *,
2149 size_t, const char *, const char *,
2150 char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2151 int ns_format_ttl (u_long, char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2152 int ns_parse_ttl (const char *, u_long *) __attribute__ ((__nothrow__ , __leaf__));
2153 u_int32_t ns_datetosecs (const char *, int *) __attribute__ ((__nothrow__ , __leaf__));
2154 int ns_name_ntol (const u_char *, u_char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2155 int ns_name_ntop (const u_char *, char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2156 int ns_name_pton (const char *, u_char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2157 int ns_name_unpack (const u_char *, const u_char *,
2158 const u_char *, u_char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2159 int ns_name_pack (const u_char *, u_char *, int,
2160 const u_char **, const u_char **) __attribute__ ((__nothrow__ , __leaf__));
2161 int ns_name_uncompress (const u_char *, const u_char *,
2162 const u_char *, char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2163 int ns_name_compress (const char *, u_char *, size_t,
2164 const u_char **, const u_char **) __attribute__ ((__nothrow__ , __leaf__));
2165 int ns_name_skip (const u_char **, const u_char *) __attribute__ ((__nothrow__ , __leaf__));
2166 void ns_name_rollback (const u_char *, const u_char **,
2167 const u_char **) __attribute__ ((__nothrow__ , __leaf__));
2168 int ns_sign (u_char *, int *, int, int, void *,
2169 const u_char *, int, u_char *, int *, time_t) __attribute__ ((__nothrow__ , __leaf__));
2170 int ns_sign2 (u_char *, int *, int, int, void *,
2171 const u_char *, int, u_char *, int *, time_t,
2172 u_char **, u_char **) __attribute__ ((__nothrow__ , __leaf__));
2173 int ns_sign_tcp (u_char *, int *, int, int,
2174 ns_tcp_tsig_state *, int) __attribute__ ((__nothrow__ , __leaf__));
2175 int ns_sign_tcp2 (u_char *, int *, int, int,
2176 ns_tcp_tsig_state *, int,
2177 u_char **, u_char **) __attribute__ ((__nothrow__ , __leaf__));
2178 int ns_sign_tcp_init (void *, const u_char *, int,
2179 ns_tcp_tsig_state *) __attribute__ ((__nothrow__ , __leaf__));
2180 u_char *ns_find_tsig (u_char *, u_char *) __attribute__ ((__nothrow__ , __leaf__));
2181 int ns_verify (u_char *, int *, void *, const u_char *, int,
2182 u_char *, int *, time_t *, int) __attribute__ ((__nothrow__ , __leaf__));
2183 int ns_verify_tcp (u_char *, int *, ns_tcp_tsig_state *, int)
2184 __attribute__ ((__nothrow__ , __leaf__));
2185 int ns_verify_tcp_init (void *, const u_char *, int,
2186 ns_tcp_tsig_state *) __attribute__ ((__nothrow__ , __leaf__));
2187 int ns_samedomain (const char *, const char *) __attribute__ ((__nothrow__ , __leaf__));
2188 int ns_subdomain (const char *, const char *) __attribute__ ((__nothrow__ , __leaf__));
2189 int ns_makecanon (const char *, char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2190 int ns_samename (const char *, const char *) __attribute__ ((__nothrow__ , __leaf__));
2191 typedef struct {
2192 unsigned id :16;
2193 unsigned qr: 1;
2194 unsigned opcode: 4;
2195 unsigned aa: 1;
2196 unsigned tc: 1;
2197 unsigned rd: 1;
2198 unsigned ra: 1;
2199 unsigned unused :1;
2200 unsigned ad: 1;
2201 unsigned cd: 1;
2202 unsigned rcode :4;
2203 unsigned qdcount :16;
2204 unsigned ancount :16;
2205 unsigned nscount :16;
2206 unsigned arcount :16;
2207 } HEADER;
2208 struct rpcent
2209 {
2210 char *r_name;
2211 char **r_aliases;
2212 int r_number;
2213 };
2214 extern void setrpcent (int __stayopen) __attribute__ ((__nothrow__ , __leaf__));
2215 extern void endrpcent (void) __attribute__ ((__nothrow__ , __leaf__));
2216 extern struct rpcent *getrpcbyname (const char *__name) __attribute__ ((__nothrow__ , __leaf__));
2217 extern struct rpcent *getrpcbynumber (int __number) __attribute__ ((__nothrow__ , __leaf__));
2218 extern struct rpcent *getrpcent (void) __attribute__ ((__nothrow__ , __leaf__));
2219 extern int getrpcbyname_r (const char *__name, struct rpcent *__result_buf,
2220 char *__buffer, size_t __buflen,
2221 struct rpcent **__result) __attribute__ ((__nothrow__ , __leaf__));
2222 extern int getrpcbynumber_r (int __number, struct rpcent *__result_buf,
2223 char *__buffer, size_t __buflen,
2224 struct rpcent **__result) __attribute__ ((__nothrow__ , __leaf__));
2225 extern int getrpcent_r (struct rpcent *__result_buf, char *__buffer,
2226 size_t __buflen, struct rpcent **__result) __attribute__ ((__nothrow__ , __leaf__));
2227 struct netent
2228 {
2229 char *n_name;
2230 char **n_aliases;
2231 int n_addrtype;
2232 uint32_t n_net;
2233 };
2234 extern int *__h_errno_location (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
2235 extern void herror (const char *__str) __attribute__ ((__nothrow__ , __leaf__));
2236 extern const char *hstrerror (int __err_num) __attribute__ ((__nothrow__ , __leaf__));
2237 struct hostent
2238 {
2239 char *h_name;
2240 char **h_aliases;
2241 int h_addrtype;
2242 int h_length;
2243 char **h_addr_list;
2244 };
2245 extern void sethostent (int __stay_open);
2246 extern void endhostent (void);
2247 extern struct hostent *gethostent (void);
2248 extern struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len,
2249 int __type);
2250 extern struct hostent *gethostbyname (const char *__name);
2251 extern struct hostent *gethostbyname2 (const char *__name, int __af);
2252 extern int gethostent_r (struct hostent *__restrict __result_buf,
2253 char *__restrict __buf, size_t __buflen,
2254 struct hostent **__restrict __result,
2255 int *__restrict __h_errnop);
2256 extern int gethostbyaddr_r (const void *__restrict __addr, __socklen_t __len,
2257 int __type,
2258 struct hostent *__restrict __result_buf,
2259 char *__restrict __buf, size_t __buflen,
2260 struct hostent **__restrict __result,
2261 int *__restrict __h_errnop);
2262 extern int gethostbyname_r (const char *__restrict __name,
2263 struct hostent *__restrict __result_buf,
2264 char *__restrict __buf, size_t __buflen,
2265 struct hostent **__restrict __result,
2266 int *__restrict __h_errnop);
2267 extern int gethostbyname2_r (const char *__restrict __name, int __af,
2268 struct hostent *__restrict __result_buf,
2269 char *__restrict __buf, size_t __buflen,
2270 struct hostent **__restrict __result,
2271 int *__restrict __h_errnop);
2272 extern void setnetent (int __stay_open);
2273 extern void endnetent (void);
2274 extern struct netent *getnetent (void);
2275 extern struct netent *getnetbyaddr (uint32_t __net, int __type);
2276 extern struct netent *getnetbyname (const char *__name);
2277 extern int getnetent_r (struct netent *__restrict __result_buf,
2278 char *__restrict __buf, size_t __buflen,
2279 struct netent **__restrict __result,
2280 int *__restrict __h_errnop);
2281 extern int getnetbyaddr_r (uint32_t __net, int __type,
2282 struct netent *__restrict __result_buf,
2283 char *__restrict __buf, size_t __buflen,
2284 struct netent **__restrict __result,
2285 int *__restrict __h_errnop);
2286 extern int getnetbyname_r (const char *__restrict __name,
2287 struct netent *__restrict __result_buf,
2288 char *__restrict __buf, size_t __buflen,
2289 struct netent **__restrict __result,
2290 int *__restrict __h_errnop);
2291 struct servent
2292 {
2293 char *s_name;
2294 char **s_aliases;
2295 int s_port;
2296 char *s_proto;
2297 };
2298 extern void setservent (int __stay_open);
2299 extern void endservent (void);
2300 extern struct servent *getservent (void);
2301 extern struct servent *getservbyname (const char *__name, const char *__proto);
2302 extern struct servent *getservbyport (int __port, const char *__proto);
2303 extern int getservent_r (struct servent *__restrict __result_buf,
2304 char *__restrict __buf, size_t __buflen,
2305 struct servent **__restrict __result);
2306 extern int getservbyname_r (const char *__restrict __name,
2307 const char *__restrict __proto,
2308 struct servent *__restrict __result_buf,
2309 char *__restrict __buf, size_t __buflen,
2310 struct servent **__restrict __result);
2311 extern int getservbyport_r (int __port, const char *__restrict __proto,
2312 struct servent *__restrict __result_buf,
2313 char *__restrict __buf, size_t __buflen,
2314 struct servent **__restrict __result);
2315 struct protoent
2316 {
2317 char *p_name;
2318 char **p_aliases;
2319 int p_proto;
2320 };
2321 extern void setprotoent (int __stay_open);
2322 extern void endprotoent (void);
2323 extern struct protoent *getprotoent (void);
2324 extern struct protoent *getprotobyname (const char *__name);
2325 extern struct protoent *getprotobynumber (int __proto);
2326 extern int getprotoent_r (struct protoent *__restrict __result_buf,
2327 char *__restrict __buf, size_t __buflen,
2328 struct protoent **__restrict __result);
2329 extern int getprotobyname_r (const char *__restrict __name,
2330 struct protoent *__restrict __result_buf,
2331 char *__restrict __buf, size_t __buflen,
2332 struct protoent **__restrict __result);
2333 extern int getprotobynumber_r (int __proto,
2334 struct protoent *__restrict __result_buf,
2335 char *__restrict __buf, size_t __buflen,
2336 struct protoent **__restrict __result);
2337 extern int setnetgrent (const char *__netgroup);
2338 extern void endnetgrent (void);
2339 extern int getnetgrent (char **__restrict __hostp,
2340 char **__restrict __userp,
2341 char **__restrict __domainp);
2342 extern int innetgr (const char *__netgroup, const char *__host,
2343 const char *__user, const char *__domain);
2344 extern int getnetgrent_r (char **__restrict __hostp,
2345 char **__restrict __userp,
2346 char **__restrict __domainp,
2347 char *__restrict __buffer, size_t __buflen);
2348 extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
2349 const char *__restrict __locuser,
2350 const char *__restrict __remuser,
2351 const char *__restrict __cmd, int *__restrict __fd2p);
2352 extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
2353 const char *__restrict __locuser,
2354 const char *__restrict __remuser,
2355 const char *__restrict __cmd, int *__restrict __fd2p,
2356 sa_family_t __af);
2357 extern int rexec (char **__restrict __ahost, int __rport,
2358 const char *__restrict __name,
2359 const char *__restrict __pass,
2360 const char *__restrict __cmd, int *__restrict __fd2p);
2361 extern int rexec_af (char **__restrict __ahost, int __rport,
2362 const char *__restrict __name,
2363 const char *__restrict __pass,
2364 const char *__restrict __cmd, int *__restrict __fd2p,
2365 sa_family_t __af);
2366 extern int ruserok (const char *__rhost, int __suser,
2367 const char *__remuser, const char *__locuser);
2368 extern int ruserok_af (const char *__rhost, int __suser,
2369 const char *__remuser, const char *__locuser,
2370 sa_family_t __af);
2371 extern int iruserok (uint32_t __raddr, int __suser,
2372 const char *__remuser, const char *__locuser);
2373 extern int iruserok_af (const void *__raddr, int __suser,
2374 const char *__remuser, const char *__locuser,
2375 sa_family_t __af);
2376 extern int rresvport (int *__alport);
2377 extern int rresvport_af (int *__alport, sa_family_t __af);
2378 struct addrinfo
2379 {
2380 int ai_flags;
2381 int ai_family;
2382 int ai_socktype;
2383 int ai_protocol;
2384 socklen_t ai_addrlen;
2385 struct sockaddr *ai_addr;
2386 char *ai_canonname;
2387 struct addrinfo *ai_next;
2388 };
2389 struct gaicb
2390 {
2391 const char *ar_name;
2392 const char *ar_service;
2393 const struct addrinfo *ar_request;
2394 struct addrinfo *ar_result;
2395 int __return;
2396 int __unused[5];
2397 };
2398 extern int getaddrinfo (const char *__restrict __name,
2399 const char *__restrict __service,
2400 const struct addrinfo *__restrict __req,
2401 struct addrinfo **__restrict __pai);
2402 extern void freeaddrinfo (struct addrinfo *__ai) __attribute__ ((__nothrow__ , __leaf__));
2403 extern const char *gai_strerror (int __ecode) __attribute__ ((__nothrow__ , __leaf__));
2404 extern int getnameinfo (const struct sockaddr *__restrict __sa,
2405 socklen_t __salen, char *__restrict __host,
2406 socklen_t __hostlen, char *__restrict __serv,
2407 socklen_t __servlen, int __flags);
2408 extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict],
2409 int __ent, struct sigevent *__restrict __sig);
2410 extern int gai_suspend (const struct gaicb *const __list[], int __ent,
2411 const struct timespec *__timeout);
2412 extern int gai_error (struct gaicb *__req) __attribute__ ((__nothrow__ , __leaf__));
2413 extern int gai_cancel (struct gaicb *__gaicbp) __attribute__ ((__nothrow__ , __leaf__));
2414 typedef struct _IO_FILE __FILE;
2415 typedef struct
2416 {
2417 int __count;
2418 union
2419 {
2420 unsigned int __wch;
2421 char __wchb[4];
2422 } __value;
2423 } __mbstate_t;
2424 typedef struct
2425 {
2426 __off_t __pos;
2427 __mbstate_t __state;
2428 } _G_fpos_t;
2429 typedef struct
2430 {
2431 __off64_t __pos;
2432 __mbstate_t __state;
2433 } _G_fpos64_t;
2434 typedef __builtin_va_list __gnuc_va_list;
2435 struct _IO_jump_t; struct _IO_FILE;
2436 typedef void _IO_lock_t;
2437 struct _IO_marker {
2438 struct _IO_marker *_next;
2439 struct _IO_FILE *_sbuf;
2440 int _pos;
2441 };
2442 enum __codecvt_result
2443 {
2444 __codecvt_ok,
2445 __codecvt_partial,
2446 __codecvt_error,
2447 __codecvt_noconv
2448 };
2449 struct _IO_FILE {
2450 int _flags;
2451 char* _IO_read_ptr;
2452 char* _IO_read_end;
2453 char* _IO_read_base;
2454 char* _IO_write_base;
2455 char* _IO_write_ptr;
2456 char* _IO_write_end;
2457 char* _IO_buf_base;
2458 char* _IO_buf_end;
2459 char *_IO_save_base;
2460 char *_IO_backup_base;
2461 char *_IO_save_end;
2462 struct _IO_marker *_markers;
2463 struct _IO_FILE *_chain;
2464 int _fileno;
2465 int _flags2;
2466 __off_t _old_offset;
2467 unsigned short _cur_column;
2468 signed char _vtable_offset;
2469 char _shortbuf[1];
2470 _IO_lock_t *_lock;
2471 __off64_t _offset;
2472 void *__pad1;
2473 void *__pad2;
2474 void *__pad3;
2475 void *__pad4;
2476 size_t __pad5;
2477 int _mode;
2478 char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
2479 };
2480 typedef struct _IO_FILE _IO_FILE;
2481 struct _IO_FILE_plus;
2482 extern struct _IO_FILE_plus _IO_2_1_stdin_;
2483 extern struct _IO_FILE_plus _IO_2_1_stdout_;
2484 extern struct _IO_FILE_plus _IO_2_1_stderr_;
2485 typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
2486 typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,
2487 size_t __n);
2488 typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
2489 typedef int __io_close_fn (void *__cookie);
2490 typedef __io_read_fn cookie_read_function_t;
2491 typedef __io_write_fn cookie_write_function_t;
2492 typedef __io_seek_fn cookie_seek_function_t;
2493 typedef __io_close_fn cookie_close_function_t;
2494 typedef struct
2495 {
2496 __io_read_fn *read;
2497 __io_write_fn *write;
2498 __io_seek_fn *seek;
2499 __io_close_fn *close;
2500 } _IO_cookie_io_functions_t;
2501 typedef _IO_cookie_io_functions_t cookie_io_functions_t;
2502 struct _IO_cookie_file;
2503 extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
2504 void *__cookie, _IO_cookie_io_functions_t __fns);
2505 extern int __underflow (_IO_FILE *);
2506 extern int __uflow (_IO_FILE *);
2507 extern int __overflow (_IO_FILE *, int);
2508 extern int _IO_getc (_IO_FILE *__fp);
2509 extern int _IO_putc (int __c, _IO_FILE *__fp);
2510 extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
2511 extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
2512 extern int _IO_peekc_locked (_IO_FILE *__fp);
2513 extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
2514 extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
2515 extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
2516 extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
2517 __gnuc_va_list, int *__restrict);
2518 extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
2519 __gnuc_va_list);
2520 extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
2521 extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
2522 extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
2523 extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
2524 extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
2525 typedef __gnuc_va_list va_list;
2526 typedef _G_fpos64_t fpos_t;
2527 typedef _G_fpos64_t fpos64_t;
2528 extern struct _IO_FILE *stdin;
2529 extern struct _IO_FILE *stdout;
2530 extern struct _IO_FILE *stderr;
2531 extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__));
2532 extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));
2533 extern int renameat (int __oldfd, const char *__old, int __newfd,
2534 const char *__new) __attribute__ ((__nothrow__ , __leaf__));
2535 extern FILE *tmpfile (void) __asm__ ("" "tmpfile64") __attribute__ ((__warn_unused_result__));
2536 extern FILE *tmpfile64 (void) __attribute__ ((__warn_unused_result__));
2537 extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2538 extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2539 extern char *tempnam (const char *__dir, const char *__pfx)
2540 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
2541 extern int fclose (FILE *__stream);
2542 extern int fflush (FILE *__stream);
2543 extern int fflush_unlocked (FILE *__stream);
2544 extern int fcloseall (void);
2545 extern FILE *fopen (const char *__restrict __filename, const char *__restrict __modes) __asm__ ("" "fopen64")
2546 __attribute__ ((__warn_unused_result__));
2547 extern FILE *freopen (const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream) __asm__ ("" "freopen64")
2548 __attribute__ ((__warn_unused_result__));
2549 extern FILE *fopen64 (const char *__restrict __filename,
2550 const char *__restrict __modes) __attribute__ ((__warn_unused_result__));
2551 extern FILE *freopen64 (const char *__restrict __filename,
2552 const char *__restrict __modes,
2553 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2554 extern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2555 extern FILE *fopencookie (void *__restrict __magic_cookie,
2556 const char *__restrict __modes,
2557 _IO_cookie_io_functions_t __io_funcs) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2558 extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
2559 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2560 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2561 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
2562 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
2563 int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
2564 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
2565 size_t __size) __attribute__ ((__nothrow__ , __leaf__));
2566 extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2567 extern int fprintf (FILE *__restrict __stream,
2568 const char *__restrict __format, ...);
2569 extern int printf (const char *__restrict __format, ...);
2570 extern int sprintf (char *__restrict __s,
2571 const char *__restrict __format, ...) __attribute__ ((__nothrow__));
2572 extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
2573 __gnuc_va_list __arg);
2574 extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
2575 extern int vsprintf (char *__restrict __s, const char *__restrict __format,
2576 __gnuc_va_list __arg) __attribute__ ((__nothrow__));
2577 extern int snprintf (char *__restrict __s, size_t __maxlen,
2578 const char *__restrict __format, ...)
2579 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));
2580 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
2581 const char *__restrict __format, __gnuc_va_list __arg)
2582 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));
2583 extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
2584 __gnuc_va_list __arg)
2585 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 2, 0))) __attribute__ ((__warn_unused_result__));
2586 extern int __asprintf (char **__restrict __ptr,
2587 const char *__restrict __fmt, ...)
2588 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__ ((__warn_unused_result__));
2589 extern int asprintf (char **__restrict __ptr,
2590 const char *__restrict __fmt, ...)
2591 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__ ((__warn_unused_result__));
2592 extern int vdprintf (int __fd, const char *__restrict __fmt,
2593 __gnuc_va_list __arg)
2594 __attribute__ ((__format__ (__printf__, 2, 0)));
2595 extern int dprintf (int __fd, const char *__restrict __fmt, ...)
2596 __attribute__ ((__format__ (__printf__, 2, 3)));
2597 extern int fscanf (FILE *__restrict __stream,
2598 const char *__restrict __format, ...) __attribute__ ((__warn_unused_result__));
2599 extern int scanf (const char *__restrict __format, ...) __attribute__ ((__warn_unused_result__));
2600 extern int sscanf (const char *__restrict __s,
2601 const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));
2602 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
2603 __gnuc_va_list __arg)
2604 __attribute__ ((__format__ (__scanf__, 2, 0))) __attribute__ ((__warn_unused_result__));
2605 extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
2606 __attribute__ ((__format__ (__scanf__, 1, 0))) __attribute__ ((__warn_unused_result__));
2607 extern int vsscanf (const char *__restrict __s,
2608 const char *__restrict __format, __gnuc_va_list __arg)
2609 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0)));
2610 extern int fgetc (FILE *__stream);
2611 extern int getc (FILE *__stream);
2612 extern int getchar (void);
2613 extern int getc_unlocked (FILE *__stream);
2614 extern int getchar_unlocked (void);
2615 extern int fgetc_unlocked (FILE *__stream);
2616 extern int fputc (int __c, FILE *__stream);
2617 extern int putc (int __c, FILE *__stream);
2618 extern int putchar (int __c);
2619 extern int fputc_unlocked (int __c, FILE *__stream);
2620 extern int putc_unlocked (int __c, FILE *__stream);
2621 extern int putchar_unlocked (int __c);
2622 extern int getw (FILE *__stream);
2623 extern int putw (int __w, FILE *__stream);
2624 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
2625 __attribute__ ((__warn_unused_result__));
2626 extern char *fgets_unlocked (char *__restrict __s, int __n,
2627 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2628 extern __ssize_t __getdelim (char **__restrict __lineptr,
2629 size_t *__restrict __n, int __delimiter,
2630 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2631 extern __ssize_t getdelim (char **__restrict __lineptr,
2632 size_t *__restrict __n, int __delimiter,
2633 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2634 extern __ssize_t getline (char **__restrict __lineptr,
2635 size_t *__restrict __n,
2636 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2637 extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
2638 extern int puts (const char *__s);
2639 extern int ungetc (int __c, FILE *__stream);
2640 extern size_t fread (void *__restrict __ptr, size_t __size,
2641 size_t __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2642 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
2643 size_t __n, FILE *__restrict __s);
2644 extern int fputs_unlocked (const char *__restrict __s,
2645 FILE *__restrict __stream);
2646 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
2647 size_t __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2648 extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
2649 size_t __n, FILE *__restrict __stream);
2650 extern int fseek (FILE *__stream, long int __off, int __whence);
2651 extern long int ftell (FILE *__stream) __attribute__ ((__warn_unused_result__));
2652 extern void rewind (FILE *__stream);
2653 extern int fseeko (FILE *__stream, __off64_t __off, int __whence) __asm__ ("" "fseeko64")
2654 ;
2655 extern __off64_t ftello (FILE *__stream) __asm__ ("" "ftello64");
2656 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos) __asm__ ("" "fgetpos64")
2657 ;
2658 extern int fsetpos (FILE *__stream, const fpos_t *__pos) __asm__ ("" "fsetpos64")
2659 ;
2660 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
2661 extern __off64_t ftello64 (FILE *__stream) __attribute__ ((__warn_unused_result__));
2662 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
2663 extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
2664 extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2665 extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2666 extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2667 extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2668 extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2669 extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2670 extern void perror (const char *__s);
2671 extern int sys_nerr;
2672 extern const char *const sys_errlist[];
2673 extern int _sys_nerr;
2674 extern const char *const _sys_errlist[];
2675 extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2676 extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2677 extern FILE *popen (const char *__command, const char *__modes) __attribute__ ((__warn_unused_result__));
2678 extern int pclose (FILE *__stream);
2679 extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));
2680 extern char *cuserid (char *__s);
2681 struct obstack;
2682 extern int obstack_printf (struct obstack *__restrict __obstack,
2683 const char *__restrict __format, ...)
2684 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 2, 3)));
2685 extern int obstack_vprintf (struct obstack *__restrict __obstack,
2686 const char *__restrict __format,
2687 __gnuc_va_list __args)
2688 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 2, 0)));
2689 extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2690 extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2691 extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2692 extern __inline int
2693 getchar (void)
2694 {
2695 return _IO_getc (stdin);
2696 }
2697 extern __inline int
2698 fgetc_unlocked (FILE *__fp)
2699 {
2700 return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++);
2701 }
2702 extern __inline int
2703 getc_unlocked (FILE *__fp)
2704 {
2705 return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++);
2706 }
2707 extern __inline int
2708 getchar_unlocked (void)
2709 {
2710 return (__builtin_expect (((stdin)->_IO_read_ptr >= (stdin)->_IO_read_end), 0) ? __uflow (stdin) : *(unsigned char *) (stdin)->_IO_read_ptr++);
2711 }
2712 extern __inline int
2713 putchar (int __c)
2714 {
2715 return _IO_putc (__c, stdout);
2716 }
2717 extern __inline int
2718 fputc_unlocked (int __c, FILE *__stream)
2719 {
2720 return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
2721 }
2722 extern __inline int
2723 putc_unlocked (int __c, FILE *__stream)
2724 {
2725 return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
2726 }
2727 extern __inline int
2728 putchar_unlocked (int __c)
2729 {
2730 return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (unsigned char) (*(stdout)->_IO_write_ptr++ = (__c)));
2731 }
2732 extern __inline __ssize_t
2733 getline (char **__lineptr, size_t *__n, FILE *__stream)
2734 {
2735 return __getdelim (__lineptr, __n, '\n', __stream);
2736 }
2737 extern __inline int
2738 __attribute__ ((__nothrow__ , __leaf__)) feof_unlocked (FILE *__stream)
2739 {
2740 return (((__stream)->_flags & 0x10) != 0);
2741 }
2742 extern __inline int
2743 __attribute__ ((__nothrow__ , __leaf__)) ferror_unlocked (FILE *__stream)
2744 {
2745 return (((__stream)->_flags & 0x20) != 0);
2746 }
2747 extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen,
2748 const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));
2749 extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
2750 const char *__restrict __format,
2751 __gnuc_va_list __ap) __attribute__ ((__nothrow__ , __leaf__));
2752 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2753 __attribute__ ((__nothrow__ , __leaf__)) sprintf (char *__restrict __s, const char *__restrict __fmt, ...)
2754 {
2755 return __builtin___sprintf_chk (__s, 2 - 1,
2756 __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ());
2757 }
2758 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2759 __attribute__ ((__nothrow__ , __leaf__)) vsprintf (char *__restrict __s, const char *__restrict __fmt, __gnuc_va_list __ap)
2760 {
2761 return __builtin___vsprintf_chk (__s, 2 - 1,
2762 __builtin_object_size (__s, 2 > 1), __fmt, __ap);
2763 }
2764 extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag,
2765 size_t __slen, const char *__restrict __format,
2766 ...) __attribute__ ((__nothrow__ , __leaf__));
2767 extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag,
2768 size_t __slen, const char *__restrict __format,
2769 __gnuc_va_list __ap) __attribute__ ((__nothrow__ , __leaf__));
2770 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2771 __attribute__ ((__nothrow__ , __leaf__)) snprintf (char *__restrict __s, size_t __n, const char *__restrict __fmt, ...)
2772 {
2773 return __builtin___snprintf_chk (__s, __n, 2 - 1,
2774 __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ());
2775 }
2776 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2777 __attribute__ ((__nothrow__ , __leaf__)) vsnprintf (char *__restrict __s, size_t __n, const char *__restrict __fmt, __gnuc_va_list __ap)
2778 {
2779 return __builtin___vsnprintf_chk (__s, __n, 2 - 1,
2780 __builtin_object_size (__s, 2 > 1), __fmt, __ap);
2781 }
2782 extern int __fprintf_chk (FILE *__restrict __stream, int __flag,
2783 const char *__restrict __format, ...);
2784 extern int __printf_chk (int __flag, const char *__restrict __format, ...);
2785 extern int __vfprintf_chk (FILE *__restrict __stream, int __flag,
2786 const char *__restrict __format, __gnuc_va_list __ap);
2787 extern int __vprintf_chk (int __flag, const char *__restrict __format,
2788 __gnuc_va_list __ap);
2789 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2790 fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
2791 {
2792 return __fprintf_chk (__stream, 2 - 1, __fmt,
2793 __builtin_va_arg_pack ());
2794 }
2795 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2796 printf (const char *__restrict __fmt, ...)
2797 {
2798 return __printf_chk (2 - 1, __fmt, __builtin_va_arg_pack ());
2799 }
2800 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2801 vprintf (const char *__restrict __fmt, __gnuc_va_list __ap)
2802 {
2803 return __vfprintf_chk (stdout, 2 - 1, __fmt, __ap);
2804 }
2805 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2806 vfprintf (FILE *__restrict __stream,
2807 const char *__restrict __fmt, __gnuc_va_list __ap)
2808 {
2809 return __vfprintf_chk (__stream, 2 - 1, __fmt, __ap);
2810 }
2811 extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt,
2812 ...) __attribute__ ((__format__ (__printf__, 3, 4)));
2813 extern int __vdprintf_chk (int __fd, int __flag,
2814 const char *__restrict __fmt, __gnuc_va_list __arg)
2815 __attribute__ ((__format__ (__printf__, 3, 0)));
2816 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2817 dprintf (int __fd, const char *__restrict __fmt, ...)
2818 {
2819 return __dprintf_chk (__fd, 2 - 1, __fmt,
2820 __builtin_va_arg_pack ());
2821 }
2822 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2823 vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap)
2824 {
2825 return __vdprintf_chk (__fd, 2 - 1, __fmt, __ap);
2826 }
2827 extern int __asprintf_chk (char **__restrict __ptr, int __flag,
2828 const char *__restrict __fmt, ...)
2829 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__printf__, 3, 4))) __attribute__ ((__warn_unused_result__));
2830 extern int __vasprintf_chk (char **__restrict __ptr, int __flag,
2831 const char *__restrict __fmt, __gnuc_va_list __arg)
2832 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__printf__, 3, 0))) __attribute__ ((__warn_unused_result__));
2833 extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
2834 int __flag, const char *__restrict __format,
2835 ...)
2836 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__printf__, 3, 4)));
2837 extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
2838 int __flag,
2839 const char *__restrict __format,
2840 __gnuc_va_list __args)
2841 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__printf__, 3, 0)));
2842 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2843 __attribute__ ((__nothrow__ , __leaf__)) asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...)
2844 {
2845 return __asprintf_chk (__ptr, 2 - 1, __fmt,
2846 __builtin_va_arg_pack ());
2847 }
2848 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2849 __attribute__ ((__nothrow__ , __leaf__)) __asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...)
2850 {
2851 return __asprintf_chk (__ptr, 2 - 1, __fmt,
2852 __builtin_va_arg_pack ());
2853 }
2854 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2855 __attribute__ ((__nothrow__ , __leaf__)) obstack_printf (struct obstack *__restrict __obstack, const char *__restrict __fmt, ...)
2856 {
2857 return __obstack_printf_chk (__obstack, 2 - 1, __fmt,
2858 __builtin_va_arg_pack ());
2859 }
2860 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2861 __attribute__ ((__nothrow__ , __leaf__)) vasprintf (char **__restrict __ptr, const char *__restrict __fmt, __gnuc_va_list __ap)
2862 {
2863 return __vasprintf_chk (__ptr, 2 - 1, __fmt, __ap);
2864 }
2865 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2866 __attribute__ ((__nothrow__ , __leaf__)) obstack_vprintf (struct obstack *__restrict __obstack, const char *__restrict __fmt, __gnuc_va_list __ap)
2867 {
2868 return __obstack_vprintf_chk (__obstack, 2 - 1, __fmt,
2869 __ap);
2870 }
2871 extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n,
2872 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2873 extern char *__fgets_alias (char *__restrict __s, int __n, FILE *__restrict __stream) __asm__ ("" "fgets")
2874 __attribute__ ((__warn_unused_result__));
2875 extern char *__fgets_chk_warn (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __asm__ ("" "__fgets_chk")
2876 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fgets called with bigger size than length " "of destination buffer")))
2877 ;
2878 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
2879 fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
2880 {
2881 if (__builtin_object_size (__s, 2 > 1) != (size_t) -1)
2882 {
2883 if (!__builtin_constant_p (__n) || __n <= 0)
2884 return __fgets_chk (__s, __builtin_object_size (__s, 2 > 1), __n, __stream);
2885 if ((size_t) __n > __builtin_object_size (__s, 2 > 1))
2886 return __fgets_chk_warn (__s, __builtin_object_size (__s, 2 > 1), __n, __stream);
2887 }
2888 return __fgets_alias (__s, __n, __stream);
2889 }
2890 extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen,
2891 size_t __size, size_t __n,
2892 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2893 extern size_t __fread_alias (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "fread")
2894 __attribute__ ((__warn_unused_result__));
2895 extern size_t __fread_chk_warn (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "__fread_chk")
2896 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fread called with bigger size * nmemb than length " "of destination buffer")))
2897 ;
2898 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) size_t
2899 fread (void *__restrict __ptr, size_t __size, size_t __n,
2900 FILE *__restrict __stream)
2901 {
2902 if (__builtin_object_size (__ptr, 0) != (size_t) -1)
2903 {
2904 if (!__builtin_constant_p (__size)
2905 || !__builtin_constant_p (__n)
2906 || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2)))
2907 return __fread_chk (__ptr, __builtin_object_size (__ptr, 0), __size, __n, __stream);
2908 if (__size * __n > __builtin_object_size (__ptr, 0))
2909 return __fread_chk_warn (__ptr, __builtin_object_size (__ptr, 0), __size, __n, __stream);
2910 }
2911 return __fread_alias (__ptr, __size, __n, __stream);
2912 }
2913 extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size,
2914 int __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2915 extern char *__fgets_unlocked_alias (char *__restrict __s, int __n, FILE *__restrict __stream) __asm__ ("" "fgets_unlocked")
2916 __attribute__ ((__warn_unused_result__));
2917 extern char *__fgets_unlocked_chk_warn (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __asm__ ("" "__fgets_unlocked_chk")
2918 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fgets_unlocked called with bigger size than length " "of destination buffer")))
2919 ;
2920 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
2921 fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
2922 {
2923 if (__builtin_object_size (__s, 2 > 1) != (size_t) -1)
2924 {
2925 if (!__builtin_constant_p (__n) || __n <= 0)
2926 return __fgets_unlocked_chk (__s, __builtin_object_size (__s, 2 > 1), __n, __stream);
2927 if ((size_t) __n > __builtin_object_size (__s, 2 > 1))
2928 return __fgets_unlocked_chk_warn (__s, __builtin_object_size (__s, 2 > 1), __n, __stream);
2929 }
2930 return __fgets_unlocked_alias (__s, __n, __stream);
2931 }
2932 extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen,
2933 size_t __size, size_t __n,
2934 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2935 extern size_t __fread_unlocked_alias (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "fread_unlocked")
2936 __attribute__ ((__warn_unused_result__));
2937 extern size_t __fread_unlocked_chk_warn (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "__fread_unlocked_chk")
2938 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fread_unlocked called with bigger size * nmemb than " "length of destination buffer")))
2939 ;
2940 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) size_t
2941 fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
2942 FILE *__restrict __stream)
2943 {
2944 if (__builtin_object_size (__ptr, 0) != (size_t) -1)
2945 {
2946 if (!__builtin_constant_p (__size)
2947 || !__builtin_constant_p (__n)
2948 || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2)))
2949 return __fread_unlocked_chk (__ptr, __builtin_object_size (__ptr, 0), __size, __n,
2950 __stream);
2951 if (__size * __n > __builtin_object_size (__ptr, 0))
2952 return __fread_unlocked_chk_warn (__ptr, __builtin_object_size (__ptr, 0), __size, __n,
2953 __stream);
2954 }
2955 if (__builtin_constant_p (__size)
2956 && __builtin_constant_p (__n)
2957 && (__size | __n) < (((size_t) 1) << (8 * sizeof (size_t) / 2))
2958 && __size * __n <= 8)
2959 {
2960 size_t __cnt = __size * __n;
2961 char *__cptr = (char *) __ptr;
2962 if (__cnt == 0)
2963 return 0;
2964 for (; __cnt > 0; --__cnt)
2965 {
2966 int __c = (__builtin_expect (((__stream)->_IO_read_ptr >= (__stream)->_IO_read_end), 0) ? __uflow (__stream) : *(unsigned char *) (__stream)->_IO_read_ptr++);
2967 if (__c == (-1))
2968 break;
2969 *__cptr++ = __c;
2970 }
2971 return (__cptr - (char *) __ptr) / __size;
2972 }
2973 return __fread_unlocked_alias (__ptr, __size, __n, __stream);
2974 }
2975 typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
2976 res_sendhookact;
2977 typedef res_sendhookact (*res_send_qhook) (struct sockaddr_in * const *__ns,
2978 const u_char **__query,
2979 int *__querylen,
2980 u_char *__ans,
2981 int __anssiz,
2982 int *__resplen);
2983 typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *__ns,
2984 const u_char *__query,
2985 int __querylen,
2986 u_char *__ans,
2987 int __anssiz,
2988 int *__resplen);
2989 struct __res_state {
2990 int retrans;
2991 int retry;
2992 u_long options;
2993 int nscount;
2994 struct sockaddr_in
2995 nsaddr_list[3];
2996 u_short id;
2997 char *dnsrch[6 +1];
2998 char defdname[256];
2999 u_long pfcode;
3000 unsigned ndots:4;
3001 unsigned nsort:4;
3002 unsigned ipv6_unavail:1;
3003 unsigned unused:23;
3004 struct {
3005 struct in_addr addr;
3006 u_int32_t mask;
3007 } sort_list[10];
3008 res_send_qhook qhook;
3009 res_send_rhook rhook;
3010 int res_h_errno;
3011 int _vcsock;
3012 u_int _flags;
3013 union {
3014 char pad[52];
3015 struct {
3016 u_int16_t nscount;
3017 u_int16_t nsmap[3];
3018 int nssocks[3];
3019 u_int16_t nscount6;
3020 u_int16_t nsinit;
3021 struct sockaddr_in6 *nsaddrs[3];
3022 unsigned int _initstamp[2];
3023 } _ext;
3024 } _u;
3025 };
3026 typedef struct __res_state *res_state;
3027 struct res_sym {
3028 int number;
3029 char * name;
3030 char * humanname;
3031 };
3032 extern struct __res_state *__res_state(void) __attribute__ ((__const__));
3033 void __fp_nquery (const u_char *, int, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3034 void __fp_query (const u_char *, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3035 const char * __hostalias (const char *) __attribute__ ((__nothrow__ , __leaf__));
3036 void __p_query (const u_char *) __attribute__ ((__nothrow__ , __leaf__));
3037 void __res_close (void) __attribute__ ((__nothrow__ , __leaf__));
3038 int __res_init (void) __attribute__ ((__nothrow__ , __leaf__));
3039 int __res_isourserver (const struct sockaddr_in *) __attribute__ ((__nothrow__ , __leaf__));
3040 int __res_mkquery (int, const char *, int, int, const u_char *,
3041 int, const u_char *, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3042 int __res_query (const char *, int, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3043 int __res_querydomain (const char *, const char *, int, int,
3044 u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3045 int __res_search (const char *, int, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3046 int __res_send (const u_char *, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3047 int __res_hnok (const char *) __attribute__ ((__nothrow__ , __leaf__));
3048 int __res_ownok (const char *) __attribute__ ((__nothrow__ , __leaf__));
3049 int __res_mailok (const char *) __attribute__ ((__nothrow__ , __leaf__));
3050 int __res_dnok (const char *) __attribute__ ((__nothrow__ , __leaf__));
3051 int __sym_ston (const struct res_sym *, const char *, int *) __attribute__ ((__nothrow__ , __leaf__));
3052 const char * __sym_ntos (const struct res_sym *, int, int *) __attribute__ ((__nothrow__ , __leaf__));
3053 const char * __sym_ntop (const struct res_sym *, int, int *) __attribute__ ((__nothrow__ , __leaf__));
3054 int __b64_ntop(u_char const *,size_t,char *,size_t) __attribute__ ((__nothrow__ , __leaf__));
3055 int __b64_pton(char const *,u_char *,size_t) __attribute__ ((__nothrow__ , __leaf__));
3056 int __loc_aton (const char *__ascii, u_char *__binary) __attribute__ ((__nothrow__ , __leaf__));
3057 const char * __loc_ntoa (const u_char *__binary, char *__ascii) __attribute__ ((__nothrow__ , __leaf__));
3058 int __dn_skipname (const u_char *, const u_char *) __attribute__ ((__nothrow__ , __leaf__));
3059 void __putlong (u_int32_t, u_char *) __attribute__ ((__nothrow__ , __leaf__));
3060 void __putshort (u_int16_t, u_char *) __attribute__ ((__nothrow__ , __leaf__));
3061 const char * __p_class (int) __attribute__ ((__nothrow__ , __leaf__));
3062 const char * __p_time (u_int32_t) __attribute__ ((__nothrow__ , __leaf__));
3063 const char * __p_type (int) __attribute__ ((__nothrow__ , __leaf__));
3064 const char * __p_rcode (int) __attribute__ ((__nothrow__ , __leaf__));
3065 const u_char * __p_cdnname (const u_char *, const u_char *, int, FILE *)
3066 __attribute__ ((__nothrow__ , __leaf__));
3067 const u_char * __p_cdname (const u_char *, const u_char *, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3068 const u_char * __p_fqnname (const u_char *__cp, const u_char *__msg,
3069 int, char *, int) __attribute__ ((__nothrow__ , __leaf__));
3070 const u_char * __p_fqname (const u_char *, const u_char *, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3071 const char * __p_option (u_long __option) __attribute__ ((__nothrow__ , __leaf__));
3072 char * __p_secstodate (u_long) __attribute__ ((__nothrow__ , __leaf__));
3073 int __dn_count_labels (const char *) __attribute__ ((__nothrow__ , __leaf__));
3074 int __dn_comp (const char *, u_char *, int, u_char **, u_char **)
3075 __attribute__ ((__nothrow__ , __leaf__));
3076 int __dn_expand (const u_char *, const u_char *, const u_char *,
3077 char *, int) __attribute__ ((__nothrow__ , __leaf__));
3078 u_int __res_randomid (void) __attribute__ ((__nothrow__ , __leaf__));
3079 int __res_nameinquery (const char *, int, int,
3080 const u_char *, const u_char *) __attribute__ ((__nothrow__ , __leaf__));
3081 int __res_queriesmatch (const u_char *, const u_char *,
3082 const u_char *, const u_char *) __attribute__ ((__nothrow__ , __leaf__));
3083 const char * __p_section (int __section, int __opcode) __attribute__ ((__nothrow__ , __leaf__));
3084 int __res_ninit (res_state) __attribute__ ((__nothrow__ , __leaf__));
3085 int __res_nisourserver (const res_state,
3086 const struct sockaddr_in *) __attribute__ ((__nothrow__ , __leaf__));
3087 void __fp_resstat (const res_state, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3088 void __res_npquery (const res_state, const u_char *, int, FILE *)
3089 __attribute__ ((__nothrow__ , __leaf__));
3090 const char * __res_hostalias (const res_state, const char *, char *, size_t)
3091 __attribute__ ((__nothrow__ , __leaf__));
3092 int __res_nquery (res_state, const char *, int, int, u_char *, int)
3093 __attribute__ ((__nothrow__ , __leaf__));
3094 int __res_nsearch (res_state, const char *, int, int, u_char *, int)
3095 __attribute__ ((__nothrow__ , __leaf__));
3096 int __res_nquerydomain (res_state, const char *, const char *, int,
3097 int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3098 int __res_nmkquery (res_state, int, const char *, int, int,
3099 const u_char *, int, const u_char *, u_char *,
3100 int) __attribute__ ((__nothrow__ , __leaf__));
3101 int __res_nsend (res_state, const u_char *, int, u_char *, int)
3102 __attribute__ ((__nothrow__ , __leaf__));
3103 void __res_nclose (res_state) __attribute__ ((__nothrow__ , __leaf__));
3104 struct rdatainfo {
3105 unsigned int rdi_length;
3106 unsigned char *rdi_data;
3107 };
3108 struct rrsetinfo {
3109 unsigned int rri_flags;
3110 unsigned int rri_rdclass;
3111 unsigned int rri_rdtype;
3112 unsigned int rri_ttl;
3113 unsigned int rri_nrdatas;
3114 unsigned int rri_nsigs;
3115 char *rri_name;
3116 struct rdatainfo *rri_rdatas;
3117 struct rdatainfo *rri_sigs;
3118 };
3119 int getrrsetbyname(const char *, unsigned int, unsigned int, unsigned int, struct rrsetinfo **);
3120 void freerrset(struct rrsetinfo *);
3121 typedef struct BlowfishContext {
3122 u_int32_t S[4][256];
3123 u_int32_t P[16 + 2];
3124 } blf_ctx;
3125 void Blowfish_encipher(blf_ctx *, u_int32_t *, u_int32_t *);
3126 void Blowfish_decipher(blf_ctx *, u_int32_t *, u_int32_t *);
3127 void Blowfish_initstate(blf_ctx *);
3128 void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t);
3129 void Blowfish_expandstate
3130 (blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t);
3131 void blf_key(blf_ctx *, const u_int8_t *, u_int16_t);
3132 void blf_enc(blf_ctx *, u_int32_t *, u_int16_t);
3133 void blf_dec(blf_ctx *, u_int32_t *, u_int16_t);
3134 void blf_ecb_encrypt(blf_ctx *, u_int8_t *, u_int32_t);
3135 void blf_ecb_decrypt(blf_ctx *, u_int8_t *, u_int32_t);
3136 void blf_cbc_encrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t);
3137 void blf_cbc_decrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t);
3138 u_int32_t Blowfish_stream2word(const u_int8_t *, u_int16_t , u_int16_t *);
3139 int bindresvport_sa(int sd, struct sockaddr *sa);
3140 void closefrom(int);
3141 size_t strlcpy(char *dst, const char *src, size_t siz);
3142 size_t strlcat(char *dst, const char *src, size_t siz);
3143 void strmode(int mode, char *p);
3144 int mkstemps(char *path, int slen);
3145 int mkstemp(char *path);
3146 char *mkdtemp(char *path);
3147 int fmt_scaled(long long number, char *result);
3148 int scan_scaled(char *, long long *);
3149 void setproctitle(const char *fmt, ...);
3150 void compat_init_setproctitle(int argc, char *argv[]);
3151 int BSDgetopt(int argc, char * const *argv, const char *opts);
3152 struct option {
3153 const char *name;
3154 int has_arg;
3155 int *flag;
3156 int val;
3157 };
3158 int getopt_long(int, char * const *, const char *,
3159 const struct option *, int *);
3160 int getopt_long_only(int, char * const *, const char *,
3161 const struct option *, int *);
3162 int BSDgetopt(int, char * const *, const char *);
3163 int getsubopt(char **, char * const *, char **);
3164 extern char *BSDoptarg;
3165 extern int BSDopterr;
3166 extern int BSDoptind;
3167 extern int BSDoptopt;
3168 extern int BSDoptreset;
3169 extern char *suboptarg;
3170 char *ssh_get_progname(char *);
3171 int setlogin(const char *);
3172 typedef void (*mysig_t)(int);
3173 mysig_t mysignal(int sig, mysig_t act);
3174 int getpeereid(int , uid_t *, gid_t *);
3175 unsigned int arc4random(void);
3176 void arc4random_stir(void);
3177 void arc4random_buf(void *, size_t);
3178 u_int32_t arc4random_uniform(u_int32_t);
3179 long long strtonum(const char *, long long, long long, const char **);
3180 char *user_from_uid(uid_t, int);
3181 char *group_from_gid(gid_t, int);
3182 int timingsafe_bcmp(const void *, const void *, size_t);
3183 int bcrypt_pbkdf(const char *, size_t, const u_int8_t *, size_t,
3184 u_int8_t *, size_t, unsigned int);
3185 void explicit_bzero(void *p, size_t n);
3186 void *xmmap(size_t size);
3187 char *xcrypt(const char *password, const char *salt);
3188 char *shadow_pw(struct passwd *pw);
3189 void oom_adjust_restore(void);
3190 void oom_adjust_setup(void);
3191 void solaris_contract_pre_fork(void);
3192 void solaris_contract_post_fork_child(void);
3193 void solaris_contract_post_fork_parent(pid_t pid);
3194 void solaris_set_default_project(struct passwd *);
3195 struct Channel;
3196 int sys_tun_open(int, int);
3197 int sys_tun_infilter(struct Channel *, char *, int);
3198 u_char *sys_tun_outfilter(struct Channel *, u_char **, u_int *);
3199 typedef struct {
3200 u_char *buf;
3201 u_int alloc;
3202 u_int offset;
3203 u_int end;
3204 } Buffer;
3205 void buffer_init(Buffer *);
3206 void buffer_clear(Buffer *);
3207 void buffer_free(Buffer *);
3208 u_int buffer_len(const Buffer *);
3209 void *buffer_ptr(const Buffer *);
3210 void buffer_append(Buffer *, const void *, u_int);
3211 void *buffer_append_space(Buffer *, u_int);
3212 int buffer_check_alloc(Buffer *, u_int);
3213 void buffer_get(Buffer *, void *, u_int);
3214 void buffer_consume(Buffer *, u_int);
3215 void buffer_consume_end(Buffer *, u_int);
3216 void buffer_dump(const Buffer *);
3217 int buffer_get_ret(Buffer *, void *, u_int);
3218 int buffer_consume_ret(Buffer *, u_int);
3219 int buffer_consume_end_ret(Buffer *, u_int);
3220 typedef struct asn1_string_st ASN1_INTEGER;
3221 typedef struct asn1_string_st ASN1_ENUMERATED;
3222 typedef struct asn1_string_st ASN1_BIT_STRING;
3223 typedef struct asn1_string_st ASN1_OCTET_STRING;
3224 typedef struct asn1_string_st ASN1_PRINTABLESTRING;
3225 typedef struct asn1_string_st ASN1_T61STRING;
3226 typedef struct asn1_string_st ASN1_IA5STRING;
3227 typedef struct asn1_string_st ASN1_GENERALSTRING;
3228 typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
3229 typedef struct asn1_string_st ASN1_BMPSTRING;
3230 typedef struct asn1_string_st ASN1_UTCTIME;
3231 typedef struct asn1_string_st ASN1_TIME;
3232 typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
3233 typedef struct asn1_string_st ASN1_VISIBLESTRING;
3234 typedef struct asn1_string_st ASN1_UTF8STRING;
3235 typedef struct asn1_string_st ASN1_STRING;
3236 typedef int ASN1_BOOLEAN;
3237 typedef int ASN1_NULL;
3238 typedef struct ASN1_ITEM_st ASN1_ITEM;
3239 typedef struct asn1_pctx_st ASN1_PCTX;
3240 typedef struct bignum_st BIGNUM;
3241 typedef struct bignum_ctx BN_CTX;
3242 typedef struct bn_blinding_st BN_BLINDING;
3243 typedef struct bn_mont_ctx_st BN_MONT_CTX;
3244 typedef struct bn_recp_ctx_st BN_RECP_CTX;
3245 typedef struct bn_gencb_st BN_GENCB;
3246 typedef struct buf_mem_st BUF_MEM;
3247 typedef struct evp_cipher_st EVP_CIPHER;
3248 typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
3249 typedef struct env_md_st EVP_MD;
3250 typedef struct env_md_ctx_st EVP_MD_CTX;
3251 typedef struct evp_pkey_st EVP_PKEY;
3252 typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
3253 typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
3254 typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
3255 typedef struct dh_st DH;
3256 typedef struct dh_method DH_METHOD;
3257 typedef struct dsa_st DSA;
3258 typedef struct dsa_method DSA_METHOD;
3259 typedef struct rsa_st RSA;
3260 typedef struct rsa_meth_st RSA_METHOD;
3261 typedef struct rand_meth_st RAND_METHOD;
3262 typedef struct ecdh_method ECDH_METHOD;
3263 typedef struct ecdsa_method ECDSA_METHOD;
3264 typedef struct x509_st X509;
3265 typedef struct X509_algor_st X509_ALGOR;
3266 typedef struct X509_crl_st X509_CRL;
3267 typedef struct x509_crl_method_st X509_CRL_METHOD;
3268 typedef struct x509_revoked_st X509_REVOKED;
3269 typedef struct X509_name_st X509_NAME;
3270 typedef struct X509_pubkey_st X509_PUBKEY;
3271 typedef struct x509_store_st X509_STORE;
3272 typedef struct x509_store_ctx_st X509_STORE_CTX;
3273 typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;
3274 typedef struct v3_ext_ctx X509V3_CTX;
3275 typedef struct conf_st CONF;
3276 typedef struct store_st STORE;
3277 typedef struct store_method_st STORE_METHOD;
3278 typedef struct ui_st UI;
3279 typedef struct ui_method_st UI_METHOD;
3280 typedef struct st_ERR_FNS ERR_FNS;
3281 typedef struct engine_st ENGINE;
3282 typedef struct ssl_st SSL;
3283 typedef struct ssl_ctx_st SSL_CTX;
3284 typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
3285 typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
3286 typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
3287 typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
3288 typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;
3289 typedef struct DIST_POINT_st DIST_POINT;
3290 typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
3291 typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
3292 typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
3293 typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
3294 int idx, long argl, void *argp);
3295 typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
3296 int idx, long argl, void *argp);
3297 typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
3298 int idx, long argl, void *argp);
3299 typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
3300 typedef struct ocsp_response_st OCSP_RESPONSE;
3301 typedef struct ocsp_responder_id_st OCSP_RESPID;
3302 typedef struct stack_st
3303 {
3304 int num;
3305 char **data;
3306 int sorted;
3307 int num_alloc;
3308 int (*comp)(const void *, const void *);
3309 } _STACK;
3310 int sk_num(const _STACK *);
3311 void *sk_value(const _STACK *, int);
3312 void *sk_set(_STACK *, int, void *);
3313 _STACK *sk_new(int (*cmp)(const void *, const void *));
3314 _STACK *sk_new_null(void);
3315 void sk_free(_STACK *);
3316 void sk_pop_free(_STACK *st, void (*func)(void *));
3317 int sk_insert(_STACK *sk, void *data, int where);
3318 void *sk_delete(_STACK *st, int loc);
3319 void *sk_delete_ptr(_STACK *st, void *p);
3320 int sk_find(_STACK *st, void *data);
3321 int sk_find_ex(_STACK *st, void *data);
3322 int sk_push(_STACK *st, void *data);
3323 int sk_unshift(_STACK *st, void *data);
3324 void *sk_shift(_STACK *st);
3325 void *sk_pop(_STACK *st);
3326 void sk_zero(_STACK *st);
3327 int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))
3328 (const void *, const void *);
3329 _STACK *sk_dup(_STACK *st);
3330 void sk_sort(_STACK *st);
3331 int sk_is_sorted(const _STACK *st);
3332 typedef char *OPENSSL_STRING;
3333 typedef const char *OPENSSL_CSTRING;
3334 struct stack_st_OPENSSL_STRING { _STACK stack; };
3335 typedef void *OPENSSL_BLOCK;
3336 struct stack_st_OPENSSL_BLOCK { _STACK stack; };
3337 typedef struct openssl_item_st
3338 {
3339 int code;
3340 void *value;
3341 size_t value_size;
3342 size_t *value_length;
3343 } OPENSSL_ITEM;
3344 typedef struct
3345 {
3346 int references;
3347 struct CRYPTO_dynlock_value *data;
3348 } CRYPTO_dynlock;
3349 typedef struct bio_st BIO_dummy;
3350 struct crypto_ex_data_st
3351 {
3352 struct stack_st_void *sk;
3353 int dummy;
3354 };
3355 struct stack_st_void { _STACK stack; };
3356 typedef struct crypto_ex_data_func_st
3357 {
3358 long argl;
3359 void *argp;
3360 CRYPTO_EX_new *new_func;
3361 CRYPTO_EX_free *free_func;
3362 CRYPTO_EX_dup *dup_func;
3363 } CRYPTO_EX_DATA_FUNCS;
3364 struct stack_st_CRYPTO_EX_DATA_FUNCS { _STACK stack; };
3365 int CRYPTO_mem_ctrl(int mode);
3366 int CRYPTO_is_mem_check_on(void);
3367 const char *SSLeay_version(int type);
3368 unsigned long SSLeay(void);
3369 int OPENSSL_issetugid(void);
3370 typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
3371 const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
3372 int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
3373 int CRYPTO_ex_data_new_class(void);
3374 int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
3375 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
3376 CRYPTO_EX_free *free_func);
3377 int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
3378 int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
3379 CRYPTO_EX_DATA *from);
3380 void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
3381 int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
3382 void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
3383 void CRYPTO_cleanup_all_ex_data(void);
3384 int CRYPTO_get_new_lockid(char *name);
3385 int CRYPTO_num_locks(void);
3386 void CRYPTO_lock(int mode, int type,const char *file,int line);
3387 void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
3388 const char *file,int line));
3389 void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
3390 int line);
3391 void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
3392 const char *file, int line));
3393 int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
3394 const char *file,int line);
3395 typedef struct crypto_threadid_st
3396 {
3397 void *ptr;
3398 unsigned long val;
3399 } CRYPTO_THREADID;
3400 void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
3401 void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
3402 int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID *));
3403 void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *);
3404 void CRYPTO_THREADID_current(CRYPTO_THREADID *id);
3405 int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);
3406 void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);
3407 unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);
3408 void CRYPTO_set_id_callback(unsigned long (*func)(void));
3409 unsigned long (*CRYPTO_get_id_callback(void))(void);
3410 unsigned long CRYPTO_thread_id(void);
3411 const char *CRYPTO_get_lock_name(int type);
3412 int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
3413 int line);
3414 int CRYPTO_get_new_dynlockid(void);
3415 void CRYPTO_destroy_dynlockid(int i);
3416 struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
3417 void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
3418 void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
3419 void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
3420 struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
3421 void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
3422 void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
3423 int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
3424 int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
3425 int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
3426 void *(*r)(void *,size_t,const char *,int),
3427 void (*f)(void *));
3428 int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
3429 void (*free_func)(void *));
3430 int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
3431 void (*r)(void *,void *,int,const char *,int,int),
3432 void (*f)(void *,int),
3433 void (*so)(long),
3434 long (*go)(void));
3435 void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
3436 void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
3437 void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
3438 void *(**r)(void *, size_t,const char *,int),
3439 void (**f)(void *));
3440 void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
3441 void (**f)(void *));
3442 void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
3443 void (**r)(void *,void *,int,const char *,int,int),
3444 void (**f)(void *,int),
3445 void (**so)(long),
3446 long (**go)(void));
3447 void *CRYPTO_malloc_locked(int num, const char *file, int line);
3448 void CRYPTO_free_locked(void *ptr);
3449 void *CRYPTO_malloc(int num, const char *file, int line);
3450 char *CRYPTO_strdup(const char *str, const char *file, int line);
3451 void CRYPTO_free(void *ptr);
3452 void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
3453 void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
3454 int line);
3455 void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
3456 void OPENSSL_cleanse(void *ptr, size_t len);
3457 void CRYPTO_set_mem_debug_options(long bits);
3458 long CRYPTO_get_mem_debug_options(void);
3459 int CRYPTO_push_info_(const char *info, const char *file, int line);
3460 int CRYPTO_pop_info(void);
3461 int CRYPTO_remove_all_info(void);
3462 void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
3463 void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
3464 void CRYPTO_dbg_free(void *addr,int before_p);
3465 void CRYPTO_dbg_set_options(long bits);
3466 long CRYPTO_dbg_get_options(void);
3467 void CRYPTO_mem_leaks_fp(FILE *);
3468 void CRYPTO_mem_leaks(struct bio_st *bio);
3469 typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
3470 void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
3471 void OpenSSLDie(const char *file,int line,const char *assertion);
3472 unsigned long *OPENSSL_ia32cap_loc(void);
3473 int OPENSSL_isservice(void);
3474 int FIPS_mode(void);
3475 int FIPS_mode_set(int r);
3476 void OPENSSL_init(void);
3477 int CRYPTO_memcmp(const void *a, const void *b, size_t len);
3478 void ERR_load_CRYPTO_strings(void);
3479 struct bignum_st
3480 {
3481 unsigned int *d;
3482 int top;
3483 int dmax;
3484 int neg;
3485 int flags;
3486 };
3487 struct bn_mont_ctx_st
3488 {
3489 int ri;
3490 BIGNUM RR;
3491 BIGNUM N;
3492 BIGNUM Ni;
3493 unsigned int n0[2];
3494 int flags;
3495 };
3496 struct bn_recp_ctx_st
3497 {
3498 BIGNUM N;
3499 BIGNUM Nr;
3500 int num_bits;
3501 int shift;
3502 int flags;
3503 };
3504 struct bn_gencb_st
3505 {
3506 unsigned int ver;
3507 void *arg;
3508 union
3509 {
3510 void (*cb_1)(int, int, void *);
3511 int (*cb_2)(int, int, BN_GENCB *);
3512 } cb;
3513 };
3514 int BN_GENCB_call(BN_GENCB *cb, int a, int b);
3515 const BIGNUM *BN_value_one(void);
3516 char * BN_options(void);
3517 BN_CTX *BN_CTX_new(void);
3518 void BN_CTX_init(BN_CTX *c);
3519 void BN_CTX_free(BN_CTX *c);
3520 void BN_CTX_start(BN_CTX *ctx);
3521 BIGNUM *BN_CTX_get(BN_CTX *ctx);
3522 void BN_CTX_end(BN_CTX *ctx);
3523 int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
3524 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
3525 int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
3526 int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
3527 int BN_num_bits(const BIGNUM *a);
3528 int BN_num_bits_word(unsigned int);
3529 BIGNUM *BN_new(void);
3530 void BN_init(BIGNUM *);
3531 void BN_clear_free(BIGNUM *a);
3532 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
3533 void BN_swap(BIGNUM *a, BIGNUM *b);
3534 BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
3535 int BN_bn2bin(const BIGNUM *a, unsigned char *to);
3536 BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
3537 int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
3538 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3539 int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3540 int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3541 int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3542 int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
3543 int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx);
3544 void BN_set_negative(BIGNUM *b, int n);
3545 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
3546 BN_CTX *ctx);
3547 int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
3548 int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
3549 int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
3550 int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
3551 int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
3552 int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3553 const BIGNUM *m, BN_CTX *ctx);
3554 int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
3555 int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
3556 int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
3557 int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx);
3558 int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
3559 unsigned int BN_mod_word(const BIGNUM *a, unsigned int w);
3560 unsigned int BN_div_word(BIGNUM *a, unsigned int w);
3561 int BN_mul_word(BIGNUM *a, unsigned int w);
3562 int BN_add_word(BIGNUM *a, unsigned int w);
3563 int BN_sub_word(BIGNUM *a, unsigned int w);
3564 int BN_set_word(BIGNUM *a, unsigned int w);
3565 unsigned int BN_get_word(const BIGNUM *a);
3566 int BN_cmp(const BIGNUM *a, const BIGNUM *b);
3567 void BN_free(BIGNUM *a);
3568 int BN_is_bit_set(const BIGNUM *a, int n);
3569 int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
3570 int BN_lshift1(BIGNUM *r, const BIGNUM *a);
3571 int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx);
3572 int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3573 const BIGNUM *m,BN_CTX *ctx);
3574 int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3575 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
3576 int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
3577 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
3578 int BN_mod_exp_mont_word(BIGNUM *r, unsigned int a, const BIGNUM *p,
3579 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
3580 int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
3581 const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m,
3582 BN_CTX *ctx,BN_MONT_CTX *m_ctx);
3583 int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3584 const BIGNUM *m,BN_CTX *ctx);
3585 int BN_mask_bits(BIGNUM *a,int n);
3586 int BN_print_fp(FILE *fp, const BIGNUM *a);
3587 int BN_print(void *fp, const BIGNUM *a);
3588 int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
3589 int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
3590 int BN_rshift1(BIGNUM *r, const BIGNUM *a);
3591 void BN_clear(BIGNUM *a);
3592 BIGNUM *BN_dup(const BIGNUM *a);
3593 int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
3594 int BN_set_bit(BIGNUM *a, int n);
3595 int BN_clear_bit(BIGNUM *a, int n);
3596 char * BN_bn2hex(const BIGNUM *a);
3597 char * BN_bn2dec(const BIGNUM *a);
3598 int BN_hex2bn(BIGNUM **a, const char *str);
3599 int BN_dec2bn(BIGNUM **a, const char *str);
3600 int BN_asc2bn(BIGNUM **a, const char *str);
3601 int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
3602 int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
3603 BIGNUM *BN_mod_inverse(BIGNUM *ret,
3604 const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
3605 BIGNUM *BN_mod_sqrt(BIGNUM *ret,
3606 const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
3607 BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,
3608 const BIGNUM *add, const BIGNUM *rem,
3609 void (*callback)(int,int,void *),void *cb_arg);
3610 int BN_is_prime(const BIGNUM *p,int nchecks,
3611 void (*callback)(int,int,void *),
3612 BN_CTX *ctx,void *cb_arg);
3613 int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
3614 void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
3615 int do_trial_division);
3616 int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add,
3617 const BIGNUM *rem, BN_GENCB *cb);
3618 int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
3619 int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
3620 int do_trial_division, BN_GENCB *cb);
3621 int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
3622 int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
3623 const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
3624 const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
3625 int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
3626 BIGNUM *Xp1, BIGNUM *Xp2,
3627 const BIGNUM *Xp,
3628 const BIGNUM *e, BN_CTX *ctx,
3629 BN_GENCB *cb);
3630 BN_MONT_CTX *BN_MONT_CTX_new(void );
3631 void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
3632 int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
3633 BN_MONT_CTX *mont, BN_CTX *ctx);
3634 int BN_from_montgomery(BIGNUM *r,const BIGNUM *a,
3635 BN_MONT_CTX *mont, BN_CTX *ctx);
3636 void BN_MONT_CTX_free(BN_MONT_CTX *mont);
3637 int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx);
3638 BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
3639 BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
3640 const BIGNUM *mod, BN_CTX *ctx);
3641 BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
3642 void BN_BLINDING_free(BN_BLINDING *b);
3643 int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
3644 int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
3645 int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
3646 int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
3647 int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
3648 unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
3649 void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
3650 CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
3651 unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
3652 void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
3653 BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
3654 const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
3655 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3656 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
3657 BN_MONT_CTX *m_ctx);
3658 void BN_set_params(int mul,int high,int low,int mont);
3659 int BN_get_params(int which);
3660 void BN_RECP_CTX_init(BN_RECP_CTX *recp);
3661 BN_RECP_CTX *BN_RECP_CTX_new(void);
3662 void BN_RECP_CTX_free(BN_RECP_CTX *recp);
3663 int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
3664 int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
3665 BN_RECP_CTX *recp,BN_CTX *ctx);
3666 int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3667 const BIGNUM *m, BN_CTX *ctx);
3668 int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
3669 BN_RECP_CTX *recp, BN_CTX *ctx);
3670 int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3671 int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);
3672 int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3673 const BIGNUM *p, BN_CTX *ctx);
3674 int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3675 BN_CTX *ctx);
3676 int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p,
3677 BN_CTX *ctx);
3678 int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3679 const BIGNUM *p, BN_CTX *ctx);
3680 int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3681 const BIGNUM *p, BN_CTX *ctx);
3682 int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3683 BN_CTX *ctx);
3684 int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3685 BN_CTX *ctx);
3686 int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
3687 int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3688 const int p[], BN_CTX *ctx);
3689 int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
3690 BN_CTX *ctx);
3691 int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
3692 BN_CTX *ctx);
3693 int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3694 const int p[], BN_CTX *ctx);
3695 int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3696 const int p[], BN_CTX *ctx);
3697 int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
3698 const int p[], BN_CTX *ctx);
3699 int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
3700 const int p[], BN_CTX *ctx);
3701 int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
3702 int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
3703 int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3704 int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3705 int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3706 int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3707 int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3708 const BIGNUM *BN_get0_nist_prime_192(void);
3709 const BIGNUM *BN_get0_nist_prime_224(void);
3710 const BIGNUM *BN_get0_nist_prime_256(void);
3711 const BIGNUM *BN_get0_nist_prime_384(void);
3712 const BIGNUM *BN_get0_nist_prime_521(void);
3713 BIGNUM *bn_expand2(BIGNUM *a, int words);
3714 BIGNUM *bn_dup_expand(const BIGNUM *a, int words);
3715 unsigned int bn_mul_add_words(unsigned int *rp, const unsigned int *ap, int num, unsigned int w);
3716 unsigned int bn_mul_words(unsigned int *rp, const unsigned int *ap, int num, unsigned int w);
3717 void bn_sqr_words(unsigned int *rp, const unsigned int *ap, int num);
3718 unsigned int bn_div_words(unsigned int h, unsigned int l, unsigned int d);
3719 unsigned int bn_add_words(unsigned int *rp, const unsigned int *ap, const unsigned int *bp,int num);
3720 unsigned int bn_sub_words(unsigned int *rp, const unsigned int *ap, const unsigned int *bp,int num);
3721 BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
3722 BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);
3723 BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);
3724 BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);
3725 BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);
3726 BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
3727 BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
3728 BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
3729 int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
3730 void ERR_load_BN_strings(void);
3731 void buffer_put_bignum(Buffer *, const BIGNUM *);
3732 void buffer_put_bignum2(Buffer *, const BIGNUM *);
3733 void buffer_get_bignum(Buffer *, BIGNUM *);
3734 void buffer_get_bignum2(Buffer *, BIGNUM *);
3735 u_short buffer_get_short(Buffer *);
3736 void buffer_put_short(Buffer *, u_short);
3737 u_int buffer_get_int(Buffer *);
3738 void buffer_put_int(Buffer *, u_int);
3739 u_int64_t buffer_get_int64(Buffer *);
3740 void buffer_put_int64(Buffer *, u_int64_t);
3741 int buffer_get_char(Buffer *);
3742 void buffer_put_char(Buffer *, int);
3743 void *buffer_get_string(Buffer *, u_int *);
3744 void *buffer_get_string_ptr(Buffer *, u_int *);
3745 void buffer_put_string(Buffer *, const void *, u_int);
3746 char *buffer_get_cstring(Buffer *, u_int *);
3747 void buffer_put_cstring(Buffer *, const char *);
3748 int buffer_put_bignum_ret(Buffer *, const BIGNUM *);
3749 int buffer_get_bignum_ret(Buffer *, BIGNUM *);
3750 int buffer_put_bignum2_ret(Buffer *, const BIGNUM *);
3751 int buffer_get_bignum2_ret(Buffer *, BIGNUM *);
3752 int buffer_get_short_ret(u_short *, Buffer *);
3753 int buffer_get_int_ret(u_int *, Buffer *);
3754 int buffer_get_int64_ret(u_int64_t *, Buffer *);
3755 void *buffer_get_string_ret(Buffer *, u_int *);
3756 char *buffer_get_cstring_ret(Buffer *, u_int *);
3757 void *buffer_get_string_ptr_ret(Buffer *, u_int *);
3758 int buffer_get_char_ret(u_char *, Buffer *);
3759 void *buffer_get_bignum2_as_string_ret(Buffer *, u_int *);
3760 void *buffer_get_bignum2_as_string(Buffer *, u_int *);
3761 void buffer_put_bignum2_from_string(Buffer *, const u_char *, u_int);
3762 struct timex
3763 {
3764 unsigned int modes;
3765 __syscall_slong_t offset;
3766 __syscall_slong_t freq;
3767 __syscall_slong_t maxerror;
3768 __syscall_slong_t esterror;
3769 int status;
3770 __syscall_slong_t constant;
3771 __syscall_slong_t precision;
3772 __syscall_slong_t tolerance;
3773 struct timeval time;
3774 __syscall_slong_t tick;
3775 __syscall_slong_t ppsfreq;
3776 __syscall_slong_t jitter;
3777 int shift;
3778 __syscall_slong_t stabil;
3779 __syscall_slong_t jitcnt;
3780 __syscall_slong_t calcnt;
3781 __syscall_slong_t errcnt;
3782 __syscall_slong_t stbcnt;
3783 int tai;
3784 int :32; int :32; int :32; int :32;
3785 int :32; int :32; int :32; int :32;
3786 int :32; int :32; int :32;
3787 };
3788 extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __attribute__ ((__nothrow__ , __leaf__));
3789 struct tm
3790 {
3791 int tm_sec;
3792 int tm_min;
3793 int tm_hour;
3794 int tm_mday;
3795 int tm_mon;
3796 int tm_year;
3797 int tm_wday;
3798 int tm_yday;
3799 int tm_isdst;
3800 long int tm_gmtoff;
3801 const char *tm_zone;
3802 };
3803 struct itimerspec
3804 {
3805 struct timespec it_interval;
3806 struct timespec it_value;
3807 };
3808 struct sigevent;
3809 extern clock_t clock (void) __attribute__ ((__nothrow__ , __leaf__));
3810 extern time_t time (time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
3811 extern double difftime (time_t __time1, time_t __time0)
3812 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
3813 extern time_t mktime (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
3814 extern size_t strftime (char *__restrict __s, size_t __maxsize,
3815 const char *__restrict __format,
3816 const struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
3817 extern char *strptime (const char *__restrict __s,
3818 const char *__restrict __fmt, struct tm *__tp)
3819 __attribute__ ((__nothrow__ , __leaf__));
3820 extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
3821 const char *__restrict __format,
3822 const struct tm *__restrict __tp,
3823 __locale_t __loc) __attribute__ ((__nothrow__ , __leaf__));
3824 extern char *strptime_l (const char *__restrict __s,
3825 const char *__restrict __fmt, struct tm *__tp,
3826 __locale_t __loc) __attribute__ ((__nothrow__ , __leaf__));
3827 extern struct tm *gmtime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
3828 extern struct tm *localtime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
3829 extern struct tm *gmtime_r (const time_t *__restrict __timer,
3830 struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
3831 extern struct tm *localtime_r (const time_t *__restrict __timer,
3832 struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
3833 extern char *asctime (const struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
3834 extern char *ctime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
3835 extern char *asctime_r (const struct tm *__restrict __tp,
3836 char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
3837 extern char *ctime_r (const time_t *__restrict __timer,
3838 char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
3839 extern char *__tzname[2];
3840 extern int __daylight;
3841 extern long int __timezone;
3842 extern char *tzname[2];
3843 extern void tzset (void) __attribute__ ((__nothrow__ , __leaf__));
3844 extern int daylight;
3845 extern long int timezone;
3846 extern int stime (const time_t *__when) __attribute__ ((__nothrow__ , __leaf__));
3847 extern time_t timegm (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
3848 extern time_t timelocal (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
3849 extern int dysize (int __year) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
3850 extern int nanosleep (const struct timespec *__requested_time,
3851 struct timespec *__remaining);
3852 extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __attribute__ ((__nothrow__ , __leaf__));
3853 extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __attribute__ ((__nothrow__ , __leaf__));
3854 extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
3855 __attribute__ ((__nothrow__ , __leaf__));
3856 extern int clock_nanosleep (clockid_t __clock_id, int __flags,
3857 const struct timespec *__req,
3858 struct timespec *__rem);
3859 extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __attribute__ ((__nothrow__ , __leaf__));
3860 extern int timer_create (clockid_t __clock_id,
3861 struct sigevent *__restrict __evp,
3862 timer_t *__restrict __timerid) __attribute__ ((__nothrow__ , __leaf__));
3863 extern int timer_delete (timer_t __timerid) __attribute__ ((__nothrow__ , __leaf__));
3864 extern int timer_settime (timer_t __timerid, int __flags,
3865 const struct itimerspec *__restrict __value,
3866 struct itimerspec *__restrict __ovalue) __attribute__ ((__nothrow__ , __leaf__));
3867 extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
3868 __attribute__ ((__nothrow__ , __leaf__));
3869 extern int timer_getoverrun (timer_t __timerid) __attribute__ ((__nothrow__ , __leaf__));
3870 extern int timespec_get (struct timespec *__ts, int __base)
3871 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
3872 extern int getdate_err;
3873 extern struct tm *getdate (const char *__string);
3874 extern int getdate_r (const char *__restrict __string,
3875 struct tm *__restrict __resbufp);
3876 typedef struct bio_st BIO;
3877 void BIO_set_flags(BIO *b, int flags);
3878 int BIO_test_flags(const BIO *b, int flags);
3879 void BIO_clear_flags(BIO *b, int flags);
3880 long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long);
3881 void BIO_set_callback(BIO *b,
3882 long (*callback)(struct bio_st *,int,const char *,int, long,long));
3883 char *BIO_get_callback_arg(const BIO *b);
3884 void BIO_set_callback_arg(BIO *b, char *arg);
3885 const char * BIO_method_name(const BIO *b);
3886 int BIO_method_type(const BIO *b);
3887 typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
3888 typedef struct bio_method_st
3889 {
3890 int type;
3891 const char *name;
3892 int (*bwrite)(BIO *, const char *, int);
3893 int (*bread)(BIO *, char *, int);
3894 int (*bputs)(BIO *, const char *);
3895 int (*bgets)(BIO *, char *, int);
3896 long (*ctrl)(BIO *, int, long, void *);
3897 int (*create)(BIO *);
3898 int (*destroy)(BIO *);
3899 long (*callback_ctrl)(BIO *, int, bio_info_cb *);
3900 } BIO_METHOD;
3901 struct bio_st
3902 {
3903 BIO_METHOD *method;
3904 long (*callback)(struct bio_st *,int,const char *,int, long,long);
3905 char *cb_arg;
3906 int init;
3907 int shutdown;
3908 int flags;
3909 int retry_reason;
3910 int num;
3911 void *ptr;
3912 struct bio_st *next_bio;
3913 struct bio_st *prev_bio;
3914 int references;
3915 unsigned long num_read;
3916 unsigned long num_write;
3917 CRYPTO_EX_DATA ex_data;
3918 };
3919 struct stack_st_BIO { _STACK stack; };
3920 typedef struct bio_f_buffer_ctx_struct
3921 {
3922 int ibuf_size;
3923 int obuf_size;
3924 char *ibuf;
3925 int ibuf_len;
3926 int ibuf_off;
3927 char *obuf;
3928 int obuf_len;
3929 int obuf_off;
3930 } BIO_F_BUFFER_CTX;
3931 typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg);
3932 size_t BIO_ctrl_pending(BIO *b);
3933 size_t BIO_ctrl_wpending(BIO *b);
3934 size_t BIO_ctrl_get_write_guarantee(BIO *b);
3935 size_t BIO_ctrl_get_read_request(BIO *b);
3936 int BIO_ctrl_reset_read_request(BIO *b);
3937 int BIO_set_ex_data(BIO *bio,int idx,void *data);
3938 void *BIO_get_ex_data(BIO *bio,int idx);
3939 int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
3940 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
3941 unsigned long BIO_number_read(BIO *bio);
3942 unsigned long BIO_number_written(BIO *bio);
3943 int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
3944 asn1_ps_func *prefix_free);
3945 int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
3946 asn1_ps_func **pprefix_free);
3947 int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
3948 asn1_ps_func *suffix_free);
3949 int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
3950 asn1_ps_func **psuffix_free);
3951 BIO_METHOD *BIO_s_file(void );
3952 BIO *BIO_new_file(const char *filename, const char *mode);
3953 BIO *BIO_new_fp(FILE *stream, int close_flag);
3954 BIO * BIO_new(BIO_METHOD *type);
3955 int BIO_set(BIO *a,BIO_METHOD *type);
3956 int BIO_free(BIO *a);
3957 void BIO_vfree(BIO *a);
3958 int BIO_read(BIO *b, void *data, int len);
3959 int BIO_gets(BIO *bp,char *buf, int size);
3960 int BIO_write(BIO *b, const void *data, int len);
3961 int BIO_puts(BIO *bp,const char *buf);
3962 int BIO_indent(BIO *b,int indent,int max);
3963 long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
3964 long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
3965 char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
3966 long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
3967 BIO * BIO_push(BIO *b,BIO *append);
3968 BIO * BIO_pop(BIO *b);
3969 void BIO_free_all(BIO *a);
3970 BIO * BIO_find_type(BIO *b,int bio_type);
3971 BIO * BIO_next(BIO *b);
3972 BIO * BIO_get_retry_BIO(BIO *bio, int *reason);
3973 int BIO_get_retry_reason(BIO *bio);
3974 BIO * BIO_dup_chain(BIO *in);
3975 int BIO_nread0(BIO *bio, char **buf);
3976 int BIO_nread(BIO *bio, char **buf, int num);
3977 int BIO_nwrite0(BIO *bio, char **buf);
3978 int BIO_nwrite(BIO *bio, char **buf, int num);
3979 long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
3980 long argl,long ret);
3981 BIO_METHOD *BIO_s_mem(void);
3982 BIO *BIO_new_mem_buf(void *buf, int len);
3983 BIO_METHOD *BIO_s_socket(void);
3984 BIO_METHOD *BIO_s_connect(void);
3985 BIO_METHOD *BIO_s_accept(void);
3986 BIO_METHOD *BIO_s_fd(void);
3987 BIO_METHOD *BIO_s_log(void);
3988 BIO_METHOD *BIO_s_bio(void);
3989 BIO_METHOD *BIO_s_null(void);
3990 BIO_METHOD *BIO_f_null(void);
3991 BIO_METHOD *BIO_f_buffer(void);
3992 BIO_METHOD *BIO_f_nbio_test(void);
3993 BIO_METHOD *BIO_s_datagram(void);
3994 int BIO_sock_should_retry(int i);
3995 int BIO_sock_non_fatal_error(int error);
3996 int BIO_dgram_non_fatal_error(int error);
3997 int BIO_fd_should_retry(int i);
3998 int BIO_fd_non_fatal_error(int error);
3999 int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u),
4000 void *u, const char *s, int len);
4001 int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
4002 void *u, const char *s, int len, int indent);
4003 int BIO_dump(BIO *b,const char *bytes,int len);
4004 int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
4005 int BIO_dump_fp(FILE *fp, const char *s, int len);
4006 int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
4007 struct hostent *BIO_gethostbyname(const char *name);
4008 int BIO_sock_error(int sock);
4009 int BIO_socket_ioctl(int fd, long type, void *arg);
4010 int BIO_socket_nbio(int fd,int mode);
4011 int BIO_get_port(const char *str, unsigned short *port_ptr);
4012 int BIO_get_host_ip(const char *str, unsigned char *ip);
4013 int BIO_get_accept_socket(char *host_port,int mode);
4014 int BIO_accept(int sock,char **ip_port);
4015 int BIO_sock_init(void );
4016 void BIO_sock_cleanup(void);
4017 int BIO_set_tcp_ndelay(int sock,int turn_on);
4018 BIO *BIO_new_socket(int sock, int close_flag);
4019 BIO *BIO_new_dgram(int fd, int close_flag);
4020 BIO *BIO_new_fd(int fd, int close_flag);
4021 BIO *BIO_new_connect(char *host_port);
4022 BIO *BIO_new_accept(char *host_port);
4023 int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
4024 BIO **bio2, size_t writebuf2);
4025 void BIO_copy_next_retry(BIO *b);
4026 int BIO_printf(BIO *bio, const char *format, ...)
4027 __attribute__((__format__(__printf__,2,3)));
4028 int BIO_vprintf(BIO *bio, const char *format, va_list args)
4029 __attribute__((__format__(__printf__,2,0)));
4030 int BIO_snprintf(char *buf, size_t n, const char *format, ...)
4031 __attribute__((__format__(__printf__,3,4)));
4032 int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
4033 __attribute__((__format__(__printf__,3,0)));
4034 void ERR_load_BIO_strings(void);
4035 struct X509_algor_st;
4036 struct stack_st_X509_ALGOR { _STACK stack; };
4037 typedef struct asn1_ctx_st
4038 {
4039 unsigned char *p;
4040 int eos;
4041 int error;
4042 int inf;
4043 int tag;
4044 int xclass;
4045 long slen;
4046 unsigned char *max;
4047 unsigned char *q;
4048 unsigned char **pp;
4049 int line;
4050 } ASN1_CTX;
4051 typedef struct asn1_const_ctx_st
4052 {
4053 const unsigned char *p;
4054 int eos;
4055 int error;
4056 int inf;
4057 int tag;
4058 int xclass;
4059 long slen;
4060 const unsigned char *max;
4061 const unsigned char *q;
4062 const unsigned char **pp;
4063 int line;
4064 } ASN1_const_CTX;
4065 typedef struct asn1_object_st
4066 {
4067 const char *sn,*ln;
4068 int nid;
4069 int length;
4070 const unsigned char *data;
4071 int flags;
4072 } ASN1_OBJECT;
4073 struct asn1_string_st
4074 {
4075 int length;
4076 int type;
4077 unsigned char *data;
4078 long flags;
4079 };
4080 typedef struct ASN1_ENCODING_st
4081 {
4082 unsigned char *enc;
4083 long len;
4084 int modified;
4085 } ASN1_ENCODING;
4086 typedef struct asn1_string_table_st {
4087 int nid;
4088 long minsize;
4089 long maxsize;
4090 unsigned long mask;
4091 unsigned long flags;
4092 } ASN1_STRING_TABLE;
4093 struct stack_st_ASN1_STRING_TABLE { _STACK stack; };
4094 typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
4095 typedef struct ASN1_TLC_st ASN1_TLC;
4096 typedef struct ASN1_VALUE_st ASN1_VALUE;
4097 typedef void *d2i_of_void(void **,const unsigned char **,long); typedef int i2d_of_void(void *,unsigned char **);
4098 typedef const ASN1_ITEM ASN1_ITEM_EXP;
4099 struct stack_st_ASN1_INTEGER { _STACK stack; };
4100 struct stack_st_ASN1_GENERALSTRING { _STACK stack; };
4101 typedef struct asn1_type_st
4102 {
4103 int type;
4104 union {
4105 char *ptr;
4106 ASN1_BOOLEAN boolean;
4107 ASN1_STRING * asn1_string;
4108 ASN1_OBJECT * object;
4109 ASN1_INTEGER * integer;
4110 ASN1_ENUMERATED * enumerated;
4111 ASN1_BIT_STRING * bit_string;
4112 ASN1_OCTET_STRING * octet_string;
4113 ASN1_PRINTABLESTRING * printablestring;
4114 ASN1_T61STRING * t61string;
4115 ASN1_IA5STRING * ia5string;
4116 ASN1_GENERALSTRING * generalstring;
4117 ASN1_BMPSTRING * bmpstring;
4118 ASN1_UNIVERSALSTRING * universalstring;
4119 ASN1_UTCTIME * utctime;
4120 ASN1_GENERALIZEDTIME * generalizedtime;
4121 ASN1_VISIBLESTRING * visiblestring;
4122 ASN1_UTF8STRING * utf8string;
4123 ASN1_STRING * set;
4124 ASN1_STRING * sequence;
4125 ASN1_VALUE * asn1_value;
4126 } value;
4127 } ASN1_TYPE;
4128 struct stack_st_ASN1_TYPE { _STACK stack; };
4129 typedef struct stack_st_ASN1_TYPE ASN1_SEQUENCE_ANY;
4130 ASN1_SEQUENCE_ANY *d2i_ASN1_SEQUENCE_ANY(ASN1_SEQUENCE_ANY **a, const unsigned char **in, long len); int i2d_ASN1_SEQUENCE_ANY(const ASN1_SEQUENCE_ANY *a, unsigned char **out); extern const ASN1_ITEM ASN1_SEQUENCE_ANY_it;
4131 ASN1_SEQUENCE_ANY *d2i_ASN1_SET_ANY(ASN1_SEQUENCE_ANY **a, const unsigned char **in, long len); int i2d_ASN1_SET_ANY(const ASN1_SEQUENCE_ANY *a, unsigned char **out); extern const ASN1_ITEM ASN1_SET_ANY_it;
4132 typedef struct NETSCAPE_X509_st
4133 {
4134 ASN1_OCTET_STRING *header;
4135 X509 *cert;
4136 } NETSCAPE_X509;
4137 typedef struct BIT_STRING_BITNAME_st {
4138 int bitnum;
4139 const char *lname;
4140 const char *sname;
4141 } BIT_STRING_BITNAME;
4142 ASN1_TYPE *ASN1_TYPE_new(void); void ASN1_TYPE_free(ASN1_TYPE *a); ASN1_TYPE *d2i_ASN1_TYPE(ASN1_TYPE **a, const unsigned char **in, long len); int i2d_ASN1_TYPE(ASN1_TYPE *a, unsigned char **out); extern const ASN1_ITEM ASN1_ANY_it;
4143 int ASN1_TYPE_get(ASN1_TYPE *a);
4144 void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
4145 int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
4146 int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b);
4147 ASN1_OBJECT * ASN1_OBJECT_new(void );
4148 void ASN1_OBJECT_free(ASN1_OBJECT *a);
4149 int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
4150 ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
4151 long length);
4152 ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
4153 long length);
4154 extern const ASN1_ITEM ASN1_OBJECT_it;
4155 struct stack_st_ASN1_OBJECT { _STACK stack; };
4156 ASN1_STRING * ASN1_STRING_new(void);
4157 void ASN1_STRING_free(ASN1_STRING *a);
4158 int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);
4159 ASN1_STRING * ASN1_STRING_dup(const ASN1_STRING *a);
4160 ASN1_STRING * ASN1_STRING_type_new(int type );
4161 int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
4162 int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
4163 void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
4164 int ASN1_STRING_length(const ASN1_STRING *x);
4165 void ASN1_STRING_length_set(ASN1_STRING *x, int n);
4166 int ASN1_STRING_type(ASN1_STRING *x);
4167 unsigned char * ASN1_STRING_data(ASN1_STRING *x);
4168 ASN1_BIT_STRING *ASN1_BIT_STRING_new(void); void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a); ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **in, long len); int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_BIT_STRING_it;
4169 int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
4170 ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp,
4171 long length);
4172 int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
4173 int length );
4174 int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
4175 int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
4176 int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
4177 unsigned char *flags, int flags_len);
4178 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
4179 BIT_STRING_BITNAME *tbl, int indent);
4180 int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
4181 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
4182 BIT_STRING_BITNAME *tbl);
4183 int i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
4184 int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length);
4185 ASN1_INTEGER *ASN1_INTEGER_new(void); void ASN1_INTEGER_free(ASN1_INTEGER *a); ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **in, long len); int i2d_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **out); extern const ASN1_ITEM ASN1_INTEGER_it;
4186 int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
4187 ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp,
4188 long length);
4189 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp,
4190 long length);
4191 ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x);
4192 int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
4193 ASN1_ENUMERATED *ASN1_ENUMERATED_new(void); void ASN1_ENUMERATED_free(ASN1_ENUMERATED *a); ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, const unsigned char **in, long len); int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **out); extern const ASN1_ITEM ASN1_ENUMERATED_it;
4194 int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
4195 ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
4196 ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
4197 int offset_day, long offset_sec);
4198 int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
4199 int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
4200 int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
4201 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
4202 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
4203 time_t t, int offset_day, long offset_sec);
4204 int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
4205 ASN1_OCTET_STRING *ASN1_OCTET_STRING_new(void); void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a); ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a, const unsigned char **in, long len); int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_OCTET_STRING_it;
4206 ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
4207 int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b);
4208 int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len);
4209 ASN1_VISIBLESTRING *ASN1_VISIBLESTRING_new(void); void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *a); ASN1_VISIBLESTRING *d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **a, const unsigned char **in, long len); int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_VISIBLESTRING_it;
4210 ASN1_UNIVERSALSTRING *ASN1_UNIVERSALSTRING_new(void); void ASN1_UNIVERSALSTRING_free(ASN1_UNIVERSALSTRING *a); ASN1_UNIVERSALSTRING *d2i_ASN1_UNIVERSALSTRING(ASN1_UNIVERSALSTRING **a, const unsigned char **in, long len); int i2d_ASN1_UNIVERSALSTRING(ASN1_UNIVERSALSTRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_UNIVERSALSTRING_it;
4211 ASN1_UTF8STRING *ASN1_UTF8STRING_new(void); void ASN1_UTF8STRING_free(ASN1_UTF8STRING *a); ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a, const unsigned char **in, long len); int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_UTF8STRING_it;
4212 ASN1_NULL *ASN1_NULL_new(void); void ASN1_NULL_free(ASN1_NULL *a); ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, const unsigned char **in, long len); int i2d_ASN1_NULL(ASN1_NULL *a, unsigned char **out); extern const ASN1_ITEM ASN1_NULL_it;
4213 ASN1_BMPSTRING *ASN1_BMPSTRING_new(void); void ASN1_BMPSTRING_free(ASN1_BMPSTRING *a); ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, const unsigned char **in, long len); int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_BMPSTRING_it;
4214 int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
4215 int UTF8_putc(unsigned char *str, int len, unsigned long value);
4216 ASN1_STRING *ASN1_PRINTABLE_new(void); void ASN1_PRINTABLE_free(ASN1_STRING *a); ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a, const unsigned char **in, long len); int i2d_ASN1_PRINTABLE(ASN1_STRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_PRINTABLE_it;
4217 ASN1_STRING *DIRECTORYSTRING_new(void); void DIRECTORYSTRING_free(ASN1_STRING *a); ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, const unsigned char **in, long len); int i2d_DIRECTORYSTRING(ASN1_STRING *a, unsigned char **out); extern const ASN1_ITEM DIRECTORYSTRING_it;
4218 ASN1_STRING *DISPLAYTEXT_new(void); void DISPLAYTEXT_free(ASN1_STRING *a); ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, const unsigned char **in, long len); int i2d_DISPLAYTEXT(ASN1_STRING *a, unsigned char **out); extern const ASN1_ITEM DISPLAYTEXT_it;
4219 ASN1_PRINTABLESTRING *ASN1_PRINTABLESTRING_new(void); void ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *a); ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a, const unsigned char **in, long len); int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_PRINTABLESTRING_it;
4220 ASN1_T61STRING *ASN1_T61STRING_new(void); void ASN1_T61STRING_free(ASN1_T61STRING *a); ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, const unsigned char **in, long len); int i2d_ASN1_T61STRING(ASN1_T61STRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_T61STRING_it;
4221 ASN1_IA5STRING *ASN1_IA5STRING_new(void); void ASN1_IA5STRING_free(ASN1_IA5STRING *a); ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a, const unsigned char **in, long len); int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_IA5STRING_it;
4222 ASN1_GENERALSTRING *ASN1_GENERALSTRING_new(void); void ASN1_GENERALSTRING_free(ASN1_GENERALSTRING *a); ASN1_GENERALSTRING *d2i_ASN1_GENERALSTRING(ASN1_GENERALSTRING **a, const unsigned char **in, long len); int i2d_ASN1_GENERALSTRING(ASN1_GENERALSTRING *a, unsigned char **out); extern const ASN1_ITEM ASN1_GENERALSTRING_it;
4223 ASN1_UTCTIME *ASN1_UTCTIME_new(void); void ASN1_UTCTIME_free(ASN1_UTCTIME *a); ASN1_UTCTIME *d2i_ASN1_UTCTIME(ASN1_UTCTIME **a, const unsigned char **in, long len); int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **out); extern const ASN1_ITEM ASN1_UTCTIME_it;
4224 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_new(void); void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *a); ASN1_GENERALIZEDTIME *d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a, const unsigned char **in, long len); int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **out); extern const ASN1_ITEM ASN1_GENERALIZEDTIME_it;
4225 ASN1_TIME *ASN1_TIME_new(void); void ASN1_TIME_free(ASN1_TIME *a); ASN1_TIME *d2i_ASN1_TIME(ASN1_TIME **a, const unsigned char **in, long len); int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **out); extern const ASN1_ITEM ASN1_TIME_it;
4226 extern const ASN1_ITEM ASN1_OCTET_STRING_NDEF_it;
4227 ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
4228 ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s,time_t t,
4229 int offset_day, long offset_sec);
4230 int ASN1_TIME_check(ASN1_TIME *t);
4231 ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
4232 int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
4233 int i2d_ASN1_SET(struct stack_st_OPENSSL_BLOCK *a, unsigned char **pp,
4234 i2d_of_void *i2d, int ex_tag, int ex_class,
4235 int is_set);
4236 struct stack_st_OPENSSL_BLOCK *d2i_ASN1_SET(struct stack_st_OPENSSL_BLOCK **a,
4237 const unsigned char **pp,
4238 long length, d2i_of_void *d2i,
4239 void (*free_func)(OPENSSL_BLOCK), int ex_tag,
4240 int ex_class);
4241 int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
4242 int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
4243 int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
4244 int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size);
4245 int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a);
4246 int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size);
4247 int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
4248 int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a);
4249 int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num);
4250 ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
4251 const char *sn, const char *ln);
4252 int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
4253 long ASN1_INTEGER_get(const ASN1_INTEGER *a);
4254 ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
4255 BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai,BIGNUM *bn);
4256 int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
4257 long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);
4258 ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);
4259 BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn);
4260 int ASN1_PRINTABLE_type(const unsigned char *s, int max);
4261 int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
4262 ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
4263 long length, int Ptag, int Pclass);
4264 unsigned long ASN1_tag2bit(int tag);
4265 ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp,
4266 long length,int type);
4267 int asn1_Finish(ASN1_CTX *c);
4268 int asn1_const_Finish(ASN1_const_CTX *c);
4269 int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
4270 int *pclass, long omax);
4271 int ASN1_check_infinite_end(unsigned char **p,long len);
4272 int ASN1_const_check_infinite_end(const unsigned char **p,long len);
4273 void ASN1_put_object(unsigned char **pp, int constructed, int length,
4274 int tag, int xclass);
4275 int ASN1_put_eoc(unsigned char **pp);
4276 int ASN1_object_size(int constructed, int length, int tag);
4277 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);
4278 void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
4279 void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x);
4280 void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
4281 int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x);
4282 int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
4283 int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
4284 int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
4285 void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x);
4286 void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
4287 int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x);
4288 int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
4289 int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);
4290 int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);
4291 int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);
4292 int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
4293 int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
4294 int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
4295 unsigned char *buf, int off);
4296 int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent);
4297 int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump);
4298 const char *ASN1_tag2str(int tag);
4299 NETSCAPE_X509 *NETSCAPE_X509_new(void); void NETSCAPE_X509_free(NETSCAPE_X509 *a); NETSCAPE_X509 *d2i_NETSCAPE_X509(NETSCAPE_X509 **a, const unsigned char **in, long len); int i2d_NETSCAPE_X509(NETSCAPE_X509 *a, unsigned char **out); extern const ASN1_ITEM NETSCAPE_X509_it;
4300 int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
4301 int ASN1_TYPE_set_octetstring(ASN1_TYPE *a,
4302 unsigned char *data, int len);
4303 int ASN1_TYPE_get_octetstring(ASN1_TYPE *a,
4304 unsigned char *data, int max_len);
4305 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
4306 unsigned char *data, int len);
4307 int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
4308 unsigned char *data, int max_len);
4309 struct stack_st_OPENSSL_BLOCK *ASN1_seq_unpack(const unsigned char *buf, int len,
4310 d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK));
4311 unsigned char *ASN1_seq_pack(struct stack_st_OPENSSL_BLOCK *safes, i2d_of_void *i2d,
4312 unsigned char **buf, int *len );
4313 void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
4314 void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
4315 ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
4316 ASN1_OCTET_STRING **oct);
4317 ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct);
4318 void ASN1_STRING_set_default_mask(unsigned long mask);
4319 int ASN1_STRING_set_default_mask_asc(const char *p);
4320 unsigned long ASN1_STRING_get_default_mask(void);
4321 int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
4322 int inform, unsigned long mask);
4323 int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
4324 int inform, unsigned long mask,
4325 long minsize, long maxsize);
4326 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
4327 const unsigned char *in, int inlen, int inform, int nid);
4328 ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
4329 int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
4330 void ASN1_STRING_TABLE_cleanup(void);
4331 ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
4332 void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
4333 ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it);
4334 int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
4335 int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
4336 void ASN1_add_oid_module(void);
4337 ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);
4338 ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);
4339 int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
4340 const ASN1_ITEM *it, const ASN1_PCTX *pctx);
4341 ASN1_PCTX *ASN1_PCTX_new(void);
4342 void ASN1_PCTX_free(ASN1_PCTX *p);
4343 unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p);
4344 void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);
4345 unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p);
4346 void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);
4347 unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p);
4348 void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);
4349 unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p);
4350 void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);
4351 unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p);
4352 void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);
4353 BIO_METHOD *BIO_f_asn1(void);
4354 BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);
4355 int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
4356 const ASN1_ITEM *it);
4357 int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
4358 const char *hdr,
4359 const ASN1_ITEM *it);
4360 int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
4361 int ctype_nid, int econt_nid,
4362 struct stack_st_X509_ALGOR *mdalgs,
4363 const ASN1_ITEM *it);
4364 ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
4365 int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
4366 int SMIME_text(BIO *in, BIO *out);
4367 void ERR_load_ASN1_strings(void);
4368 typedef enum {
4369 POINT_CONVERSION_COMPRESSED = 2,
4370 POINT_CONVERSION_UNCOMPRESSED = 4,
4371 POINT_CONVERSION_HYBRID = 6
4372 } point_conversion_form_t;
4373 typedef struct ec_method_st EC_METHOD;
4374 typedef struct ec_group_st
4375 EC_GROUP;
4376 typedef struct ec_point_st EC_POINT;
4377 const EC_METHOD *EC_GFp_simple_method(void);
4378 const EC_METHOD *EC_GFp_mont_method(void);
4379 const EC_METHOD *EC_GFp_nist_method(void);
4380 const EC_METHOD *EC_GF2m_simple_method(void);
4381 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
4382 void EC_GROUP_free(EC_GROUP *group);
4383 void EC_GROUP_clear_free(EC_GROUP *group);
4384 int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
4385 EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
4386 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
4387 int EC_METHOD_get_field_type(const EC_METHOD *meth);
4388 int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
4389 const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
4390 int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
4391 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
4392 void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
4393 int EC_GROUP_get_curve_name(const EC_GROUP *group);
4394 void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
4395 int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
4396 void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form);
4397 point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
4398 unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
4399 size_t EC_GROUP_get_seed_len(const EC_GROUP *);
4400 size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
4401 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
4402 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
4403 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
4404 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
4405 int EC_GROUP_get_degree(const EC_GROUP *group);
4406 int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
4407 int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
4408 int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
4409 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
4410 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
4411 EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
4412 typedef struct {
4413 int nid;
4414 const char *comment;
4415 } EC_builtin_curve;
4416 size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
4417 EC_POINT *EC_POINT_new(const EC_GROUP *group);
4418 void EC_POINT_free(EC_POINT *point);
4419 void EC_POINT_clear_free(EC_POINT *point);
4420 int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
4421 EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
4422 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
4423 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
4424 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
4425 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);
4426 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
4427 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
4428 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
4429 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
4430 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
4431 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
4432 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
4433 const BIGNUM *x, int y_bit, BN_CTX *ctx);
4434 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
4435 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
4436 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
4437 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
4438 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
4439 const BIGNUM *x, int y_bit, BN_CTX *ctx);
4440 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
4441 point_conversion_form_t form,
4442 unsigned char *buf, size_t len, BN_CTX *ctx);
4443 int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
4444 const unsigned char *buf, size_t len, BN_CTX *ctx);
4445 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
4446 point_conversion_form_t form, BIGNUM *, BN_CTX *);
4447 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
4448 EC_POINT *, BN_CTX *);
4449 char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
4450 point_conversion_form_t form, BN_CTX *);
4451 EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
4452 EC_POINT *, BN_CTX *);
4453 int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
4454 int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
4455 int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
4456 int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
4457 int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
4458 int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
4459 int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
4460 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx);
4461 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx);
4462 int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
4463 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
4464 int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
4465 int EC_GROUP_get_basis_type(const EC_GROUP *);
4466 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
4467 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
4468 unsigned int *k2, unsigned int *k3);
4469 typedef struct ecpk_parameters_st ECPKPARAMETERS;
4470 EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
4471 int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
4472 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
4473 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
4474 typedef struct ec_key_st EC_KEY;
4475 EC_KEY *EC_KEY_new(void);
4476 int EC_KEY_get_flags(const EC_KEY *key);
4477 void EC_KEY_set_flags(EC_KEY *key, int flags);
4478 void EC_KEY_clear_flags(EC_KEY *key, int flags);
4479 EC_KEY *EC_KEY_new_by_curve_name(int nid);
4480 void EC_KEY_free(EC_KEY *key);
4481 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
4482 EC_KEY *EC_KEY_dup(const EC_KEY *src);
4483 int EC_KEY_up_ref(EC_KEY *key);
4484 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
4485 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
4486 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
4487 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
4488 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
4489 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
4490 unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
4491 void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);
4492 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
4493 void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
4494 void *EC_KEY_get_key_method_data(EC_KEY *key,
4495 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
4496 void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
4497 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
4498 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
4499 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
4500 int EC_KEY_generate_key(EC_KEY *key);
4501 int EC_KEY_check_key(const EC_KEY *key);
4502 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);
4503 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
4504 int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
4505 EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
4506 int i2d_ECParameters(EC_KEY *key, unsigned char **out);
4507 EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
4508 int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
4509 int ECParameters_print(BIO *bp, const EC_KEY *key);
4510 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
4511 int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
4512 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
4513 void ERR_load_EC_strings(void);
4514 int buffer_put_ecpoint_ret(Buffer *, const EC_GROUP *, const EC_POINT *);
4515 void buffer_put_ecpoint(Buffer *, const EC_GROUP *, const EC_POINT *);
4516 int buffer_get_ecpoint_ret(Buffer *, const EC_GROUP *, EC_POINT *);
4517 void buffer_get_ecpoint(Buffer *, const EC_GROUP *, EC_POINT *);
4518 void seed_rng(void);
4519 void rexec_send_rng_seed(Buffer *);
4520 void rexec_recv_rng_seed(Buffer *);
4521 typedef struct obj_name_st
4522 {
4523 int type;
4524 int alias;
4525 const char *name;
4526 const char *data;
4527 } OBJ_NAME;
4528 int OBJ_NAME_init(void);
4529 int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
4530 int (*cmp_func)(const char *, const char *),
4531 void (*free_func)(const char *, int, const char *));
4532 const char *OBJ_NAME_get(const char *name,int type);
4533 int OBJ_NAME_add(const char *name,int type,const char *data);
4534 int OBJ_NAME_remove(const char *name,int type);
4535 void OBJ_NAME_cleanup(int type);
4536 void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),
4537 void *arg);
4538 void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
4539 void *arg);
4540 ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
4541 ASN1_OBJECT * OBJ_nid2obj(int n);
4542 const char * OBJ_nid2ln(int n);
4543 const char * OBJ_nid2sn(int n);
4544 int OBJ_obj2nid(const ASN1_OBJECT *o);
4545 ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
4546 int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
4547 int OBJ_txt2nid(const char *s);
4548 int OBJ_ln2nid(const char *s);
4549 int OBJ_sn2nid(const char *s);
4550 int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
4551 const void * OBJ_bsearch_(const void *key,const void *base,int num,int size,
4552 int (*cmp)(const void *, const void *));
4553 const void * OBJ_bsearch_ex_(const void *key,const void *base,int num,
4554 int size,
4555 int (*cmp)(const void *, const void *),
4556 int flags);
4557 int OBJ_new_nid(int num);
4558 int OBJ_add_object(const ASN1_OBJECT *obj);
4559 int OBJ_create(const char *oid,const char *sn,const char *ln);
4560 void OBJ_cleanup(void );
4561 int OBJ_create_objects(BIO *in);
4562 int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);
4563 int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);
4564 int OBJ_add_sigid(int signid, int dig_id, int pkey_id);
4565 void OBJ_sigid_free(void);
4566 extern int obj_cleanup_defer;
4567 void check_defer(int nid);
4568 void ERR_load_OBJ_strings(void);
4569 struct evp_pkey_st
4570 {
4571 int type;
4572 int save_type;
4573 int references;
4574 const EVP_PKEY_ASN1_METHOD *ameth;
4575 ENGINE *engine;
4576 union {
4577 char *ptr;
4578 struct rsa_st *rsa;
4579 struct dsa_st *dsa;
4580 struct dh_st *dh;
4581 struct ec_key_st *ec;
4582 } pkey;
4583 int save_parameters;
4584 struct stack_st_X509_ATTRIBUTE *attributes;
4585 } ;
4586 struct env_md_st
4587 {
4588 int type;
4589 int pkey_type;
4590 int md_size;
4591 unsigned long flags;
4592 int (*init)(EVP_MD_CTX *ctx);
4593 int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count);
4594 int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
4595 int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
4596 int (*cleanup)(EVP_MD_CTX *ctx);
4597 int (*sign)(int type, const unsigned char *m, unsigned int m_length,
4598 unsigned char *sigret, unsigned int *siglen, void *key);
4599 int (*verify)(int type, const unsigned char *m, unsigned int m_length,
4600 const unsigned char *sigbuf, unsigned int siglen,
4601 void *key);
4602 int required_pkey_type[5];
4603 int block_size;
4604 int ctx_size;
4605 int (*md_ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
4606 } ;
4607 typedef int evp_sign_method(int type,const unsigned char *m,
4608 unsigned int m_length,unsigned char *sigret,
4609 unsigned int *siglen, void *key);
4610 typedef int evp_verify_method(int type,const unsigned char *m,
4611 unsigned int m_length,const unsigned char *sigbuf,
4612 unsigned int siglen, void *key);
4613 struct env_md_ctx_st
4614 {
4615 const EVP_MD *digest;
4616 ENGINE *engine;
4617 unsigned long flags;
4618 void *md_data;
4619 EVP_PKEY_CTX *pctx;
4620 int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count);
4621 } ;
4622 struct evp_cipher_st
4623 {
4624 int nid;
4625 int block_size;
4626 int key_len;
4627 int iv_len;
4628 unsigned long flags;
4629 int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
4630 const unsigned char *iv, int enc);
4631 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
4632 const unsigned char *in, size_t inl);
4633 int (*cleanup)(EVP_CIPHER_CTX *);
4634 int ctx_size;
4635 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *);
4636 int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *);
4637 int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr);
4638 void *app_data;
4639 } ;
4640 typedef struct evp_cipher_info_st
4641 {
4642 const EVP_CIPHER *cipher;
4643 unsigned char iv[16];
4644 } EVP_CIPHER_INFO;
4645 struct evp_cipher_ctx_st
4646 {
4647 const EVP_CIPHER *cipher;
4648 ENGINE *engine;
4649 int encrypt;
4650 int buf_len;
4651 unsigned char oiv[16];
4652 unsigned char iv[16];
4653 unsigned char buf[32];
4654 int num;
4655 void *app_data;
4656 int key_len;
4657 unsigned long flags;
4658 void *cipher_data;
4659 int final_used;
4660 int block_mask;
4661 unsigned char final[32];
4662 } ;
4663 typedef struct evp_Encode_Ctx_st
4664 {
4665 int num;
4666 int length;
4667 unsigned char enc_data[80];
4668 int line_num;
4669 int expect_nl;
4670 } EVP_ENCODE_CTX;
4671 typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
4672 ASN1_TYPE *param, const EVP_CIPHER *cipher,
4673 const EVP_MD *md, int en_de);
4674 int EVP_MD_type(const EVP_MD *md);
4675 int EVP_MD_pkey_type(const EVP_MD *md);
4676 int EVP_MD_size(const EVP_MD *md);
4677 int EVP_MD_block_size(const EVP_MD *md);
4678 unsigned long EVP_MD_flags(const EVP_MD *md);
4679 const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
4680 int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
4681 int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
4682 int EVP_CIPHER_key_length(const EVP_CIPHER *cipher);
4683 int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);
4684 unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);
4685 const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
4686 int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);
4687 int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);
4688 int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);
4689 int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);
4690 int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
4691 void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
4692 void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
4693 unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);
4694 int EVP_Cipher(EVP_CIPHER_CTX *c,
4695 unsigned char *out,
4696 const unsigned char *in,
4697 unsigned int inl);
4698 void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
4699 int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
4700 EVP_MD_CTX *EVP_MD_CTX_create(void);
4701 void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
4702 int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
4703 void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
4704 void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
4705 int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx,int flags);
4706 int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
4707 int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
4708 size_t cnt);
4709 int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
4710 int EVP_Digest(const void *data, size_t count,
4711 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
4712 int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);
4713 int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
4714 int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
4715 int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
4716 int EVP_read_pw_string_min(char *buf,int minlen,int maxlen,const char *prompt,int verify);
4717 void EVP_set_pw_prompt(const char *prompt);
4718 char * EVP_get_pw_prompt(void);
4719 int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
4720 const unsigned char *salt, const unsigned char *data,
4721 int datal, int count, unsigned char *key,unsigned char *iv);
4722 void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
4723 void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
4724 int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx,int flags);
4725 int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
4726 const unsigned char *key, const unsigned char *iv);
4727 int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
4728 const unsigned char *key, const unsigned char *iv);
4729 int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
4730 int *outl, const unsigned char *in, int inl);
4731 int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
4732 int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
4733 int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
4734 const unsigned char *key, const unsigned char *iv);
4735 int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
4736 const unsigned char *key, const unsigned char *iv);
4737 int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
4738 int *outl, const unsigned char *in, int inl);
4739 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
4740 int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
4741 int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
4742 const unsigned char *key,const unsigned char *iv,
4743 int enc);
4744 int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
4745 const unsigned char *key,const unsigned char *iv,
4746 int enc);
4747 int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
4748 int *outl, const unsigned char *in, int inl);
4749 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
4750 int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
4751 int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
4752 EVP_PKEY *pkey);
4753 int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf,
4754 unsigned int siglen,EVP_PKEY *pkey);
4755 int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
4756 const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
4757 int EVP_DigestSignFinal(EVP_MD_CTX *ctx,
4758 unsigned char *sigret, size_t *siglen);
4759 int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
4760 const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
4761 int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx,
4762 unsigned char *sig, size_t siglen);
4763 int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
4764 const unsigned char *ek, int ekl, const unsigned char *iv,
4765 EVP_PKEY *priv);
4766 int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
4767 int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
4768 unsigned char **ek, int *ekl, unsigned char *iv,
4769 EVP_PKEY **pubk, int npubk);
4770 int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
4771 void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
4772 void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
4773 const unsigned char *in,int inl);
4774 void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
4775 int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
4776 void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
4777 int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
4778 const unsigned char *in, int inl);
4779 int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
4780 char *out, int *outl);
4781 int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
4782 void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
4783 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
4784 EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
4785 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
4786 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
4787 int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
4788 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
4789 int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
4790 BIO_METHOD *BIO_f_md(void);
4791 BIO_METHOD *BIO_f_base64(void);
4792 BIO_METHOD *BIO_f_cipher(void);
4793 BIO_METHOD *BIO_f_reliable(void);
4794 void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k,
4795 const unsigned char *i, int enc);
4796 const EVP_MD *EVP_md_null(void);
4797 const EVP_MD *EVP_md4(void);
4798 const EVP_MD *EVP_md5(void);
4799 const EVP_MD *EVP_sha(void);
4800 const EVP_MD *EVP_sha1(void);
4801 const EVP_MD *EVP_dss(void);
4802 const EVP_MD *EVP_dss1(void);
4803 const EVP_MD *EVP_ecdsa(void);
4804 const EVP_MD *EVP_sha224(void);
4805 const EVP_MD *EVP_sha256(void);
4806 const EVP_MD *EVP_sha384(void);
4807 const EVP_MD *EVP_sha512(void);
4808 const EVP_MD *EVP_mdc2(void);
4809 const EVP_MD *EVP_ripemd160(void);
4810 const EVP_MD *EVP_whirlpool(void);
4811 const EVP_CIPHER *EVP_enc_null(void);
4812 const EVP_CIPHER *EVP_des_ecb(void);
4813 const EVP_CIPHER *EVP_des_ede(void);
4814 const EVP_CIPHER *EVP_des_ede3(void);
4815 const EVP_CIPHER *EVP_des_ede_ecb(void);
4816 const EVP_CIPHER *EVP_des_ede3_ecb(void);
4817 const EVP_CIPHER *EVP_des_cfb64(void);
4818 const EVP_CIPHER *EVP_des_cfb1(void);
4819 const EVP_CIPHER *EVP_des_cfb8(void);
4820 const EVP_CIPHER *EVP_des_ede_cfb64(void);
4821 const EVP_CIPHER *EVP_des_ede3_cfb64(void);
4822 const EVP_CIPHER *EVP_des_ede3_cfb1(void);
4823 const EVP_CIPHER *EVP_des_ede3_cfb8(void);
4824 const EVP_CIPHER *EVP_des_ofb(void);
4825 const EVP_CIPHER *EVP_des_ede_ofb(void);
4826 const EVP_CIPHER *EVP_des_ede3_ofb(void);
4827 const EVP_CIPHER *EVP_des_cbc(void);
4828 const EVP_CIPHER *EVP_des_ede_cbc(void);
4829 const EVP_CIPHER *EVP_des_ede3_cbc(void);
4830 const EVP_CIPHER *EVP_desx_cbc(void);
4831 const EVP_CIPHER *EVP_rc4(void);
4832 const EVP_CIPHER *EVP_rc4_40(void);
4833 const EVP_CIPHER *EVP_rc4_hmac_md5(void);
4834 const EVP_CIPHER *EVP_idea_ecb(void);
4835 const EVP_CIPHER *EVP_idea_cfb64(void);
4836 const EVP_CIPHER *EVP_idea_ofb(void);
4837 const EVP_CIPHER *EVP_idea_cbc(void);
4838 const EVP_CIPHER *EVP_rc2_ecb(void);
4839 const EVP_CIPHER *EVP_rc2_cbc(void);
4840 const EVP_CIPHER *EVP_rc2_40_cbc(void);
4841 const EVP_CIPHER *EVP_rc2_64_cbc(void);
4842 const EVP_CIPHER *EVP_rc2_cfb64(void);
4843 const EVP_CIPHER *EVP_rc2_ofb(void);
4844 const EVP_CIPHER *EVP_bf_ecb(void);
4845 const EVP_CIPHER *EVP_bf_cbc(void);
4846 const EVP_CIPHER *EVP_bf_cfb64(void);
4847 const EVP_CIPHER *EVP_bf_ofb(void);
4848 const EVP_CIPHER *EVP_cast5_ecb(void);
4849 const EVP_CIPHER *EVP_cast5_cbc(void);
4850 const EVP_CIPHER *EVP_cast5_cfb64(void);
4851 const EVP_CIPHER *EVP_cast5_ofb(void);
4852 const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
4853 const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
4854 const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);
4855 const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
4856 const EVP_CIPHER *EVP_aes_128_ecb(void);
4857 const EVP_CIPHER *EVP_aes_128_cbc(void);
4858 const EVP_CIPHER *EVP_aes_128_cfb1(void);
4859 const EVP_CIPHER *EVP_aes_128_cfb8(void);
4860 const EVP_CIPHER *EVP_aes_128_cfb128(void);
4861 const EVP_CIPHER *EVP_aes_128_ofb(void);
4862 const EVP_CIPHER *EVP_aes_128_ctr(void);
4863 const EVP_CIPHER *EVP_aes_128_ccm(void);
4864 const EVP_CIPHER *EVP_aes_128_gcm(void);
4865 const EVP_CIPHER *EVP_aes_128_xts(void);
4866 const EVP_CIPHER *EVP_aes_192_ecb(void);
4867 const EVP_CIPHER *EVP_aes_192_cbc(void);
4868 const EVP_CIPHER *EVP_aes_192_cfb1(void);
4869 const EVP_CIPHER *EVP_aes_192_cfb8(void);
4870 const EVP_CIPHER *EVP_aes_192_cfb128(void);
4871 const EVP_CIPHER *EVP_aes_192_ofb(void);
4872 const EVP_CIPHER *EVP_aes_192_ctr(void);
4873 const EVP_CIPHER *EVP_aes_192_ccm(void);
4874 const EVP_CIPHER *EVP_aes_192_gcm(void);
4875 const EVP_CIPHER *EVP_aes_256_ecb(void);
4876 const EVP_CIPHER *EVP_aes_256_cbc(void);
4877 const EVP_CIPHER *EVP_aes_256_cfb1(void);
4878 const EVP_CIPHER *EVP_aes_256_cfb8(void);
4879 const EVP_CIPHER *EVP_aes_256_cfb128(void);
4880 const EVP_CIPHER *EVP_aes_256_ofb(void);
4881 const EVP_CIPHER *EVP_aes_256_ctr(void);
4882 const EVP_CIPHER *EVP_aes_256_ccm(void);
4883 const EVP_CIPHER *EVP_aes_256_gcm(void);
4884 const EVP_CIPHER *EVP_aes_256_xts(void);
4885 const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
4886 const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
4887 const EVP_CIPHER *EVP_camellia_128_ecb(void);
4888 const EVP_CIPHER *EVP_camellia_128_cbc(void);
4889 const EVP_CIPHER *EVP_camellia_128_cfb1(void);
4890 const EVP_CIPHER *EVP_camellia_128_cfb8(void);
4891 const EVP_CIPHER *EVP_camellia_128_cfb128(void);
4892 const EVP_CIPHER *EVP_camellia_128_ofb(void);
4893 const EVP_CIPHER *EVP_camellia_192_ecb(void);
4894 const EVP_CIPHER *EVP_camellia_192_cbc(void);
4895 const EVP_CIPHER *EVP_camellia_192_cfb1(void);
4896 const EVP_CIPHER *EVP_camellia_192_cfb8(void);
4897 const EVP_CIPHER *EVP_camellia_192_cfb128(void);
4898 const EVP_CIPHER *EVP_camellia_192_ofb(void);
4899 const EVP_CIPHER *EVP_camellia_256_ecb(void);
4900 const EVP_CIPHER *EVP_camellia_256_cbc(void);
4901 const EVP_CIPHER *EVP_camellia_256_cfb1(void);
4902 const EVP_CIPHER *EVP_camellia_256_cfb8(void);
4903 const EVP_CIPHER *EVP_camellia_256_cfb128(void);
4904 const EVP_CIPHER *EVP_camellia_256_ofb(void);
4905 const EVP_CIPHER *EVP_seed_ecb(void);
4906 const EVP_CIPHER *EVP_seed_cbc(void);
4907 const EVP_CIPHER *EVP_seed_cfb128(void);
4908 const EVP_CIPHER *EVP_seed_ofb(void);
4909 void OPENSSL_add_all_algorithms_noconf(void);
4910 void OPENSSL_add_all_algorithms_conf(void);
4911 void OpenSSL_add_all_ciphers(void);
4912 void OpenSSL_add_all_digests(void);
4913 int EVP_add_cipher(const EVP_CIPHER *cipher);
4914 int EVP_add_digest(const EVP_MD *digest);
4915 const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
4916 const EVP_MD *EVP_get_digestbyname(const char *name);
4917 void EVP_cleanup(void);
4918 void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph,
4919 const char *from, const char *to, void *x), void *arg);
4920 void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph,
4921 const char *from, const char *to, void *x), void *arg);
4922 void EVP_MD_do_all(void (*fn)(const EVP_MD *ciph,
4923 const char *from, const char *to, void *x), void *arg);
4924 void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *ciph,
4925 const char *from, const char *to, void *x), void *arg);
4926 int EVP_PKEY_decrypt_old(unsigned char *dec_key,
4927 const unsigned char *enc_key,int enc_key_len,
4928 EVP_PKEY *private_key);
4929 int EVP_PKEY_encrypt_old(unsigned char *enc_key,
4930 const unsigned char *key,int key_len,
4931 EVP_PKEY *pub_key);
4932 int EVP_PKEY_type(int type);
4933 int EVP_PKEY_id(const EVP_PKEY *pkey);
4934 int EVP_PKEY_base_id(const EVP_PKEY *pkey);
4935 int EVP_PKEY_bits(EVP_PKEY *pkey);
4936 int EVP_PKEY_size(EVP_PKEY *pkey);
4937 int EVP_PKEY_set_type(EVP_PKEY *pkey,int type);
4938 int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
4939 int EVP_PKEY_assign(EVP_PKEY *pkey,int type,void *key);
4940 void * EVP_PKEY_get0(EVP_PKEY *pkey);
4941 struct rsa_st;
4942 int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key);
4943 struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
4944 struct dsa_st;
4945 int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key);
4946 struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
4947 struct dh_st;
4948 int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key);
4949 struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
4950 struct ec_key_st;
4951 int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key);
4952 struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
4953 EVP_PKEY * EVP_PKEY_new(void);
4954 void EVP_PKEY_free(EVP_PKEY *pkey);
4955 EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp,
4956 long length);
4957 int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
4958 EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp,
4959 long length);
4960 EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
4961 long length);
4962 int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
4963 int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
4964 int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
4965 int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
4966 int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
4967 int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
4968 int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,
4969 int indent, ASN1_PCTX *pctx);
4970 int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,
4971 int indent, ASN1_PCTX *pctx);
4972 int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,
4973 int indent, ASN1_PCTX *pctx);
4974 int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
4975 int EVP_CIPHER_type(const EVP_CIPHER *ctx);
4976 int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
4977 int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
4978 int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
4979 int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
4980 int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
4981 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
4982 int en_de);
4983 int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
4984 const unsigned char *salt, int saltlen, int iter,
4985 int keylen, unsigned char *out);
4986 int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
4987 const unsigned char *salt, int saltlen, int iter,
4988 const EVP_MD *digest,
4989 int keylen, unsigned char *out);
4990 int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
4991 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
4992 int en_de);
4993 void PKCS5_PBE_add(void);
4994 int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
4995 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
4996 int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
4997 EVP_PBE_KEYGEN *keygen);
4998 int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
4999 EVP_PBE_KEYGEN *keygen);
5000 int EVP_PBE_find(int type, int pbe_nid,
5001 int *pcnid, int *pmnid, EVP_PBE_KEYGEN **pkeygen);
5002 void EVP_PBE_cleanup(void);
5003 int EVP_PKEY_asn1_get_count(void);
5004 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
5005 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);
5006 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
5007 const char *str, int len);
5008 int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);
5009 int EVP_PKEY_asn1_add_alias(int to, int from);
5010 int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, int *ppkey_flags,
5011 const char **pinfo, const char **ppem_str,
5012 const EVP_PKEY_ASN1_METHOD *ameth);
5013 const EVP_PKEY_ASN1_METHOD* EVP_PKEY_get0_asn1(EVP_PKEY *pkey);
5014 EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
5015 const char *pem_str, const char *info);
5016 void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
5017 const EVP_PKEY_ASN1_METHOD *src);
5018 void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);
5019 void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,
5020 int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub),
5021 int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk),
5022 int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b),
5023 int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent,
5024 ASN1_PCTX *pctx),
5025 int (*pkey_size)(const EVP_PKEY *pk),
5026 int (*pkey_bits)(const EVP_PKEY *pk));
5027 void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,
5028 int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf),
5029 int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk),
5030 int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent,
5031 ASN1_PCTX *pctx));
5032 void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
5033 int (*param_decode)(EVP_PKEY *pkey,
5034 const unsigned char **pder, int derlen),
5035 int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder),
5036 int (*param_missing)(const EVP_PKEY *pk),
5037 int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from),
5038 int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b),
5039 int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent,
5040 ASN1_PCTX *pctx));
5041 void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
5042 void (*pkey_free)(EVP_PKEY *pkey));
5043 void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
5044 int (*pkey_ctrl)(EVP_PKEY *pkey, int op,
5045 long arg1, void *arg2));
5046 const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
5047 EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags);
5048 void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,
5049 const EVP_PKEY_METHOD *meth);
5050 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
5051 void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
5052 int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
5053 EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
5054 EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
5055 EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);
5056 void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
5057 int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
5058 int cmd, int p1, void *p2);
5059 int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
5060 const char *value);
5061 int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
5062 void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);
5063 EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,
5064 const unsigned char *key, int keylen);
5065 void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);
5066 void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);
5067 EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
5068 EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);
5069 void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);
5070 void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);
5071 int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
5072 int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
5073 unsigned char *sig, size_t *siglen,
5074 const unsigned char *tbs, size_t tbslen);
5075 int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
5076 int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
5077 const unsigned char *sig, size_t siglen,
5078 const unsigned char *tbs, size_t tbslen);
5079 int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
5080 int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
5081 unsigned char *rout, size_t *routlen,
5082 const unsigned char *sig, size_t siglen);
5083 int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
5084 int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
5085 unsigned char *out, size_t *outlen,
5086 const unsigned char *in, size_t inlen);
5087 int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);
5088 int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
5089 unsigned char *out, size_t *outlen,
5090 const unsigned char *in, size_t inlen);
5091 int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);
5092 int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);
5093 int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
5094 typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
5095 int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
5096 int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
5097 int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
5098 int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
5099 void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
5100 EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);
5101 int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);
5102 void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
5103 int (*init)(EVP_PKEY_CTX *ctx));
5104 void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
5105 int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src));
5106 void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
5107 void (*cleanup)(EVP_PKEY_CTX *ctx));
5108 void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
5109 int (*paramgen_init)(EVP_PKEY_CTX *ctx),
5110 int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));
5111 void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
5112 int (*keygen_init)(EVP_PKEY_CTX *ctx),
5113 int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));
5114 void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
5115 int (*sign_init)(EVP_PKEY_CTX *ctx),
5116 int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
5117 const unsigned char *tbs, size_t tbslen));
5118 void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
5119 int (*verify_init)(EVP_PKEY_CTX *ctx),
5120 int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
5121 const unsigned char *tbs, size_t tbslen));
5122 void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
5123 int (*verify_recover_init)(EVP_PKEY_CTX *ctx),
5124 int (*verify_recover)(EVP_PKEY_CTX *ctx,
5125 unsigned char *sig, size_t *siglen,
5126 const unsigned char *tbs, size_t tbslen));
5127 void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
5128 int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
5129 int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
5130 EVP_MD_CTX *mctx));
5131 void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
5132 int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
5133 int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig,int siglen,
5134 EVP_MD_CTX *mctx));
5135 void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
5136 int (*encrypt_init)(EVP_PKEY_CTX *ctx),
5137 int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
5138 const unsigned char *in, size_t inlen));
5139 void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
5140 int (*decrypt_init)(EVP_PKEY_CTX *ctx),
5141 int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
5142 const unsigned char *in, size_t inlen));
5143 void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
5144 int (*derive_init)(EVP_PKEY_CTX *ctx),
5145 int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen));
5146 void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
5147 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
5148 int (*ctrl_str)(EVP_PKEY_CTX *ctx,
5149 const char *type, const char *value));
5150 void EVP_add_alg_module(void);
5151 void ERR_load_EVP_strings(void);
5152 typedef int ptrdiff_t;
5153 struct buf_mem_st
5154 {
5155 size_t length;
5156 char *data;
5157 size_t max;
5158 };
5159 BUF_MEM *BUF_MEM_new(void);
5160 void BUF_MEM_free(BUF_MEM *a);
5161 int BUF_MEM_grow(BUF_MEM *str, size_t len);
5162 int BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
5163 char * BUF_strdup(const char *str);
5164 char * BUF_strndup(const char *str, size_t siz);
5165 void * BUF_memdup(const void *data, size_t siz);
5166 void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
5167 size_t BUF_strlcpy(char *dst,const char *src,size_t siz);
5168 size_t BUF_strlcat(char *dst,const char *src,size_t siz);
5169 void ERR_load_BUF_strings(void);
5170 typedef struct ECDSA_SIG_st
5171 {
5172 BIGNUM *r;
5173 BIGNUM *s;
5174 } ECDSA_SIG;
5175 ECDSA_SIG *ECDSA_SIG_new(void);
5176 void ECDSA_SIG_free(ECDSA_SIG *sig);
5177 int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);
5178 ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);
5179 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey);
5180 ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
5181 const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
5182 int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
5183 const ECDSA_SIG *sig, EC_KEY* eckey);
5184 const ECDSA_METHOD *ECDSA_OpenSSL(void);
5185 void ECDSA_set_default_method(const ECDSA_METHOD *meth);
5186 const ECDSA_METHOD *ECDSA_get_default_method(void);
5187 int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);
5188 int ECDSA_size(const EC_KEY *eckey);
5189 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv,
5190 BIGNUM **rp);
5191 int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
5192 unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
5193 int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,
5194 unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,
5195 const BIGNUM *rp, EC_KEY *eckey);
5196 int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
5197 const unsigned char *sig, int siglen, EC_KEY *eckey);
5198 int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new
5199 *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
5200 int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);
5201 void *ECDSA_get_ex_data(EC_KEY *d, int idx);
5202 void ERR_load_ECDSA_strings(void);
5203 const ECDH_METHOD *ECDH_OpenSSL(void);
5204 void ECDH_set_default_method(const ECDH_METHOD *);
5205 const ECDH_METHOD *ECDH_get_default_method(void);
5206 int ECDH_set_method(EC_KEY *, const ECDH_METHOD *);
5207 int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh,
5208 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));
5209 int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new
5210 *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
5211 int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);
5212 void *ECDH_get_ex_data(EC_KEY *d, int idx);
5213 void ERR_load_ECDH_strings(void);
5214 struct rsa_meth_st
5215 {
5216 const char *name;
5217 int (*rsa_pub_enc)(int flen,const unsigned char *from,
5218 unsigned char *to,
5219 RSA *rsa,int padding);
5220 int (*rsa_pub_dec)(int flen,const unsigned char *from,
5221 unsigned char *to,
5222 RSA *rsa,int padding);
5223 int (*rsa_priv_enc)(int flen,const unsigned char *from,
5224 unsigned char *to,
5225 RSA *rsa,int padding);
5226 int (*rsa_priv_dec)(int flen,const unsigned char *from,
5227 unsigned char *to,
5228 RSA *rsa,int padding);
5229 int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx);
5230 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
5231 const BIGNUM *m, BN_CTX *ctx,
5232 BN_MONT_CTX *m_ctx);
5233 int (*init)(RSA *rsa);
5234 int (*finish)(RSA *rsa);
5235 int flags;
5236 char *app_data;
5237 int (*rsa_sign)(int type,
5238 const unsigned char *m, unsigned int m_length,
5239 unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
5240 int (*rsa_verify)(int dtype,
5241 const unsigned char *m, unsigned int m_length,
5242 const unsigned char *sigbuf, unsigned int siglen,
5243 const RSA *rsa);
5244 int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
5245 };
5246 struct rsa_st
5247 {
5248 int pad;
5249 long version;
5250 const RSA_METHOD *meth;
5251 ENGINE *engine;
5252 BIGNUM *n;
5253 BIGNUM *e;
5254 BIGNUM *d;
5255 BIGNUM *p;
5256 BIGNUM *q;
5257 BIGNUM *dmp1;
5258 BIGNUM *dmq1;
5259 BIGNUM *iqmp;
5260 CRYPTO_EX_DATA ex_data;
5261 int references;
5262 int flags;
5263 BN_MONT_CTX *_method_mod_n;
5264 BN_MONT_CTX *_method_mod_p;
5265 BN_MONT_CTX *_method_mod_q;
5266 char *bignum_data;
5267 BN_BLINDING *blinding;
5268 BN_BLINDING *mt_blinding;
5269 };
5270 RSA * RSA_new(void);
5271 RSA * RSA_new_method(ENGINE *engine);
5272 int RSA_size(const RSA *rsa);
5273 RSA * RSA_generate_key(int bits, unsigned long e,void
5274 (*callback)(int,int,void *),void *cb_arg);
5275 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
5276 int RSA_check_key(const RSA *);
5277 int RSA_public_encrypt(int flen, const unsigned char *from,
5278 unsigned char *to, RSA *rsa,int padding);
5279 int RSA_private_encrypt(int flen, const unsigned char *from,
5280 unsigned char *to, RSA *rsa,int padding);
5281 int RSA_public_decrypt(int flen, const unsigned char *from,
5282 unsigned char *to, RSA *rsa,int padding);
5283 int RSA_private_decrypt(int flen, const unsigned char *from,
5284 unsigned char *to, RSA *rsa,int padding);
5285 void RSA_free (RSA *r);
5286 int RSA_up_ref(RSA *r);
5287 int RSA_flags(const RSA *r);
5288 void RSA_set_default_method(const RSA_METHOD *meth);
5289 const RSA_METHOD *RSA_get_default_method(void);
5290 const RSA_METHOD *RSA_get_method(const RSA *rsa);
5291 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
5292 int RSA_memory_lock(RSA *r);
5293 const RSA_METHOD *RSA_PKCS1_SSLeay(void);
5294 const RSA_METHOD *RSA_null_method(void);
5295 RSA *d2i_RSAPublicKey(RSA **a, const unsigned char **in, long len); int i2d_RSAPublicKey(const RSA *a, unsigned char **out); extern const ASN1_ITEM RSAPublicKey_it;
5296 RSA *d2i_RSAPrivateKey(RSA **a, const unsigned char **in, long len); int i2d_RSAPrivateKey(const RSA *a, unsigned char **out); extern const ASN1_ITEM RSAPrivateKey_it;
5297 typedef struct rsa_pss_params_st
5298 {
5299 X509_ALGOR *hashAlgorithm;
5300 X509_ALGOR *maskGenAlgorithm;
5301 ASN1_INTEGER *saltLength;
5302 ASN1_INTEGER *trailerField;
5303 } RSA_PSS_PARAMS;
5304 RSA_PSS_PARAMS *RSA_PSS_PARAMS_new(void); void RSA_PSS_PARAMS_free(RSA_PSS_PARAMS *a); RSA_PSS_PARAMS *d2i_RSA_PSS_PARAMS(RSA_PSS_PARAMS **a, const unsigned char **in, long len); int i2d_RSA_PSS_PARAMS(RSA_PSS_PARAMS *a, unsigned char **out); extern const ASN1_ITEM RSA_PSS_PARAMS_it;
5305 int RSA_print_fp(FILE *fp, const RSA *r,int offset);
5306 int RSA_print(BIO *bp, const RSA *r,int offset);
5307 int i2d_RSA_NET(const RSA *a, unsigned char **pp,
5308 int (*cb)(char *buf, int len, const char *prompt, int verify),
5309 int sgckey);
5310 RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,
5311 int (*cb)(char *buf, int len, const char *prompt, int verify),
5312 int sgckey);
5313 int i2d_Netscape_RSA(const RSA *a, unsigned char **pp,
5314 int (*cb)(char *buf, int len, const char *prompt,
5315 int verify));
5316 RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,
5317 int (*cb)(char *buf, int len, const char *prompt,
5318 int verify));
5319 int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
5320 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
5321 int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
5322 const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
5323 int RSA_sign_ASN1_OCTET_STRING(int type,
5324 const unsigned char *m, unsigned int m_length,
5325 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
5326 int RSA_verify_ASN1_OCTET_STRING(int type,
5327 const unsigned char *m, unsigned int m_length,
5328 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
5329 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
5330 void RSA_blinding_off(RSA *rsa);
5331 BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
5332 int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen,
5333 const unsigned char *f,int fl);
5334 int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen,
5335 const unsigned char *f,int fl,int rsa_len);
5336 int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen,
5337 const unsigned char *f,int fl);
5338 int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen,
5339 const unsigned char *f,int fl,int rsa_len);
5340 int PKCS1_MGF1(unsigned char *mask, long len,
5341 const unsigned char *seed, long seedlen, const EVP_MD *dgst);
5342 int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen,
5343 const unsigned char *f,int fl,
5344 const unsigned char *p,int pl);
5345 int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen,
5346 const unsigned char *f,int fl,int rsa_len,
5347 const unsigned char *p,int pl);
5348 int RSA_padding_add_SSLv23(unsigned char *to,int tlen,
5349 const unsigned char *f,int fl);
5350 int RSA_padding_check_SSLv23(unsigned char *to,int tlen,
5351 const unsigned char *f,int fl,int rsa_len);
5352 int RSA_padding_add_none(unsigned char *to,int tlen,
5353 const unsigned char *f,int fl);
5354 int RSA_padding_check_none(unsigned char *to,int tlen,
5355 const unsigned char *f,int fl,int rsa_len);
5356 int RSA_padding_add_X931(unsigned char *to,int tlen,
5357 const unsigned char *f,int fl);
5358 int RSA_padding_check_X931(unsigned char *to,int tlen,
5359 const unsigned char *f,int fl,int rsa_len);
5360 int RSA_X931_hash_id(int nid);
5361 int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
5362 const EVP_MD *Hash, const unsigned char *EM, int sLen);
5363 int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
5364 const unsigned char *mHash,
5365 const EVP_MD *Hash, int sLen);
5366 int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
5367 const EVP_MD *Hash, const EVP_MD *mgf1Hash,
5368 const unsigned char *EM, int sLen);
5369 int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
5370 const unsigned char *mHash,
5371 const EVP_MD *Hash, const EVP_MD *mgf1Hash, int sLen);
5372 int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
5373 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
5374 int RSA_set_ex_data(RSA *r,int idx,void *arg);
5375 void *RSA_get_ex_data(const RSA *r, int idx);
5376 RSA *RSAPublicKey_dup(RSA *rsa);
5377 RSA *RSAPrivateKey_dup(RSA *rsa);
5378 void ERR_load_RSA_strings(void);
5379 struct dh_method
5380 {
5381 const char *name;
5382 int (*generate_key)(DH *dh);
5383 int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh);
5384 int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a,
5385 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
5386 BN_MONT_CTX *m_ctx);
5387 int (*init)(DH *dh);
5388 int (*finish)(DH *dh);
5389 int flags;
5390 char *app_data;
5391 int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb);
5392 };
5393 struct dh_st
5394 {
5395 int pad;
5396 int version;
5397 BIGNUM *p;
5398 BIGNUM *g;
5399 long length;
5400 BIGNUM *pub_key;
5401 BIGNUM *priv_key;
5402 int flags;
5403 BN_MONT_CTX *method_mont_p;
5404 BIGNUM *q;
5405 BIGNUM *j;
5406 unsigned char *seed;
5407 int seedlen;
5408 BIGNUM *counter;
5409 int references;
5410 CRYPTO_EX_DATA ex_data;
5411 const DH_METHOD *meth;
5412 ENGINE *engine;
5413 };
5414 DH *DHparams_dup(DH *);
5415 const DH_METHOD *DH_OpenSSL(void);
5416 void DH_set_default_method(const DH_METHOD *meth);
5417 const DH_METHOD *DH_get_default_method(void);
5418 int DH_set_method(DH *dh, const DH_METHOD *meth);
5419 DH *DH_new_method(ENGINE *engine);
5420 DH * DH_new(void);
5421 void DH_free(DH *dh);
5422 int DH_up_ref(DH *dh);
5423 int DH_size(const DH *dh);
5424 int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
5425 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
5426 int DH_set_ex_data(DH *d, int idx, void *arg);
5427 void *DH_get_ex_data(DH *d, int idx);
5428 DH * DH_generate_parameters(int prime_len,int generator,
5429 void (*callback)(int,int,void *),void *cb_arg);
5430 int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb);
5431 int DH_check(const DH *dh,int *codes);
5432 int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes);
5433 int DH_generate_key(DH *dh);
5434 int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
5435 DH * d2i_DHparams(DH **a,const unsigned char **pp, long length);
5436 int i2d_DHparams(const DH *a,unsigned char **pp);
5437 int DHparams_print_fp(FILE *fp, const DH *x);
5438 int DHparams_print(BIO *bp, const DH *x);
5439 void ERR_load_DH_strings(void);
5440 typedef struct DSA_SIG_st
5441 {
5442 BIGNUM *r;
5443 BIGNUM *s;
5444 } DSA_SIG;
5445 struct dsa_method
5446 {
5447 const char *name;
5448 DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
5449 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
5450 BIGNUM **rp);
5451 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
5452 DSA_SIG *sig, DSA *dsa);
5453 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
5454 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
5455 BN_MONT_CTX *in_mont);
5456 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
5457 const BIGNUM *m, BN_CTX *ctx,
5458 BN_MONT_CTX *m_ctx);
5459 int (*init)(DSA *dsa);
5460 int (*finish)(DSA *dsa);
5461 int flags;
5462 char *app_data;
5463 int (*dsa_paramgen)(DSA *dsa, int bits,
5464 const unsigned char *seed, int seed_len,
5465 int *counter_ret, unsigned long *h_ret,
5466 BN_GENCB *cb);
5467 int (*dsa_keygen)(DSA *dsa);
5468 };
5469 struct dsa_st
5470 {
5471 int pad;
5472 long version;
5473 int write_params;
5474 BIGNUM *p;
5475 BIGNUM *q;
5476 BIGNUM *g;
5477 BIGNUM *pub_key;
5478 BIGNUM *priv_key;
5479 BIGNUM *kinv;
5480 BIGNUM *r;
5481 int flags;
5482 BN_MONT_CTX *method_mont_p;
5483 int references;
5484 CRYPTO_EX_DATA ex_data;
5485 const DSA_METHOD *meth;
5486 ENGINE *engine;
5487 };
5488 DSA *DSAparams_dup(DSA *x);
5489 DSA_SIG * DSA_SIG_new(void);
5490 void DSA_SIG_free(DSA_SIG *a);
5491 int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
5492 DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
5493 DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
5494 int DSA_do_verify(const unsigned char *dgst,int dgst_len,
5495 DSA_SIG *sig,DSA *dsa);
5496 const DSA_METHOD *DSA_OpenSSL(void);
5497 void DSA_set_default_method(const DSA_METHOD *);
5498 const DSA_METHOD *DSA_get_default_method(void);
5499 int DSA_set_method(DSA *dsa, const DSA_METHOD *);
5500 DSA * DSA_new(void);
5501 DSA * DSA_new_method(ENGINE *engine);
5502 void DSA_free (DSA *r);
5503 int DSA_up_ref(DSA *r);
5504 int DSA_size(const DSA *);
5505 int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
5506 int DSA_sign(int type,const unsigned char *dgst,int dlen,
5507 unsigned char *sig, unsigned int *siglen, DSA *dsa);
5508 int DSA_verify(int type,const unsigned char *dgst,int dgst_len,
5509 const unsigned char *sigbuf, int siglen, DSA *dsa);
5510 int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
5511 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
5512 int DSA_set_ex_data(DSA *d, int idx, void *arg);
5513 void *DSA_get_ex_data(DSA *d, int idx);
5514 DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
5515 DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
5516 DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
5517 DSA * DSA_generate_parameters(int bits,
5518 unsigned char *seed,int seed_len,
5519 int *counter_ret, unsigned long *h_ret,void
5520 (*callback)(int, int, void *),void *cb_arg);
5521 int DSA_generate_parameters_ex(DSA *dsa, int bits,
5522 const unsigned char *seed,int seed_len,
5523 int *counter_ret, unsigned long *h_ret, BN_GENCB *cb);
5524 int DSA_generate_key(DSA *a);
5525 int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
5526 int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
5527 int i2d_DSAparams(const DSA *a,unsigned char **pp);
5528 int DSAparams_print(BIO *bp, const DSA *x);
5529 int DSA_print(BIO *bp, const DSA *x, int off);
5530 int DSAparams_print_fp(FILE *fp, const DSA *x);
5531 int DSA_print_fp(FILE *bp, const DSA *x, int off);
5532 DH *DSA_dup_DH(const DSA *r);
5533 void ERR_load_DSA_strings(void);
5534 typedef struct SHAstate_st
5535 {
5536 unsigned int h0,h1,h2,h3,h4;
5537 unsigned int Nl,Nh;
5538 unsigned int data[16];
5539 unsigned int num;
5540 } SHA_CTX;
5541 int SHA_Init(SHA_CTX *c);
5542 int SHA_Update(SHA_CTX *c, const void *data, size_t len);
5543 int SHA_Final(unsigned char *md, SHA_CTX *c);
5544 unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md);
5545 void SHA_Transform(SHA_CTX *c, const unsigned char *data);
5546 int SHA1_Init(SHA_CTX *c);
5547 int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
5548 int SHA1_Final(unsigned char *md, SHA_CTX *c);
5549 unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
5550 void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
5551 typedef struct SHA256state_st
5552 {
5553 unsigned int h[8];
5554 unsigned int Nl,Nh;
5555 unsigned int data[16];
5556 unsigned int num,md_len;
5557 } SHA256_CTX;
5558 int SHA224_Init(SHA256_CTX *c);
5559 int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
5560 int SHA224_Final(unsigned char *md, SHA256_CTX *c);
5561 unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md);
5562 int SHA256_Init(SHA256_CTX *c);
5563 int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
5564 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
5565 unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md);
5566 void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
5567 typedef struct SHA512state_st
5568 {
5569 unsigned long long h[8];
5570 unsigned long long Nl,Nh;
5571 union {
5572 unsigned long long d[16];
5573 unsigned char p[(16*8)];
5574 } u;
5575 unsigned int num,md_len;
5576 } SHA512_CTX;
5577 int SHA384_Init(SHA512_CTX *c);
5578 int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
5579 int SHA384_Final(unsigned char *md, SHA512_CTX *c);
5580 unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md);
5581 int SHA512_Init(SHA512_CTX *c);
5582 int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
5583 int SHA512_Final(unsigned char *md, SHA512_CTX *c);
5584 unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md);
5585 void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
5586 typedef struct X509_objects_st
5587 {
5588 int nid;
5589 int (*a2i)(void);
5590 int (*i2a)(void);
5591 } X509_OBJECTS;
5592 struct X509_algor_st
5593 {
5594 ASN1_OBJECT *algorithm;
5595 ASN1_TYPE *parameter;
5596 } ;
5597 typedef struct stack_st_X509_ALGOR X509_ALGORS;
5598 typedef struct X509_val_st
5599 {
5600 ASN1_TIME *notBefore;
5601 ASN1_TIME *notAfter;
5602 } X509_VAL;
5603 struct X509_pubkey_st
5604 {
5605 X509_ALGOR *algor;
5606 ASN1_BIT_STRING *public_key;
5607 EVP_PKEY *pkey;
5608 };
5609 typedef struct X509_sig_st
5610 {
5611 X509_ALGOR *algor;
5612 ASN1_OCTET_STRING *digest;
5613 } X509_SIG;
5614 typedef struct X509_name_entry_st
5615 {
5616 ASN1_OBJECT *object;
5617 ASN1_STRING *value;
5618 int set;
5619 int size;
5620 } X509_NAME_ENTRY;
5621 struct stack_st_X509_NAME_ENTRY { _STACK stack; };
5622 struct X509_name_st
5623 {
5624 struct stack_st_X509_NAME_ENTRY *entries;
5625 int modified;
5626 BUF_MEM *bytes;
5627 unsigned char *canon_enc;
5628 int canon_enclen;
5629 } ;
5630 struct stack_st_X509_NAME { _STACK stack; };
5631 typedef struct X509_extension_st
5632 {
5633 ASN1_OBJECT *object;
5634 ASN1_BOOLEAN critical;
5635 ASN1_OCTET_STRING *value;
5636 } X509_EXTENSION;
5637 typedef struct stack_st_X509_EXTENSION X509_EXTENSIONS;
5638 struct stack_st_X509_EXTENSION { _STACK stack; };
5639 typedef struct x509_attributes_st
5640 {
5641 ASN1_OBJECT *object;
5642 int single;
5643 union {
5644 char *ptr;
5645 struct stack_st_ASN1_TYPE *set;
5646 ASN1_TYPE *single;
5647 } value;
5648 } X509_ATTRIBUTE;
5649 struct stack_st_X509_ATTRIBUTE { _STACK stack; };
5650 typedef struct X509_req_info_st
5651 {
5652 ASN1_ENCODING enc;
5653 ASN1_INTEGER *version;
5654 X509_NAME *subject;
5655 X509_PUBKEY *pubkey;
5656 struct stack_st_X509_ATTRIBUTE *attributes;
5657 } X509_REQ_INFO;
5658 typedef struct X509_req_st
5659 {
5660 X509_REQ_INFO *req_info;
5661 X509_ALGOR *sig_alg;
5662 ASN1_BIT_STRING *signature;
5663 int references;
5664 } X509_REQ;
5665 typedef struct x509_cinf_st
5666 {
5667 ASN1_INTEGER *version;
5668 ASN1_INTEGER *serialNumber;
5669 X509_ALGOR *signature;
5670 X509_NAME *issuer;
5671 X509_VAL *validity;
5672 X509_NAME *subject;
5673 X509_PUBKEY *key;
5674 ASN1_BIT_STRING *issuerUID;
5675 ASN1_BIT_STRING *subjectUID;
5676 struct stack_st_X509_EXTENSION *extensions;
5677 ASN1_ENCODING enc;
5678 } X509_CINF;
5679 typedef struct x509_cert_aux_st
5680 {
5681 struct stack_st_ASN1_OBJECT *trust;
5682 struct stack_st_ASN1_OBJECT *reject;
5683 ASN1_UTF8STRING *alias;
5684 ASN1_OCTET_STRING *keyid;
5685 struct stack_st_X509_ALGOR *other;
5686 } X509_CERT_AUX;
5687 struct x509_st
5688 {
5689 X509_CINF *cert_info;
5690 X509_ALGOR *sig_alg;
5691 ASN1_BIT_STRING *signature;
5692 int valid;
5693 int references;
5694 char *name;
5695 CRYPTO_EX_DATA ex_data;
5696 long ex_pathlen;
5697 long ex_pcpathlen;
5698 unsigned long ex_flags;
5699 unsigned long ex_kusage;
5700 unsigned long ex_xkusage;
5701 unsigned long ex_nscert;
5702 ASN1_OCTET_STRING *skid;
5703 AUTHORITY_KEYID *akid;
5704 X509_POLICY_CACHE *policy_cache;
5705 struct stack_st_DIST_POINT *crldp;
5706 struct stack_st_GENERAL_NAME *altname;
5707 NAME_CONSTRAINTS *nc;
5708 unsigned char sha1_hash[20];
5709 X509_CERT_AUX *aux;
5710 } ;
5711 struct stack_st_X509 { _STACK stack; };
5712 typedef struct x509_trust_st {
5713 int trust;
5714 int flags;
5715 int (*check_trust)(struct x509_trust_st *, X509 *, int);
5716 char *name;
5717 int arg1;
5718 void *arg2;
5719 } X509_TRUST;
5720 struct stack_st_X509_TRUST { _STACK stack; };
5721 typedef struct x509_cert_pair_st {
5722 X509 *forward;
5723 X509 *reverse;
5724 } X509_CERT_PAIR;
5725 struct x509_revoked_st
5726 {
5727 ASN1_INTEGER *serialNumber;
5728 ASN1_TIME *revocationDate;
5729 struct stack_st_X509_EXTENSION *extensions;
5730 struct stack_st_GENERAL_NAME *issuer;
5731 int reason;
5732 int sequence;
5733 };
5734 struct stack_st_X509_REVOKED { _STACK stack; };
5735 typedef struct X509_crl_info_st
5736 {
5737 ASN1_INTEGER *version;
5738 X509_ALGOR *sig_alg;
5739 X509_NAME *issuer;
5740 ASN1_TIME *lastUpdate;
5741 ASN1_TIME *nextUpdate;
5742 struct stack_st_X509_REVOKED *revoked;
5743 struct stack_st_X509_EXTENSION *extensions;
5744 ASN1_ENCODING enc;
5745 } X509_CRL_INFO;
5746 struct X509_crl_st
5747 {
5748 X509_CRL_INFO *crl;
5749 X509_ALGOR *sig_alg;
5750 ASN1_BIT_STRING *signature;
5751 int references;
5752 int flags;
5753 AUTHORITY_KEYID *akid;
5754 ISSUING_DIST_POINT *idp;
5755 int idp_flags;
5756 int idp_reasons;
5757 ASN1_INTEGER *crl_number;
5758 ASN1_INTEGER *base_crl_number;
5759 unsigned char sha1_hash[20];
5760 struct stack_st_GENERAL_NAMES *issuers;
5761 const X509_CRL_METHOD *meth;
5762 void *meth_data;
5763 } ;
5764 struct stack_st_X509_CRL { _STACK stack; };
5765 typedef struct private_key_st
5766 {
5767 int version;
5768 X509_ALGOR *enc_algor;
5769 ASN1_OCTET_STRING *enc_pkey;
5770 EVP_PKEY *dec_pkey;
5771 int key_length;
5772 char *key_data;
5773 int key_free;
5774 EVP_CIPHER_INFO cipher;
5775 int references;
5776 } X509_PKEY;
5777 typedef struct X509_info_st
5778 {
5779 X509 *x509;
5780 X509_CRL *crl;
5781 X509_PKEY *x_pkey;
5782 EVP_CIPHER_INFO enc_cipher;
5783 int enc_len;
5784 char *enc_data;
5785 int references;
5786 } X509_INFO;
5787 struct stack_st_X509_INFO { _STACK stack; };
5788 typedef struct Netscape_spkac_st
5789 {
5790 X509_PUBKEY *pubkey;
5791 ASN1_IA5STRING *challenge;
5792 } NETSCAPE_SPKAC;
5793 typedef struct Netscape_spki_st
5794 {
5795 NETSCAPE_SPKAC *spkac;
5796 X509_ALGOR *sig_algor;
5797 ASN1_BIT_STRING *signature;
5798 } NETSCAPE_SPKI;
5799 typedef struct Netscape_certificate_sequence
5800 {
5801 ASN1_OBJECT *type;
5802 struct stack_st_X509 *certs;
5803 } NETSCAPE_CERT_SEQUENCE;
5804 typedef struct PBEPARAM_st {
5805 ASN1_OCTET_STRING *salt;
5806 ASN1_INTEGER *iter;
5807 } PBEPARAM;
5808 typedef struct PBE2PARAM_st {
5809 X509_ALGOR *keyfunc;
5810 X509_ALGOR *encryption;
5811 } PBE2PARAM;
5812 typedef struct PBKDF2PARAM_st {
5813 ASN1_TYPE *salt;
5814 ASN1_INTEGER *iter;
5815 ASN1_INTEGER *keylength;
5816 X509_ALGOR *prf;
5817 } PBKDF2PARAM;
5818 struct pkcs8_priv_key_info_st
5819 {
5820 int broken;
5821 ASN1_INTEGER *version;
5822 X509_ALGOR *pkeyalg;
5823 ASN1_TYPE *pkey;
5824 struct stack_st_X509_ATTRIBUTE *attributes;
5825 };
5826 typedef struct lhash_node_st
5827 {
5828 void *data;
5829 struct lhash_node_st *next;
5830 unsigned long hash;
5831 } LHASH_NODE;
5832 typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
5833 typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
5834 typedef void (*LHASH_DOALL_FN_TYPE)(void *);
5835 typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);
5836 typedef struct lhash_st
5837 {
5838 LHASH_NODE **b;
5839 LHASH_COMP_FN_TYPE comp;
5840 LHASH_HASH_FN_TYPE hash;
5841 unsigned int num_nodes;
5842 unsigned int num_alloc_nodes;
5843 unsigned int p;
5844 unsigned int pmax;
5845 unsigned long up_load;
5846 unsigned long down_load;
5847 unsigned long num_items;
5848 unsigned long num_expands;
5849 unsigned long num_expand_reallocs;
5850 unsigned long num_contracts;
5851 unsigned long num_contract_reallocs;
5852 unsigned long num_hash_calls;
5853 unsigned long num_comp_calls;
5854 unsigned long num_insert;
5855 unsigned long num_replace;
5856 unsigned long num_delete;
5857 unsigned long num_no_delete;
5858 unsigned long num_retrieve;
5859 unsigned long num_retrieve_miss;
5860 unsigned long num_hash_comps;
5861 int error;
5862 } _LHASH;
5863 _LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
5864 void lh_free(_LHASH *lh);
5865 void *lh_insert(_LHASH *lh, void *data);
5866 void *lh_delete(_LHASH *lh, const void *data);
5867 void *lh_retrieve(_LHASH *lh, const void *data);
5868 void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);
5869 void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
5870 unsigned long lh_strhash(const char *c);
5871 unsigned long lh_num_items(const _LHASH *lh);
5872 void lh_stats(const _LHASH *lh, FILE *out);
5873 void lh_node_stats(const _LHASH *lh, FILE *out);
5874 void lh_node_usage_stats(const _LHASH *lh, FILE *out);
5875 void lh_stats_bio(const _LHASH *lh, BIO *out);
5876 void lh_node_stats_bio(const _LHASH *lh, BIO *out);
5877 void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);
5878 struct lhash_st_OPENSSL_STRING { int dummy; };
5879 struct lhash_st_OPENSSL_CSTRING { int dummy; };
5880 typedef struct x509_file_st
5881 {
5882 int num_paths;
5883 int num_alloced;
5884 char **paths;
5885 int *path_type;
5886 } X509_CERT_FILE_CTX;
5887 typedef struct x509_object_st
5888 {
5889 int type;
5890 union {
5891 char *ptr;
5892 X509 *x509;
5893 X509_CRL *crl;
5894 EVP_PKEY *pkey;
5895 } data;
5896 } X509_OBJECT;
5897 typedef struct x509_lookup_st X509_LOOKUP;
5898 struct stack_st_X509_LOOKUP { _STACK stack; };
5899 struct stack_st_X509_OBJECT { _STACK stack; };
5900 typedef struct x509_lookup_method_st
5901 {
5902 const char *name;
5903 int (*new_item)(X509_LOOKUP *ctx);
5904 void (*free)(X509_LOOKUP *ctx);
5905 int (*init)(X509_LOOKUP *ctx);
5906 int (*shutdown)(X509_LOOKUP *ctx);
5907 int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl,
5908 char **ret);
5909 int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name,
5910 X509_OBJECT *ret);
5911 int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name,
5912 ASN1_INTEGER *serial,X509_OBJECT *ret);
5913 int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type,
5914 unsigned char *bytes,int len,
5915 X509_OBJECT *ret);
5916 int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len,
5917 X509_OBJECT *ret);
5918 } X509_LOOKUP_METHOD;
5919 typedef struct X509_VERIFY_PARAM_st
5920 {
5921 char *name;
5922 time_t check_time;
5923 unsigned long inh_flags;
5924 unsigned long flags;
5925 int purpose;
5926 int trust;
5927 int depth;
5928 struct stack_st_ASN1_OBJECT *policies;
5929 } X509_VERIFY_PARAM;
5930 struct stack_st_X509_VERIFY_PARAM { _STACK stack; };
5931 struct x509_store_st
5932 {
5933 int cache;
5934 struct stack_st_X509_OBJECT *objs;
5935 struct stack_st_X509_LOOKUP *get_cert_methods;
5936 X509_VERIFY_PARAM *param;
5937 int (*verify)(X509_STORE_CTX *ctx);
5938 int (*verify_cb)(int ok,X509_STORE_CTX *ctx);
5939 int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
5940 int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
5941 int (*check_revocation)(X509_STORE_CTX *ctx);
5942 int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);
5943 int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl);
5944 int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);
5945 struct stack_st_X509 * (*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm);
5946 struct stack_st_X509_CRL * (*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm);
5947 int (*cleanup)(X509_STORE_CTX *ctx);
5948 CRYPTO_EX_DATA ex_data;
5949 int references;
5950 } ;
5951 int X509_STORE_set_depth(X509_STORE *store, int depth);
5952 struct x509_lookup_st
5953 {
5954 int init;
5955 int skip;
5956 X509_LOOKUP_METHOD *method;
5957 char *method_data;
5958 X509_STORE *store_ctx;
5959 } ;
5960 struct x509_store_ctx_st
5961 {
5962 X509_STORE *ctx;
5963 int current_method;
5964 X509 *cert;
5965 struct stack_st_X509 *untrusted;
5966 struct stack_st_X509_CRL *crls;
5967 X509_VERIFY_PARAM *param;
5968 void *other_ctx;
5969 int (*verify)(X509_STORE_CTX *ctx);
5970 int (*verify_cb)(int ok,X509_STORE_CTX *ctx);
5971 int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
5972 int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
5973 int (*check_revocation)(X509_STORE_CTX *ctx);
5974 int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);
5975 int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl);
5976 int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);
5977 int (*check_policy)(X509_STORE_CTX *ctx);
5978 struct stack_st_X509 * (*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm);
5979 struct stack_st_X509_CRL * (*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm);
5980 int (*cleanup)(X509_STORE_CTX *ctx);
5981 int valid;
5982 int last_untrusted;
5983 struct stack_st_X509 *chain;
5984 X509_POLICY_TREE *tree;
5985 int explicit_policy;
5986 int error_depth;
5987 int error;
5988 X509 *current_cert;
5989 X509 *current_issuer;
5990 X509_CRL *current_crl;
5991 int current_crl_score;
5992 unsigned int current_reasons;
5993 X509_STORE_CTX *parent;
5994 CRYPTO_EX_DATA ex_data;
5995 } ;
5996 void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
5997 int X509_OBJECT_idx_by_subject(struct stack_st_X509_OBJECT *h, int type,
5998 X509_NAME *name);
5999 X509_OBJECT *X509_OBJECT_retrieve_by_subject(struct stack_st_X509_OBJECT *h,int type,X509_NAME *name);
6000 X509_OBJECT *X509_OBJECT_retrieve_match(struct stack_st_X509_OBJECT *h, X509_OBJECT *x);
6001 void X509_OBJECT_up_ref_count(X509_OBJECT *a);
6002 void X509_OBJECT_free_contents(X509_OBJECT *a);
6003 X509_STORE *X509_STORE_new(void );
6004 void X509_STORE_free(X509_STORE *v);
6005 struct stack_st_X509* X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);
6006 struct stack_st_X509_CRL* X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);
6007 int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
6008 int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
6009 int X509_STORE_set_trust(X509_STORE *ctx, int trust);
6010 int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);
6011 void X509_STORE_set_verify_cb(X509_STORE *ctx,
6012 int (*verify_cb)(int, X509_STORE_CTX *));
6013 X509_STORE_CTX *X509_STORE_CTX_new(void);
6014 int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
6015 void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
6016 int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
6017 X509 *x509, struct stack_st_X509 *chain);
6018 void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, struct stack_st_X509 *sk);
6019 void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
6020 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
6021 X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
6022 X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
6023 int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
6024 int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
6025 int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name,
6026 X509_OBJECT *ret);
6027 int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
6028 long argl, char **ret);
6029 int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
6030 int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
6031 int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
6032 X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
6033 void X509_LOOKUP_free(X509_LOOKUP *ctx);
6034 int X509_LOOKUP_init(X509_LOOKUP *ctx);
6035 int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,
6036 X509_OBJECT *ret);
6037 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,
6038 ASN1_INTEGER *serial, X509_OBJECT *ret);
6039 int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,
6040 unsigned char *bytes, int len, X509_OBJECT *ret);
6041 int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str,
6042 int len, X509_OBJECT *ret);
6043 int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
6044 int X509_STORE_load_locations (X509_STORE *ctx,
6045 const char *file, const char *dir);
6046 int X509_STORE_set_default_paths(X509_STORE *ctx);
6047 int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
6048 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
6049 int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data);
6050 void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx);
6051 int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
6052 void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
6053 int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
6054 X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
6055 X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);
6056 X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);
6057 X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);
6058 struct stack_st_X509 *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
6059 struct stack_st_X509 *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
6060 void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
6061 void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,struct stack_st_X509 *sk);
6062 void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,struct stack_st_X509_CRL *sk);
6063 int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
6064 int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
6065 int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
6066 int purpose, int trust);
6067 void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
6068 void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
6069 time_t t);
6070 void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
6071 int (*verify_cb)(int, X509_STORE_CTX *));
6072 X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);
6073 int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);
6074 X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
6075 void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
6076 int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
6077 X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);
6078 void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);
6079 int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,
6080 const X509_VERIFY_PARAM *from);
6081 int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,
6082 const X509_VERIFY_PARAM *from);
6083 int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);
6084 int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags);
6085 int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,
6086 unsigned long flags);
6087 unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);
6088 int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);
6089 int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);
6090 void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);
6091 void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);
6092 int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
6093 ASN1_OBJECT *policy);
6094 int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,
6095 struct stack_st_ASN1_OBJECT *policies);
6096 int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);
6097 int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);
6098 const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);
6099 void X509_VERIFY_PARAM_table_cleanup(void);
6100 int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
6101 struct stack_st_X509 *certs,
6102 struct stack_st_ASN1_OBJECT *policy_oids,
6103 unsigned int flags);
6104 void X509_policy_tree_free(X509_POLICY_TREE *tree);
6105 int X509_policy_tree_level_count(const X509_POLICY_TREE *tree);
6106 X509_POLICY_LEVEL *
6107 X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i);
6108 struct stack_st_X509_POLICY_NODE *
6109 X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree);
6110 struct stack_st_X509_POLICY_NODE *
6111 X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree);
6112 int X509_policy_level_node_count(X509_POLICY_LEVEL *level);
6113 X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i);
6114 const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);
6115 struct stack_st_POLICYQUALINFO *
6116 X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node);
6117 const X509_POLICY_NODE *
6118 X509_policy_node_get0_parent(const X509_POLICY_NODE *node);
6119 typedef struct pkcs7_issuer_and_serial_st
6120 {
6121 X509_NAME *issuer;
6122 ASN1_INTEGER *serial;
6123 } PKCS7_ISSUER_AND_SERIAL;
6124 typedef struct pkcs7_signer_info_st
6125 {
6126 ASN1_INTEGER *version;
6127 PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
6128 X509_ALGOR *digest_alg;
6129 struct stack_st_X509_ATTRIBUTE *auth_attr;
6130 X509_ALGOR *digest_enc_alg;
6131 ASN1_OCTET_STRING *enc_digest;
6132 struct stack_st_X509_ATTRIBUTE *unauth_attr;
6133 EVP_PKEY *pkey;
6134 } PKCS7_SIGNER_INFO;
6135 struct stack_st_PKCS7_SIGNER_INFO { _STACK stack; };
6136 typedef struct pkcs7_recip_info_st
6137 {
6138 ASN1_INTEGER *version;
6139 PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
6140 X509_ALGOR *key_enc_algor;
6141 ASN1_OCTET_STRING *enc_key;
6142 X509 *cert;
6143 } PKCS7_RECIP_INFO;
6144 struct stack_st_PKCS7_RECIP_INFO { _STACK stack; };
6145 typedef struct pkcs7_signed_st
6146 {
6147 ASN1_INTEGER *version;
6148 struct stack_st_X509_ALGOR *md_algs;
6149 struct stack_st_X509 *cert;
6150 struct stack_st_X509_CRL *crl;
6151 struct stack_st_PKCS7_SIGNER_INFO *signer_info;
6152 struct pkcs7_st *contents;
6153 } PKCS7_SIGNED;
6154 typedef struct pkcs7_enc_content_st
6155 {
6156 ASN1_OBJECT *content_type;
6157 X509_ALGOR *algorithm;
6158 ASN1_OCTET_STRING *enc_data;
6159 const EVP_CIPHER *cipher;
6160 } PKCS7_ENC_CONTENT;
6161 typedef struct pkcs7_enveloped_st
6162 {
6163 ASN1_INTEGER *version;
6164 struct stack_st_PKCS7_RECIP_INFO *recipientinfo;
6165 PKCS7_ENC_CONTENT *enc_data;
6166 } PKCS7_ENVELOPE;
6167 typedef struct pkcs7_signedandenveloped_st
6168 {
6169 ASN1_INTEGER *version;
6170 struct stack_st_X509_ALGOR *md_algs;
6171 struct stack_st_X509 *cert;
6172 struct stack_st_X509_CRL *crl;
6173 struct stack_st_PKCS7_SIGNER_INFO *signer_info;
6174 PKCS7_ENC_CONTENT *enc_data;
6175 struct stack_st_PKCS7_RECIP_INFO *recipientinfo;
6176 } PKCS7_SIGN_ENVELOPE;
6177 typedef struct pkcs7_digest_st
6178 {
6179 ASN1_INTEGER *version;
6180 X509_ALGOR *md;
6181 struct pkcs7_st *contents;
6182 ASN1_OCTET_STRING *digest;
6183 } PKCS7_DIGEST;
6184 typedef struct pkcs7_encrypted_st
6185 {
6186 ASN1_INTEGER *version;
6187 PKCS7_ENC_CONTENT *enc_data;
6188 } PKCS7_ENCRYPT;
6189 typedef struct pkcs7_st
6190 {
6191 unsigned char *asn1;
6192 long length;
6193 int state;
6194 int detached;
6195 ASN1_OBJECT *type;
6196 union {
6197 char *ptr;
6198 ASN1_OCTET_STRING *data;
6199 PKCS7_SIGNED *sign;
6200 PKCS7_ENVELOPE *enveloped;
6201 PKCS7_SIGN_ENVELOPE *signed_and_enveloped;
6202 PKCS7_DIGEST *digest;
6203 PKCS7_ENCRYPT *encrypted;
6204 ASN1_TYPE *other;
6205 } d;
6206 } PKCS7;
6207 struct stack_st_PKCS7 { _STACK stack; };
6208 PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void); void PKCS7_ISSUER_AND_SERIAL_free(PKCS7_ISSUER_AND_SERIAL *a); PKCS7_ISSUER_AND_SERIAL *d2i_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL **a, const unsigned char **in, long len); int i2d_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL *a, unsigned char **out); extern const ASN1_ITEM PKCS7_ISSUER_AND_SERIAL_it;
6209 int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type,
6210 unsigned char *md,unsigned int *len);
6211 PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7);
6212 int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7);
6213 PKCS7 *PKCS7_dup(PKCS7 *p7);
6214 PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7);
6215 int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7);
6216 int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
6217 int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
6218 PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new(void); void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a); PKCS7_SIGNER_INFO *d2i_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO **a, const unsigned char **in, long len); int i2d_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO *a, unsigned char **out); extern const ASN1_ITEM PKCS7_SIGNER_INFO_it;
6219 PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new(void); void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a); PKCS7_RECIP_INFO *d2i_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO **a, const unsigned char **in, long len); int i2d_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO *a, unsigned char **out); extern const ASN1_ITEM PKCS7_RECIP_INFO_it;
6220 PKCS7_SIGNED *PKCS7_SIGNED_new(void); void PKCS7_SIGNED_free(PKCS7_SIGNED *a); PKCS7_SIGNED *d2i_PKCS7_SIGNED(PKCS7_SIGNED **a, const unsigned char **in, long len); int i2d_PKCS7_SIGNED(PKCS7_SIGNED *a, unsigned char **out); extern const ASN1_ITEM PKCS7_SIGNED_it;
6221 PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new(void); void PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a); PKCS7_ENC_CONTENT *d2i_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT **a, const unsigned char **in, long len); int i2d_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT *a, unsigned char **out); extern const ASN1_ITEM PKCS7_ENC_CONTENT_it;
6222 PKCS7_ENVELOPE *PKCS7_ENVELOPE_new(void); void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a); PKCS7_ENVELOPE *d2i_PKCS7_ENVELOPE(PKCS7_ENVELOPE **a, const unsigned char **in, long len); int i2d_PKCS7_ENVELOPE(PKCS7_ENVELOPE *a, unsigned char **out); extern const ASN1_ITEM PKCS7_ENVELOPE_it;
6223 PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void); void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a); PKCS7_SIGN_ENVELOPE *d2i_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE **a, const unsigned char **in, long len); int i2d_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE *a, unsigned char **out); extern const ASN1_ITEM PKCS7_SIGN_ENVELOPE_it;
6224 PKCS7_DIGEST *PKCS7_DIGEST_new(void); void PKCS7_DIGEST_free(PKCS7_DIGEST *a); PKCS7_DIGEST *d2i_PKCS7_DIGEST(PKCS7_DIGEST **a, const unsigned char **in, long len); int i2d_PKCS7_DIGEST(PKCS7_DIGEST *a, unsigned char **out); extern const ASN1_ITEM PKCS7_DIGEST_it;
6225 PKCS7_ENCRYPT *PKCS7_ENCRYPT_new(void); void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a); PKCS7_ENCRYPT *d2i_PKCS7_ENCRYPT(PKCS7_ENCRYPT **a, const unsigned char **in, long len); int i2d_PKCS7_ENCRYPT(PKCS7_ENCRYPT *a, unsigned char **out); extern const ASN1_ITEM PKCS7_ENCRYPT_it;
6226 PKCS7 *PKCS7_new(void); void PKCS7_free(PKCS7 *a); PKCS7 *d2i_PKCS7(PKCS7 **a, const unsigned char **in, long len); int i2d_PKCS7(PKCS7 *a, unsigned char **out); extern const ASN1_ITEM PKCS7_it;
6227 extern const ASN1_ITEM PKCS7_ATTR_SIGN_it;
6228 extern const ASN1_ITEM PKCS7_ATTR_VERIFY_it;
6229 int i2d_PKCS7_NDEF(PKCS7 *a, unsigned char **out);
6230 int PKCS7_print_ctx(BIO *out, PKCS7 *x, int indent, const ASN1_PCTX *pctx);
6231 long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);
6232 int PKCS7_set_type(PKCS7 *p7, int type);
6233 int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);
6234 int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
6235 int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
6236 const EVP_MD *dgst);
6237 int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);
6238 int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
6239 int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
6240 int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
6241 int PKCS7_content_new(PKCS7 *p7, int nid);
6242 int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,
6243 BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);
6244 int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
6245 X509 *x509);
6246 BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);
6247 int PKCS7_dataFinal(PKCS7 *p7, BIO *bio);
6248 BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);
6249 PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
6250 EVP_PKEY *pkey, const EVP_MD *dgst);
6251 X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
6252 int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);
6253 struct stack_st_PKCS7_SIGNER_INFO *PKCS7_get_signer_info(PKCS7 *p7);
6254 PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);
6255 void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,
6256 X509_ALGOR **pdig, X509_ALGOR **psig);
6257 void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);
6258 int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);
6259 int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);
6260 int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);
6261 int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);
6262 PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);
6263 ASN1_OCTET_STRING *PKCS7_digest_from_attributes(struct stack_st_X509_ATTRIBUTE *sk);
6264 int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si,int nid,int type,
6265 void *data);
6266 int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
6267 void *value);
6268 ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);
6269 ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);
6270 int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,
6271 struct stack_st_X509_ATTRIBUTE *sk);
6272 int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,struct stack_st_X509_ATTRIBUTE *sk);
6273 PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, struct stack_st_X509 *certs,
6274 BIO *data, int flags);
6275 PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,
6276 X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md,
6277 int flags);
6278 int PKCS7_final(PKCS7 *p7, BIO *data, int flags);
6279 int PKCS7_verify(PKCS7 *p7, struct stack_st_X509 *certs, X509_STORE *store,
6280 BIO *indata, BIO *out, int flags);
6281 struct stack_st_X509 *PKCS7_get0_signers(PKCS7 *p7, struct stack_st_X509 *certs, int flags);
6282 PKCS7 *PKCS7_encrypt(struct stack_st_X509 *certs, BIO *in, const EVP_CIPHER *cipher,
6283 int flags);
6284 int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
6285 int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
6286 struct stack_st_X509_ALGOR *cap);
6287 struct stack_st_X509_ALGOR *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
6288 int PKCS7_simple_smimecap(struct stack_st_X509_ALGOR *sk, int nid, int arg);
6289 int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);
6290 int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);
6291 int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
6292 const unsigned char *md, int mdlen);
6293 int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
6294 PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);
6295 BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);
6296 void ERR_load_PKCS7_strings(void);
6297 void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
6298 X509_CRL_METHOD *X509_CRL_METHOD_new(
6299 int (*crl_init)(X509_CRL *crl),
6300 int (*crl_free)(X509_CRL *crl),
6301 int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret,
6302 ASN1_INTEGER *ser, X509_NAME *issuer),
6303 int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk));
6304 void X509_CRL_METHOD_free(X509_CRL_METHOD *m);
6305 void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
6306 void *X509_CRL_get_meth_data(X509_CRL *crl);
6307 const char *X509_verify_cert_error_string(long n);
6308 int X509_verify(X509 *a, EVP_PKEY *r);
6309 int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
6310 int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
6311 int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
6312 NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
6313 char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
6314 EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
6315 int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
6316 int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
6317 int X509_signature_dump(BIO *bp,const ASN1_STRING *sig, int indent);
6318 int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig);
6319 int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
6320 int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
6321 int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
6322 int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
6323 int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
6324 int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
6325 int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
6326 int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
6327 unsigned char *md, unsigned int *len);
6328 int X509_digest(const X509 *data,const EVP_MD *type,
6329 unsigned char *md, unsigned int *len);
6330 int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
6331 unsigned char *md, unsigned int *len);
6332 int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type,
6333 unsigned char *md, unsigned int *len);
6334 int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
6335 unsigned char *md, unsigned int *len);
6336 X509 *d2i_X509_fp(FILE *fp, X509 **x509);
6337 int i2d_X509_fp(FILE *fp,X509 *x509);
6338 X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
6339 int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
6340 X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
6341 int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
6342 RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
6343 int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
6344 RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
6345 int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
6346 RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
6347 int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
6348 DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
6349 int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
6350 DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
6351 int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
6352 EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
6353 int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);
6354 EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
6355 int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);
6356 X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
6357 int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
6358 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
6359 PKCS8_PRIV_KEY_INFO **p8inf);
6360 int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
6361 int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
6362 int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
6363 EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
6364 int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
6365 EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
6366 X509 *d2i_X509_bio(BIO *bp,X509 **x509);
6367 int i2d_X509_bio(BIO *bp,X509 *x509);
6368 X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
6369 int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
6370 X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
6371 int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
6372 RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
6373 int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
6374 RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
6375 int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
6376 RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
6377 int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
6378 DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
6379 int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
6380 DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
6381 int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
6382 EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
6383 int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);
6384 EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
6385 int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);
6386 X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8);
6387 int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
6388 PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
6389 PKCS8_PRIV_KEY_INFO **p8inf);
6390 int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
6391 int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
6392 int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
6393 EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
6394 int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
6395 EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
6396 X509 *X509_dup(X509 *x509);
6397 X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
6398 X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
6399 X509_CRL *X509_CRL_dup(X509_CRL *crl);
6400 X509_REQ *X509_REQ_dup(X509_REQ *req);
6401 X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
6402 int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
6403 void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
6404 X509_ALGOR *algor);
6405 void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
6406 X509_NAME *X509_NAME_dup(X509_NAME *xn);
6407 X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
6408 int X509_cmp_time(const ASN1_TIME *s, time_t *t);
6409 int X509_cmp_current_time(const ASN1_TIME *s);
6410 ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
6411 ASN1_TIME * X509_time_adj_ex(ASN1_TIME *s,
6412 int offset_day, long offset_sec, time_t *t);
6413 ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj);
6414 const char * X509_get_default_cert_area(void );
6415 const char * X509_get_default_cert_dir(void );
6416 const char * X509_get_default_cert_file(void );
6417 const char * X509_get_default_cert_dir_env(void );
6418 const char * X509_get_default_cert_file_env(void );
6419 const char * X509_get_default_private_dir(void );
6420 X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
6421 X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
6422 X509_ALGOR *X509_ALGOR_new(void); void X509_ALGOR_free(X509_ALGOR *a); X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **a, const unsigned char **in, long len); int i2d_X509_ALGOR(X509_ALGOR *a, unsigned char **out); extern const ASN1_ITEM X509_ALGOR_it;
6423 X509_ALGORS *d2i_X509_ALGORS(X509_ALGORS **a, const unsigned char **in, long len); int i2d_X509_ALGORS(X509_ALGORS *a, unsigned char **out); extern const ASN1_ITEM X509_ALGORS_it;
6424 X509_VAL *X509_VAL_new(void); void X509_VAL_free(X509_VAL *a); X509_VAL *d2i_X509_VAL(X509_VAL **a, const unsigned char **in, long len); int i2d_X509_VAL(X509_VAL *a, unsigned char **out); extern const ASN1_ITEM X509_VAL_it;
6425 X509_PUBKEY *X509_PUBKEY_new(void); void X509_PUBKEY_free(X509_PUBKEY *a); X509_PUBKEY *d2i_X509_PUBKEY(X509_PUBKEY **a, const unsigned char **in, long len); int i2d_X509_PUBKEY(X509_PUBKEY *a, unsigned char **out); extern const ASN1_ITEM X509_PUBKEY_it;
6426 int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
6427 EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key);
6428 int X509_get_pubkey_parameters(EVP_PKEY *pkey,
6429 struct stack_st_X509 *chain);
6430 int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
6431 EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp,
6432 long length);
6433 int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
6434 RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp,
6435 long length);
6436 int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
6437 DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp,
6438 long length);
6439 int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
6440 EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp,
6441 long length);
6442 X509_SIG *X509_SIG_new(void); void X509_SIG_free(X509_SIG *a); X509_SIG *d2i_X509_SIG(X509_SIG **a, const unsigned char **in, long len); int i2d_X509_SIG(X509_SIG *a, unsigned char **out); extern const ASN1_ITEM X509_SIG_it;
6443 X509_REQ_INFO *X509_REQ_INFO_new(void); void X509_REQ_INFO_free(X509_REQ_INFO *a); X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a, const unsigned char **in, long len); int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **out); extern const ASN1_ITEM X509_REQ_INFO_it;
6444 X509_REQ *X509_REQ_new(void); void X509_REQ_free(X509_REQ *a); X509_REQ *d2i_X509_REQ(X509_REQ **a, const unsigned char **in, long len); int i2d_X509_REQ(X509_REQ *a, unsigned char **out); extern const ASN1_ITEM X509_REQ_it;
6445 X509_ATTRIBUTE *X509_ATTRIBUTE_new(void); void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a); X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a, const unsigned char **in, long len); int i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a, unsigned char **out); extern const ASN1_ITEM X509_ATTRIBUTE_it;
6446 X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
6447 X509_EXTENSION *X509_EXTENSION_new(void); void X509_EXTENSION_free(X509_EXTENSION *a); X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a, const unsigned char **in, long len); int i2d_X509_EXTENSION(X509_EXTENSION *a, unsigned char **out); extern const ASN1_ITEM X509_EXTENSION_it;
6448 X509_EXTENSIONS *d2i_X509_EXTENSIONS(X509_EXTENSIONS **a, const unsigned char **in, long len); int i2d_X509_EXTENSIONS(X509_EXTENSIONS *a, unsigned char **out); extern const ASN1_ITEM X509_EXTENSIONS_it;
6449 X509_NAME_ENTRY *X509_NAME_ENTRY_new(void); void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a); X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a, const unsigned char **in, long len); int i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a, unsigned char **out); extern const ASN1_ITEM X509_NAME_ENTRY_it;
6450 X509_NAME *X509_NAME_new(void); void X509_NAME_free(X509_NAME *a); X509_NAME *d2i_X509_NAME(X509_NAME **a, const unsigned char **in, long len); int i2d_X509_NAME(X509_NAME *a, unsigned char **out); extern const ASN1_ITEM X509_NAME_it;
6451 int X509_NAME_set(X509_NAME **xn, X509_NAME *name);
6452 X509_CINF *X509_CINF_new(void); void X509_CINF_free(X509_CINF *a); X509_CINF *d2i_X509_CINF(X509_CINF **a, const unsigned char **in, long len); int i2d_X509_CINF(X509_CINF *a, unsigned char **out); extern const ASN1_ITEM X509_CINF_it;
6453 X509 *X509_new(void); void X509_free(X509 *a); X509 *d2i_X509(X509 **a, const unsigned char **in, long len); int i2d_X509(X509 *a, unsigned char **out); extern const ASN1_ITEM X509_it;
6454 X509_CERT_AUX *X509_CERT_AUX_new(void); void X509_CERT_AUX_free(X509_CERT_AUX *a); X509_CERT_AUX *d2i_X509_CERT_AUX(X509_CERT_AUX **a, const unsigned char **in, long len); int i2d_X509_CERT_AUX(X509_CERT_AUX *a, unsigned char **out); extern const ASN1_ITEM X509_CERT_AUX_it;
6455 X509_CERT_PAIR *X509_CERT_PAIR_new(void); void X509_CERT_PAIR_free(X509_CERT_PAIR *a); X509_CERT_PAIR *d2i_X509_CERT_PAIR(X509_CERT_PAIR **a, const unsigned char **in, long len); int i2d_X509_CERT_PAIR(X509_CERT_PAIR *a, unsigned char **out); extern const ASN1_ITEM X509_CERT_PAIR_it;
6456 int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
6457 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
6458 int X509_set_ex_data(X509 *r, int idx, void *arg);
6459 void *X509_get_ex_data(X509 *r, int idx);
6460 int i2d_X509_AUX(X509 *a,unsigned char **pp);
6461 X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length);
6462 int X509_alias_set1(X509 *x, unsigned char *name, int len);
6463 int X509_keyid_set1(X509 *x, unsigned char *id, int len);
6464 unsigned char * X509_alias_get0(X509 *x, int *len);
6465 unsigned char * X509_keyid_get0(X509 *x, int *len);
6466 int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
6467 int X509_TRUST_set(int *t, int trust);
6468 int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
6469 int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
6470 void X509_trust_clear(X509 *x);
6471 void X509_reject_clear(X509 *x);
6472 X509_REVOKED *X509_REVOKED_new(void); void X509_REVOKED_free(X509_REVOKED *a); X509_REVOKED *d2i_X509_REVOKED(X509_REVOKED **a, const unsigned char **in, long len); int i2d_X509_REVOKED(X509_REVOKED *a, unsigned char **out); extern const ASN1_ITEM X509_REVOKED_it;
6473 X509_CRL_INFO *X509_CRL_INFO_new(void); void X509_CRL_INFO_free(X509_CRL_INFO *a); X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, const unsigned char **in, long len); int i2d_X509_CRL_INFO(X509_CRL_INFO *a, unsigned char **out); extern const ASN1_ITEM X509_CRL_INFO_it;
6474 X509_CRL *X509_CRL_new(void); void X509_CRL_free(X509_CRL *a); X509_CRL *d2i_X509_CRL(X509_CRL **a, const unsigned char **in, long len); int i2d_X509_CRL(X509_CRL *a, unsigned char **out); extern const ASN1_ITEM X509_CRL_it;
6475 int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
6476 int X509_CRL_get0_by_serial(X509_CRL *crl,
6477 X509_REVOKED **ret, ASN1_INTEGER *serial);
6478 int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
6479 X509_PKEY * X509_PKEY_new(void );
6480 void X509_PKEY_free(X509_PKEY *a);
6481 int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp);
6482 X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length);
6483 NETSCAPE_SPKI *NETSCAPE_SPKI_new(void); void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a); NETSCAPE_SPKI *d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a, const unsigned char **in, long len); int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **out); extern const ASN1_ITEM NETSCAPE_SPKI_it;
6484 NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void); void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a); NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **a, const unsigned char **in, long len); int i2d_NETSCAPE_SPKAC(NETSCAPE_SPKAC *a, unsigned char **out); extern const ASN1_ITEM NETSCAPE_SPKAC_it;
6485 NETSCAPE_CERT_SEQUENCE *NETSCAPE_CERT_SEQUENCE_new(void); void NETSCAPE_CERT_SEQUENCE_free(NETSCAPE_CERT_SEQUENCE *a); NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a, const unsigned char **in, long len); int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **out); extern const ASN1_ITEM NETSCAPE_CERT_SEQUENCE_it;
6486 X509_INFO * X509_INFO_new(void);
6487 void X509_INFO_free(X509_INFO *a);
6488 char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
6489 int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
6490 ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey);
6491 int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data,
6492 unsigned char *md,unsigned int *len);
6493 int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,
6494 X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
6495 char *data,EVP_PKEY *pkey, const EVP_MD *type);
6496 int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
6497 unsigned char *md,unsigned int *len);
6498 int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
6499 ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);
6500 int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
6501 ASN1_BIT_STRING *signature,
6502 void *data, EVP_PKEY *pkey, const EVP_MD *type);
6503 int ASN1_item_sign_ctx(const ASN1_ITEM *it,
6504 X509_ALGOR *algor1, X509_ALGOR *algor2,
6505 ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx);
6506 int X509_set_version(X509 *x,long version);
6507 int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
6508 ASN1_INTEGER * X509_get_serialNumber(X509 *x);
6509 int X509_set_issuer_name(X509 *x, X509_NAME *name);
6510 X509_NAME * X509_get_issuer_name(X509 *a);
6511 int X509_set_subject_name(X509 *x, X509_NAME *name);
6512 X509_NAME * X509_get_subject_name(X509 *a);
6513 int X509_set_notBefore(X509 *x, const ASN1_TIME *tm);
6514 int X509_set_notAfter(X509 *x, const ASN1_TIME *tm);
6515 int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
6516 EVP_PKEY * X509_get_pubkey(X509 *x);
6517 ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
6518 int X509_certificate_type(X509 *x,EVP_PKEY *pubkey );
6519 int X509_REQ_set_version(X509_REQ *x,long version);
6520 int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
6521 int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
6522 EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req);
6523 int X509_REQ_extension_nid(int nid);
6524 int * X509_REQ_get_extension_nids(void);
6525 void X509_REQ_set_extension_nids(int *nids);
6526 struct stack_st_X509_EXTENSION *X509_REQ_get_extensions(X509_REQ *req);
6527 int X509_REQ_add_extensions_nid(X509_REQ *req, struct stack_st_X509_EXTENSION *exts,
6528 int nid);
6529 int X509_REQ_add_extensions(X509_REQ *req, struct stack_st_X509_EXTENSION *exts);
6530 int X509_REQ_get_attr_count(const X509_REQ *req);
6531 int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
6532 int lastpos);
6533 int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
6534 int lastpos);
6535 X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
6536 X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
6537 int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
6538 int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
6539 const ASN1_OBJECT *obj, int type,
6540 const unsigned char *bytes, int len);
6541 int X509_REQ_add1_attr_by_NID(X509_REQ *req,
6542 int nid, int type,
6543 const unsigned char *bytes, int len);
6544 int X509_REQ_add1_attr_by_txt(X509_REQ *req,
6545 const char *attrname, int type,
6546 const unsigned char *bytes, int len);
6547 int X509_CRL_set_version(X509_CRL *x, long version);
6548 int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
6549 int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
6550 int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
6551 int X509_CRL_sort(X509_CRL *crl);
6552 int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
6553 int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
6554 int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey);
6555 int X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
6556 int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
6557 unsigned long X509_issuer_and_serial_hash(X509 *a);
6558 int X509_issuer_name_cmp(const X509 *a, const X509 *b);
6559 unsigned long X509_issuer_name_hash(X509 *a);
6560 int X509_subject_name_cmp(const X509 *a, const X509 *b);
6561 unsigned long X509_subject_name_hash(X509 *x);
6562 unsigned long X509_issuer_name_hash_old(X509 *a);
6563 unsigned long X509_subject_name_hash_old(X509 *x);
6564 int X509_cmp(const X509 *a, const X509 *b);
6565 int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
6566 unsigned long X509_NAME_hash(X509_NAME *x);
6567 unsigned long X509_NAME_hash_old(X509_NAME *x);
6568 int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
6569 int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
6570 int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
6571 int X509_print_fp(FILE *bp,X509 *x);
6572 int X509_CRL_print_fp(FILE *bp,X509_CRL *x);
6573 int X509_REQ_print_fp(FILE *bp,X509_REQ *req);
6574 int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);
6575 int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
6576 int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
6577 int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
6578 int X509_print(BIO *bp,X509 *x);
6579 int X509_ocspid_print(BIO *bp,X509 *x);
6580 int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
6581 int X509_CRL_print(BIO *bp,X509_CRL *x);
6582 int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
6583 int X509_REQ_print(BIO *bp,X509_REQ *req);
6584 int X509_NAME_entry_count(X509_NAME *name);
6585 int X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
6586 char *buf,int len);
6587 int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
6588 char *buf,int len);
6589 int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
6590 int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
6591 int lastpos);
6592 X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
6593 X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
6594 int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
6595 int loc, int set);
6596 int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
6597 unsigned char *bytes, int len, int loc, int set);
6598 int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
6599 unsigned char *bytes, int len, int loc, int set);
6600 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
6601 const char *field, int type, const unsigned char *bytes, int len);
6602 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
6603 int type,unsigned char *bytes, int len);
6604 int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
6605 const unsigned char *bytes, int len, int loc, int set);
6606 X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
6607 ASN1_OBJECT *obj, int type,const unsigned char *bytes,
6608 int len);
6609 int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
6610 ASN1_OBJECT *obj);
6611 int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
6612 const unsigned char *bytes, int len);
6613 ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
6614 ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
6615 int X509v3_get_ext_count(const struct stack_st_X509_EXTENSION *x);
6616 int X509v3_get_ext_by_NID(const struct stack_st_X509_EXTENSION *x,
6617 int nid, int lastpos);
6618 int X509v3_get_ext_by_OBJ(const struct stack_st_X509_EXTENSION *x,
6619 ASN1_OBJECT *obj,int lastpos);
6620 int X509v3_get_ext_by_critical(const struct stack_st_X509_EXTENSION *x,
6621 int crit, int lastpos);
6622 X509_EXTENSION *X509v3_get_ext(const struct stack_st_X509_EXTENSION *x, int loc);
6623 X509_EXTENSION *X509v3_delete_ext(struct stack_st_X509_EXTENSION *x, int loc);
6624 struct stack_st_X509_EXTENSION *X509v3_add_ext(struct stack_st_X509_EXTENSION **x,
6625 X509_EXTENSION *ex, int loc);
6626 int X509_get_ext_count(X509 *x);
6627 int X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
6628 int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos);
6629 int X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
6630 X509_EXTENSION *X509_get_ext(X509 *x, int loc);
6631 X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
6632 int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
6633 void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
6634 int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
6635 unsigned long flags);
6636 int X509_CRL_get_ext_count(X509_CRL *x);
6637 int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
6638 int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos);
6639 int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
6640 X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
6641 X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
6642 int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
6643 void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
6644 int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
6645 unsigned long flags);
6646 int X509_REVOKED_get_ext_count(X509_REVOKED *x);
6647 int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
6648 int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos);
6649 int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
6650 X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
6651 X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
6652 int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
6653 void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
6654 int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
6655 unsigned long flags);
6656 X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
6657 int nid, int crit, ASN1_OCTET_STRING *data);
6658 X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
6659 ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data);
6660 int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj);
6661 int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
6662 int X509_EXTENSION_set_data(X509_EXTENSION *ex,
6663 ASN1_OCTET_STRING *data);
6664 ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex);
6665 ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
6666 int X509_EXTENSION_get_critical(X509_EXTENSION *ex);
6667 int X509at_get_attr_count(const struct stack_st_X509_ATTRIBUTE *x);
6668 int X509at_get_attr_by_NID(const struct stack_st_X509_ATTRIBUTE *x, int nid,
6669 int lastpos);
6670 int X509at_get_attr_by_OBJ(const struct stack_st_X509_ATTRIBUTE *sk, ASN1_OBJECT *obj,
6671 int lastpos);
6672 X509_ATTRIBUTE *X509at_get_attr(const struct stack_st_X509_ATTRIBUTE *x, int loc);
6673 X509_ATTRIBUTE *X509at_delete_attr(struct stack_st_X509_ATTRIBUTE *x, int loc);
6674 struct stack_st_X509_ATTRIBUTE *X509at_add1_attr(struct stack_st_X509_ATTRIBUTE **x,
6675 X509_ATTRIBUTE *attr);
6676 struct stack_st_X509_ATTRIBUTE *X509at_add1_attr_by_OBJ(struct stack_st_X509_ATTRIBUTE **x,
6677 const ASN1_OBJECT *obj, int type,
6678 const unsigned char *bytes, int len);
6679 struct stack_st_X509_ATTRIBUTE *X509at_add1_attr_by_NID(struct stack_st_X509_ATTRIBUTE **x,
6680 int nid, int type,
6681 const unsigned char *bytes, int len);
6682 struct stack_st_X509_ATTRIBUTE *X509at_add1_attr_by_txt(struct stack_st_X509_ATTRIBUTE **x,
6683 const char *attrname, int type,
6684 const unsigned char *bytes, int len);
6685 void *X509at_get0_data_by_OBJ(struct stack_st_X509_ATTRIBUTE *x,
6686 ASN1_OBJECT *obj, int lastpos, int type);
6687 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
6688 int atrtype, const void *data, int len);
6689 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
6690 const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
6691 X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
6692 const char *atrname, int type, const unsigned char *bytes, int len);
6693 int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
6694 int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
6695 void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
6696 int atrtype, void *data);
6697 int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
6698 ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
6699 ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
6700 int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
6701 int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid,
6702 int lastpos);
6703 int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,
6704 int lastpos);
6705 X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
6706 X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
6707 int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
6708 int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
6709 const ASN1_OBJECT *obj, int type,
6710 const unsigned char *bytes, int len);
6711 int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
6712 int nid, int type,
6713 const unsigned char *bytes, int len);
6714 int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
6715 const char *attrname, int type,
6716 const unsigned char *bytes, int len);
6717 int X509_verify_cert(X509_STORE_CTX *ctx);
6718 X509 *X509_find_by_issuer_and_serial(struct stack_st_X509 *sk,X509_NAME *name,
6719 ASN1_INTEGER *serial);
6720 X509 *X509_find_by_subject(struct stack_st_X509 *sk,X509_NAME *name);
6721 PBEPARAM *PBEPARAM_new(void); void PBEPARAM_free(PBEPARAM *a); PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, const unsigned char **in, long len); int i2d_PBEPARAM(PBEPARAM *a, unsigned char **out); extern const ASN1_ITEM PBEPARAM_it;
6722 PBE2PARAM *PBE2PARAM_new(void); void PBE2PARAM_free(PBE2PARAM *a); PBE2PARAM *d2i_PBE2PARAM(PBE2PARAM **a, const unsigned char **in, long len); int i2d_PBE2PARAM(PBE2PARAM *a, unsigned char **out); extern const ASN1_ITEM PBE2PARAM_it;
6723 PBKDF2PARAM *PBKDF2PARAM_new(void); void PBKDF2PARAM_free(PBKDF2PARAM *a); PBKDF2PARAM *d2i_PBKDF2PARAM(PBKDF2PARAM **a, const unsigned char **in, long len); int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **out); extern const ASN1_ITEM PBKDF2PARAM_it;
6724 int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
6725 const unsigned char *salt, int saltlen);
6726 X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
6727 const unsigned char *salt, int saltlen);
6728 X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
6729 unsigned char *salt, int saltlen);
6730 X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
6731 unsigned char *salt, int saltlen,
6732 unsigned char *aiv, int prf_nid);
6733 X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
6734 int prf_nid, int keylen);
6735 PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void); void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a); PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a, const unsigned char **in, long len); int i2d_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO *a, unsigned char **out); extern const ASN1_ITEM PKCS8_PRIV_KEY_INFO_it;
6736 EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
6737 PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
6738 PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
6739 PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
6740 int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
6741 int version, int ptype, void *pval,
6742 unsigned char *penc, int penclen);
6743 int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,
6744 const unsigned char **pk, int *ppklen,
6745 X509_ALGOR **pa,
6746 PKCS8_PRIV_KEY_INFO *p8);
6747 int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
6748 int ptype, void *pval,
6749 unsigned char *penc, int penclen);
6750 int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
6751 const unsigned char **pk, int *ppklen,
6752 X509_ALGOR **pa,
6753 X509_PUBKEY *pub);
6754 int X509_check_trust(X509 *x, int id, int flags);
6755 int X509_TRUST_get_count(void);
6756 X509_TRUST * X509_TRUST_get0(int idx);
6757 int X509_TRUST_get_by_id(int id);
6758 int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
6759 char *name, int arg1, void *arg2);
6760 void X509_TRUST_cleanup(void);
6761 int X509_TRUST_get_flags(X509_TRUST *xp);
6762 char *X509_TRUST_get0_name(X509_TRUST *xp);
6763 int X509_TRUST_get_trust(X509_TRUST *xp);
6764 void ERR_load_X509_strings(void);
6765 typedef struct PEM_Encode_Seal_st
6766 {
6767 EVP_ENCODE_CTX encode;
6768 EVP_MD_CTX md;
6769 EVP_CIPHER_CTX cipher;
6770 } PEM_ENCODE_SEAL_CTX;
6771 typedef struct pem_recip_st
6772 {
6773 char *name;
6774 X509_NAME *dn;
6775 int cipher;
6776 int key_enc;
6777 } PEM_USER;
6778 typedef struct pem_ctx_st
6779 {
6780 int type;
6781 struct {
6782 int version;
6783 int mode;
6784 } proc_type;
6785 char *domain;
6786 struct {
6787 int cipher;
6788 } DEK_info;
6789 PEM_USER *originator;
6790 int num_recipient;
6791 PEM_USER **recipient;
6792 EVP_MD *md;
6793 int md_enc;
6794 int md_len;
6795 char *md_data;
6796 EVP_CIPHER *dec;
6797 int key_len;
6798 unsigned char *key;
6799 int data_enc;
6800 int data_len;
6801 unsigned char *data;
6802 } PEM_CTX;
6803 typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
6804 int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
6805 int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
6806 pem_password_cb *callback,void *u);
6807 int PEM_read_bio(BIO *bp, char **name, char **header,
6808 unsigned char **data,long *len);
6809 int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data,
6810 long len);
6811 int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp,
6812 pem_password_cb *cb, void *u);
6813 void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
6814 void **x, pem_password_cb *cb, void *u);
6815 int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp, void *x,
6816 const EVP_CIPHER *enc,unsigned char *kstr,int klen,
6817 pem_password_cb *cb, void *u);
6818 struct stack_st_X509_INFO * PEM_X509_INFO_read_bio(BIO *bp, struct stack_st_X509_INFO *sk, pem_password_cb *cb, void *u);
6819 int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
6820 unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
6821 int PEM_read(FILE *fp, char **name, char **header,
6822 unsigned char **data,long *len);
6823 int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
6824 void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
6825 pem_password_cb *cb, void *u);
6826 int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp,
6827 void *x,const EVP_CIPHER *enc,unsigned char *kstr,
6828 int klen,pem_password_cb *callback, void *u);
6829 struct stack_st_X509_INFO * PEM_X509_INFO_read(FILE *fp, struct stack_st_X509_INFO *sk,
6830 pem_password_cb *cb, void *u);
6831 int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
6832 EVP_MD *md_type, unsigned char **ek, int *ekl,
6833 unsigned char *iv, EVP_PKEY **pubk, int npubk);
6834 void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
6835 unsigned char *in, int inl);
6836 int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
6837 unsigned char *out, int *outl, EVP_PKEY *priv);
6838 void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
6839 void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
6840 int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
6841 unsigned int *siglen, EVP_PKEY *pkey);
6842 int PEM_def_callback(char *buf, int num, int w, void *key);
6843 void PEM_proc_type(char *buf, int type);
6844 void PEM_dek_info(char *buf, const char *type, int len, char *str);
6845 X509 *PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u); X509 *PEM_read_X509(FILE *fp, X509 **x, pem_password_cb *cb, void *u); int PEM_write_bio_X509(BIO *bp, X509 *x); int PEM_write_X509(FILE *fp, X509 *x);
6846 X509 *PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u); X509 *PEM_read_X509_AUX(FILE *fp, X509 **x, pem_password_cb *cb, void *u); int PEM_write_bio_X509_AUX(BIO *bp, X509 *x); int PEM_write_X509_AUX(FILE *fp, X509 *x);
6847 X509_CERT_PAIR *PEM_read_bio_X509_CERT_PAIR(BIO *bp, X509_CERT_PAIR **x, pem_password_cb *cb, void *u); X509_CERT_PAIR *PEM_read_X509_CERT_PAIR(FILE *fp, X509_CERT_PAIR **x, pem_password_cb *cb, void *u); int PEM_write_bio_X509_CERT_PAIR(BIO *bp, X509_CERT_PAIR *x); int PEM_write_X509_CERT_PAIR(FILE *fp, X509_CERT_PAIR *x);
6848 X509_REQ *PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x, pem_password_cb *cb, void *u); X509_REQ *PEM_read_X509_REQ(FILE *fp, X509_REQ **x, pem_password_cb *cb, void *u); int PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x); int PEM_write_X509_REQ(FILE *fp, X509_REQ *x);
6849 int PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x); int PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x);
6850 X509_CRL *PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x, pem_password_cb *cb, void *u); X509_CRL *PEM_read_X509_CRL(FILE *fp, X509_CRL **x, pem_password_cb *cb, void *u); int PEM_write_bio_X509_CRL(BIO *bp, X509_CRL *x); int PEM_write_X509_CRL(FILE *fp, X509_CRL *x);
6851 PKCS7 *PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u); PKCS7 *PEM_read_PKCS7(FILE *fp, PKCS7 **x, pem_password_cb *cb, void *u); int PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x); int PEM_write_PKCS7(FILE *fp, PKCS7 *x);
6852 NETSCAPE_CERT_SEQUENCE *PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, NETSCAPE_CERT_SEQUENCE **x, pem_password_cb *cb, void *u); NETSCAPE_CERT_SEQUENCE *PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE **x, pem_password_cb *cb, void *u); int PEM_write_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, NETSCAPE_CERT_SEQUENCE *x); int PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE *x);
6853 X509_SIG *PEM_read_bio_PKCS8(BIO *bp, X509_SIG **x, pem_password_cb *cb, void *u); X509_SIG *PEM_read_PKCS8(FILE *fp, X509_SIG **x, pem_password_cb *cb, void *u); int PEM_write_bio_PKCS8(BIO *bp, X509_SIG *x); int PEM_write_PKCS8(FILE *fp, X509_SIG *x);
6854 PKCS8_PRIV_KEY_INFO *PEM_read_bio_PKCS8_PRIV_KEY_INFO(BIO *bp, PKCS8_PRIV_KEY_INFO **x, pem_password_cb *cb, void *u); PKCS8_PRIV_KEY_INFO *PEM_read_PKCS8_PRIV_KEY_INFO(FILE *fp, PKCS8_PRIV_KEY_INFO **x, pem_password_cb *cb, void *u); int PEM_write_bio_PKCS8_PRIV_KEY_INFO(BIO *bp, PKCS8_PRIV_KEY_INFO *x); int PEM_write_PKCS8_PRIV_KEY_INFO(FILE *fp, PKCS8_PRIV_KEY_INFO *x);
6855 RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **x, pem_password_cb *cb, void *u); RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **x, pem_password_cb *cb, void *u); int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u); int PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
6856 RSA *PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x, pem_password_cb *cb, void *u); RSA *PEM_read_RSAPublicKey(FILE *fp, RSA **x, pem_password_cb *cb, void *u); int PEM_write_bio_RSAPublicKey(BIO *bp, const RSA *x); int PEM_write_RSAPublicKey(FILE *fp, const RSA *x);
6857 RSA *PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x, pem_password_cb *cb, void *u); RSA *PEM_read_RSA_PUBKEY(FILE *fp, RSA **x, pem_password_cb *cb, void *u); int PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x); int PEM_write_RSA_PUBKEY(FILE *fp, RSA *x);
6858 DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **x, pem_password_cb *cb, void *u); DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **x, pem_password_cb *cb, void *u); int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u); int PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
6859 DSA *PEM_read_bio_DSA_PUBKEY(BIO *bp, DSA **x, pem_password_cb *cb, void *u); DSA *PEM_read_DSA_PUBKEY(FILE *fp, DSA **x, pem_password_cb *cb, void *u); int PEM_write_bio_DSA_PUBKEY(BIO *bp, DSA *x); int PEM_write_DSA_PUBKEY(FILE *fp, DSA *x);
6860 DSA *PEM_read_bio_DSAparams(BIO *bp, DSA **x, pem_password_cb *cb, void *u); DSA *PEM_read_DSAparams(FILE *fp, DSA **x, pem_password_cb *cb, void *u); int PEM_write_bio_DSAparams(BIO *bp, const DSA *x); int PEM_write_DSAparams(FILE *fp, const DSA *x);
6861 EC_GROUP *PEM_read_bio_ECPKParameters(BIO *bp, EC_GROUP **x, pem_password_cb *cb, void *u); EC_GROUP *PEM_read_ECPKParameters(FILE *fp, EC_GROUP **x, pem_password_cb *cb, void *u); int PEM_write_bio_ECPKParameters(BIO *bp, const EC_GROUP *x); int PEM_write_ECPKParameters(FILE *fp, const EC_GROUP *x);
6862 EC_KEY *PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **x, pem_password_cb *cb, void *u); EC_KEY *PEM_read_ECPrivateKey(FILE *fp, EC_KEY **x, pem_password_cb *cb, void *u); int PEM_write_bio_ECPrivateKey(BIO *bp, EC_KEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u); int PEM_write_ECPrivateKey(FILE *fp, EC_KEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
6863 EC_KEY *PEM_read_bio_EC_PUBKEY(BIO *bp, EC_KEY **x, pem_password_cb *cb, void *u); EC_KEY *PEM_read_EC_PUBKEY(FILE *fp, EC_KEY **x, pem_password_cb *cb, void *u); int PEM_write_bio_EC_PUBKEY(BIO *bp, EC_KEY *x); int PEM_write_EC_PUBKEY(FILE *fp, EC_KEY *x);
6864 DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u); DH *PEM_read_DHparams(FILE *fp, DH **x, pem_password_cb *cb, void *u); int PEM_write_bio_DHparams(BIO *bp, const DH *x); int PEM_write_DHparams(FILE *fp, const DH *x);
6865 EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u); int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
6866 EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); EVP_PKEY *PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); int PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x); int PEM_write_PUBKEY(FILE *fp, EVP_PKEY *x);
6867 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
6868 char *kstr, int klen,
6869 pem_password_cb *cb, void *u);
6870 int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
6871 char *, int, pem_password_cb *, void *);
6872 int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
6873 char *kstr, int klen,
6874 pem_password_cb *cb, void *u);
6875 int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
6876 char *kstr, int klen,
6877 pem_password_cb *cb, void *u);
6878 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
6879 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
6880 char *kstr, int klen,
6881 pem_password_cb *cb, void *u);
6882 int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
6883 char *kstr, int klen,
6884 pem_password_cb *cb, void *u);
6885 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
6886 char *kstr, int klen,
6887 pem_password_cb *cb, void *u);
6888 EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
6889 int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
6890 char *kstr,int klen, pem_password_cb *cd, void *u);
6891 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
6892 int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
6893 EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
6894 EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
6895 EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
6896 EVP_PKEY *b2i_PublicKey_bio(BIO *in);
6897 int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
6898 int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
6899 EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
6900 int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
6901 pem_password_cb *cb, void *u);
6902 void ERR_load_PEM_strings(void);
6903 int EVP_DigestFinal_ex(EVP_MD_CTX *, unsigned char *, unsigned int *);
6904 int EVP_MD_CTX_copy_ex(EVP_MD_CTX *, const EVP_MD_CTX *);
6905 int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *,
6906 unsigned char *, int);
6907 int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int);
6908 int ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *);
6909 void ssh_OpenSSL_add_all_algorithms(void);
6910 struct flock
6911 {
6912 short int l_type;
6913 short int l_whence;
6914 __off64_t l_start;
6915 __off64_t l_len;
6916 __pid_t l_pid;
6917 };
6918 struct flock64
6919 {
6920 short int l_type;
6921 short int l_whence;
6922 __off64_t l_start;
6923 __off64_t l_len;
6924 __pid_t l_pid;
6925 };
6926 enum __pid_type
6927 {
6928 F_OWNER_TID = 0,
6929 F_OWNER_PID,
6930 F_OWNER_PGRP,
6931 F_OWNER_GID = F_OWNER_PGRP
6932 };
6933 struct f_owner_ex
6934 {
6935 enum __pid_type type;
6936 __pid_t pid;
6937 };
6938 struct file_handle
6939 {
6940 unsigned int handle_bytes;
6941 int handle_type;
6942 unsigned char f_handle[0];
6943 };
6944 extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
6945 __attribute__ ((__nothrow__ , __leaf__));
6946 extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count,
6947 unsigned int __flags);
6948 extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
6949 size_t __count, unsigned int __flags);
6950 extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
6951 __off64_t *__offout, size_t __len,
6952 unsigned int __flags);
6953 extern ssize_t tee (int __fdin, int __fdout, size_t __len,
6954 unsigned int __flags);
6955 extern int fallocate (int __fd, int __mode, __off64_t __offset, __off64_t __len) __asm__ ("" "fallocate64")
6956 ;
6957 extern int fallocate64 (int __fd, int __mode, __off64_t __offset,
6958 __off64_t __len);
6959 extern int name_to_handle_at (int __dfd, const char *__name,
6960 struct file_handle *__handle, int *__mnt_id,
6961 int __flags) __attribute__ ((__nothrow__ , __leaf__));
6962 extern int open_by_handle_at (int __mountdirfd, struct file_handle *__handle,
6963 int __flags);
6964 extern int fcntl (int __fd, int __cmd, ...);
6965 extern int open (const char *__file, int __oflag, ...) __asm__ ("" "open64")
6966 __attribute__ ((__nonnull__ (1)));
6967 extern int open64 (const char *__file, int __oflag, ...) __attribute__ ((__nonnull__ (1)));
6968 extern int openat (int __fd, const char *__file, int __oflag, ...) __asm__ ("" "openat64")
6969 __attribute__ ((__nonnull__ (2)));
6970 extern int openat64 (int __fd, const char *__file, int __oflag, ...)
6971 __attribute__ ((__nonnull__ (2)));
6972 extern int creat (const char *__file, mode_t __mode) __asm__ ("" "creat64")
6973 __attribute__ ((__nonnull__ (1)));
6974 extern int creat64 (const char *__file, mode_t __mode) __attribute__ ((__nonnull__ (1)));
6975 extern int lockf (int __fd, int __cmd, __off64_t __len) __asm__ ("" "lockf64");
6976 extern int lockf64 (int __fd, int __cmd, off64_t __len);
6977 extern int posix_fadvise (int __fd, __off64_t __offset, __off64_t __len, int __advise) __asm__ ("" "posix_fadvise64") __attribute__ ((__nothrow__ , __leaf__))
6978 ;
6979 extern int posix_fadvise64 (int __fd, off64_t __offset, off64_t __len,
6980 int __advise) __attribute__ ((__nothrow__ , __leaf__));
6981 extern int posix_fallocate (int __fd, __off64_t __offset, __off64_t __len) __asm__ ("" "posix_fallocate64")
6982 ;
6983 extern int posix_fallocate64 (int __fd, off64_t __offset, off64_t __len);
6984 extern int __open_2 (const char *__path, int __oflag) __asm__ ("" "__open64_2")
6985 __attribute__ ((__nonnull__ (1)));
6986 extern int __open_alias (const char *__path, int __oflag, ...) __asm__ ("" "open64")
6987 __attribute__ ((__nonnull__ (1)));
6988 extern void __open_too_many_args (void) __attribute__((__error__ ("open can be called either with 2 or 3 arguments, not more")))
6989 ;
6990 extern void __open_missing_mode (void) __attribute__((__error__ ("open with O_CREAT in second argument needs 3 arguments")))
6991 ;
6992 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
6993 open (const char *__path, int __oflag, ...)
6994 {
6995 if (__builtin_va_arg_pack_len () > 1)
6996 __open_too_many_args ();
6997 if (__builtin_constant_p (__oflag))
6998 {
6999 if ((__oflag & 00000400) != 0 && __builtin_va_arg_pack_len () < 1)
7000 {
7001 __open_missing_mode ();
7002 return __open_2 (__path, __oflag);
7003 }
7004 return __open_alias (__path, __oflag, __builtin_va_arg_pack ());
7005 }
7006 if (__builtin_va_arg_pack_len () < 1)
7007 return __open_2 (__path, __oflag);
7008 return __open_alias (__path, __oflag, __builtin_va_arg_pack ());
7009 }
7010 extern int __open64_2 (const char *__path, int __oflag) __attribute__ ((__nonnull__ (1)));
7011 extern int __open64_alias (const char *__path, int __oflag, ...) __asm__ ("" "open64")
7012 __attribute__ ((__nonnull__ (1)));
7013 extern void __open64_too_many_args (void) __attribute__((__error__ ("open64 can be called either with 2 or 3 arguments, not more")))
7014 ;
7015 extern void __open64_missing_mode (void) __attribute__((__error__ ("open64 with O_CREAT in second argument needs 3 arguments")))
7016 ;
7017 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
7018 open64 (const char *__path, int __oflag, ...)
7019 {
7020 if (__builtin_va_arg_pack_len () > 1)
7021 __open64_too_many_args ();
7022 if (__builtin_constant_p (__oflag))
7023 {
7024 if ((__oflag & 00000400) != 0 && __builtin_va_arg_pack_len () < 1)
7025 {
7026 __open64_missing_mode ();
7027 return __open64_2 (__path, __oflag);
7028 }
7029 return __open64_alias (__path, __oflag, __builtin_va_arg_pack ());
7030 }
7031 if (__builtin_va_arg_pack_len () < 1)
7032 return __open64_2 (__path, __oflag);
7033 return __open64_alias (__path, __oflag, __builtin_va_arg_pack ());
7034 }
7035 extern int __openat_2 (int __fd, const char *__path, int __oflag) __asm__ ("" "__openat64_2")
7036 __attribute__ ((__nonnull__ (2)));
7037 extern int __openat_alias (int __fd, const char *__path, int __oflag, ...) __asm__ ("" "openat64")
7038 __attribute__ ((__nonnull__ (2)));
7039 extern void __openat_too_many_args (void) __attribute__((__error__ ("openat can be called either with 3 or 4 arguments, not more")))
7040 ;
7041 extern void __openat_missing_mode (void) __attribute__((__error__ ("openat with O_CREAT in third argument needs 4 arguments")))
7042 ;
7043 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
7044 openat (int __fd, const char *__path, int __oflag, ...)
7045 {
7046 if (__builtin_va_arg_pack_len () > 1)
7047 __openat_too_many_args ();
7048 if (__builtin_constant_p (__oflag))
7049 {
7050 if ((__oflag & 00000400) != 0 && __builtin_va_arg_pack_len () < 1)
7051 {
7052 __openat_missing_mode ();
7053 return __openat_2 (__fd, __path, __oflag);
7054 }
7055 return __openat_alias (__fd, __path, __oflag, __builtin_va_arg_pack ());
7056 }
7057 if (__builtin_va_arg_pack_len () < 1)
7058 return __openat_2 (__fd, __path, __oflag);
7059 return __openat_alias (__fd, __path, __oflag, __builtin_va_arg_pack ());
7060 }
7061 extern int __openat64_2 (int __fd, const char *__path, int __oflag)
7062 __attribute__ ((__nonnull__ (2)));
7063 extern int __openat64_alias (int __fd, const char *__path, int __oflag, ...) __asm__ ("" "openat64")
7064 __attribute__ ((__nonnull__ (2)));
7065 extern void __openat64_too_many_args (void) __attribute__((__error__ ("openat64 can be called either with 3 or 4 arguments, not more")))
7066 ;
7067 extern void __openat64_missing_mode (void) __attribute__((__error__ ("openat64 with O_CREAT in third argument needs 4 arguments")))
7068 ;
7069 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
7070 openat64 (int __fd, const char *__path, int __oflag, ...)
7071 {
7072 if (__builtin_va_arg_pack_len () > 1)
7073 __openat64_too_many_args ();
7074 if (__builtin_constant_p (__oflag))
7075 {
7076 if ((__oflag & 00000400) != 0 && __builtin_va_arg_pack_len () < 1)
7077 {
7078 __openat64_missing_mode ();
7079 return __openat64_2 (__fd, __path, __oflag);
7080 }
7081 return __openat64_alias (__fd, __path, __oflag, __builtin_va_arg_pack ());
7082 }
7083 if (__builtin_va_arg_pack_len () < 1)
7084 return __openat64_2 (__fd, __path, __oflag);
7085 return __openat64_alias (__fd, __path, __oflag, __builtin_va_arg_pack ());
7086 }
7087 extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
7088 size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7089 extern void *memmove (void *__dest, const void *__src, size_t __n)
7090 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7091 extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
7092 int __c, size_t __n)
7093 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7094 extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7095 extern int memcmp (const void *__s1, const void *__s2, size_t __n)
7096 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7097 extern void *memchr (const void *__s, int __c, size_t __n)
7098 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7099 extern void *rawmemchr (const void *__s, int __c)
7100 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7101 extern void *memrchr (const void *__s, int __c, size_t __n)
7102 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7103 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
7104 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7105 extern char *strncpy (char *__restrict __dest,
7106 const char *__restrict __src, size_t __n)
7107 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7108 extern char *strcat (char *__restrict __dest, const char *__restrict __src)
7109 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7110 extern char *strncat (char *__restrict __dest, const char *__restrict __src,
7111 size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7112 extern int strcmp (const char *__s1, const char *__s2)
7113 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7114 extern int strncmp (const char *__s1, const char *__s2, size_t __n)
7115 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7116 extern int strcoll (const char *__s1, const char *__s2)
7117 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7118 extern size_t strxfrm (char *__restrict __dest,
7119 const char *__restrict __src, size_t __n)
7120 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
7121 extern int strcoll_l (const char *__s1, const char *__s2, __locale_t __l)
7122 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
7123 extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
7124 __locale_t __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));
7125 extern char *strdup (const char *__s)
7126 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
7127 extern char *strndup (const char *__string, size_t __n)
7128 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
7129 extern char *strchr (const char *__s, int __c)
7130 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7131 extern char *strrchr (const char *__s, int __c)
7132 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7133 extern char *strchrnul (const char *__s, int __c)
7134 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7135 extern size_t strcspn (const char *__s, const char *__reject)
7136 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7137 extern size_t strspn (const char *__s, const char *__accept)
7138 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7139 extern char *strpbrk (const char *__s, const char *__accept)
7140 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7141 extern char *strstr (const char *__haystack, const char *__needle)
7142 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7143 extern char *strtok (char *__restrict __s, const char *__restrict __delim)
7144 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
7145 extern char *__strtok_r (char *__restrict __s,
7146 const char *__restrict __delim,
7147 char **__restrict __save_ptr)
7148 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
7149 extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
7150 char **__restrict __save_ptr)
7151 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
7152 extern char *strcasestr (const char *__haystack, const char *__needle)
7153 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7154 extern void *memmem (const void *__haystack, size_t __haystacklen,
7155 const void *__needle, size_t __needlelen)
7156 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 3)));
7157 extern void *__mempcpy (void *__restrict __dest,
7158 const void *__restrict __src, size_t __n)
7159 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7160 extern void *mempcpy (void *__restrict __dest,
7161 const void *__restrict __src, size_t __n)
7162 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7163 extern size_t strlen (const char *__s)
7164 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7165 extern size_t strnlen (const char *__string, size_t __maxlen)
7166 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7167 extern char *strerror (int __errnum) __attribute__ ((__nothrow__ , __leaf__));
7168 extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
7169 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
7170 extern char *strerror_l (int __errnum, __locale_t __l) __attribute__ ((__nothrow__ , __leaf__));
7171 extern void __bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7172 extern void bcopy (const void *__src, void *__dest, size_t __n)
7173 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7174 extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7175 extern int bcmp (const void *__s1, const void *__s2, size_t __n)
7176 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7177 extern char *index (const char *__s, int __c)
7178 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7179 extern char *rindex (const char *__s, int __c)
7180 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7181 extern int ffs (int __i) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
7182 extern int ffsl (long int __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
7183 __extension__ extern int ffsll (long long int __ll)
7184 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
7185 extern int strcasecmp (const char *__s1, const char *__s2)
7186 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7187 extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
7188 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7189 extern int strcasecmp_l (const char *__s1, const char *__s2,
7190 __locale_t __loc)
7191 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
7192 extern int strncasecmp_l (const char *__s1, const char *__s2,
7193 size_t __n, __locale_t __loc)
7194 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4)));
7195 extern char *strsep (char **__restrict __stringp,
7196 const char *__restrict __delim)
7197 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7198 extern char *strsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__));
7199 extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
7200 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7201 extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
7202 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7203 extern char *__stpncpy (char *__restrict __dest,
7204 const char *__restrict __src, size_t __n)
7205 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7206 extern char *stpncpy (char *__restrict __dest,
7207 const char *__restrict __src, size_t __n)
7208 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7209 extern int strverscmp (const char *__s1, const char *__s2)
7210 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7211 extern char *strfry (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7212 extern void *memfrob (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7213 extern char *basename (const char *__filename) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7214 typedef struct { unsigned char __arr[2]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR2;
7215 typedef struct { unsigned char __arr[3]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR3;
7216 typedef struct { unsigned char __arr[4]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR4;
7217 typedef struct { unsigned char __arr[5]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR5;
7218 typedef struct { unsigned char __arr[6]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR6;
7219 typedef struct { unsigned char __arr[7]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR7;
7220 typedef struct { unsigned char __arr[8]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR8;
7221 extern void *__rawmemchr (const void *__s, int __c);
7222 extern __inline size_t __strcspn_c1 (const char *__s, int __reject);
7223 extern __inline size_t
7224 __strcspn_c1 (const char *__s, int __reject)
7225 {
7226 register size_t __result = 0;
7227 while (__s[__result] != '\0' && __s[__result] != __reject)
7228 ++__result;
7229 return __result;
7230 }
7231 extern __inline size_t __strcspn_c2 (const char *__s, int __reject1,
7232 int __reject2);
7233 extern __inline size_t
7234 __strcspn_c2 (const char *__s, int __reject1, int __reject2)
7235 {
7236 register size_t __result = 0;
7237 while (__s[__result] != '\0' && __s[__result] != __reject1
7238 && __s[__result] != __reject2)
7239 ++__result;
7240 return __result;
7241 }
7242 extern __inline size_t __strcspn_c3 (const char *__s, int __reject1,
7243 int __reject2, int __reject3);
7244 extern __inline size_t
7245 __strcspn_c3 (const char *__s, int __reject1, int __reject2,
7246 int __reject3)
7247 {
7248 register size_t __result = 0;
7249 while (__s[__result] != '\0' && __s[__result] != __reject1
7250 && __s[__result] != __reject2 && __s[__result] != __reject3)
7251 ++__result;
7252 return __result;
7253 }
7254 extern __inline size_t __strspn_c1 (const char *__s, int __accept);
7255 extern __inline size_t
7256 __strspn_c1 (const char *__s, int __accept)
7257 {
7258 register size_t __result = 0;
7259 while (__s[__result] == __accept)
7260 ++__result;
7261 return __result;
7262 }
7263 extern __inline size_t __strspn_c2 (const char *__s, int __accept1,
7264 int __accept2);
7265 extern __inline size_t
7266 __strspn_c2 (const char *__s, int __accept1, int __accept2)
7267 {
7268 register size_t __result = 0;
7269 while (__s[__result] == __accept1 || __s[__result] == __accept2)
7270 ++__result;
7271 return __result;
7272 }
7273 extern __inline size_t __strspn_c3 (const char *__s, int __accept1,
7274 int __accept2, int __accept3);
7275 extern __inline size_t
7276 __strspn_c3 (const char *__s, int __accept1, int __accept2, int __accept3)
7277 {
7278 register size_t __result = 0;
7279 while (__s[__result] == __accept1 || __s[__result] == __accept2
7280 || __s[__result] == __accept3)
7281 ++__result;
7282 return __result;
7283 }
7284 extern __inline char *__strpbrk_c2 (const char *__s, int __accept1,
7285 int __accept2);
7286 extern __inline char *
7287 __strpbrk_c2 (const char *__s, int __accept1, int __accept2)
7288 {
7289 while (*__s != '\0' && *__s != __accept1 && *__s != __accept2)
7290 ++__s;
7291 return *__s == '\0' ? ((void *)0) : (char *) (size_t) __s;
7292 }
7293 extern __inline char *__strpbrk_c3 (const char *__s, int __accept1,
7294 int __accept2, int __accept3);
7295 extern __inline char *
7296 __strpbrk_c3 (const char *__s, int __accept1, int __accept2, int __accept3)
7297 {
7298 while (*__s != '\0' && *__s != __accept1 && *__s != __accept2
7299 && *__s != __accept3)
7300 ++__s;
7301 return *__s == '\0' ? ((void *)0) : (char *) (size_t) __s;
7302 }
7303 extern __inline char *__strtok_r_1c (char *__s, char __sep, char **__nextp);
7304 extern __inline char *
7305 __strtok_r_1c (char *__s, char __sep, char **__nextp)
7306 {
7307 char *__result;
7308 if (__s == ((void *)0))
7309 __s = *__nextp;
7310 while (*__s == __sep)
7311 ++__s;
7312 __result = ((void *)0);
7313 if (*__s != '\0')
7314 {
7315 __result = __s++;
7316 while (*__s != '\0')
7317 if (*__s++ == __sep)
7318 {
7319 __s[-1] = '\0';
7320 break;
7321 }
7322 }
7323 *__nextp = __s;
7324 return __result;
7325 }
7326 extern char *__strsep_g (char **__stringp, const char *__delim);
7327 extern __inline char *__strsep_1c (char **__s, char __reject);
7328 extern __inline char *
7329 __strsep_1c (char **__s, char __reject)
7330 {
7331 register char *__retval = *__s;
7332 if (__retval != ((void *)0) && (*__s = (__extension__ (__builtin_constant_p (__reject) && !__builtin_constant_p (__retval) && (__reject) == '\0' ? (char *) __rawmemchr (__retval, __reject) : __builtin_strchr (__retval, __reject)))) != ((void *)0))
7333 *(*__s)++ = '\0';
7334 return __retval;
7335 }
7336 extern __inline char *__strsep_2c (char **__s, char __reject1, char __reject2);
7337 extern __inline char *
7338 __strsep_2c (char **__s, char __reject1, char __reject2)
7339 {
7340 register char *__retval = *__s;
7341 if (__retval != ((void *)0))
7342 {
7343 register char *__cp = __retval;
7344 while (1)
7345 {
7346 if (*__cp == '\0')
7347 {
7348 __cp = ((void *)0);
7349 break;
7350 }
7351 if (*__cp == __reject1 || *__cp == __reject2)
7352 {
7353 *__cp++ = '\0';
7354 break;
7355 }
7356 ++__cp;
7357 }
7358 *__s = __cp;
7359 }
7360 return __retval;
7361 }
7362 extern __inline char *__strsep_3c (char **__s, char __reject1, char __reject2,
7363 char __reject3);
7364 extern __inline char *
7365 __strsep_3c (char **__s, char __reject1, char __reject2, char __reject3)
7366 {
7367 register char *__retval = *__s;
7368 if (__retval != ((void *)0))
7369 {
7370 register char *__cp = __retval;
7371 while (1)
7372 {
7373 if (*__cp == '\0')
7374 {
7375 __cp = ((void *)0);
7376 break;
7377 }
7378 if (*__cp == __reject1 || *__cp == __reject2 || *__cp == __reject3)
7379 {
7380 *__cp++ = '\0';
7381 break;
7382 }
7383 ++__cp;
7384 }
7385 *__s = __cp;
7386 }
7387 return __retval;
7388 }
7389 extern char *__strdup (const char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__));
7390 extern char *__strndup (const char *__string, size_t __n)
7391 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__));
7392 extern void __warn_memset_zero_len (void) __attribute__((__warning__ ("memset used with constant zero length parameter; this could be due to transposed parameters")))
7393 ;
7394 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) void *
7395 __attribute__ ((__nothrow__ , __leaf__)) memcpy (void *__restrict __dest, const void *__restrict __src, size_t __len)
7396 {
7397 return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
7398 }
7399 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) void *
7400 __attribute__ ((__nothrow__ , __leaf__)) memmove (void *__dest, const void *__src, size_t __len)
7401 {
7402 return __builtin___memmove_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
7403 }
7404 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) void *
7405 __attribute__ ((__nothrow__ , __leaf__)) mempcpy (void *__restrict __dest, const void *__restrict __src, size_t __len)
7406 {
7407 return __builtin___mempcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
7408 }
7409 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) void *
7410 __attribute__ ((__nothrow__ , __leaf__)) memset (void *__dest, int __ch, size_t __len)
7411 {
7412 if (__builtin_constant_p (__len) && __len == 0
7413 && (!__builtin_constant_p (__ch) || __ch != 0))
7414 {
7415 __warn_memset_zero_len ();
7416 return __dest;
7417 }
7418 return __builtin___memset_chk (__dest, __ch, __len, __builtin_object_size (__dest, 0));
7419 }
7420 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) void
7421 __attribute__ ((__nothrow__ , __leaf__)) bcopy (const void *__src, void *__dest, size_t __len)
7422 {
7423 (void) __builtin___memmove_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
7424 }
7425 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) void
7426 __attribute__ ((__nothrow__ , __leaf__)) bzero (void *__dest, size_t __len)
7427 {
7428 (void) __builtin___memset_chk (__dest, '\0', __len, __builtin_object_size (__dest, 0));
7429 }
7430 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) char *
7431 __attribute__ ((__nothrow__ , __leaf__)) strcpy (char *__restrict __dest, const char *__restrict __src)
7432 {
7433 return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
7434 }
7435 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) char *
7436 __attribute__ ((__nothrow__ , __leaf__)) stpcpy (char *__restrict __dest, const char *__restrict __src)
7437 {
7438 return __builtin___stpcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
7439 }
7440 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) char *
7441 __attribute__ ((__nothrow__ , __leaf__)) strncpy (char *__restrict __dest, const char *__restrict __src, size_t __len)
7442 {
7443 return __builtin___strncpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 2 > 1));
7444 }
7445 extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
7446 size_t __destlen) __attribute__ ((__nothrow__ , __leaf__));
7447 extern char *__stpncpy_alias (char *__dest, const char *__src, size_t __n) __asm__ ("" "stpncpy") __attribute__ ((__nothrow__ , __leaf__))
7448 ;
7449 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) char *
7450 __attribute__ ((__nothrow__ , __leaf__)) stpncpy (char *__dest, const char *__src, size_t __n)
7451 {
7452 if (__builtin_object_size (__dest, 2 > 1) != (size_t) -1
7453 && (!__builtin_constant_p (__n) || __n <= __builtin_object_size (__dest, 2 > 1)))
7454 return __stpncpy_chk (__dest, __src, __n, __builtin_object_size (__dest, 2 > 1));
7455 return __stpncpy_alias (__dest, __src, __n);
7456 }
7457 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) char *
7458 __attribute__ ((__nothrow__ , __leaf__)) strcat (char *__restrict __dest, const char *__restrict __src)
7459 {
7460 return __builtin___strcat_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
7461 }
7462 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) char *
7463 __attribute__ ((__nothrow__ , __leaf__)) strncat (char *__restrict __dest, const char *__restrict __src, size_t __len)
7464 {
7465 return __builtin___strncat_chk (__dest, __src, __len, __builtin_object_size (__dest, 2 > 1));
7466 }
7467 extern int access (const char *__name, int __type) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7468 extern int euidaccess (const char *__name, int __type)
7469 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7470 extern int eaccess (const char *__name, int __type)
7471 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7472 extern int faccessat (int __fd, const char *__file, int __type, int __flag)
7473 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
7474 extern __off64_t lseek (int __fd, __off64_t __offset, int __whence) __asm__ ("" "lseek64") __attribute__ ((__nothrow__ , __leaf__))
7475 ;
7476 extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
7477 __attribute__ ((__nothrow__ , __leaf__));
7478 extern int close (int __fd);
7479 extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __attribute__ ((__warn_unused_result__));
7480 extern ssize_t write (int __fd, const void *__buf, size_t __n) __attribute__ ((__warn_unused_result__));
7481 extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pread64")
7482 __attribute__ ((__warn_unused_result__));
7483 extern ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pwrite64")
7484 __attribute__ ((__warn_unused_result__));
7485 extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
7486 __off64_t __offset) __attribute__ ((__warn_unused_result__));
7487 extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n,
7488 __off64_t __offset) __attribute__ ((__warn_unused_result__));
7489 extern int pipe (int __pipedes[2]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7490 extern int pipe2 (int __pipedes[2], int __flags) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7491 extern unsigned int alarm (unsigned int __seconds) __attribute__ ((__nothrow__ , __leaf__));
7492 extern unsigned int sleep (unsigned int __seconds);
7493 extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
7494 __attribute__ ((__nothrow__ , __leaf__));
7495 extern int usleep (__useconds_t __useconds);
7496 extern int pause (void);
7497 extern int chown (const char *__file, __uid_t __owner, __gid_t __group)
7498 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7499 extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7500 extern int lchown (const char *__file, __uid_t __owner, __gid_t __group)
7501 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7502 extern int fchownat (int __fd, const char *__file, __uid_t __owner,
7503 __gid_t __group, int __flag)
7504 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
7505 extern int chdir (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7506 extern int fchdir (int __fd) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7507 extern char *getcwd (char *__buf, size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7508 extern char *get_current_dir_name (void) __attribute__ ((__nothrow__ , __leaf__));
7509 extern char *getwd (char *__buf)
7510 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)) __attribute__ ((__warn_unused_result__));
7511 extern int dup (int __fd) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7512 extern int dup2 (int __fd, int __fd2) __attribute__ ((__nothrow__ , __leaf__));
7513 extern int dup3 (int __fd, int __fd2, int __flags) __attribute__ ((__nothrow__ , __leaf__));
7514 extern char **__environ;
7515 extern char **environ;
7516 extern int execve (const char *__path, char *const __argv[],
7517 char *const __envp[]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7518 extern int fexecve (int __fd, char *const __argv[], char *const __envp[])
7519 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
7520 extern int execv (const char *__path, char *const __argv[])
7521 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7522 extern int execle (const char *__path, const char *__arg, ...)
7523 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7524 extern int execl (const char *__path, const char *__arg, ...)
7525 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7526 extern int execvp (const char *__file, char *const __argv[])
7527 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7528 extern int execlp (const char *__file, const char *__arg, ...)
7529 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7530 extern int execvpe (const char *__file, char *const __argv[],
7531 char *const __envp[])
7532 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7533 extern int nice (int __inc) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7534 extern void _exit (int __status) __attribute__ ((__noreturn__));
7535 enum
7536 {
7537 _PC_LINK_MAX,
7538 _PC_MAX_CANON,
7539 _PC_MAX_INPUT,
7540 _PC_NAME_MAX,
7541 _PC_PATH_MAX,
7542 _PC_PIPE_BUF,
7543 _PC_CHOWN_RESTRICTED,
7544 _PC_NO_TRUNC,
7545 _PC_VDISABLE,
7546 _PC_SYNC_IO,
7547 _PC_ASYNC_IO,
7548 _PC_PRIO_IO,
7549 _PC_SOCK_MAXBUF,
7550 _PC_FILESIZEBITS,
7551 _PC_REC_INCR_XFER_SIZE,
7552 _PC_REC_MAX_XFER_SIZE,
7553 _PC_REC_MIN_XFER_SIZE,
7554 _PC_REC_XFER_ALIGN,
7555 _PC_ALLOC_SIZE_MIN,
7556 _PC_SYMLINK_MAX,
7557 _PC_2_SYMLINKS
7558 };
7559 enum
7560 {
7561 _SC_ARG_MAX,
7562 _SC_CHILD_MAX,
7563 _SC_CLK_TCK,
7564 _SC_NGROUPS_MAX,
7565 _SC_OPEN_MAX,
7566 _SC_STREAM_MAX,
7567 _SC_TZNAME_MAX,
7568 _SC_JOB_CONTROL,
7569 _SC_SAVED_IDS,
7570 _SC_REALTIME_SIGNALS,
7571 _SC_PRIORITY_SCHEDULING,
7572 _SC_TIMERS,
7573 _SC_ASYNCHRONOUS_IO,
7574 _SC_PRIORITIZED_IO,
7575 _SC_SYNCHRONIZED_IO,
7576 _SC_FSYNC,
7577 _SC_MAPPED_FILES,
7578 _SC_MEMLOCK,
7579 _SC_MEMLOCK_RANGE,
7580 _SC_MEMORY_PROTECTION,
7581 _SC_MESSAGE_PASSING,
7582 _SC_SEMAPHORES,
7583 _SC_SHARED_MEMORY_OBJECTS,
7584 _SC_AIO_LISTIO_MAX,
7585 _SC_AIO_MAX,
7586 _SC_AIO_PRIO_DELTA_MAX,
7587 _SC_DELAYTIMER_MAX,
7588 _SC_MQ_OPEN_MAX,
7589 _SC_MQ_PRIO_MAX,
7590 _SC_VERSION,
7591 _SC_PAGESIZE,
7592 _SC_RTSIG_MAX,
7593 _SC_SEM_NSEMS_MAX,
7594 _SC_SEM_VALUE_MAX,
7595 _SC_SIGQUEUE_MAX,
7596 _SC_TIMER_MAX,
7597 _SC_BC_BASE_MAX,
7598 _SC_BC_DIM_MAX,
7599 _SC_BC_SCALE_MAX,
7600 _SC_BC_STRING_MAX,
7601 _SC_COLL_WEIGHTS_MAX,
7602 _SC_EQUIV_CLASS_MAX,
7603 _SC_EXPR_NEST_MAX,
7604 _SC_LINE_MAX,
7605 _SC_RE_DUP_MAX,
7606 _SC_CHARCLASS_NAME_MAX,
7607 _SC_2_VERSION,
7608 _SC_2_C_BIND,
7609 _SC_2_C_DEV,
7610 _SC_2_FORT_DEV,
7611 _SC_2_FORT_RUN,
7612 _SC_2_SW_DEV,
7613 _SC_2_LOCALEDEF,
7614 _SC_PII,
7615 _SC_PII_XTI,
7616 _SC_PII_SOCKET,
7617 _SC_PII_INTERNET,
7618 _SC_PII_OSI,
7619 _SC_POLL,
7620 _SC_SELECT,
7621 _SC_UIO_MAXIOV,
7622 _SC_IOV_MAX = _SC_UIO_MAXIOV,
7623 _SC_PII_INTERNET_STREAM,
7624 _SC_PII_INTERNET_DGRAM,
7625 _SC_PII_OSI_COTS,
7626 _SC_PII_OSI_CLTS,
7627 _SC_PII_OSI_M,
7628 _SC_T_IOV_MAX,
7629 _SC_THREADS,
7630 _SC_THREAD_SAFE_FUNCTIONS,
7631 _SC_GETGR_R_SIZE_MAX,
7632 _SC_GETPW_R_SIZE_MAX,
7633 _SC_LOGIN_NAME_MAX,
7634 _SC_TTY_NAME_MAX,
7635 _SC_THREAD_DESTRUCTOR_ITERATIONS,
7636 _SC_THREAD_KEYS_MAX,
7637 _SC_THREAD_STACK_MIN,
7638 _SC_THREAD_THREADS_MAX,
7639 _SC_THREAD_ATTR_STACKADDR,
7640 _SC_THREAD_ATTR_STACKSIZE,
7641 _SC_THREAD_PRIORITY_SCHEDULING,
7642 _SC_THREAD_PRIO_INHERIT,
7643 _SC_THREAD_PRIO_PROTECT,
7644 _SC_THREAD_PROCESS_SHARED,
7645 _SC_NPROCESSORS_CONF,
7646 _SC_NPROCESSORS_ONLN,
7647 _SC_PHYS_PAGES,
7648 _SC_AVPHYS_PAGES,
7649 _SC_ATEXIT_MAX,
7650 _SC_PASS_MAX,
7651 _SC_XOPEN_VERSION,
7652 _SC_XOPEN_XCU_VERSION,
7653 _SC_XOPEN_UNIX,
7654 _SC_XOPEN_CRYPT,
7655 _SC_XOPEN_ENH_I18N,
7656 _SC_XOPEN_SHM,
7657 _SC_2_CHAR_TERM,
7658 _SC_2_C_VERSION,
7659 _SC_2_UPE,
7660 _SC_XOPEN_XPG2,
7661 _SC_XOPEN_XPG3,
7662 _SC_XOPEN_XPG4,
7663 _SC_CHAR_BIT,
7664 _SC_CHAR_MAX,
7665 _SC_CHAR_MIN,
7666 _SC_INT_MAX,
7667 _SC_INT_MIN,
7668 _SC_LONG_BIT,
7669 _SC_WORD_BIT,
7670 _SC_MB_LEN_MAX,
7671 _SC_NZERO,
7672 _SC_SSIZE_MAX,
7673 _SC_SCHAR_MAX,
7674 _SC_SCHAR_MIN,
7675 _SC_SHRT_MAX,
7676 _SC_SHRT_MIN,
7677 _SC_UCHAR_MAX,
7678 _SC_UINT_MAX,
7679 _SC_ULONG_MAX,
7680 _SC_USHRT_MAX,
7681 _SC_NL_ARGMAX,
7682 _SC_NL_LANGMAX,
7683 _SC_NL_MSGMAX,
7684 _SC_NL_NMAX,
7685 _SC_NL_SETMAX,
7686 _SC_NL_TEXTMAX,
7687 _SC_XBS5_ILP32_OFF32,
7688 _SC_XBS5_ILP32_OFFBIG,
7689 _SC_XBS5_LP64_OFF64,
7690 _SC_XBS5_LPBIG_OFFBIG,
7691 _SC_XOPEN_LEGACY,
7692 _SC_XOPEN_REALTIME,
7693 _SC_XOPEN_REALTIME_THREADS,
7694 _SC_ADVISORY_INFO,
7695 _SC_BARRIERS,
7696 _SC_BASE,
7697 _SC_C_LANG_SUPPORT,
7698 _SC_C_LANG_SUPPORT_R,
7699 _SC_CLOCK_SELECTION,
7700 _SC_CPUTIME,
7701 _SC_THREAD_CPUTIME,
7702 _SC_DEVICE_IO,
7703 _SC_DEVICE_SPECIFIC,
7704 _SC_DEVICE_SPECIFIC_R,
7705 _SC_FD_MGMT,
7706 _SC_FIFO,
7707 _SC_PIPE,
7708 _SC_FILE_ATTRIBUTES,
7709 _SC_FILE_LOCKING,
7710 _SC_FILE_SYSTEM,
7711 _SC_MONOTONIC_CLOCK,
7712 _SC_MULTI_PROCESS,
7713 _SC_SINGLE_PROCESS,
7714 _SC_NETWORKING,
7715 _SC_READER_WRITER_LOCKS,
7716 _SC_SPIN_LOCKS,
7717 _SC_REGEXP,
7718 _SC_REGEX_VERSION,
7719 _SC_SHELL,
7720 _SC_SIGNALS,
7721 _SC_SPAWN,
7722 _SC_SPORADIC_SERVER,
7723 _SC_THREAD_SPORADIC_SERVER,
7724 _SC_SYSTEM_DATABASE,
7725 _SC_SYSTEM_DATABASE_R,
7726 _SC_TIMEOUTS,
7727 _SC_TYPED_MEMORY_OBJECTS,
7728 _SC_USER_GROUPS,
7729 _SC_USER_GROUPS_R,
7730 _SC_2_PBS,
7731 _SC_2_PBS_ACCOUNTING,
7732 _SC_2_PBS_LOCATE,
7733 _SC_2_PBS_MESSAGE,
7734 _SC_2_PBS_TRACK,
7735 _SC_SYMLOOP_MAX,
7736 _SC_STREAMS,
7737 _SC_2_PBS_CHECKPOINT,
7738 _SC_V6_ILP32_OFF32,
7739 _SC_V6_ILP32_OFFBIG,
7740 _SC_V6_LP64_OFF64,
7741 _SC_V6_LPBIG_OFFBIG,
7742 _SC_HOST_NAME_MAX,
7743 _SC_TRACE,
7744 _SC_TRACE_EVENT_FILTER,
7745 _SC_TRACE_INHERIT,
7746 _SC_TRACE_LOG,
7747 _SC_LEVEL1_ICACHE_SIZE,
7748 _SC_LEVEL1_ICACHE_ASSOC,
7749 _SC_LEVEL1_ICACHE_LINESIZE,
7750 _SC_LEVEL1_DCACHE_SIZE,
7751 _SC_LEVEL1_DCACHE_ASSOC,
7752 _SC_LEVEL1_DCACHE_LINESIZE,
7753 _SC_LEVEL2_CACHE_SIZE,
7754 _SC_LEVEL2_CACHE_ASSOC,
7755 _SC_LEVEL2_CACHE_LINESIZE,
7756 _SC_LEVEL3_CACHE_SIZE,
7757 _SC_LEVEL3_CACHE_ASSOC,
7758 _SC_LEVEL3_CACHE_LINESIZE,
7759 _SC_LEVEL4_CACHE_SIZE,
7760 _SC_LEVEL4_CACHE_ASSOC,
7761 _SC_LEVEL4_CACHE_LINESIZE,
7762 _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
7763 _SC_RAW_SOCKETS,
7764 _SC_V7_ILP32_OFF32,
7765 _SC_V7_ILP32_OFFBIG,
7766 _SC_V7_LP64_OFF64,
7767 _SC_V7_LPBIG_OFFBIG,
7768 _SC_SS_REPL_MAX,
7769 _SC_TRACE_EVENT_NAME_MAX,
7770 _SC_TRACE_NAME_MAX,
7771 _SC_TRACE_SYS_MAX,
7772 _SC_TRACE_USER_EVENT_MAX,
7773 _SC_XOPEN_STREAMS,
7774 _SC_THREAD_ROBUST_PRIO_INHERIT,
7775 _SC_THREAD_ROBUST_PRIO_PROTECT
7776 };
7777 enum
7778 {
7779 _CS_PATH,
7780 _CS_V6_WIDTH_RESTRICTED_ENVS,
7781 _CS_GNU_LIBC_VERSION,
7782 _CS_GNU_LIBPTHREAD_VERSION,
7783 _CS_V5_WIDTH_RESTRICTED_ENVS,
7784 _CS_V7_WIDTH_RESTRICTED_ENVS,
7785 _CS_LFS_CFLAGS = 1000,
7786 _CS_LFS_LDFLAGS,
7787 _CS_LFS_LIBS,
7788 _CS_LFS_LINTFLAGS,
7789 _CS_LFS64_CFLAGS,
7790 _CS_LFS64_LDFLAGS,
7791 _CS_LFS64_LIBS,
7792 _CS_LFS64_LINTFLAGS,
7793 _CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
7794 _CS_XBS5_ILP32_OFF32_LDFLAGS,
7795 _CS_XBS5_ILP32_OFF32_LIBS,
7796 _CS_XBS5_ILP32_OFF32_LINTFLAGS,
7797 _CS_XBS5_ILP32_OFFBIG_CFLAGS,
7798 _CS_XBS5_ILP32_OFFBIG_LDFLAGS,
7799 _CS_XBS5_ILP32_OFFBIG_LIBS,
7800 _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
7801 _CS_XBS5_LP64_OFF64_CFLAGS,
7802 _CS_XBS5_LP64_OFF64_LDFLAGS,
7803 _CS_XBS5_LP64_OFF64_LIBS,
7804 _CS_XBS5_LP64_OFF64_LINTFLAGS,
7805 _CS_XBS5_LPBIG_OFFBIG_CFLAGS,
7806 _CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
7807 _CS_XBS5_LPBIG_OFFBIG_LIBS,
7808 _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
7809 _CS_POSIX_V6_ILP32_OFF32_CFLAGS,
7810 _CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
7811 _CS_POSIX_V6_ILP32_OFF32_LIBS,
7812 _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
7813 _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
7814 _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
7815 _CS_POSIX_V6_ILP32_OFFBIG_LIBS,
7816 _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
7817 _CS_POSIX_V6_LP64_OFF64_CFLAGS,
7818 _CS_POSIX_V6_LP64_OFF64_LDFLAGS,
7819 _CS_POSIX_V6_LP64_OFF64_LIBS,
7820 _CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
7821 _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
7822 _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
7823 _CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
7824 _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,
7825 _CS_POSIX_V7_ILP32_OFF32_CFLAGS,
7826 _CS_POSIX_V7_ILP32_OFF32_LDFLAGS,
7827 _CS_POSIX_V7_ILP32_OFF32_LIBS,
7828 _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,
7829 _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,
7830 _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,
7831 _CS_POSIX_V7_ILP32_OFFBIG_LIBS,
7832 _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,
7833 _CS_POSIX_V7_LP64_OFF64_CFLAGS,
7834 _CS_POSIX_V7_LP64_OFF64_LDFLAGS,
7835 _CS_POSIX_V7_LP64_OFF64_LIBS,
7836 _CS_POSIX_V7_LP64_OFF64_LINTFLAGS,
7837 _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,
7838 _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,
7839 _CS_POSIX_V7_LPBIG_OFFBIG_LIBS,
7840 _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,
7841 _CS_V6_ENV,
7842 _CS_V7_ENV
7843 };
7844 extern long int pathconf (const char *__path, int __name)
7845 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7846 extern long int fpathconf (int __fd, int __name) __attribute__ ((__nothrow__ , __leaf__));
7847 extern long int sysconf (int __name) __attribute__ ((__nothrow__ , __leaf__));
7848 extern size_t confstr (int __name, char *__buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__));
7849 extern __pid_t getpid (void) __attribute__ ((__nothrow__ , __leaf__));
7850 extern __pid_t getppid (void) __attribute__ ((__nothrow__ , __leaf__));
7851 extern __pid_t getpgrp (void) __attribute__ ((__nothrow__ , __leaf__));
7852 extern __pid_t __getpgid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));
7853 extern __pid_t getpgid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));
7854 extern int setpgid (__pid_t __pid, __pid_t __pgid) __attribute__ ((__nothrow__ , __leaf__));
7855 extern int setpgrp (void) __attribute__ ((__nothrow__ , __leaf__));
7856 extern __pid_t setsid (void) __attribute__ ((__nothrow__ , __leaf__));
7857 extern __pid_t getsid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));
7858 extern __uid_t getuid (void) __attribute__ ((__nothrow__ , __leaf__));
7859 extern __uid_t geteuid (void) __attribute__ ((__nothrow__ , __leaf__));
7860 extern __gid_t getgid (void) __attribute__ ((__nothrow__ , __leaf__));
7861 extern __gid_t getegid (void) __attribute__ ((__nothrow__ , __leaf__));
7862 extern int getgroups (int __size, __gid_t __list[]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7863 extern int group_member (__gid_t __gid) __attribute__ ((__nothrow__ , __leaf__));
7864 extern int setuid (__uid_t __uid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7865 extern int setreuid (__uid_t __ruid, __uid_t __euid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7866 extern int seteuid (__uid_t __uid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7867 extern int setgid (__gid_t __gid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7868 extern int setregid (__gid_t __rgid, __gid_t __egid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7869 extern int setegid (__gid_t __gid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7870 extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid)
7871 __attribute__ ((__nothrow__ , __leaf__));
7872 extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid)
7873 __attribute__ ((__nothrow__ , __leaf__));
7874 extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid)
7875 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7876 extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
7877 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7878 extern __pid_t fork (void) __attribute__ ((__nothrow__));
7879 extern __pid_t vfork (void) __attribute__ ((__nothrow__ , __leaf__));
7880 extern char *ttyname (int __fd) __attribute__ ((__nothrow__ , __leaf__));
7881 extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
7882 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
7883 extern int isatty (int __fd) __attribute__ ((__nothrow__ , __leaf__));
7884 extern int ttyslot (void) __attribute__ ((__nothrow__ , __leaf__));
7885 extern int link (const char *__from, const char *__to)
7886 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__));
7887 extern int linkat (int __fromfd, const char *__from, int __tofd,
7888 const char *__to, int __flags)
7889 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4))) __attribute__ ((__warn_unused_result__));
7890 extern int symlink (const char *__from, const char *__to)
7891 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__));
7892 extern ssize_t readlink (const char *__restrict __path,
7893 char *__restrict __buf, size_t __len)
7894 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__));
7895 extern int symlinkat (const char *__from, int __tofd,
7896 const char *__to) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3))) __attribute__ ((__warn_unused_result__));
7897 extern ssize_t readlinkat (int __fd, const char *__restrict __path,
7898 char *__restrict __buf, size_t __len)
7899 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3))) __attribute__ ((__warn_unused_result__));
7900 extern int unlink (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7901 extern int unlinkat (int __fd, const char *__name, int __flag)
7902 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
7903 extern int rmdir (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7904 extern __pid_t tcgetpgrp (int __fd) __attribute__ ((__nothrow__ , __leaf__));
7905 extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __attribute__ ((__nothrow__ , __leaf__));
7906 extern char *getlogin (void);
7907 extern int getlogin_r (char *__name, size_t __name_len) __attribute__ ((__nonnull__ (1)));
7908 extern int setlogin (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7909 extern char *BSDoptarg;
7910 extern int BSDoptind;
7911 extern int BSDopterr;
7912 extern int BSDoptopt;
7913 extern int BSDgetopt(int ___argc, char *const *___argv, const char *__shortopts)
7914 __attribute__ ((__nothrow__ , __leaf__));
7915 extern int gethostname (char *__name, size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7916 extern int sethostname (const char *__name, size_t __len)
7917 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7918 extern int sethostid (long int __id) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7919 extern int getdomainname (char *__name, size_t __len)
7920 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7921 extern int setdomainname (const char *__name, size_t __len)
7922 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7923 extern int vhangup (void) __attribute__ ((__nothrow__ , __leaf__));
7924 extern int revoke (const char *__file) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7925 extern int profil (unsigned short int *__sample_buffer, size_t __size,
7926 size_t __offset, unsigned int __scale)
7927 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7928 extern int acct (const char *__name) __attribute__ ((__nothrow__ , __leaf__));
7929 extern char *getusershell (void) __attribute__ ((__nothrow__ , __leaf__));
7930 extern void endusershell (void) __attribute__ ((__nothrow__ , __leaf__));
7931 extern void setusershell (void) __attribute__ ((__nothrow__ , __leaf__));
7932 extern int daemon (int __nochdir, int __noclose) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7933 extern int chroot (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7934 extern char *getpass (const char *__prompt) __attribute__ ((__nonnull__ (1)));
7935 extern int fsync (int __fd);
7936 extern int syncfs (int __fd) __attribute__ ((__nothrow__ , __leaf__));
7937 extern long int gethostid (void);
7938 extern void sync (void) __attribute__ ((__nothrow__ , __leaf__));
7939 extern int getpagesize (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
7940 extern int getdtablesize (void) __attribute__ ((__nothrow__ , __leaf__));
7941 extern int truncate (const char *__file, __off64_t __length) __asm__ ("" "truncate64") __attribute__ ((__nothrow__ , __leaf__))
7942 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7943 extern int truncate64 (const char *__file, __off64_t __length)
7944 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7945 extern int ftruncate (int __fd, __off64_t __length) __asm__ ("" "ftruncate64") __attribute__ ((__nothrow__ , __leaf__))
7946 __attribute__ ((__warn_unused_result__));
7947 extern int ftruncate64 (int __fd, __off64_t __length) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7948 extern int brk (void *__addr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7949 extern void *sbrk (intptr_t __delta) __attribute__ ((__nothrow__ , __leaf__));
7950 extern long int syscall (long int __sysno, ...) __attribute__ ((__nothrow__ , __leaf__));
7951 extern int fdatasync (int __fildes);
7952 extern char *crypt (const char *__key, const char *__salt)
7953 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7954 extern void encrypt (char *__block, int __edflag) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7955 extern void swab (const void *__restrict __from, void *__restrict __to,
7956 ssize_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7957 extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
7958 size_t __buflen) __attribute__ ((__warn_unused_result__));
7959 extern ssize_t __read_alias (int __fd, void *__buf, size_t __nbytes) __asm__ ("" "read")
7960 __attribute__ ((__warn_unused_result__));
7961 extern ssize_t __read_chk_warn (int __fd, void *__buf, size_t __nbytes, size_t __buflen) __asm__ ("" "__read_chk")
7962 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("read called with bigger length than size of " "the destination buffer")))
7963 ;
7964 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) ssize_t
7965 read (int __fd, void *__buf, size_t __nbytes)
7966 {
7967 if (__builtin_object_size (__buf, 0) != (size_t) -1)
7968 {
7969 if (!__builtin_constant_p (__nbytes))
7970 return __read_chk (__fd, __buf, __nbytes, __builtin_object_size (__buf, 0));
7971 if (__nbytes > __builtin_object_size (__buf, 0))
7972 return __read_chk_warn (__fd, __buf, __nbytes, __builtin_object_size (__buf, 0));
7973 }
7974 return __read_alias (__fd, __buf, __nbytes);
7975 }
7976 extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
7977 __off_t __offset, size_t __bufsize) __attribute__ ((__warn_unused_result__));
7978 extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes,
7979 __off64_t __offset, size_t __bufsize) __attribute__ ((__warn_unused_result__));
7980 extern ssize_t __pread_alias (int __fd, void *__buf, size_t __nbytes, __off_t __offset) __asm__ ("" "pread")
7981 __attribute__ ((__warn_unused_result__));
7982 extern ssize_t __pread64_alias (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pread64")
7983 __attribute__ ((__warn_unused_result__));
7984 extern ssize_t __pread_chk_warn (int __fd, void *__buf, size_t __nbytes, __off_t __offset, size_t __bufsize) __asm__ ("" "__pread_chk")
7985 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("pread called with bigger length than size of " "the destination buffer")))
7986 ;
7987 extern ssize_t __pread64_chk_warn (int __fd, void *__buf, size_t __nbytes, __off64_t __offset, size_t __bufsize) __asm__ ("" "__pread64_chk")
7988 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("pread64 called with bigger length than size of " "the destination buffer")))
7989 ;
7990 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) ssize_t
7991 pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
7992 {
7993 if (__builtin_object_size (__buf, 0) != (size_t) -1)
7994 {
7995 if (!__builtin_constant_p (__nbytes))
7996 return __pread64_chk (__fd, __buf, __nbytes, __offset, __builtin_object_size (__buf, 0));
7997 if ( __nbytes > __builtin_object_size (__buf, 0))
7998 return __pread64_chk_warn (__fd, __buf, __nbytes, __offset,
7999 __builtin_object_size (__buf, 0));
8000 }
8001 return __pread64_alias (__fd, __buf, __nbytes, __offset);
8002 }
8003 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) ssize_t
8004 pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
8005 {
8006 if (__builtin_object_size (__buf, 0) != (size_t) -1)
8007 {
8008 if (!__builtin_constant_p (__nbytes))
8009 return __pread64_chk (__fd, __buf, __nbytes, __offset, __builtin_object_size (__buf, 0));
8010 if ( __nbytes > __builtin_object_size (__buf, 0))
8011 return __pread64_chk_warn (__fd, __buf, __nbytes, __offset,
8012 __builtin_object_size (__buf, 0));
8013 }
8014 return __pread64_alias (__fd, __buf, __nbytes, __offset);
8015 }
8016 extern ssize_t __readlink_chk (const char *__restrict __path,
8017 char *__restrict __buf, size_t __len,
8018 size_t __buflen)
8019 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__));
8020 extern ssize_t __readlink_alias (const char *__restrict __path, char *__restrict __buf, size_t __len) __asm__ ("" "readlink") __attribute__ ((__nothrow__ , __leaf__))
8021 __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__));
8022 extern ssize_t __readlink_chk_warn (const char *__restrict __path, char *__restrict __buf, size_t __len, size_t __buflen) __asm__ ("" "__readlink_chk") __attribute__ ((__nothrow__ , __leaf__))
8023 __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("readlink called with bigger length " "than size of destination buffer")))
8024 ;
8025 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__)) ssize_t
8026 __attribute__ ((__nothrow__ , __leaf__)) readlink (const char *__restrict __path, char *__restrict __buf, size_t __len)
8027 {
8028 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8029 {
8030 if (!__builtin_constant_p (__len))
8031 return __readlink_chk (__path, __buf, __len, __builtin_object_size (__buf, 2 > 1));
8032 if ( __len > __builtin_object_size (__buf, 2 > 1))
8033 return __readlink_chk_warn (__path, __buf, __len, __builtin_object_size (__buf, 2 > 1));
8034 }
8035 return __readlink_alias (__path, __buf, __len);
8036 }
8037 extern ssize_t __readlinkat_chk (int __fd, const char *__restrict __path,
8038 char *__restrict __buf, size_t __len,
8039 size_t __buflen)
8040 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3))) __attribute__ ((__warn_unused_result__));
8041 extern ssize_t __readlinkat_alias (int __fd, const char *__restrict __path, char *__restrict __buf, size_t __len) __asm__ ("" "readlinkat") __attribute__ ((__nothrow__ , __leaf__))
8042 __attribute__ ((__nonnull__ (2, 3))) __attribute__ ((__warn_unused_result__));
8043 extern ssize_t __readlinkat_chk_warn (int __fd, const char *__restrict __path, char *__restrict __buf, size_t __len, size_t __buflen) __asm__ ("" "__readlinkat_chk") __attribute__ ((__nothrow__ , __leaf__))
8044 __attribute__ ((__nonnull__ (2, 3))) __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("readlinkat called with bigger " "length than size of destination " "buffer")))
8045 ;
8046 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__nonnull__ (2, 3))) __attribute__ ((__warn_unused_result__)) ssize_t
8047 __attribute__ ((__nothrow__ , __leaf__)) readlinkat (int __fd, const char *__restrict __path, char *__restrict __buf, size_t __len)
8048 {
8049 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8050 {
8051 if (!__builtin_constant_p (__len))
8052 return __readlinkat_chk (__fd, __path, __buf, __len, __builtin_object_size (__buf, 2 > 1));
8053 if (__len > __builtin_object_size (__buf, 2 > 1))
8054 return __readlinkat_chk_warn (__fd, __path, __buf, __len,
8055 __builtin_object_size (__buf, 2 > 1));
8056 }
8057 return __readlinkat_alias (__fd, __path, __buf, __len);
8058 }
8059 extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
8060 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
8061 extern char *__getcwd_alias (char *__buf, size_t __size) __asm__ ("" "getcwd") __attribute__ ((__nothrow__ , __leaf__))
8062 __attribute__ ((__warn_unused_result__));
8063 extern char *__getcwd_chk_warn (char *__buf, size_t __size, size_t __buflen) __asm__ ("" "__getcwd_chk") __attribute__ ((__nothrow__ , __leaf__))
8064 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("getcwd caller with bigger length than size of " "destination buffer")))
8065 ;
8066 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
8067 __attribute__ ((__nothrow__ , __leaf__)) getcwd (char *__buf, size_t __size)
8068 {
8069 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8070 {
8071 if (!__builtin_constant_p (__size))
8072 return __getcwd_chk (__buf, __size, __builtin_object_size (__buf, 2 > 1));
8073 if (__size > __builtin_object_size (__buf, 2 > 1))
8074 return __getcwd_chk_warn (__buf, __size, __builtin_object_size (__buf, 2 > 1));
8075 }
8076 return __getcwd_alias (__buf, __size);
8077 }
8078 extern char *__getwd_chk (char *__buf, size_t buflen)
8079 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
8080 extern char *__getwd_warn (char *__buf) __asm__ ("" "getwd") __attribute__ ((__nothrow__ , __leaf__))
8081 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("please use getcwd instead, as getwd " "doesn't specify buffer size")))
8082 ;
8083 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)) __attribute__ ((__warn_unused_result__)) char *
8084 __attribute__ ((__nothrow__ , __leaf__)) getwd (char *__buf)
8085 {
8086 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8087 return __getwd_chk (__buf, __builtin_object_size (__buf, 2 > 1));
8088 return __getwd_warn (__buf);
8089 }
8090 extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
8091 size_t __buflen) __attribute__ ((__nothrow__ , __leaf__));
8092 extern size_t __confstr_alias (int __name, char *__buf, size_t __len) __asm__ ("" "confstr") __attribute__ ((__nothrow__ , __leaf__))
8093 ;
8094 extern size_t __confstr_chk_warn (int __name, char *__buf, size_t __len, size_t __buflen) __asm__ ("" "__confstr_chk") __attribute__ ((__nothrow__ , __leaf__))
8095 __attribute__((__warning__ ("confstr called with bigger length than size of destination " "buffer")))
8096 ;
8097 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) size_t
8098 __attribute__ ((__nothrow__ , __leaf__)) confstr (int __name, char *__buf, size_t __len)
8099 {
8100 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8101 {
8102 if (!__builtin_constant_p (__len))
8103 return __confstr_chk (__name, __buf, __len, __builtin_object_size (__buf, 2 > 1));
8104 if (__builtin_object_size (__buf, 2 > 1) < __len)
8105 return __confstr_chk_warn (__name, __buf, __len, __builtin_object_size (__buf, 2 > 1));
8106 }
8107 return __confstr_alias (__name, __buf, __len);
8108 }
8109 extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen)
8110 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
8111 extern int __getgroups_alias (int __size, __gid_t __list[]) __asm__ ("" "getgroups") __attribute__ ((__nothrow__ , __leaf__))
8112 __attribute__ ((__warn_unused_result__));
8113 extern int __getgroups_chk_warn (int __size, __gid_t __list[], size_t __listlen) __asm__ ("" "__getgroups_chk") __attribute__ ((__nothrow__ , __leaf__))
8114 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("getgroups called with bigger group count than what " "can fit into destination buffer")))
8115 ;
8116 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
8117 __attribute__ ((__nothrow__ , __leaf__)) getgroups (int __size, __gid_t __list[])
8118 {
8119 if (__builtin_object_size (__list, 2 > 1) != (size_t) -1)
8120 {
8121 if (!__builtin_constant_p (__size) || __size < 0)
8122 return __getgroups_chk (__size, __list, __builtin_object_size (__list, 2 > 1));
8123 if (__size * sizeof (__gid_t) > __builtin_object_size (__list, 2 > 1))
8124 return __getgroups_chk_warn (__size, __list, __builtin_object_size (__list, 2 > 1));
8125 }
8126 return __getgroups_alias (__size, __list);
8127 }
8128 extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
8129 size_t __nreal) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
8130 extern int __ttyname_r_alias (int __fd, char *__buf, size_t __buflen) __asm__ ("" "ttyname_r") __attribute__ ((__nothrow__ , __leaf__))
8131 __attribute__ ((__nonnull__ (2)));
8132 extern int __ttyname_r_chk_warn (int __fd, char *__buf, size_t __buflen, size_t __nreal) __asm__ ("" "__ttyname_r_chk") __attribute__ ((__nothrow__ , __leaf__))
8133 __attribute__ ((__nonnull__ (2))) __attribute__((__warning__ ("ttyname_r called with bigger buflen than " "size of destination buffer")))
8134 ;
8135 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
8136 __attribute__ ((__nothrow__ , __leaf__)) ttyname_r (int __fd, char *__buf, size_t __buflen)
8137 {
8138 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8139 {
8140 if (!__builtin_constant_p (__buflen))
8141 return __ttyname_r_chk (__fd, __buf, __buflen, __builtin_object_size (__buf, 2 > 1));
8142 if (__buflen > __builtin_object_size (__buf, 2 > 1))
8143 return __ttyname_r_chk_warn (__fd, __buf, __buflen, __builtin_object_size (__buf, 2 > 1));
8144 }
8145 return __ttyname_r_alias (__fd, __buf, __buflen);
8146 }
8147 extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
8148 __attribute__ ((__nonnull__ (1)));
8149 extern int __getlogin_r_alias (char *__buf, size_t __buflen) __asm__ ("" "getlogin_r")
8150 __attribute__ ((__nonnull__ (1)));
8151 extern int __getlogin_r_chk_warn (char *__buf, size_t __buflen, size_t __nreal) __asm__ ("" "__getlogin_r_chk")
8152 __attribute__ ((__nonnull__ (1))) __attribute__((__warning__ ("getlogin_r called with bigger buflen than " "size of destination buffer")))
8153 ;
8154 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
8155 getlogin_r (char *__buf, size_t __buflen)
8156 {
8157 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8158 {
8159 if (!__builtin_constant_p (__buflen))
8160 return __getlogin_r_chk (__buf, __buflen, __builtin_object_size (__buf, 2 > 1));
8161 if (__buflen > __builtin_object_size (__buf, 2 > 1))
8162 return __getlogin_r_chk_warn (__buf, __buflen, __builtin_object_size (__buf, 2 > 1));
8163 }
8164 return __getlogin_r_alias (__buf, __buflen);
8165 }
8166 extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
8167 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
8168 extern int __gethostname_alias (char *__buf, size_t __buflen) __asm__ ("" "gethostname") __attribute__ ((__nothrow__ , __leaf__))
8169 __attribute__ ((__nonnull__ (1)));
8170 extern int __gethostname_chk_warn (char *__buf, size_t __buflen, size_t __nreal) __asm__ ("" "__gethostname_chk") __attribute__ ((__nothrow__ , __leaf__))
8171 __attribute__ ((__nonnull__ (1))) __attribute__((__warning__ ("gethostname called with bigger buflen than " "size of destination buffer")))
8172 ;
8173 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
8174 __attribute__ ((__nothrow__ , __leaf__)) gethostname (char *__buf, size_t __buflen)
8175 {
8176 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8177 {
8178 if (!__builtin_constant_p (__buflen))
8179 return __gethostname_chk (__buf, __buflen, __builtin_object_size (__buf, 2 > 1));
8180 if (__buflen > __builtin_object_size (__buf, 2 > 1))
8181 return __gethostname_chk_warn (__buf, __buflen, __builtin_object_size (__buf, 2 > 1));
8182 }
8183 return __gethostname_alias (__buf, __buflen);
8184 }
8185 extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
8186 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
8187 extern int __getdomainname_alias (char *__buf, size_t __buflen) __asm__ ("" "getdomainname") __attribute__ ((__nothrow__ , __leaf__))
8188 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
8189 extern int __getdomainname_chk_warn (char *__buf, size_t __buflen, size_t __nreal) __asm__ ("" "__getdomainname_chk") __attribute__ ((__nothrow__ , __leaf__))
8190 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("getdomainname called with bigger " "buflen than size of destination " "buffer")))
8191 ;
8192 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
8193 __attribute__ ((__nothrow__ , __leaf__)) getdomainname (char *__buf, size_t __buflen)
8194 {
8195 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
8196 {
8197 if (!__builtin_constant_p (__buflen))
8198 return __getdomainname_chk (__buf, __buflen, __builtin_object_size (__buf, 2 > 1));
8199 if (__buflen > __builtin_object_size (__buf, 2 > 1))
8200 return __getdomainname_chk_warn (__buf, __buflen, __builtin_object_size (__buf, 2 > 1));
8201 }
8202 return __getdomainname_alias (__buf, __buflen);
8203 }
8204 void *xmalloc(size_t);
8205 void *xcalloc(size_t, size_t);
8206 void *xrealloc(void *, size_t, size_t);
8207 char *xstrdup(const char *);
8208 int xasprintf(char **, const char *, ...)
8209 __attribute__((__format__ (printf, 2, 3)))
8210 __attribute__((__nonnull__ (2)));
8211 typedef struct Key Key;
8212 enum types {
8213 KEY_RSA1,
8214 KEY_RSA,
8215 KEY_DSA,
8216 KEY_ECDSA,
8217 KEY_ED25519,
8218 KEY_RSA_CERT,
8219 KEY_DSA_CERT,
8220 KEY_ECDSA_CERT,
8221 KEY_ED25519_CERT,
8222 KEY_RSA_CERT_V00,
8223 KEY_DSA_CERT_V00,
8224 KEY_UNSPEC
8225 };
8226 enum fp_type {
8227 SSH_FP_SHA1,
8228 SSH_FP_MD5,
8229 SSH_FP_SHA256
8230 };
8231 enum fp_rep {
8232 SSH_FP_HEX,
8233 SSH_FP_BUBBLEBABBLE,
8234 SSH_FP_RANDOMART
8235 };
8236 struct KeyCert {
8237 Buffer certblob;
8238 u_int type;
8239 u_int64_t serial;
8240 char *key_id;
8241 u_int nprincipals;
8242 char **principals;
8243 u_int64_t valid_after, valid_before;
8244 Buffer critical;
8245 Buffer extensions;
8246 Key *signature_key;
8247 };
8248 struct Key {
8249 int type;
8250 int flags;
8251 RSA *rsa;
8252 DSA *dsa;
8253 int ecdsa_nid;
8254 EC_KEY *ecdsa;
8255 struct KeyCert *cert;
8256 u_char *ed25519_sk;
8257 u_char *ed25519_pk;
8258 };
8259 Key *key_new(int);
8260 void key_add_private(Key *);
8261 Key *key_new_private(int);
8262 void key_free(Key *);
8263 Key *key_demote(const Key *);
8264 int key_equal_public(const Key *, const Key *);
8265 int key_equal(const Key *, const Key *);
8266 char *key_fingerprint(const Key *, enum fp_type, enum fp_rep);
8267 u_char *key_fingerprint_raw(const Key *, enum fp_type, u_int *);
8268 const char *key_type(const Key *);
8269 const char *key_cert_type(const Key *);
8270 int key_write(const Key *, FILE *);
8271 int key_read(Key *, char **);
8272 u_int key_size(const Key *);
8273 Key *key_generate(int, u_int);
8274 Key *key_from_private(const Key *);
8275 int key_type_from_name(char *);
8276 int key_is_cert(const Key *);
8277 int key_type_is_cert(int);
8278 int key_type_plain(int);
8279 int key_to_certified(Key *, int);
8280 int key_drop_cert(Key *);
8281 int key_certify(Key *, Key *);
8282 void key_cert_copy(const Key *, struct Key *);
8283 int key_cert_check_authority(const Key *, int, int, const char *,
8284 const char **);
8285 int key_cert_is_legacy(const Key *);
8286 int key_ecdsa_nid_from_name(const char *);
8287 int key_curve_name_to_nid(const char *);
8288 const char *key_curve_nid_to_name(int);
8289 u_int key_curve_nid_to_bits(int);
8290 int key_ecdsa_bits_to_nid(int);
8291 int key_ecdsa_key_to_nid(EC_KEY *);
8292 int key_ec_nid_to_hash_alg(int nid);
8293 int key_ec_validate_public(const EC_GROUP *, const EC_POINT *);
8294 int key_ec_validate_private(const EC_KEY *);
8295 char *key_alg_list(int, int);
8296 Key *key_from_blob(const u_char *, u_int);
8297 int key_to_blob(const Key *, u_char **, u_int *);
8298 const char *key_ssh_name(const Key *);
8299 const char *key_ssh_name_plain(const Key *);
8300 int key_names_valid2(const char *);
8301 int key_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8302 int key_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8303 int ssh_dss_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8304 int ssh_dss_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8305 int ssh_ecdsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8306 int ssh_ecdsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8307 int ssh_rsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8308 int ssh_rsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8309 int ssh_ed25519_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8310 int ssh_ed25519_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8311 void key_private_serialize(const Key *, Buffer *);
8312 Key *key_private_deserialize(Buffer *);
8313 void rsa_public_encrypt(BIGNUM *, BIGNUM *, RSA *);
8314 int rsa_private_decrypt(BIGNUM *, BIGNUM *, RSA *);
8315 void rsa_generate_additional_parameters(RSA *);
8316 int key_save_private(Key *, const char *, const char *, const char *,
8317 int, const char *, int);
8318 int key_load_file(int, const char *, Buffer *);
8319 Key *key_load_cert(const char *);
8320 Key *key_load_public(const char *, char **);
8321 Key *key_load_public_type(int, const char *, char **);
8322 Key *key_parse_private(Buffer *, const char *, const char *, char **);
8323 Key *key_load_private(const char *, const char *, char **);
8324 Key *key_load_private_cert(int, const char *, const char *, int *);
8325 Key *key_load_private_type(int, const char *, const char *, char **, int *);
8326 Key *key_load_private_pem(int, int, const char *, char **);
8327 int key_perm_ok(int, const char *);
8328 int key_in_file(Key *, const char *, int);
8329 int uuencode(const u_char *, u_int, char *, size_t);
8330 int uudecode(const char *, u_char *, size_t);
8331 void dump_base64(FILE *, const u_char *, u_int);
8332 typedef enum {
8333 SYSLOG_FACILITY_DAEMON,
8334 SYSLOG_FACILITY_USER,
8335 SYSLOG_FACILITY_AUTH,
8336 SYSLOG_FACILITY_LOCAL0,
8337 SYSLOG_FACILITY_LOCAL1,
8338 SYSLOG_FACILITY_LOCAL2,
8339 SYSLOG_FACILITY_LOCAL3,
8340 SYSLOG_FACILITY_LOCAL4,
8341 SYSLOG_FACILITY_LOCAL5,
8342 SYSLOG_FACILITY_LOCAL6,
8343 SYSLOG_FACILITY_LOCAL7,
8344 SYSLOG_FACILITY_NOT_SET = -1
8345 } SyslogFacility;
8346 typedef enum {
8347 SYSLOG_LEVEL_QUIET,
8348 SYSLOG_LEVEL_FATAL,
8349 SYSLOG_LEVEL_ERROR,
8350 SYSLOG_LEVEL_INFO,
8351 SYSLOG_LEVEL_VERBOSE,
8352 SYSLOG_LEVEL_DEBUG1,
8353 SYSLOG_LEVEL_DEBUG2,
8354 SYSLOG_LEVEL_DEBUG3,
8355 SYSLOG_LEVEL_NOT_SET = -1
8356 } LogLevel;
8357 typedef void (log_handler_fn)(LogLevel, const char *, void *);
8358 void log_init(char *, LogLevel, SyslogFacility, int);
8359 void log_change_level(LogLevel);
8360 int log_is_on_stderr(void);
8361 void log_redirect_stderr_to(const char *);
8362 SyslogFacility log_facility_number(char *);
8363 const char * log_facility_name(SyslogFacility);
8364 LogLevel log_level_number(char *);
8365 const char * log_level_name(LogLevel);
8366 void fatal(const char *, ...) __attribute__((noreturn))
8367 __attribute__((format(printf, 1, 2)));
8368 void error(const char *, ...) __attribute__((format(printf, 1, 2)));
8369 void sigdie(const char *, ...) __attribute__((noreturn))
8370 __attribute__((format(printf, 1, 2)));
8371 void logit(const char *, ...) __attribute__((format(printf, 1, 2)));
8372 void verbose(const char *, ...) __attribute__((format(printf, 1, 2)));
8373 void debug(const char *, ...) __attribute__((format(printf, 1, 2)));
8374 void debug2(const char *, ...) __attribute__((format(printf, 1, 2)));
8375 void debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
8376 void set_log_handler(log_handler_fn *, void *);
8377 void do_log2(LogLevel, const char *, ...)
8378 __attribute__((format(printf, 2, 3)));
8379 void do_log(LogLevel, const char *, va_list);
8380 void cleanup_exit(int) __attribute__((noreturn));
8381 char *chop(char *);
8382 char *strdelim(char **);
8383 int set_nonblock(int);
8384 int unset_nonblock(int);
8385 void set_nodelay(int);
8386 int a2port(const char *);
8387 int a2tun(const char *, int *);
8388 char *put_host_port(const char *, u_short);
8389 char *hpdelim(char **);
8390 char *cleanhostname(char *);
8391 char *colon(char *);
8392 long convtime(const char *);
8393 char *tilde_expand_filename(const char *, uid_t);
8394 char *percent_expand(const char *, ...) __attribute__(());
8395 char *tohex(const void *, size_t);
8396 void sanitise_stdfd(void);
8397 void ms_subtract_diff(struct timeval *, int *);
8398 void ms_to_timeval(struct timeval *, int);
8399 time_t monotime(void);
8400 void lowercase(char *s);
8401 void sock_set_v6only(int);
8402 struct passwd *pwcopy(struct passwd *);
8403 const char *ssh_gai_strerror(int);
8404 typedef struct arglist arglist;
8405 struct arglist {
8406 char **list;
8407 u_int num;
8408 u_int nalloc;
8409 };
8410 void addargs(arglist *, char *, ...)
8411 __attribute__((format(printf, 2, 3)));
8412 void replacearg(arglist *, u_int, char *, ...)
8413 __attribute__((format(printf, 3, 4)));
8414 void freeargs(arglist *);
8415 int tun_open(int, int);
8416 u_int64_t get_u64(const void *)
8417 __attribute__(());
8418 u_int32_t get_u32(const void *)
8419 __attribute__(());
8420 u_int16_t get_u16(const void *)
8421 __attribute__(());
8422 void put_u64(void *, u_int64_t)
8423 __attribute__(());
8424 void put_u32(void *, u_int32_t)
8425 __attribute__(());
8426 void put_u16(void *, u_int16_t)
8427 __attribute__(());
8428 struct bwlimit {
8429 size_t buflen;
8430 u_int64_t rate, thresh, lamt;
8431 struct timeval bwstart, bwend;
8432 };
8433 void bandwidth_limit_init(struct bwlimit *, u_int64_t, size_t);
8434 void bandwidth_limit(struct bwlimit *, size_t);
8435 int parse_ipqos(const char *);
8436 const char *iptos2str(int);
8437 void mktemp_proto(char *, size_t);
8438 char *read_passphrase(const char *, int);
8439 int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
8440 int read_keyfile_line(FILE *, const char *, char *, size_t, u_long *);
8441 int match_pattern(const char *, const char *);
8442 int match_pattern_list(const char *, const char *, u_int, int);
8443 int match_hostname(const char *, const char *, u_int);
8444 int match_host_and_ip(const char *, const char *, const char *);
8445 int match_user(const char *, const char *, const char *, const char *);
8446 char *match_list(const char *, const char *, u_int *);
8447 int addr_match_list(const char *, const char *);
8448 int addr_match_cidr_list(const char *, const char *);
8449 typedef enum {
8450 HOST_OK, HOST_NEW, HOST_CHANGED, HOST_REVOKED, HOST_FOUND
8451 } HostStatus;
8452 typedef enum {
8453 MRK_ERROR, MRK_NONE, MRK_REVOKE, MRK_CA
8454 } HostkeyMarker;
8455 struct hostkey_entry {
8456 char *host;
8457 char *file;
8458 u_long line;
8459 Key *key;
8460 HostkeyMarker marker;
8461 };
8462 struct hostkeys;
8463 struct hostkeys *init_hostkeys(void);
8464 void load_hostkeys(struct hostkeys *, const char *, const char *);
8465 void free_hostkeys(struct hostkeys *);
8466 HostStatus check_key_in_hostkeys(struct hostkeys *, Key *,
8467 const struct hostkey_entry **);
8468 int lookup_key_in_hostkeys_by_type(struct hostkeys *, int,
8469 const struct hostkey_entry **);
8470 int hostfile_read_key(char **, int *, Key *);
8471 int add_host_to_hostfile(const char *, const char *, const Key *, int);
8472 char *host_hash(const char *, const char *, u_int);
8473 enum sshfp_types {
8474 SSHFP_KEY_RESERVED = 0,
8475 SSHFP_KEY_RSA = 1,
8476 SSHFP_KEY_DSA = 2,
8477 SSHFP_KEY_ECDSA = 3
8478 };
8479 enum sshfp_hashes {
8480 SSHFP_HASH_RESERVED = 0,
8481 SSHFP_HASH_SHA1 = 1,
8482 SSHFP_HASH_SHA256 = 2,
8483 SSHFP_HASH_MAX = 3
8484 };
8485 int verify_host_key_dns(const char *, struct sockaddr *, Key *, int *);
8486 int export_dns_rr(const char *, Key *, FILE *, int);
8487 int pkcs11_init(int);
8488 void pkcs11_terminate(void);
8489 int pkcs11_add_provider(char *, char *, Key ***);
8490 int pkcs11_del_provider(char *);
8491 size_t
8492 atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
8493 int (*cb)(void *, size_t), void *);
8494 size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
8495 size_t
8496 atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
8497 const struct iovec *_iov, int iovcnt, int (*cb)(void *, size_t), void *);
8498 size_t atomiciov(ssize_t (*)(int, const struct iovec *, int),
8499 int, const struct iovec *, int);
8500 struct ssh_krl;
8501 struct ssh_krl *ssh_krl_init(void);
8502 void ssh_krl_free(struct ssh_krl *krl);
8503 void ssh_krl_set_version(struct ssh_krl *krl, u_int64_t version);
8504 void ssh_krl_set_sign_key(struct ssh_krl *krl, const Key *sign_key);
8505 void ssh_krl_set_comment(struct ssh_krl *krl, const char *comment);
8506 int ssh_krl_revoke_cert_by_serial(struct ssh_krl *krl, const Key *ca_key,
8507 u_int64_t serial);
8508 int ssh_krl_revoke_cert_by_serial_range(struct ssh_krl *krl, const Key *ca_key,
8509 u_int64_t lo, u_int64_t hi);
8510 int ssh_krl_revoke_cert_by_key_id(struct ssh_krl *krl, const Key *ca_key,
8511 const char *key_id);
8512 int ssh_krl_revoke_key_explicit(struct ssh_krl *krl, const Key *key);
8513 int ssh_krl_revoke_key_sha1(struct ssh_krl *krl, const Key *key);
8514 int ssh_krl_revoke_key(struct ssh_krl *krl, const Key *key);
8515 int ssh_krl_to_blob(struct ssh_krl *krl, Buffer *buf, const Key **sign_keys,
8516 u_int nsign_keys);
8517 int ssh_krl_from_blob(Buffer *buf, struct ssh_krl **krlp,
8518 const Key **sign_ca_keys, u_int nsign_ca_keys);
8519 int ssh_krl_check_key(struct ssh_krl *krl, const Key *key);
8520 int ssh_krl_file_contains_key(const char *path, const Key *key);
8521 u_int32_t bits = 0;
8522 int change_passphrase = 0;
8523 int change_comment = 0;
8524 int quiet = 0;
8525 int log_level = SYSLOG_LEVEL_INFO;
8526 int hash_hosts = 0;
8527 int find_host = 0;
8528 int delete_host = 0;
8529 int show_cert = 0;
8530 int print_fingerprint = 0;
8531 int print_bubblebabble = 0;
8532 char identity_file[1024];
8533 int have_identity = 0;
8534 char *identity_passphrase = ((void *)0);
8535 char *identity_new_passphrase = ((void *)0);
8536 char *identity_comment = ((void *)0);
8537 char *ca_key_path = ((void *)0);
8538 unsigned long long cert_serial = 0;
8539 u_int cert_key_type = 1;
8540 char *cert_key_id = ((void *)0);
8541 char *cert_principals = ((void *)0);
8542 u_int64_t cert_valid_from = 0;
8543 u_int64_t cert_valid_to = ~0ULL;
8544 u_int32_t certflags_flags = ((1)|(1<<1)| (1<<2)|(1<<3)|(1<<4));
8545 char *certflags_command = ((void *)0);
8546 char *certflags_src_addr = ((void *)0);
8547 int convert_to = 0;
8548 int convert_from = 0;
8549 enum {
8550 FMT_RFC4716,
8551 FMT_PKCS8,
8552 FMT_PEM
8553 } convert_format = FMT_RFC4716;
8554 int print_public = 0;
8555 int print_generic = 0;
8556 char *key_type_name = ((void *)0);
8557 char *pkcs11provider = ((void *)0);
8558 int use_new_format = 0;
8559 char *new_format_cipher = ((void *)0);
8560 int rounds = 0;
8561 extern char *__progname;
8562 char hostname[64];
8563 int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *);
8564 int prime_test(FILE *, FILE *, u_int32_t, u_int32_t, char *, unsigned long,
8565 unsigned long);
8566 static void
8567 type_bits_valid(int type, u_int32_t *bitsp)
8568 {
8569 u_int maxbits;
8570 if (type == KEY_UNSPEC) {
8571 fprintf(stderr, "unknown key type %s\n", key_type_name);
8572 exit(1);
8573 }
8574 if (*bitsp == 0) {
8575 if (type == KEY_DSA)
8576 *bitsp = 1024;
8577 else if (type == KEY_ECDSA)
8578 *bitsp = 256;
8579 else
8580 *bitsp = 2048;
8581 }
8582 maxbits = (type == KEY_DSA) ?
8583 10000 : 16384;
8584 if (*bitsp > maxbits) {
8585 fprintf(stderr, "key bits exceeds maximum %d\n", maxbits);
8586 exit(1);
8587 }
8588 if (type == KEY_DSA && *bitsp != 1024)
8589 fatal("DSA keys must be 1024 bits");
8590 else if (type != KEY_ECDSA && type != KEY_ED25519 && *bitsp < 768)
8591 fatal("Key must at least be 768 bits");
8592 else if (type == KEY_ECDSA && key_ecdsa_bits_to_nid(*bitsp) == -1)
8593 fatal("Invalid ECDSA key length - valid lengths are "
8594 "256, 384 or 521 bits");
8595 }
8596 static void
8597 ask_filename(struct passwd *pw, const char *prompt)
8598 {
8599 char buf[1024];
8600 char *name = ((void *)0);
8601 if (key_type_name == ((void *)0))
8602 name = ".ssh" "/id_rsa";
8603 else {
8604 switch (key_type_from_name(key_type_name)) {
8605 case KEY_RSA1:
8606 name = ".ssh" "/identity";
8607 break;
8608 case KEY_DSA_CERT:
8609 case KEY_DSA_CERT_V00:
8610 case KEY_DSA:
8611 name = ".ssh" "/id_dsa";
8612 break;
8613 case KEY_ECDSA_CERT:
8614 case KEY_ECDSA:
8615 name = ".ssh" "/id_ecdsa";
8616 break;
8617 case KEY_RSA_CERT:
8618 case KEY_RSA_CERT_V00:
8619 case KEY_RSA:
8620 name = ".ssh" "/id_rsa";
8621 break;
8622 case KEY_ED25519:
8623 case KEY_ED25519_CERT:
8624 name = ".ssh" "/id_ed25519";
8625 break;
8626 default:
8627 fprintf(stderr, "bad key type\n");
8628 exit(1);
8629 break;
8630 }
8631 }
8632 snprintf(identity_file, sizeof(identity_file), "%s/%s", pw->pw_dir, name);
8633 fprintf(stderr, "%s (%s): ", prompt, identity_file);
8634 if (fgets(buf, sizeof(buf), stdin) == ((void *)0))
8635 exit(1);
8636 buf[__extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p ("\n") && ((size_t)(const void *)(("\n") + 1) - (size_t)(const void *)("\n") == 1) ? ((__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1)) ? __builtin_strcspn (buf, "\n") : ((__r0 = ((const char *) ("\n"))[0], __r0 == '\0') ? strlen (buf) : ((__r1 = ((const char *) ("\n"))[1], __r1 == '\0') ? __strcspn_c1 (buf, __r0) : ((__r2 = ((const char *) ("\n"))[2], __r2 == '\0') ? __strcspn_c2 (buf, __r0, __r1) : (((const char *) ("\n"))[3] == '\0' ? __strcspn_c3 (buf, __r0, __r1, __r2) : __builtin_strcspn (buf, "\n")))))) : __builtin_strcspn (buf, "\n")); })] = '\0';
8637 if (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("") && (__s1_len = strlen (buf), __s2_len = strlen (""), (!((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("") + 1) - (size_t)(const void *)("") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "") : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("") && ((size_t)(const void *)(("") + 1) - (size_t)(const void *)("") == 1) ? __builtin_strcmp (buf, "") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (""); register int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("") && ((size_t)(const void *)(("") + 1) - (size_t)(const void *)("") == 1) && (__s2_len = strlen (""), __s2_len < 4) ? (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) ? __builtin_strcmp (buf, "") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (buf); register int __result = __s1[0] - ((const unsigned char *) (const char *) (""))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) (""))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) (""))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) (""))[3]); } } __result; }))) : __builtin_strcmp (buf, "")))); }) != 0)
8638 strlcpy(identity_file, buf, sizeof(identity_file));
8639 have_identity = 1;
8640 }
8641 static Key *
8642 load_identity(char *filename)
8643 {
8644 char *pass;
8645 Key *prv;
8646 prv = key_load_private(filename, "", ((void *)0));
8647 if (prv == ((void *)0)) {
8648 if (identity_passphrase)
8649 pass = xstrdup(identity_passphrase);
8650 else
8651 pass = read_passphrase("Enter passphrase: ",
8652 0x0002);
8653 prv = key_load_private(filename, pass, ((void *)0));
8654 explicit_bzero(pass, strlen(pass));
8655 free(pass);
8656 }
8657 return prv;
8658 }
8659 static void
8660 do_convert_to_ssh2(struct passwd *pw, Key *k)
8661 {
8662 u_int len;
8663 u_char *blob;
8664 char comment[61];
8665 if (k->type == KEY_RSA1) {
8666 fprintf(stderr, "version 1 keys are not supported\n");
8667 exit(1);
8668 }
8669 if (key_to_blob(k, &blob, &len) <= 0) {
8670 fprintf(stderr, "key_to_blob failed\n");
8671 exit(1);
8672 }
8673 snprintf(comment, sizeof(comment),
8674 "%u-bit %s, converted by %s@%s from OpenSSH",
8675 key_size(k), key_type(k),
8676 pw->pw_name, hostname);
8677 fprintf(stdout, "%s\n", "---- BEGIN SSH2 PUBLIC KEY ----");
8678 fprintf(stdout, "Comment: \"%s\"\n", comment);
8679 dump_base64(stdout, blob, len);
8680 fprintf(stdout, "%s\n", "---- END SSH2 PUBLIC KEY ----");
8681 key_free(k);
8682 free(blob);
8683 exit(0);
8684 }
8685 static void
8686 do_convert_to_pkcs8(Key *k)
8687 {
8688 switch (key_type_plain(k->type)) {
8689 case KEY_RSA1:
8690 case KEY_RSA:
8691 if (!PEM_write_RSA_PUBKEY(stdout, k->rsa))
8692 fatal("PEM_write_RSA_PUBKEY failed");
8693 break;
8694 case KEY_DSA:
8695 if (!PEM_write_DSA_PUBKEY(stdout, k->dsa))
8696 fatal("PEM_write_DSA_PUBKEY failed");
8697 break;
8698 case KEY_ECDSA:
8699 if (!PEM_write_EC_PUBKEY(stdout, k->ecdsa))
8700 fatal("PEM_write_EC_PUBKEY failed");
8701 break;
8702 default:
8703 fatal("%s: unsupported key type %s", __func__, key_type(k));
8704 }
8705 exit(0);
8706 }
8707 static void
8708 do_convert_to_pem(Key *k)
8709 {
8710 switch (key_type_plain(k->type)) {
8711 case KEY_RSA1:
8712 case KEY_RSA:
8713 if (!PEM_write_RSAPublicKey(stdout, k->rsa))
8714 fatal("PEM_write_RSAPublicKey failed");
8715 break;
8716 default:
8717 fatal("%s: unsupported key type %s", __func__, key_type(k));
8718 }
8719 exit(0);
8720 }
8721 static void
8722 do_convert_to(struct passwd *pw)
8723 {
8724 Key *k;
8725 struct stat st;
8726 if (!have_identity)
8727 ask_filename(pw, "Enter file in which the key is");
8728 if (stat(identity_file, &st) < 0)
8729 fatal("%s: %s: %s", __progname, identity_file, strerror((*__errno_location ())));
8730 if ((k = key_load_public(identity_file, ((void *)0))) == ((void *)0)) {
8731 if ((k = load_identity(identity_file)) == ((void *)0)) {
8732 fprintf(stderr, "load failed\n");
8733 exit(1);
8734 }
8735 }
8736 switch (convert_format) {
8737 case FMT_RFC4716:
8738 do_convert_to_ssh2(pw, k);
8739 break;
8740 case FMT_PKCS8:
8741 do_convert_to_pkcs8(k);
8742 break;
8743 case FMT_PEM:
8744 do_convert_to_pem(k);
8745 break;
8746 default:
8747 fatal("%s: unknown key format %d", __func__, convert_format);
8748 }
8749 exit(0);
8750 }
8751 static void
8752 buffer_get_bignum_bits(Buffer *b, BIGNUM *value)
8753 {
8754 u_int bignum_bits = buffer_get_int(b);
8755 u_int bytes = (bignum_bits + 7) / 8;
8756 if (buffer_len(b) < bytes)
8757 fatal("buffer_get_bignum_bits: input buffer too small: "
8758 "need %d have %d", bytes, buffer_len(b));
8759 if (BN_bin2bn(buffer_ptr(b), bytes, value) == ((void *)0))
8760 fatal("buffer_get_bignum_bits: BN_bin2bn failed");
8761 buffer_consume(b, bytes);
8762 }
8763 static Key *
8764 do_convert_private_ssh2_from_blob(u_char *blob, u_int blen)
8765 {
8766 Buffer b;
8767 Key *key = ((void *)0);
8768 char *type, *cipher;
8769 u_char *sig, data[] = "abcde12345";
8770 int magic, rlen, ktype, i1, i2, i3, i4;
8771 u_int slen;
8772 u_long e;
8773 buffer_init(&b);
8774 buffer_append(&b, blob, blen);
8775 magic = buffer_get_int(&b);
8776 if (magic != 0x3f6ff9eb) {
8777 error("bad magic 0x%x != 0x%x", magic, 0x3f6ff9eb);
8778 buffer_free(&b);
8779 return ((void *)0);
8780 }
8781 i1 = buffer_get_int(&b);
8782 type = buffer_get_string(&b, ((void *)0));
8783 cipher = buffer_get_string(&b, ((void *)0));
8784 i2 = buffer_get_int(&b);
8785 i3 = buffer_get_int(&b);
8786 i4 = buffer_get_int(&b);
8787 debug("ignore (%d %d %d %d)", i1, i2, i3, i4);
8788 if (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (cipher) && __builtin_constant_p ("none") && (__s1_len = strlen (cipher), __s2_len = strlen ("none"), (!((size_t)(const void *)((cipher) + 1) - (size_t)(const void *)(cipher) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("none") + 1) - (size_t)(const void *)("none") == 1) || __s2_len >= 4)) ? __builtin_strcmp (cipher, "none") : (__builtin_constant_p (cipher) && ((size_t)(const void *)((cipher) + 1) - (size_t)(const void *)(cipher) == 1) && (__s1_len = strlen (cipher), __s1_len < 4) ? (__builtin_constant_p ("none") && ((size_t)(const void *)(("none") + 1) - (size_t)(const void *)("none") == 1) ? __builtin_strcmp (cipher, "none") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("none"); register int __result = (((const unsigned char *) (const char *) (cipher))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (cipher))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (cipher))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (cipher))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("none") && ((size_t)(const void *)(("none") + 1) - (size_t)(const void *)("none") == 1) && (__s2_len = strlen ("none"), __s2_len < 4) ? (__builtin_constant_p (cipher) && ((size_t)(const void *)((cipher) + 1) - (size_t)(const void *)(cipher) == 1) ? __builtin_strcmp (cipher, "none") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (cipher); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("none"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("none"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("none"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("none"))[3]); } } __result; }))) : __builtin_strcmp (cipher, "none")))); }) != 0) {
8789 error("unsupported cipher %s", cipher);
8790 free(cipher);
8791 buffer_free(&b);
8792 free(type);
8793 return ((void *)0);
8794 }
8795 free(cipher);
8796 if (strstr(type, "dsa")) {
8797 ktype = KEY_DSA;
8798 } else if (strstr(type, "rsa")) {
8799 ktype = KEY_RSA;
8800 } else {
8801 buffer_free(&b);
8802 free(type);
8803 return ((void *)0);
8804 }
8805 key = key_new_private(ktype);
8806 free(type);
8807 switch (key->type) {
8808 case KEY_DSA:
8809 buffer_get_bignum_bits(&b, key->dsa->p);
8810 buffer_get_bignum_bits(&b, key->dsa->g);
8811 buffer_get_bignum_bits(&b, key->dsa->q);
8812 buffer_get_bignum_bits(&b, key->dsa->pub_key);
8813 buffer_get_bignum_bits(&b, key->dsa->priv_key);
8814 break;
8815 case KEY_RSA:
8816 e = buffer_get_char(&b);
8817 debug("e %lx", e);
8818 if (e < 30) {
8819 e <<= 8;
8820 e += buffer_get_char(&b);
8821 debug("e %lx", e);
8822 e <<= 8;
8823 e += buffer_get_char(&b);
8824 debug("e %lx", e);
8825 }
8826 if (!BN_set_word(key->rsa->e, e)) {
8827 buffer_free(&b);
8828 key_free(key);
8829 return ((void *)0);
8830 }
8831 buffer_get_bignum_bits(&b, key->rsa->d);
8832 buffer_get_bignum_bits(&b, key->rsa->n);
8833 buffer_get_bignum_bits(&b, key->rsa->iqmp);
8834 buffer_get_bignum_bits(&b, key->rsa->q);
8835 buffer_get_bignum_bits(&b, key->rsa->p);
8836 rsa_generate_additional_parameters(key->rsa);
8837 break;
8838 }
8839 rlen = buffer_len(&b);
8840 if (rlen != 0)
8841 error("do_convert_private_ssh2_from_blob: "
8842 "remaining bytes in key blob %d", rlen);
8843 buffer_free(&b);
8844 key_sign(key, &sig, &slen, data, sizeof(data));
8845 key_verify(key, sig, slen, data, sizeof(data));
8846 free(sig);
8847 return key;
8848 }
8849 static int
8850 get_line(FILE *fp, char *line, size_t len)
8851 {
8852 int c;
8853 size_t pos = 0;
8854 line[0] = '\0';
8855 while ((c = fgetc(fp)) != (-1)) {
8856 if (pos >= len - 1) {
8857 fprintf(stderr, "input line too long.\n");
8858 exit(1);
8859 }
8860 switch (c) {
8861 case '\r':
8862 c = fgetc(fp);
8863 if (c != (-1) && c != '\n' && ungetc(c, fp) == (-1)) {
8864 fprintf(stderr, "unget: %s\n", strerror((*__errno_location ())));
8865 exit(1);
8866 }
8867 return pos;
8868 case '\n':
8869 return pos;
8870 }
8871 line[pos++] = c;
8872 line[pos] = '\0';
8873 }
8874 return -1;
8875 }
8876 static void
8877 do_convert_from_ssh2(struct passwd *pw, Key **k, int *private)
8878 {
8879 int blen;
8880 u_int len;
8881 char line[1024];
8882 u_char blob[8096];
8883 char encoded[8096];
8884 int escaped = 0;
8885 FILE *fp;
8886 if ((fp = fopen(identity_file, "r")) == ((void *)0))
8887 fatal("%s: %s: %s", __progname, identity_file, strerror((*__errno_location ())));
8888 encoded[0] = '\0';
8889 while ((blen = get_line(fp, line, sizeof(line))) != -1) {
8890 if (blen > 0 && line[blen - 1] == '\\')
8891 escaped++;
8892 if ((__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (line) && strlen (line) < ((size_t) (4))) || (__builtin_constant_p ("----") && strlen ("----") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (line) && __builtin_constant_p ("----") && (__s1_len = strlen (line), __s2_len = strlen ("----"), (!((size_t)(const void *)((line) + 1) - (size_t)(const void *)(line) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("----") + 1) - (size_t)(const void *)("----") == 1) || __s2_len >= 4)) ? __builtin_strcmp (line, "----") : (__builtin_constant_p (line) && ((size_t)(const void *)((line) + 1) - (size_t)(const void *)(line) == 1) && (__s1_len = strlen (line), __s1_len < 4) ? (__builtin_constant_p ("----") && ((size_t)(const void *)(("----") + 1) - (size_t)(const void *)("----") == 1) ? __builtin_strcmp (line, "----") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("----"); register int __result = (((const unsigned char *) (const char *) (line))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (line))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (line))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (line))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("----") && ((size_t)(const void *)(("----") + 1) - (size_t)(const void *)("----") == 1) && (__s2_len = strlen ("----"), __s2_len < 4) ? (__builtin_constant_p (line) && ((size_t)(const void *)((line) + 1) - (size_t)(const void *)(line) == 1) ? __builtin_strcmp (line, "----") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (line); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("----"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("----"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("----"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("----"))[3]); } } __result; }))) : __builtin_strcmp (line, "----")))); }) : strncmp (line, "----", 4))) == 0 ||
8893 strstr(line, ": ") != ((void *)0)) {
8894 if (strstr(line, "---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----") != ((void *)0))
8895 *private = 1;
8896 if (strstr(line, " END ") != ((void *)0)) {
8897 break;
8898 }
8899 continue;
8900 }
8901 if (escaped) {
8902 escaped--;
8903 continue;
8904 }
8905 strlcat(encoded, line, sizeof(encoded));
8906 }
8907 len = strlen(encoded);
8908 if (((len % 4) == 3) &&
8909 (encoded[len-1] == '=') &&
8910 (encoded[len-2] == '=') &&
8911 (encoded[len-3] == '='))
8912 encoded[len-3] = '\0';
8913 blen = uudecode(encoded, blob, sizeof(blob));
8914 if (blen < 0) {
8915 fprintf(stderr, "uudecode failed.\n");
8916 exit(1);
8917 }
8918 *k = *private ?
8919 do_convert_private_ssh2_from_blob(blob, blen) :
8920 key_from_blob(blob, blen);
8921 if (*k == ((void *)0)) {
8922 fprintf(stderr, "decode blob failed.\n");
8923 exit(1);
8924 }
8925 fclose(fp);
8926 }
8927 static void
8928 do_convert_from_pkcs8(Key **k, int *private)
8929 {
8930 EVP_PKEY *pubkey;
8931 FILE *fp;
8932 if ((fp = fopen(identity_file, "r")) == ((void *)0))
8933 fatal("%s: %s: %s", __progname, identity_file, strerror((*__errno_location ())));
8934 if ((pubkey = PEM_read_PUBKEY(fp, ((void *)0), ((void *)0), ((void *)0))) == ((void *)0)) {
8935 fatal("%s: %s is not a recognised public key format", __func__,
8936 identity_file);
8937 }
8938 fclose(fp);
8939 switch (EVP_PKEY_type(pubkey->type)) {
8940 case 6:
8941 *k = key_new(KEY_UNSPEC);
8942 (*k)->type = KEY_RSA;
8943 (*k)->rsa = EVP_PKEY_get1_RSA(pubkey);
8944 break;
8945 case 116:
8946 *k = key_new(KEY_UNSPEC);
8947 (*k)->type = KEY_DSA;
8948 (*k)->dsa = EVP_PKEY_get1_DSA(pubkey);
8949 break;
8950 case 408:
8951 *k = key_new(KEY_UNSPEC);
8952 (*k)->type = KEY_ECDSA;
8953 (*k)->ecdsa = EVP_PKEY_get1_EC_KEY(pubkey);
8954 (*k)->ecdsa_nid = key_ecdsa_key_to_nid((*k)->ecdsa);
8955 break;
8956 default:
8957 fatal("%s: unsupported pubkey type %d", __func__,
8958 EVP_PKEY_type(pubkey->type));
8959 }
8960 EVP_PKEY_free(pubkey);
8961 return;
8962 }
8963 static void
8964 do_convert_from_pem(Key **k, int *private)
8965 {
8966 FILE *fp;
8967 RSA *rsa;
8968 if ((fp = fopen(identity_file, "r")) == ((void *)0))
8969 fatal("%s: %s: %s", __progname, identity_file, strerror((*__errno_location ())));
8970 if ((rsa = PEM_read_RSAPublicKey(fp, ((void *)0), ((void *)0), ((void *)0))) != ((void *)0)) {
8971 *k = key_new(KEY_UNSPEC);
8972 (*k)->type = KEY_RSA;
8973 (*k)->rsa = rsa;
8974 fclose(fp);
8975 return;
8976 }
8977 fatal("%s: unrecognised raw private key format", __func__);
8978 }
8979 static void
8980 do_convert_from(struct passwd *pw)
8981 {
8982 Key *k = ((void *)0);
8983 int private = 0, ok = 0;
8984 struct stat st;
8985 if (!have_identity)
8986 ask_filename(pw, "Enter file in which the key is");
8987 if (stat(identity_file, &st) < 0)
8988 fatal("%s: %s: %s", __progname, identity_file, strerror((*__errno_location ())));
8989 switch (convert_format) {
8990 case FMT_RFC4716:
8991 do_convert_from_ssh2(pw, &k, &private);
8992 break;
8993 case FMT_PKCS8:
8994 do_convert_from_pkcs8(&k, &private);
8995 break;
8996 case FMT_PEM:
8997 do_convert_from_pem(&k, &private);
8998 break;
8999 default:
9000 fatal("%s: unknown key format %d", __func__, convert_format);
9001 }
9002 if (!private)
9003 ok = key_write(k, stdout);
9004 if (ok)
9005 fprintf(stdout, "\n");
9006 else {
9007 switch (k->type) {
9008 case KEY_DSA:
9009 ok = PEM_write_DSAPrivateKey(stdout, k->dsa, ((void *)0),
9010 ((void *)0), 0, ((void *)0), ((void *)0));
9011 break;
9012 case KEY_ECDSA:
9013 ok = PEM_write_ECPrivateKey(stdout, k->ecdsa, ((void *)0),
9014 ((void *)0), 0, ((void *)0), ((void *)0));
9015 break;
9016 case KEY_RSA:
9017 ok = PEM_write_RSAPrivateKey(stdout, k->rsa, ((void *)0),
9018 ((void *)0), 0, ((void *)0), ((void *)0));
9019 break;
9020 default:
9021 fatal("%s: unsupported key type %s", __func__,
9022 key_type(k));
9023 }
9024 }
9025 if (!ok) {
9026 fprintf(stderr, "key write failed\n");
9027 exit(1);
9028 }
9029 key_free(k);
9030 exit(0);
9031 }
9032 static void
9033 do_print_public(struct passwd *pw)
9034 {
9035 Key *prv;
9036 struct stat st;
9037 if (!have_identity)
9038 ask_filename(pw, "Enter file in which the key is");
9039 if (stat(identity_file, &st) < 0) {
9040 perror(identity_file);
9041 exit(1);
9042 }
9043 prv = load_identity(identity_file);
9044 if (prv == ((void *)0)) {
9045 fprintf(stderr, "load failed\n");
9046 exit(1);
9047 }
9048 if (!key_write(prv, stdout))
9049 fprintf(stderr, "key_write failed");
9050 key_free(prv);
9051 fprintf(stdout, "\n");
9052 exit(0);
9053 }
9054 static void
9055 do_download(struct passwd *pw)
9056 {
9057 Key **keys = ((void *)0);
9058 int i, nkeys;
9059 enum fp_rep rep;
9060 enum fp_type fptype;
9061 char *fp, *ra;
9062 fptype = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5;
9063 rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_HEX;
9064 pkcs11_init(0);
9065 nkeys = pkcs11_add_provider(pkcs11provider, ((void *)0), &keys);
9066 if (nkeys <= 0)
9067 fatal("cannot read public key from pkcs11");
9068 for (i = 0; i < nkeys; i++) {
9069 if (print_fingerprint) {
9070 fp = key_fingerprint(keys[i], fptype, rep);
9071 ra = key_fingerprint(keys[i], SSH_FP_MD5,
9072 SSH_FP_RANDOMART);
9073 printf("%u %s %s (PKCS11 key)\n", key_size(keys[i]),
9074 fp, key_type(keys[i]));
9075 if (log_level >= SYSLOG_LEVEL_VERBOSE)
9076 printf("%s\n", ra);
9077 free(ra);
9078 free(fp);
9079 } else {
9080 key_write(keys[i], stdout);
9081 fprintf(stdout, "\n");
9082 }
9083 key_free(keys[i]);
9084 }
9085 free(keys);
9086 pkcs11_terminate();
9087 exit(0);
9088 }
9089 static void
9090 do_fingerprint(struct passwd *pw)
9091 {
9092 FILE *f;
9093 Key *public;
9094 char *comment = ((void *)0), *cp, *ep, line[16*1024], *fp, *ra;
9095 int i, skip = 0, num = 0, invalid = 1;
9096 enum fp_rep rep;
9097 enum fp_type fptype;
9098 struct stat st;
9099 fptype = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5;
9100 rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_HEX;
9101 if (!have_identity)
9102 ask_filename(pw, "Enter file in which the key is");
9103 if (stat(identity_file, &st) < 0) {
9104 perror(identity_file);
9105 exit(1);
9106 }
9107 public = key_load_public(identity_file, &comment);
9108 if (public != ((void *)0)) {
9109 fp = key_fingerprint(public, fptype, rep);
9110 ra = key_fingerprint(public, SSH_FP_MD5, SSH_FP_RANDOMART);
9111 printf("%u %s %s (%s)\n", key_size(public), fp, comment,
9112 key_type(public));
9113 if (log_level >= SYSLOG_LEVEL_VERBOSE)
9114 printf("%s\n", ra);
9115 key_free(public);
9116 free(comment);
9117 free(ra);
9118 free(fp);
9119 exit(0);
9120 }
9121 if (comment) {
9122 free(comment);
9123 comment = ((void *)0);
9124 }
9125 if ((f = fopen(identity_file, "r")) == ((void *)0))
9126 fatal("%s: %s: %s", __progname, identity_file, strerror((*__errno_location ())));
9127 while (fgets(line, sizeof(line), f)) {
9128 if ((cp = (__extension__ (__builtin_constant_p ('\n') && !__builtin_constant_p (line) && ('\n') == '\0' ? (char *) __rawmemchr (line, '\n') : __builtin_strchr (line, '\n')))) == ((void *)0)) {
9129 error("line %d too long: %.40s...",
9130 num + 1, line);
9131 skip = 1;
9132 continue;
9133 }
9134 num++;
9135 if (skip) {
9136 skip = 0;
9137 continue;
9138 }
9139 *cp = '\0';
9140 for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
9141 ;
9142 if (!*cp || *cp == '\n' || *cp == '#')
9143 continue;
9144 i = strtol(cp, &ep, 10);
9145 if (i == 0 || ep == ((void *)0) || (*ep != ' ' && *ep != '\t')) {
9146 int quoted = 0;
9147 comment = cp;
9148 for (; *cp && (quoted || (*cp != ' ' &&
9149 *cp != '\t')); cp++) {
9150 if (*cp == '\\' && cp[1] == '"')
9151 cp++;
9152 else if (*cp == '"')
9153 quoted = !quoted;
9154 }
9155 if (!*cp)
9156 continue;
9157 *cp++ = '\0';
9158 }
9159 ep = cp;
9160 public = key_new(KEY_RSA1);
9161 if (key_read(public, &cp) != 1) {
9162 cp = ep;
9163 key_free(public);
9164 public = key_new(KEY_UNSPEC);
9165 if (key_read(public, &cp) != 1) {
9166 key_free(public);
9167 continue;
9168 }
9169 }
9170 comment = *cp ? cp : comment;
9171 fp = key_fingerprint(public, fptype, rep);
9172 ra = key_fingerprint(public, SSH_FP_MD5, SSH_FP_RANDOMART);
9173 printf("%u %s %s (%s)\n", key_size(public), fp,
9174 comment ? comment : "no comment", key_type(public));
9175 if (log_level >= SYSLOG_LEVEL_VERBOSE)
9176 printf("%s\n", ra);
9177 free(ra);
9178 free(fp);
9179 key_free(public);
9180 invalid = 0;
9181 }
9182 fclose(f);
9183 if (invalid) {
9184 printf("%s is not a public key file.\n", identity_file);
9185 exit(1);
9186 }
9187 exit(0);
9188 }
9189 static void
9190 do_gen_all_hostkeys(struct passwd *pw)
9191 {
9192 struct {
9193 char *key_type;
9194 char *key_type_display;
9195 char *path;
9196 } key_types[] = {
9197 { "rsa1", "RSA1", "/etc/ssh" "/ssh_host_key" },
9198 { "rsa", "RSA" ,"/etc/ssh" "/ssh_host_rsa_key" },
9199 { "dsa", "DSA", "/etc/ssh" "/ssh_host_dsa_key" },
9200 { "ecdsa", "ECDSA","/etc/ssh" "/ssh_host_ecdsa_key" },
9201 { "ed25519", "ED25519","/etc/ssh" "/ssh_host_ed25519_key" },
9202 { ((void *)0), ((void *)0), ((void *)0) }
9203 };
9204 int first = 0;
9205 struct stat st;
9206 Key *private, *public;
9207 char comment[1024];
9208 int i, type, fd;
9209 FILE *f;
9210 for (i = 0; key_types[i].key_type; i++) {
9211 if (stat(key_types[i].path, &st) == 0)
9212 continue;
9213 if ((*__errno_location ()) != 2) {
9214 printf("Could not stat %s: %s", key_types[i].path,
9215 strerror((*__errno_location ())));
9216 first = 0;
9217 continue;
9218 }
9219 if (first == 0) {
9220 first = 1;
9221 printf("%s: generating new host keys: ", __progname);
9222 }
9223 printf("%s ", key_types[i].key_type_display);
9224 fflush(stdout);
9225 type = key_type_from_name(key_types[i].key_type);
9226 strlcpy(identity_file, key_types[i].path, sizeof(identity_file));
9227 bits = 0;
9228 type_bits_valid(type, &bits);
9229 private = key_generate(type, bits);
9230 if (private == ((void *)0)) {
9231 fprintf(stderr, "key_generate failed\n");
9232 first = 0;
9233 continue;
9234 }
9235 public = key_from_private(private);
9236 snprintf(comment, sizeof comment, "%s@%s", pw->pw_name,
9237 hostname);
9238 if (!key_save_private(private, identity_file, "", comment,
9239 use_new_format, new_format_cipher, rounds)) {
9240 printf("Saving the key failed: %s.\n", identity_file);
9241 key_free(private);
9242 key_free(public);
9243 first = 0;
9244 continue;
9245 }
9246 key_free(private);
9247 strlcat(identity_file, ".pub", sizeof(identity_file));
9248 fd = open(identity_file, 01 | 00000400 | 01000, 0644);
9249 if (fd == -1) {
9250 printf("Could not save your public key in %s\n",
9251 identity_file);
9252 key_free(public);
9253 first = 0;
9254 continue;
9255 }
9256 f = fdopen(fd, "w");
9257 if (f == ((void *)0)) {
9258 printf("fdopen %s failed\n", identity_file);
9259 key_free(public);
9260 first = 0;
9261 continue;
9262 }
9263 if (!key_write(public, f)) {
9264 fprintf(stderr, "write key failed\n");
9265 key_free(public);
9266 first = 0;
9267 continue;
9268 }
9269 fprintf(f, " %s\n", comment);
9270 fclose(f);
9271 key_free(public);
9272 }
9273 if (first != 0)
9274 printf("\n");
9275 }
9276 static void
9277 printhost(FILE *f, const char *name, Key *public, int ca, int hash)
9278 {
9279 if (print_fingerprint) {
9280 enum fp_rep rep;
9281 enum fp_type fptype;
9282 char *fp, *ra;
9283 fptype = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5;
9284 rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_HEX;
9285 fp = key_fingerprint(public, fptype, rep);
9286 ra = key_fingerprint(public, SSH_FP_MD5, SSH_FP_RANDOMART);
9287 printf("%u %s %s (%s)\n", key_size(public), fp, name,
9288 key_type(public));
9289 if (log_level >= SYSLOG_LEVEL_VERBOSE)
9290 printf("%s\n", ra);
9291 free(ra);
9292 free(fp);
9293 } else {
9294 if (hash && (name = host_hash(name, ((void *)0), 0)) == ((void *)0))
9295 fatal("hash_host failed");
9296 fprintf(f, "%s%s%s ", ca ? "@cert-authority" : "", ca ? " " : "", name);
9297 if (!key_write(public, f))
9298 fatal("key_write failed");
9299 fprintf(f, "\n");
9300 }
9301 }
9302 static void
9303 do_known_hosts(struct passwd *pw, const char *name)
9304 {
9305 FILE *in, *out = stdout;
9306 Key *pub;
9307 char *cp, *cp2, *kp, *kp2;
9308 char line[16*1024], tmp[4096], old[4096];
9309 int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0;
9310 int ca;
9311 int found_key = 0;
9312 if (!have_identity) {
9313 cp = tilde_expand_filename("~/" ".ssh" "/known_hosts", pw->pw_uid);
9314 if (strlcpy(identity_file, cp, sizeof(identity_file)) >=
9315 sizeof(identity_file))
9316 fatal("Specified known hosts path too long");
9317 free(cp);
9318 have_identity = 1;
9319 }
9320 if ((in = fopen(identity_file, "r")) == ((void *)0))
9321 fatal("%s: %s: %s", __progname, identity_file, strerror((*__errno_location ())));
9322 if (!find_host && (hash_hosts || delete_host)) {
9323 if (strlcpy(tmp, identity_file, sizeof(tmp)) >= sizeof(tmp) ||
9324 strlcat(tmp, ".XXXXXXXXXX", sizeof(tmp)) >= sizeof(tmp) ||
9325 strlcpy(old, identity_file, sizeof(old)) >= sizeof(old) ||
9326 strlcat(old, ".old", sizeof(old)) >= sizeof(old))
9327 fatal("known_hosts path too long");
9328 umask(077);
9329 if ((c = mkstemp(tmp)) == -1)
9330 fatal("mkstemp: %s", strerror((*__errno_location ())));
9331 if ((out = fdopen(c, "w")) == ((void *)0)) {
9332 c = (*__errno_location ());
9333 unlink(tmp);
9334 fatal("fdopen: %s", strerror(c));
9335 }
9336 inplace = 1;
9337 }
9338 while (fgets(line, sizeof(line), in)) {
9339 if ((cp = (__extension__ (__builtin_constant_p ('\n') && !__builtin_constant_p (line) && ('\n') == '\0' ? (char *) __rawmemchr (line, '\n') : __builtin_strchr (line, '\n')))) == ((void *)0)) {
9340 error("line %d too long: %.40s...", num + 1, line);
9341 skip = 1;
9342 invalid = 1;
9343 continue;
9344 }
9345 num++;
9346 if (skip) {
9347 skip = 0;
9348 continue;
9349 }
9350 *cp = '\0';
9351 for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
9352 ;
9353 if (!*cp || *cp == '\n' || *cp == '#') {
9354 if (inplace)
9355 fprintf(out, "%s\n", cp);
9356 continue;
9357 }
9358 if (strncasecmp(cp, "@cert-authority", sizeof("@cert-authority") - 1) == 0 &&
9359 (cp[sizeof("@cert-authority") - 1] == ' ' ||
9360 cp[sizeof("@cert-authority") - 1] == '\t')) {
9361 ca = 1;
9362 cp += sizeof("@cert-authority");
9363 } else
9364 ca = 0;
9365 for (kp = cp; *kp && *kp != ' ' && *kp != '\t'; kp++)
9366 ;
9367 if (*kp == '\0' || *(kp + 1) == '\0') {
9368 error("line %d missing key: %.40s...",
9369 num, line);
9370 invalid = 1;
9371 continue;
9372 }
9373 *kp++ = '\0';
9374 kp2 = kp;
9375 pub = key_new(KEY_RSA1);
9376 if (key_read(pub, &kp) != 1) {
9377 kp = kp2;
9378 key_free(pub);
9379 pub = key_new(KEY_UNSPEC);
9380 if (key_read(pub, &kp) != 1) {
9381 error("line %d invalid key: %.40s...",
9382 num, line);
9383 key_free(pub);
9384 invalid = 1;
9385 continue;
9386 }
9387 }
9388 if (*cp == '|') {
9389 if (find_host || delete_host) {
9390 cp2 = host_hash(name, cp, strlen(cp));
9391 if (cp2 == ((void *)0)) {
9392 error("line %d: invalid hashed "
9393 "name: %.64s...", num, line);
9394 invalid = 1;
9395 continue;
9396 }
9397 c = (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (cp2) && __builtin_constant_p (cp) && (__s1_len = strlen (cp2), __s2_len = strlen (cp), (!((size_t)(const void *)((cp2) + 1) - (size_t)(const void *)(cp2) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1) || __s2_len >= 4)) ? __builtin_strcmp (cp2, cp) : (__builtin_constant_p (cp2) && ((size_t)(const void *)((cp2) + 1) - (size_t)(const void *)(cp2) == 1) && (__s1_len = strlen (cp2), __s1_len < 4) ? (__builtin_constant_p (cp) && ((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1) ? __builtin_strcmp (cp2, cp) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (cp); register int __result = (((const unsigned char *) (const char *) (cp2))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (cp2))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (cp2))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (cp2))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (cp) && ((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1) && (__s2_len = strlen (cp), __s2_len < 4) ? (__builtin_constant_p (cp2) && ((size_t)(const void *)((cp2) + 1) - (size_t)(const void *)(cp2) == 1) ? __builtin_strcmp (cp2, cp) : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (cp2); register int __result = __s1[0] - ((const unsigned char *) (const char *) (cp))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) (cp))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) (cp))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) (cp))[3]); } } __result; }))) : __builtin_strcmp (cp2, cp)))); }) == 0);
9398 if (find_host && c) {
9399 if (!quiet)
9400 printf("# Host %s found: "
9401 "line %d type %s%s\n", name,
9402 num, key_type(pub),
9403 ca ? " (CA key)" : "");
9404 printhost(out, cp, pub, ca, 0);
9405 found_key = 1;
9406 }
9407 if (delete_host) {
9408 if (!c && !ca)
9409 printhost(out, cp, pub, ca, 0);
9410 else
9411 printf("# Host %s found: "
9412 "line %d type %s\n", name,
9413 num, key_type(pub));
9414 }
9415 } else if (hash_hosts)
9416 printhost(out, cp, pub, ca, 0);
9417 } else {
9418 if (find_host || delete_host) {
9419 c = (match_hostname(name, cp,
9420 strlen(cp)) == 1);
9421 if (find_host && c) {
9422 if (!quiet)
9423 printf("# Host %s found: "
9424 "line %d type %s%s\n", name,
9425 num, key_type(pub),
9426 ca ? " (CA key)" : "");
9427 printhost(out, name, pub,
9428 ca, hash_hosts && !ca);
9429 found_key = 1;
9430 }
9431 if (delete_host) {
9432 if (!c && !ca)
9433 printhost(out, cp, pub, ca, 0);
9434 else
9435 printf("# Host %s found: "
9436 "line %d type %s\n", name,
9437 num, key_type(pub));
9438 }
9439 } else if (hash_hosts) {
9440 for (cp2 = __extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p (",") && ((size_t)(const void *)((",") + 1) - (size_t)(const void *)(",") == 1) && (__r0 = ((const char *) (","))[0], ((const char *) (","))[0] != '\0') ? ((__r1 = ((const char *) (","))[1], ((const char *) (","))[1] == '\0') ? __strsep_1c (&cp, __r0) : ((__r2 = ((const char *) (","))[2], __r2 == '\0') ? __strsep_2c (&cp, __r0, __r1) : (((const char *) (","))[3] == '\0' ? __strsep_3c (&cp, __r0, __r1, __r2) : __strsep_g (&cp, ",")))) : __strsep_g (&cp, ",")); });
9441 cp2 != ((void *)0) && *cp2 != '\0';
9442 cp2 = __extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p (",") && ((size_t)(const void *)((",") + 1) - (size_t)(const void *)(",") == 1) && (__r0 = ((const char *) (","))[0], ((const char *) (","))[0] != '\0') ? ((__r1 = ((const char *) (","))[1], ((const char *) (","))[1] == '\0') ? __strsep_1c (&cp, __r0) : ((__r2 = ((const char *) (","))[2], __r2 == '\0') ? __strsep_2c (&cp, __r0, __r1) : (((const char *) (","))[3] == '\0' ? __strsep_3c (&cp, __r0, __r1, __r2) : __strsep_g (&cp, ",")))) : __strsep_g (&cp, ",")); })) {
9443 if (ca) {
9444 fprintf(stderr, "Warning: "
9445 "ignoring CA key for host: "
9446 "%.64s\n", cp2);
9447 printhost(out, cp2, pub, ca, 0);
9448 } else if (__extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p ("*?!") && ((size_t)(const void *)(("*?!") + 1) - (size_t)(const void *)("*?!") == 1) ? ((__builtin_constant_p (cp2) && ((size_t)(const void *)((cp2) + 1) - (size_t)(const void *)(cp2) == 1)) ? __builtin_strcspn (cp2, "*?!") : ((__r0 = ((const char *) ("*?!"))[0], __r0 == '\0') ? strlen (cp2) : ((__r1 = ((const char *) ("*?!"))[1], __r1 == '\0') ? __strcspn_c1 (cp2, __r0) : ((__r2 = ((const char *) ("*?!"))[2], __r2 == '\0') ? __strcspn_c2 (cp2, __r0, __r1) : (((const char *) ("*?!"))[3] == '\0' ? __strcspn_c3 (cp2, __r0, __r1, __r2) : __builtin_strcspn (cp2, "*?!")))))) : __builtin_strcspn (cp2, "*?!")); }) !=
9449 strlen(cp2)) {
9450 fprintf(stderr, "Warning: "
9451 "ignoring host name with "
9452 "metacharacters: %.64s\n",
9453 cp2);
9454 printhost(out, cp2, pub, ca, 0);
9455 } else
9456 printhost(out, cp2, pub, ca, 1);
9457 }
9458 has_unhashed = 1;
9459 }
9460 }
9461 key_free(pub);
9462 }
9463 fclose(in);
9464 if (invalid) {
9465 fprintf(stderr, "%s is not a valid known_hosts file.\n",
9466 identity_file);
9467 if (inplace) {
9468 fprintf(stderr, "Not replacing existing known_hosts "
9469 "file because of errors\n");
9470 fclose(out);
9471 unlink(tmp);
9472 }
9473 exit(1);
9474 }
9475 if (inplace) {
9476 fclose(out);
9477 if (unlink(old) == -1 && (*__errno_location ()) != 2)
9478 fatal("unlink %.100s: %s", old, strerror((*__errno_location ())));
9479 if (link(identity_file, old) == -1)
9480 fatal("link %.100s to %.100s: %s", identity_file, old,
9481 strerror((*__errno_location ())));
9482 if (rename(tmp, identity_file) == -1) {
9483 error("rename\"%s\" to \"%s\": %s", tmp, identity_file,
9484 strerror((*__errno_location ())));
9485 unlink(tmp);
9486 unlink(old);
9487 exit(1);
9488 }
9489 fprintf(stderr, "%s updated.\n", identity_file);
9490 fprintf(stderr, "Original contents retained as %s\n", old);
9491 if (has_unhashed) {
9492 fprintf(stderr, "WARNING: %s contains unhashed "
9493 "entries\n", old);
9494 fprintf(stderr, "Delete this file to ensure privacy "
9495 "of hostnames\n");
9496 }
9497 }
9498 exit (find_host && !found_key);
9499 }
9500 static void
9501 do_change_passphrase(struct passwd *pw)
9502 {
9503 char *comment;
9504 char *old_passphrase, *passphrase1, *passphrase2;
9505 struct stat st;
9506 Key *private;
9507 if (!have_identity)
9508 ask_filename(pw, "Enter file in which the key is");
9509 if (stat(identity_file, &st) < 0) {
9510 perror(identity_file);
9511 exit(1);
9512 }
9513 private = key_load_private(identity_file, "", &comment);
9514 if (private == ((void *)0)) {
9515 if (identity_passphrase)
9516 old_passphrase = xstrdup(identity_passphrase);
9517 else
9518 old_passphrase =
9519 read_passphrase("Enter old passphrase: ",
9520 0x0002);
9521 private = key_load_private(identity_file, old_passphrase,
9522 &comment);
9523 explicit_bzero(old_passphrase, strlen(old_passphrase));
9524 free(old_passphrase);
9525 if (private == ((void *)0)) {
9526 printf("Bad passphrase.\n");
9527 exit(1);
9528 }
9529 }
9530 printf("Key has comment '%s'\n", comment);
9531 if (identity_new_passphrase) {
9532 passphrase1 = xstrdup(identity_new_passphrase);
9533 passphrase2 = ((void *)0);
9534 } else {
9535 passphrase1 =
9536 read_passphrase("Enter new passphrase (empty for no "
9537 "passphrase): ", 0x0002);
9538 passphrase2 = read_passphrase("Enter same passphrase again: ",
9539 0x0002);
9540 if (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (passphrase1) && __builtin_constant_p (passphrase2) && (__s1_len = strlen (passphrase1), __s2_len = strlen (passphrase2), (!((size_t)(const void *)((passphrase1) + 1) - (size_t)(const void *)(passphrase1) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((passphrase2) + 1) - (size_t)(const void *)(passphrase2) == 1) || __s2_len >= 4)) ? __builtin_strcmp (passphrase1, passphrase2) : (__builtin_constant_p (passphrase1) && ((size_t)(const void *)((passphrase1) + 1) - (size_t)(const void *)(passphrase1) == 1) && (__s1_len = strlen (passphrase1), __s1_len < 4) ? (__builtin_constant_p (passphrase2) && ((size_t)(const void *)((passphrase2) + 1) - (size_t)(const void *)(passphrase2) == 1) ? __builtin_strcmp (passphrase1, passphrase2) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (passphrase2); register int __result = (((const unsigned char *) (const char *) (passphrase1))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (passphrase1))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (passphrase1))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (passphrase1))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (passphrase2) && ((size_t)(const void *)((passphrase2) + 1) - (size_t)(const void *)(passphrase2) == 1) && (__s2_len = strlen (passphrase2), __s2_len < 4) ? (__builtin_constant_p (passphrase1) && ((size_t)(const void *)((passphrase1) + 1) - (size_t)(const void *)(passphrase1) == 1) ? __builtin_strcmp (passphrase1, passphrase2) : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (passphrase1); register int __result = __s1[0] - ((const unsigned char *) (const char *) (passphrase2))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) (passphrase2))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) (passphrase2))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) (passphrase2))[3]); } } __result; }))) : __builtin_strcmp (passphrase1, passphrase2)))); }) != 0) {
9541 explicit_bzero(passphrase1, strlen(passphrase1));
9542 explicit_bzero(passphrase2, strlen(passphrase2));
9543 free(passphrase1);
9544 free(passphrase2);
9545 printf("Pass phrases do not match. Try again.\n");
9546 exit(1);
9547 }
9548 explicit_bzero(passphrase2, strlen(passphrase2));
9549 free(passphrase2);
9550 }
9551 if (!key_save_private(private, identity_file, passphrase1, comment,
9552 use_new_format, new_format_cipher, rounds)) {
9553 printf("Saving the key failed: %s.\n", identity_file);
9554 explicit_bzero(passphrase1, strlen(passphrase1));
9555 free(passphrase1);
9556 key_free(private);
9557 free(comment);
9558 exit(1);
9559 }
9560 explicit_bzero(passphrase1, strlen(passphrase1));
9561 free(passphrase1);
9562 key_free(private);
9563 free(comment);
9564 printf("Your identification has been saved with the new passphrase.\n");
9565 exit(0);
9566 }
9567 static int
9568 do_print_resource_record(struct passwd *pw, char *fname, char *hname)
9569 {
9570 Key *public;
9571 char *comment = ((void *)0);
9572 struct stat st;
9573 if (fname == ((void *)0))
9574 fatal("%s: no filename", __func__);
9575 if (stat(fname, &st) < 0) {
9576 if ((*__errno_location ()) == 2)
9577 return 0;
9578 perror(fname);
9579 exit(1);
9580 }
9581 public = key_load_public(fname, &comment);
9582 if (public != ((void *)0)) {
9583 export_dns_rr(hname, public, stdout, print_generic);
9584 key_free(public);
9585 free(comment);
9586 return 1;
9587 }
9588 if (comment)
9589 free(comment);
9590 printf("failed to read v2 public key from %s.\n", fname);
9591 exit(1);
9592 }
9593 static void
9594 do_change_comment(struct passwd *pw)
9595 {
9596 char new_comment[1024], *comment, *passphrase;
9597 Key *private;
9598 Key *public;
9599 struct stat st;
9600 FILE *f;
9601 int fd;
9602 if (!have_identity)
9603 ask_filename(pw, "Enter file in which the key is");
9604 if (stat(identity_file, &st) < 0) {
9605 perror(identity_file);
9606 exit(1);
9607 }
9608 private = key_load_private(identity_file, "", &comment);
9609 if (private == ((void *)0)) {
9610 if (identity_passphrase)
9611 passphrase = xstrdup(identity_passphrase);
9612 else if (identity_new_passphrase)
9613 passphrase = xstrdup(identity_new_passphrase);
9614 else
9615 passphrase = read_passphrase("Enter passphrase: ",
9616 0x0002);
9617 private = key_load_private(identity_file, passphrase, &comment);
9618 if (private == ((void *)0)) {
9619 explicit_bzero(passphrase, strlen(passphrase));
9620 free(passphrase);
9621 printf("Bad passphrase.\n");
9622 exit(1);
9623 }
9624 } else {
9625 passphrase = xstrdup("");
9626 }
9627 if (private->type != KEY_RSA1) {
9628 fprintf(stderr, "Comments are only supported for RSA1 keys.\n");
9629 key_free(private);
9630 exit(1);
9631 }
9632 printf("Key now has comment '%s'\n", comment);
9633 if (identity_comment) {
9634 strlcpy(new_comment, identity_comment, sizeof(new_comment));
9635 } else {
9636 printf("Enter new comment: ");
9637 fflush(stdout);
9638 if (!fgets(new_comment, sizeof(new_comment), stdin)) {
9639 explicit_bzero(passphrase, strlen(passphrase));
9640 key_free(private);
9641 exit(1);
9642 }
9643 new_comment[__extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p ("\n") && ((size_t)(const void *)(("\n") + 1) - (size_t)(const void *)("\n") == 1) ? ((__builtin_constant_p (new_comment) && ((size_t)(const void *)((new_comment) + 1) - (size_t)(const void *)(new_comment) == 1)) ? __builtin_strcspn (new_comment, "\n") : ((__r0 = ((const char *) ("\n"))[0], __r0 == '\0') ? strlen (new_comment) : ((__r1 = ((const char *) ("\n"))[1], __r1 == '\0') ? __strcspn_c1 (new_comment, __r0) : ((__r2 = ((const char *) ("\n"))[2], __r2 == '\0') ? __strcspn_c2 (new_comment, __r0, __r1) : (((const char *) ("\n"))[3] == '\0' ? __strcspn_c3 (new_comment, __r0, __r1, __r2) : __builtin_strcspn (new_comment, "\n")))))) : __builtin_strcspn (new_comment, "\n")); })] = '\0';
9644 }
9645 if (!key_save_private(private, identity_file, passphrase, new_comment,
9646 use_new_format, new_format_cipher, rounds)) {
9647 printf("Saving the key failed: %s.\n", identity_file);
9648 explicit_bzero(passphrase, strlen(passphrase));
9649 free(passphrase);
9650 key_free(private);
9651 free(comment);
9652 exit(1);
9653 }
9654 explicit_bzero(passphrase, strlen(passphrase));
9655 free(passphrase);
9656 public = key_from_private(private);
9657 key_free(private);
9658 strlcat(identity_file, ".pub", sizeof(identity_file));
9659 fd = open(identity_file, 01 | 00000400 | 01000, 0644);
9660 if (fd == -1) {
9661 printf("Could not save your public key in %s\n", identity_file);
9662 exit(1);
9663 }
9664 f = fdopen(fd, "w");
9665 if (f == ((void *)0)) {
9666 printf("fdopen %s failed\n", identity_file);
9667 exit(1);
9668 }
9669 if (!key_write(public, f))
9670 fprintf(stderr, "write key failed\n");
9671 key_free(public);
9672 fprintf(f, " %s\n", new_comment);
9673 fclose(f);
9674 free(comment);
9675 printf("The comment in your key file has been changed.\n");
9676 exit(0);
9677 }
9678 static const char *
9679 fmt_validity(u_int64_t valid_from, u_int64_t valid_to)
9680 {
9681 char from[32], to[32];
9682 static char ret[64];
9683 time_t tt;
9684 struct tm *tm;
9685 *from = *to = '\0';
9686 if (valid_from == 0 && valid_to == 0xffffffffffffffffULL)
9687 return "forever";
9688 if (valid_from != 0) {
9689 tt = valid_from > 2147483647 ? 2147483647 : valid_from;
9690 tm = localtime(&tt);
9691 strftime(from, sizeof(from), "%Y-%m-%dT%H:%M:%S", tm);
9692 }
9693 if (valid_to != 0xffffffffffffffffULL) {
9694 tt = valid_to > 2147483647 ? 2147483647 : valid_to;
9695 tm = localtime(&tt);
9696 strftime(to, sizeof(to), "%Y-%m-%dT%H:%M:%S", tm);
9697 }
9698 if (valid_from == 0) {
9699 snprintf(ret, sizeof(ret), "before %s", to);
9700 return ret;
9701 }
9702 if (valid_to == 0xffffffffffffffffULL) {
9703 snprintf(ret, sizeof(ret), "after %s", from);
9704 return ret;
9705 }
9706 snprintf(ret, sizeof(ret), "from %s to %s", from, to);
9707 return ret;
9708 }
9709 static void
9710 add_flag_option(Buffer *c, const char *name)
9711 {
9712 debug3("%s: %s", __func__, name);
9713 buffer_put_cstring(c, name);
9714 buffer_put_string(c, ((void *)0), 0);
9715 }
9716 static void
9717 add_string_option(Buffer *c, const char *name, const char *value)
9718 {
9719 Buffer b;
9720 debug3("%s: %s=%s", __func__, name, value);
9721 buffer_init(&b);
9722 buffer_put_cstring(&b, value);
9723 buffer_put_cstring(c, name);
9724 buffer_put_string(c, buffer_ptr(&b), buffer_len(&b));
9725 buffer_free(&b);
9726 }
9727 static void
9728 prepare_options_buf(Buffer *c, int which)
9729 {
9730 buffer_clear(c);
9731 if ((which & 1) != 0 &&
9732 certflags_command != ((void *)0))
9733 add_string_option(c, "force-command", certflags_command);
9734 if ((which & 2) != 0 &&
9735 (certflags_flags & (1)) != 0)
9736 add_flag_option(c, "permit-X11-forwarding");
9737 if ((which & 2) != 0 &&
9738 (certflags_flags & (1<<1)) != 0)
9739 add_flag_option(c, "permit-agent-forwarding");
9740 if ((which & 2) != 0 &&
9741 (certflags_flags & (1<<2)) != 0)
9742 add_flag_option(c, "permit-port-forwarding");
9743 if ((which & 2) != 0 &&
9744 (certflags_flags & (1<<3)) != 0)
9745 add_flag_option(c, "permit-pty");
9746 if ((which & 2) != 0 &&
9747 (certflags_flags & (1<<4)) != 0)
9748 add_flag_option(c, "permit-user-rc");
9749 if ((which & 1) != 0 &&
9750 certflags_src_addr != ((void *)0))
9751 add_string_option(c, "source-address", certflags_src_addr);
9752 }
9753 static Key *
9754 load_pkcs11_key(char *path)
9755 {
9756 Key **keys = ((void *)0), *public, *private = ((void *)0);
9757 int i, nkeys;
9758 if ((public = key_load_public(path, ((void *)0))) == ((void *)0))
9759 fatal("Couldn't load CA public key \"%s\"", path);
9760 nkeys = pkcs11_add_provider(pkcs11provider, identity_passphrase, &keys);
9761 debug3("%s: %d keys", __func__, nkeys);
9762 if (nkeys <= 0)
9763 fatal("cannot read public key from pkcs11");
9764 for (i = 0; i < nkeys; i++) {
9765 if (key_equal_public(public, keys[i])) {
9766 private = keys[i];
9767 continue;
9768 }
9769 key_free(keys[i]);
9770 }
9771 free(keys);
9772 key_free(public);
9773 return private;
9774 }
9775 static void
9776 do_ca_sign(struct passwd *pw, int argc, char **argv)
9777 {
9778 int i, fd;
9779 u_int n;
9780 Key *ca, *public;
9781 char *otmp, *tmp, *cp, *out, *comment, **plist = ((void *)0);
9782 FILE *f;
9783 int v00 = 0;
9784 if (key_type_name != ((void *)0)) {
9785 switch (key_type_from_name(key_type_name)) {
9786 case KEY_RSA_CERT_V00:
9787 case KEY_DSA_CERT_V00:
9788 v00 = 1;
9789 break;
9790 case KEY_UNSPEC:
9791 if (strcasecmp(key_type_name, "v00") == 0) {
9792 v00 = 1;
9793 break;
9794 } else if (strcasecmp(key_type_name, "v01") == 0)
9795 break;
9796 default:
9797 fprintf(stderr, "unknown key type %s\n", key_type_name);
9798 exit(1);
9799 }
9800 }
9801 pkcs11_init(1);
9802 tmp = tilde_expand_filename(ca_key_path, pw->pw_uid);
9803 if (pkcs11provider != ((void *)0)) {
9804 if ((ca = load_pkcs11_key(tmp)) == ((void *)0))
9805 fatal("No PKCS#11 key matching %s found", ca_key_path);
9806 } else if ((ca = load_identity(tmp)) == ((void *)0))
9807 fatal("Couldn't load CA key \"%s\"", tmp);
9808 free(tmp);
9809 for (i = 0; i < argc; i++) {
9810 n = 0;
9811 if (cert_principals != ((void *)0)) {
9812 otmp = tmp = xstrdup(cert_principals);
9813 plist = ((void *)0);
9814 for (; (cp = __extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p (",") && ((size_t)(const void *)((",") + 1) - (size_t)(const void *)(",") == 1) && (__r0 = ((const char *) (","))[0], ((const char *) (","))[0] != '\0') ? ((__r1 = ((const char *) (","))[1], ((const char *) (","))[1] == '\0') ? __strsep_1c (&tmp, __r0) : ((__r2 = ((const char *) (","))[2], __r2 == '\0') ? __strsep_2c (&tmp, __r0, __r1) : (((const char *) (","))[3] == '\0' ? __strsep_3c (&tmp, __r0, __r1, __r2) : __strsep_g (&tmp, ",")))) : __strsep_g (&tmp, ",")); })) != ((void *)0); n++) {
9815 plist = xrealloc(plist, n + 1, sizeof(*plist));
9816 if (*(plist[n] = xstrdup(cp)) == '\0')
9817 fatal("Empty principal name");
9818 }
9819 free(otmp);
9820 }
9821 tmp = tilde_expand_filename(argv[i], pw->pw_uid);
9822 if ((public = key_load_public(tmp, &comment)) == ((void *)0))
9823 fatal("%s: unable to open \"%s\"", __func__, tmp);
9824 if (public->type != KEY_RSA && public->type != KEY_DSA &&
9825 public->type != KEY_ECDSA && public->type != KEY_ED25519)
9826 fatal("%s: key \"%s\" type %s cannot be certified",
9827 __func__, tmp, key_type(public));
9828 if (key_to_certified(public, v00) != 0)
9829 fatal("Could not upgrade key %s to certificate", tmp);
9830 public->cert->type = cert_key_type;
9831 public->cert->serial = (u_int64_t)cert_serial;
9832 public->cert->key_id = xstrdup(cert_key_id);
9833 public->cert->nprincipals = n;
9834 public->cert->principals = plist;
9835 public->cert->valid_after = cert_valid_from;
9836 public->cert->valid_before = cert_valid_to;
9837 if (v00) {
9838 prepare_options_buf(&public->cert->critical,
9839 1|2);
9840 } else {
9841 prepare_options_buf(&public->cert->critical,
9842 1);
9843 prepare_options_buf(&public->cert->extensions,
9844 2);
9845 }
9846 public->cert->signature_key = key_from_private(ca);
9847 if (key_certify(public, ca) != 0)
9848 fatal("Couldn't not certify key %s", tmp);
9849 if ((cp = strrchr(tmp, '.')) != ((void *)0) && __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (cp) && __builtin_constant_p (".pub") && (__s1_len = strlen (cp), __s2_len = strlen (".pub"), (!((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((".pub") + 1) - (size_t)(const void *)(".pub") == 1) || __s2_len >= 4)) ? __builtin_strcmp (cp, ".pub") : (__builtin_constant_p (cp) && ((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1) && (__s1_len = strlen (cp), __s1_len < 4) ? (__builtin_constant_p (".pub") && ((size_t)(const void *)((".pub") + 1) - (size_t)(const void *)(".pub") == 1) ? __builtin_strcmp (cp, ".pub") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (".pub"); register int __result = (((const unsigned char *) (const char *) (cp))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (cp))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (cp))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (cp))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (".pub") && ((size_t)(const void *)((".pub") + 1) - (size_t)(const void *)(".pub") == 1) && (__s2_len = strlen (".pub"), __s2_len < 4) ? (__builtin_constant_p (cp) && ((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1) ? __builtin_strcmp (cp, ".pub") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (cp); register int __result = __s1[0] - ((const unsigned char *) (const char *) (".pub"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) (".pub"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) (".pub"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) (".pub"))[3]); } } __result; }))) : __builtin_strcmp (cp, ".pub")))); }) == 0)
9850 *cp = '\0';
9851 xasprintf(&out, "%s-cert.pub", tmp);
9852 free(tmp);
9853 if ((fd = open(out, 01|00000400|01000, 0644)) == -1)
9854 fatal("Could not open \"%s\" for writing: %s", out,
9855 strerror((*__errno_location ())));
9856 if ((f = fdopen(fd, "w")) == ((void *)0))
9857 fatal("%s: fdopen: %s", __func__, strerror((*__errno_location ())));
9858 if (!key_write(public, f))
9859 fatal("Could not write certified key to %s", out);
9860 fprintf(f, " %s\n", comment);
9861 fclose(f);
9862 if (!quiet) {
9863 logit("Signed %s key %s: id \"%s\" serial %llu%s%s "
9864 "valid %s", key_cert_type(public),
9865 out, public->cert->key_id,
9866 (unsigned long long)public->cert->serial,
9867 cert_principals != ((void *)0) ? " for " : "",
9868 cert_principals != ((void *)0) ? cert_principals : "",
9869 fmt_validity(cert_valid_from, cert_valid_to));
9870 }
9871 key_free(public);
9872 free(out);
9873 }
9874 pkcs11_terminate();
9875 exit(0);
9876 }
9877 static u_int64_t
9878 parse_relative_time(const char *s, time_t now)
9879 {
9880 int64_t mul, secs;
9881 mul = *s == '-' ? -1 : 1;
9882 if ((secs = convtime(s + 1)) == -1)
9883 fatal("Invalid relative certificate time %s", s);
9884 if (mul == -1 && secs > now)
9885 fatal("Certificate time %s cannot be represented", s);
9886 return now + (u_int64_t)(secs * mul);
9887 }
9888 static u_int64_t
9889 parse_absolute_time(const char *s)
9890 {
9891 struct tm tm;
9892 time_t tt;
9893 char buf[32], *fmt;
9894 switch (strlen(s)) {
9895 case 8:
9896 fmt = "%Y-%m-%d";
9897 snprintf(buf, sizeof(buf), "%.4s-%.2s-%.2s", s, s + 4, s + 6);
9898 break;
9899 case 14:
9900 fmt = "%Y-%m-%dT%H:%M:%S";
9901 snprintf(buf, sizeof(buf), "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s",
9902 s, s + 4, s + 6, s + 8, s + 10, s + 12);
9903 break;
9904 default:
9905 fatal("Invalid certificate time format %s", s);
9906 }
9907 memset(&tm, 0, sizeof(tm));
9908 if (strptime(buf, fmt, &tm) == ((void *)0))
9909 fatal("Invalid certificate time %s", s);
9910 if ((tt = mktime(&tm)) < 0)
9911 fatal("Certificate time %s cannot be represented", s);
9912 return (u_int64_t)tt;
9913 }
9914 static void
9915 parse_cert_times(char *timespec)
9916 {
9917 char *from, *to;
9918 time_t now = time(((void *)0));
9919 int64_t secs;
9920 if (*timespec == '+' && (__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (timespec) && (':') == '\0' ? (char *) __rawmemchr (timespec, ':') : __builtin_strchr (timespec, ':'))) == ((void *)0)) {
9921 if ((secs = convtime(timespec + 1)) == -1)
9922 fatal("Invalid relative certificate life %s", timespec);
9923 cert_valid_to = now + secs;
9924 cert_valid_from = ((now - 59)/ 60) * 60;
9925 return;
9926 }
9927 from = xstrdup(timespec);
9928 to = (__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (from) && (':') == '\0' ? (char *) __rawmemchr (from, ':') : __builtin_strchr (from, ':')));
9929 if (to == ((void *)0) || from == to || *(to + 1) == '\0')
9930 fatal("Invalid certificate life specification %s", timespec);
9931 *to++ = '\0';
9932 if (*from == '-' || *from == '+')
9933 cert_valid_from = parse_relative_time(from, now);
9934 else
9935 cert_valid_from = parse_absolute_time(from);
9936 if (*to == '-' || *to == '+')
9937 cert_valid_to = parse_relative_time(to, now);
9938 else
9939 cert_valid_to = parse_absolute_time(to);
9940 if (cert_valid_to <= cert_valid_from)
9941 fatal("Empty certificate validity interval");
9942 free(from);
9943 }
9944 static void
9945 add_cert_option(char *opt)
9946 {
9947 char *val;
9948 if (strcasecmp(opt, "clear") == 0)
9949 certflags_flags = 0;
9950 else if (strcasecmp(opt, "no-x11-forwarding") == 0)
9951 certflags_flags &= ~(1);
9952 else if (strcasecmp(opt, "permit-x11-forwarding") == 0)
9953 certflags_flags |= (1);
9954 else if (strcasecmp(opt, "no-agent-forwarding") == 0)
9955 certflags_flags &= ~(1<<1);
9956 else if (strcasecmp(opt, "permit-agent-forwarding") == 0)
9957 certflags_flags |= (1<<1);
9958 else if (strcasecmp(opt, "no-port-forwarding") == 0)
9959 certflags_flags &= ~(1<<2);
9960 else if (strcasecmp(opt, "permit-port-forwarding") == 0)
9961 certflags_flags |= (1<<2);
9962 else if (strcasecmp(opt, "no-pty") == 0)
9963 certflags_flags &= ~(1<<3);
9964 else if (strcasecmp(opt, "permit-pty") == 0)
9965 certflags_flags |= (1<<3);
9966 else if (strcasecmp(opt, "no-user-rc") == 0)
9967 certflags_flags &= ~(1<<4);
9968 else if (strcasecmp(opt, "permit-user-rc") == 0)
9969 certflags_flags |= (1<<4);
9970 else if (strncasecmp(opt, "force-command=", 14) == 0) {
9971 val = opt + 14;
9972 if (*val == '\0')
9973 fatal("Empty force-command option");
9974 if (certflags_command != ((void *)0))
9975 fatal("force-command already specified");
9976 certflags_command = xstrdup(val);
9977 } else if (strncasecmp(opt, "source-address=", 15) == 0) {
9978 val = opt + 15;
9979 if (*val == '\0')
9980 fatal("Empty source-address option");
9981 if (certflags_src_addr != ((void *)0))
9982 fatal("source-address already specified");
9983 if (addr_match_cidr_list(((void *)0), val) != 0)
9984 fatal("Invalid source-address list");
9985 certflags_src_addr = xstrdup(val);
9986 } else
9987 fatal("Unsupported certificate option \"%s\"", opt);
9988 }
9989 static void
9990 show_options(const Buffer *optbuf, int v00, int in_critical)
9991 {
9992 char *name;
9993 u_char *data;
9994 u_int dlen;
9995 Buffer options, option;
9996 buffer_init(&options);
9997 buffer_append(&options, buffer_ptr(optbuf), buffer_len(optbuf));
9998 buffer_init(&option);
9999 while (buffer_len(&options) != 0) {
10000 name = buffer_get_string(&options, ((void *)0));
10001 data = buffer_get_string_ptr(&options, &dlen);
10002 buffer_append(&option, data, dlen);
10003 printf(" %s", name);
10004 if ((v00 || !in_critical) &&
10005 (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("permit-X11-forwarding") && (__s1_len = strlen (name), __s2_len = strlen ("permit-X11-forwarding"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("permit-X11-forwarding") + 1) - (size_t)(const void *)("permit-X11-forwarding") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "permit-X11-forwarding") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? (__builtin_constant_p ("permit-X11-forwarding") && ((size_t)(const void *)(("permit-X11-forwarding") + 1) - (size_t)(const void *)("permit-X11-forwarding") == 1) ? __builtin_strcmp (name, "permit-X11-forwarding") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("permit-X11-forwarding"); register int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("permit-X11-forwarding") && ((size_t)(const void *)(("permit-X11-forwarding") + 1) - (size_t)(const void *)("permit-X11-forwarding") == 1) && (__s2_len = strlen ("permit-X11-forwarding"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "permit-X11-forwarding") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (name); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("permit-X11-forwarding"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("permit-X11-forwarding"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("permit-X11-forwarding"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("permit-X11-forwarding"))[3]); } } __result; }))) : __builtin_strcmp (name, "permit-X11-forwarding")))); }) == 0 ||
10006 __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("permit-agent-forwarding") && (__s1_len = strlen (name), __s2_len = strlen ("permit-agent-forwarding"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("permit-agent-forwarding") + 1) - (size_t)(const void *)("permit-agent-forwarding") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "permit-agent-forwarding") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? (__builtin_constant_p ("permit-agent-forwarding") && ((size_t)(const void *)(("permit-agent-forwarding") + 1) - (size_t)(const void *)("permit-agent-forwarding") == 1) ? __builtin_strcmp (name, "permit-agent-forwarding") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("permit-agent-forwarding"); register int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("permit-agent-forwarding") && ((size_t)(const void *)(("permit-agent-forwarding") + 1) - (size_t)(const void *)("permit-agent-forwarding") == 1) && (__s2_len = strlen ("permit-agent-forwarding"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "permit-agent-forwarding") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (name); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("permit-agent-forwarding"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("permit-agent-forwarding"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("permit-agent-forwarding"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("permit-agent-forwarding"))[3]); } } __result; }))) : __builtin_strcmp (name, "permit-agent-forwarding")))); }) == 0 ||
10007 __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("permit-port-forwarding") && (__s1_len = strlen (name), __s2_len = strlen ("permit-port-forwarding"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("permit-port-forwarding") + 1) - (size_t)(const void *)("permit-port-forwarding") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "permit-port-forwarding") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? (__builtin_constant_p ("permit-port-forwarding") && ((size_t)(const void *)(("permit-port-forwarding") + 1) - (size_t)(const void *)("permit-port-forwarding") == 1) ? __builtin_strcmp (name, "permit-port-forwarding") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("permit-port-forwarding"); register int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("permit-port-forwarding") && ((size_t)(const void *)(("permit-port-forwarding") + 1) - (size_t)(const void *)("permit-port-forwarding") == 1) && (__s2_len = strlen ("permit-port-forwarding"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "permit-port-forwarding") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (name); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("permit-port-forwarding"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("permit-port-forwarding"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("permit-port-forwarding"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("permit-port-forwarding"))[3]); } } __result; }))) : __builtin_strcmp (name, "permit-port-forwarding")))); }) == 0 ||
10008 __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("permit-pty") && (__s1_len = strlen (name), __s2_len = strlen ("permit-pty"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("permit-pty") + 1) - (size_t)(const void *)("permit-pty") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "permit-pty") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? (__builtin_constant_p ("permit-pty") && ((size_t)(const void *)(("permit-pty") + 1) - (size_t)(const void *)("permit-pty") == 1) ? __builtin_strcmp (name, "permit-pty") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("permit-pty"); register int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("permit-pty") && ((size_t)(const void *)(("permit-pty") + 1) - (size_t)(const void *)("permit-pty") == 1) && (__s2_len = strlen ("permit-pty"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "permit-pty") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (name); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("permit-pty"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("permit-pty"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("permit-pty"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("permit-pty"))[3]); } } __result; }))) : __builtin_strcmp (name, "permit-pty")))); }) == 0 ||
10009 __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("permit-user-rc") && (__s1_len = strlen (name), __s2_len = strlen ("permit-user-rc"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("permit-user-rc") + 1) - (size_t)(const void *)("permit-user-rc") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "permit-user-rc") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? (__builtin_constant_p ("permit-user-rc") && ((size_t)(const void *)(("permit-user-rc") + 1) - (size_t)(const void *)("permit-user-rc") == 1) ? __builtin_strcmp (name, "permit-user-rc") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("permit-user-rc"); register int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("permit-user-rc") && ((size_t)(const void *)(("permit-user-rc") + 1) - (size_t)(const void *)("permit-user-rc") == 1) && (__s2_len = strlen ("permit-user-rc"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "permit-user-rc") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (name); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("permit-user-rc"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("permit-user-rc"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("permit-user-rc"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("permit-user-rc"))[3]); } } __result; }))) : __builtin_strcmp (name, "permit-user-rc")))); }) == 0))
10010 printf("\n");
10011 else if ((v00 || in_critical) &&
10012 (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("force-command") && (__s1_len = strlen (name), __s2_len = strlen ("force-command"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("force-command") + 1) - (size_t)(const void *)("force-command") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "force-command") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? (__builtin_constant_p ("force-command") && ((size_t)(const void *)(("force-command") + 1) - (size_t)(const void *)("force-command") == 1) ? __builtin_strcmp (name, "force-command") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("force-command"); register int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("force-command") && ((size_t)(const void *)(("force-command") + 1) - (size_t)(const void *)("force-command") == 1) && (__s2_len = strlen ("force-command"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "force-command") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (name); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("force-command"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("force-command"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("force-command"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("force-command"))[3]); } } __result; }))) : __builtin_strcmp (name, "force-command")))); }) == 0 ||
10013 __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("source-address") && (__s1_len = strlen (name), __s2_len = strlen ("source-address"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("source-address") + 1) - (size_t)(const void *)("source-address") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "source-address") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? (__builtin_constant_p ("source-address") && ((size_t)(const void *)(("source-address") + 1) - (size_t)(const void *)("source-address") == 1) ? __builtin_strcmp (name, "source-address") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("source-address"); register int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("source-address") && ((size_t)(const void *)(("source-address") + 1) - (size_t)(const void *)("source-address") == 1) && (__s2_len = strlen ("source-address"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "source-address") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (name); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("source-address"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("source-address"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("source-address"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("source-address"))[3]); } } __result; }))) : __builtin_strcmp (name, "source-address")))); }) == 0)) {
10014 data = buffer_get_string(&option, ((void *)0));
10015 printf(" %s\n", data);
10016 free(data);
10017 } else {
10018 printf(" UNKNOWN OPTION (len %u)\n",
10019 buffer_len(&option));
10020 buffer_clear(&option);
10021 }
10022 free(name);
10023 if (buffer_len(&option) != 0)
10024 fatal("Option corrupt: extra data at end");
10025 }
10026 buffer_free(&option);
10027 buffer_free(&options);
10028 }
10029 static void
10030 do_show_cert(struct passwd *pw)
10031 {
10032 Key *key;
10033 struct stat st;
10034 char *key_fp, *ca_fp;
10035 u_int i, v00;
10036 if (!have_identity)
10037 ask_filename(pw, "Enter file in which the key is");
10038 if (stat(identity_file, &st) < 0)
10039 fatal("%s: %s: %s", __progname, identity_file, strerror((*__errno_location ())));
10040 if ((key = key_load_public(identity_file, ((void *)0))) == ((void *)0))
10041 fatal("%s is not a public key", identity_file);
10042 if (!key_is_cert(key))
10043 fatal("%s is not a certificate", identity_file);
10044 v00 = key->type == KEY_RSA_CERT_V00 || key->type == KEY_DSA_CERT_V00;
10045 key_fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
10046 ca_fp = key_fingerprint(key->cert->signature_key,
10047 SSH_FP_MD5, SSH_FP_HEX);
10048 printf("%s:\n", identity_file);
10049 printf(" Type: %s %s certificate\n", key_ssh_name(key),
10050 key_cert_type(key));
10051 printf(" Public key: %s %s\n", key_type(key), key_fp);
10052 printf(" Signing CA: %s %s\n",
10053 key_type(key->cert->signature_key), ca_fp);
10054 printf(" Key ID: \"%s\"\n", key->cert->key_id);
10055 if (!v00) {
10056 printf(" Serial: %llu\n",
10057 (unsigned long long)key->cert->serial);
10058 }
10059 printf(" Valid: %s\n",
10060 fmt_validity(key->cert->valid_after, key->cert->valid_before));
10061 printf(" Principals: ");
10062 if (key->cert->nprincipals == 0)
10063 printf("(none)\n");
10064 else {
10065 for (i = 0; i < key->cert->nprincipals; i++)
10066 printf("\n %s",
10067 key->cert->principals[i]);
10068 printf("\n");
10069 }
10070 printf(" Critical Options: ");
10071 if (buffer_len(&key->cert->critical) == 0)
10072 printf("(none)\n");
10073 else {
10074 printf("\n");
10075 show_options(&key->cert->critical, v00, 1);
10076 }
10077 if (!v00) {
10078 printf(" Extensions: ");
10079 if (buffer_len(&key->cert->extensions) == 0)
10080 printf("(none)\n");
10081 else {
10082 printf("\n");
10083 show_options(&key->cert->extensions, v00, 0);
10084 }
10085 }
10086 exit(0);
10087 }
10088 static void
10089 load_krl(const char *path, struct ssh_krl **krlp)
10090 {
10091 Buffer krlbuf;
10092 int fd;
10093 buffer_init(&krlbuf);
10094 if ((fd = open(path, 00)) == -1)
10095 fatal("open %s: %s", path, strerror((*__errno_location ())));
10096 if (!key_load_file(fd, path, &krlbuf))
10097 fatal("Unable to load KRL");
10098 close(fd);
10099 if (ssh_krl_from_blob(&krlbuf, krlp, ((void *)0), 0) != 0 ||
10100 *krlp == ((void *)0))
10101 fatal("Invalid KRL file");
10102 buffer_free(&krlbuf);
10103 }
10104 static void
10105 update_krl_from_file(struct passwd *pw, const char *file, const Key *ca,
10106 struct ssh_krl *krl)
10107 {
10108 Key *key = ((void *)0);
10109 u_long lnum = 0;
10110 char *path, *cp, *ep, line[8192];
10111 unsigned long long serial, serial2;
10112 int i, was_explicit_key, was_sha1, r;
10113 FILE *krl_spec;
10114 path = tilde_expand_filename(file, pw->pw_uid);
10115 if (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (path) && __builtin_constant_p ("-") && (__s1_len = strlen (path), __s2_len = strlen ("-"), (!((size_t)(const void *)((path) + 1) - (size_t)(const void *)(path) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (path, "-") : (__builtin_constant_p (path) && ((size_t)(const void *)((path) + 1) - (size_t)(const void *)(path) == 1) && (__s1_len = strlen (path), __s1_len < 4) ? (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) ? __builtin_strcmp (path, "-") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("-"); register int __result = (((const unsigned char *) (const char *) (path))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (path))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (path))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (path))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) && (__s2_len = strlen ("-"), __s2_len < 4) ? (__builtin_constant_p (path) && ((size_t)(const void *)((path) + 1) - (size_t)(const void *)(path) == 1) ? __builtin_strcmp (path, "-") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (path); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("-"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("-"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("-"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("-"))[3]); } } __result; }))) : __builtin_strcmp (path, "-")))); }) == 0) {
10116 krl_spec = stdin;
10117 free(path);
10118 path = xstrdup("(standard input)");
10119 } else if ((krl_spec = fopen(path, "r")) == ((void *)0))
10120 fatal("fopen %s: %s", path, strerror((*__errno_location ())));
10121 if (!quiet)
10122 printf("Revoking from %s\n", path);
10123 while (read_keyfile_line(krl_spec, path, line, sizeof(line),
10124 &lnum) == 0) {
10125 was_explicit_key = was_sha1 = 0;
10126 cp = line + __extension__ ({ char __a0, __a1, __a2; (__builtin_constant_p (" \t") && ((size_t)(const void *)((" \t") + 1) - (size_t)(const void *)(" \t") == 1) ? ((__builtin_constant_p (line) && ((size_t)(const void *)((line) + 1) - (size_t)(const void *)(line) == 1)) ? __builtin_strspn (line, " \t") : ((__a0 = ((const char *) (" \t"))[0], __a0 == '\0') ? ((void) (line), (size_t) 0) : ((__a1 = ((const char *) (" \t"))[1], __a1 == '\0') ? __strspn_c1 (line, __a0) : ((__a2 = ((const char *) (" \t"))[2], __a2 == '\0') ? __strspn_c2 (line, __a0, __a1) : (((const char *) (" \t"))[3] == '\0' ? __strspn_c3 (line, __a0, __a1, __a2) : __builtin_strspn (line, " \t")))))) : __builtin_strspn (line, " \t")); });
10127 for (i = 0, r = -1; cp[i] != '\0'; i++) {
10128 if (cp[i] == '#' || cp[i] == '\n') {
10129 cp[i] = '\0';
10130 break;
10131 }
10132 if (cp[i] == ' ' || cp[i] == '\t') {
10133 if (r == -1)
10134 r = i;
10135 } else
10136 r = -1;
10137 }
10138 if (r != -1)
10139 cp[r] = '\0';
10140 if (*cp == '\0')
10141 continue;
10142 if (strncasecmp(cp, "serial:", 7) == 0) {
10143 if (ca == ((void *)0)) {
10144 fatal("revoking certificates by serial number "
10145 "requires specification of a CA key");
10146 }
10147 cp += 7;
10148 cp = cp + __extension__ ({ char __a0, __a1, __a2; (__builtin_constant_p (" \t") && ((size_t)(const void *)((" \t") + 1) - (size_t)(const void *)(" \t") == 1) ? ((__builtin_constant_p (cp) && ((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1)) ? __builtin_strspn (cp, " \t") : ((__a0 = ((const char *) (" \t"))[0], __a0 == '\0') ? ((void) (cp), (size_t) 0) : ((__a1 = ((const char *) (" \t"))[1], __a1 == '\0') ? __strspn_c1 (cp, __a0) : ((__a2 = ((const char *) (" \t"))[2], __a2 == '\0') ? __strspn_c2 (cp, __a0, __a1) : (((const char *) (" \t"))[3] == '\0' ? __strspn_c3 (cp, __a0, __a1, __a2) : __builtin_strspn (cp, " \t")))))) : __builtin_strspn (cp, " \t")); });
10149 (*__errno_location ()) = 0;
10150 serial = strtoull(cp, &ep, 0);
10151 if (*cp == '\0' || (*ep != '\0' && *ep != '-'))
10152 fatal("%s:%lu: invalid serial \"%s\"",
10153 path, lnum, cp);
10154 if ((*__errno_location ()) == 34 && serial == (9223372036854775807LL * 2ULL + 1))
10155 fatal("%s:%lu: serial out of range",
10156 path, lnum);
10157 serial2 = serial;
10158 if (*ep == '-') {
10159 cp = ep + 1;
10160 (*__errno_location ()) = 0;
10161 serial2 = strtoull(cp, &ep, 0);
10162 if (*cp == '\0' || *ep != '\0')
10163 fatal("%s:%lu: invalid serial \"%s\"",
10164 path, lnum, cp);
10165 if ((*__errno_location ()) == 34 && serial2 == (9223372036854775807LL * 2ULL + 1))
10166 fatal("%s:%lu: serial out of range",
10167 path, lnum);
10168 if (serial2 <= serial)
10169 fatal("%s:%lu: invalid serial range "
10170 "%llu:%llu", path, lnum,
10171 (unsigned long long)serial,
10172 (unsigned long long)serial2);
10173 }
10174 if (ssh_krl_revoke_cert_by_serial_range(krl,
10175 ca, serial, serial2) != 0) {
10176 fatal("%s: revoke serial failed",
10177 __func__);
10178 }
10179 } else if (strncasecmp(cp, "id:", 3) == 0) {
10180 if (ca == ((void *)0)) {
10181 fatal("revoking certificates by key ID "
10182 "requires specification of a CA key");
10183 }
10184 cp += 3;
10185 cp = cp + __extension__ ({ char __a0, __a1, __a2; (__builtin_constant_p (" \t") && ((size_t)(const void *)((" \t") + 1) - (size_t)(const void *)(" \t") == 1) ? ((__builtin_constant_p (cp) && ((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1)) ? __builtin_strspn (cp, " \t") : ((__a0 = ((const char *) (" \t"))[0], __a0 == '\0') ? ((void) (cp), (size_t) 0) : ((__a1 = ((const char *) (" \t"))[1], __a1 == '\0') ? __strspn_c1 (cp, __a0) : ((__a2 = ((const char *) (" \t"))[2], __a2 == '\0') ? __strspn_c2 (cp, __a0, __a1) : (((const char *) (" \t"))[3] == '\0' ? __strspn_c3 (cp, __a0, __a1, __a2) : __builtin_strspn (cp, " \t")))))) : __builtin_strspn (cp, " \t")); });
10186 if (ssh_krl_revoke_cert_by_key_id(krl, ca, cp) != 0)
10187 fatal("%s: revoke key ID failed", __func__);
10188 } else {
10189 if (strncasecmp(cp, "key:", 4) == 0) {
10190 cp += 4;
10191 cp = cp + __extension__ ({ char __a0, __a1, __a2; (__builtin_constant_p (" \t") && ((size_t)(const void *)((" \t") + 1) - (size_t)(const void *)(" \t") == 1) ? ((__builtin_constant_p (cp) && ((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1)) ? __builtin_strspn (cp, " \t") : ((__a0 = ((const char *) (" \t"))[0], __a0 == '\0') ? ((void) (cp), (size_t) 0) : ((__a1 = ((const char *) (" \t"))[1], __a1 == '\0') ? __strspn_c1 (cp, __a0) : ((__a2 = ((const char *) (" \t"))[2], __a2 == '\0') ? __strspn_c2 (cp, __a0, __a1) : (((const char *) (" \t"))[3] == '\0' ? __strspn_c3 (cp, __a0, __a1, __a2) : __builtin_strspn (cp, " \t")))))) : __builtin_strspn (cp, " \t")); });
10192 was_explicit_key = 1;
10193 } else if (strncasecmp(cp, "sha1:", 5) == 0) {
10194 cp += 5;
10195 cp = cp + __extension__ ({ char __a0, __a1, __a2; (__builtin_constant_p (" \t") && ((size_t)(const void *)((" \t") + 1) - (size_t)(const void *)(" \t") == 1) ? ((__builtin_constant_p (cp) && ((size_t)(const void *)((cp) + 1) - (size_t)(const void *)(cp) == 1)) ? __builtin_strspn (cp, " \t") : ((__a0 = ((const char *) (" \t"))[0], __a0 == '\0') ? ((void) (cp), (size_t) 0) : ((__a1 = ((const char *) (" \t"))[1], __a1 == '\0') ? __strspn_c1 (cp, __a0) : ((__a2 = ((const char *) (" \t"))[2], __a2 == '\0') ? __strspn_c2 (cp, __a0, __a1) : (((const char *) (" \t"))[3] == '\0' ? __strspn_c3 (cp, __a0, __a1, __a2) : __builtin_strspn (cp, " \t")))))) : __builtin_strspn (cp, " \t")); });
10196 was_sha1 = 1;
10197 } else {
10198 }
10199 if ((key = key_new(KEY_UNSPEC)) == ((void *)0))
10200 fatal("key_new");
10201 if (key_read(key, &cp) != 1)
10202 fatal("%s:%lu: invalid key", path, lnum);
10203 if (was_explicit_key)
10204 r = ssh_krl_revoke_key_explicit(krl, key);
10205 else if (was_sha1)
10206 r = ssh_krl_revoke_key_sha1(krl, key);
10207 else
10208 r = ssh_krl_revoke_key(krl, key);
10209 if (r != 0)
10210 fatal("%s: revoke key failed", __func__);
10211 key_free(key);
10212 }
10213 }
10214 if (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (path) && __builtin_constant_p ("-") && (__s1_len = strlen (path), __s2_len = strlen ("-"), (!((size_t)(const void *)((path) + 1) - (size_t)(const void *)(path) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (path, "-") : (__builtin_constant_p (path) && ((size_t)(const void *)((path) + 1) - (size_t)(const void *)(path) == 1) && (__s1_len = strlen (path), __s1_len < 4) ? (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) ? __builtin_strcmp (path, "-") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("-"); register int __result = (((const unsigned char *) (const char *) (path))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (path))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (path))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (path))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) && (__s2_len = strlen ("-"), __s2_len < 4) ? (__builtin_constant_p (path) && ((size_t)(const void *)((path) + 1) - (size_t)(const void *)(path) == 1) ? __builtin_strcmp (path, "-") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (path); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("-"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("-"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("-"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("-"))[3]); } } __result; }))) : __builtin_strcmp (path, "-")))); }) != 0)
10215 fclose(krl_spec);
10216 free(path);
10217 }
10218 static void
10219 do_gen_krl(struct passwd *pw, int updating, int argc, char **argv)
10220 {
10221 struct ssh_krl *krl;
10222 struct stat sb;
10223 Key *ca = ((void *)0);
10224 int fd, i;
10225 char *tmp;
10226 Buffer kbuf;
10227 if (*identity_file == '\0')
10228 fatal("KRL generation requires an output file");
10229 if (stat(identity_file, &sb) == -1) {
10230 if ((*__errno_location ()) != 2)
10231 fatal("Cannot access KRL \"%s\": %s",
10232 identity_file, strerror((*__errno_location ())));
10233 if (updating)
10234 fatal("KRL \"%s\" does not exist", identity_file);
10235 }
10236 if (ca_key_path != ((void *)0)) {
10237 tmp = tilde_expand_filename(ca_key_path, pw->pw_uid);
10238 if ((ca = key_load_public(tmp, ((void *)0))) == ((void *)0))
10239 fatal("Cannot load CA public key %s", tmp);
10240 free(tmp);
10241 }
10242 if (updating)
10243 load_krl(identity_file, &krl);
10244 else if ((krl = ssh_krl_init()) == ((void *)0))
10245 fatal("couldn't create KRL");
10246 if (cert_serial != 0)
10247 ssh_krl_set_version(krl, cert_serial);
10248 if (identity_comment != ((void *)0))
10249 ssh_krl_set_comment(krl, identity_comment);
10250 for (i = 0; i < argc; i++)
10251 update_krl_from_file(pw, argv[i], ca, krl);
10252 buffer_init(&kbuf);
10253 if (ssh_krl_to_blob(krl, &kbuf, ((void *)0), 0) != 0)
10254 fatal("Couldn't generate KRL");
10255 if ((fd = open(identity_file, 01|00000400|01000, 0644)) == -1)
10256 fatal("open %s: %s", identity_file, strerror((*__errno_location ())));
10257 if (atomicio((ssize_t (*)(int, void *, size_t))write, fd, buffer_ptr(&kbuf), buffer_len(&kbuf)) !=
10258 buffer_len(&kbuf))
10259 fatal("write %s: %s", identity_file, strerror((*__errno_location ())));
10260 close(fd);
10261 buffer_free(&kbuf);
10262 ssh_krl_free(krl);
10263 if (ca != ((void *)0))
10264 key_free(ca);
10265 }
10266 static void
10267 do_check_krl(struct passwd *pw, int argc, char **argv)
10268 {
10269 int i, r, ret = 0;
10270 char *comment;
10271 struct ssh_krl *krl;
10272 Key *k;
10273 if (*identity_file == '\0')
10274 fatal("KRL checking requires an input file");
10275 load_krl(identity_file, &krl);
10276 for (i = 0; i < argc; i++) {
10277 if ((k = key_load_public(argv[i], &comment)) == ((void *)0))
10278 fatal("Cannot load public key %s", argv[i]);
10279 r = ssh_krl_check_key(krl, k);
10280 printf("%s%s%s%s: %s\n", argv[i],
10281 *comment ? " (" : "", comment, *comment ? ")" : "",
10282 r == 0 ? "ok" : "REVOKED");
10283 if (r != 0)
10284 ret = 1;
10285 key_free(k);
10286 free(comment);
10287 }
10288 ssh_krl_free(krl);
10289 exit(ret);
10290 }
10291 static void
10292 usage(void)
10293 {
10294 fprintf(stderr, "usage: %s [options]\n", __progname);
10295 fprintf(stderr, "Options:\n");
10296 fprintf(stderr, " -A Generate non-existent host keys for all key types.\n");
10297 fprintf(stderr, " -a number Number of KDF rounds for new key format or moduli primality tests.\n");
10298 fprintf(stderr, " -B Show bubblebabble digest of key file.\n");
10299 fprintf(stderr, " -b bits Number of bits in the key to create.\n");
10300 fprintf(stderr, " -C comment Provide new comment.\n");
10301 fprintf(stderr, " -c Change comment in private and public key files.\n");
10302 fprintf(stderr, " -D pkcs11 Download public key from pkcs11 token.\n");
10303 fprintf(stderr, " -e Export OpenSSH to foreign format key file.\n");
10304 fprintf(stderr, " -F hostname Find hostname in known hosts file.\n");
10305 fprintf(stderr, " -f filename Filename of the key file.\n");
10306 fprintf(stderr, " -G file Generate candidates for DH-GEX moduli.\n");
10307 fprintf(stderr, " -g Use generic DNS resource record format.\n");
10308 fprintf(stderr, " -H Hash names in known_hosts file.\n");
10309 fprintf(stderr, " -h Generate host certificate instead of a user certificate.\n");
10310 fprintf(stderr, " -I key_id Key identifier to include in certificate.\n");
10311 fprintf(stderr, " -i Import foreign format to OpenSSH key file.\n");
10312 fprintf(stderr, " -J number Screen this number of moduli lines.\n");
10313 fprintf(stderr, " -j number Start screening moduli at specified line.\n");
10314 fprintf(stderr, " -K checkpt Write checkpoints to this file.\n");
10315 fprintf(stderr, " -k Generate a KRL file.\n");
10316 fprintf(stderr, " -L Print the contents of a certificate.\n");
10317 fprintf(stderr, " -l Show fingerprint of key file.\n");
10318 fprintf(stderr, " -M memory Amount of memory (MB) to use for generating DH-GEX moduli.\n");
10319 fprintf(stderr, " -m key_fmt Conversion format for -e/-i (PEM|PKCS8|RFC4716).\n");
10320 fprintf(stderr, " -N phrase Provide new passphrase.\n");
10321 fprintf(stderr, " -n name,... User/host principal names to include in certificate\n");
10322 fprintf(stderr, " -O option Specify a certificate option.\n");
10323 fprintf(stderr, " -o Enforce new private key format.\n");
10324 fprintf(stderr, " -P phrase Provide old passphrase.\n");
10325 fprintf(stderr, " -p Change passphrase of private key file.\n");
10326 fprintf(stderr, " -Q Test whether key(s) are revoked in KRL.\n");
10327 fprintf(stderr, " -q Quiet.\n");
10328 fprintf(stderr, " -R hostname Remove host from known_hosts file.\n");
10329 fprintf(stderr, " -r hostname Print DNS resource record.\n");
10330 fprintf(stderr, " -S start Start point (hex) for generating DH-GEX moduli.\n");
10331 fprintf(stderr, " -s ca_key Certify keys with CA key.\n");
10332 fprintf(stderr, " -T file Screen candidates for DH-GEX moduli.\n");
10333 fprintf(stderr, " -t type Specify type of key to create.\n");
10334 fprintf(stderr, " -u Update KRL rather than creating a new one.\n");
10335 fprintf(stderr, " -V from:to Specify certificate validity interval.\n");
10336 fprintf(stderr, " -v Verbose.\n");
10337 fprintf(stderr, " -W gen Generator to use for generating DH-GEX moduli.\n");
10338 fprintf(stderr, " -y Read private key file and print public key.\n");
10339 fprintf(stderr, " -Z cipher Specify a cipher for new private key format.\n");
10340 fprintf(stderr, " -z serial Specify a serial number.\n");
10341 exit(1);
10342 }
10343 int
10344 main(int argc, char **argv)
10345 {
10346 char dotsshdir[4096], comment[1024], *passphrase1, *passphrase2;
10347 char *checkpoint = ((void *)0);
10348 char out_file[4096], *ep, *rr_hostname = ((void *)0);
10349 Key *private, *public;
10350 struct passwd *pw;
10351 struct stat st;
10352 int opt, type, fd;
10353 u_int32_t memory = 0, generator_wanted = 0;
10354 int do_gen_candidates = 0, do_screen_candidates = 0;
10355 int gen_all_hostkeys = 0, gen_krl = 0, update_krl = 0, check_krl = 0;
10356 unsigned long start_lineno = 0, lines_to_process = 0;
10357 BIGNUM *start = ((void *)0);
10358 FILE *f;
10359 const char *errstr;
10360 extern int BSDoptind;
10361 extern char *BSDoptarg;
10362 sanitise_stdfd();
10363 __progname = ssh_get_progname(argv[0]);
10364 ssh_OpenSSL_add_all_algorithms();
10365 log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1);
10366 seed_rng();
10367 pw = getpwuid(getuid());
10368 if (!pw) {
10369 printf("No user exists for uid %lu\n", (u_long)getuid());
10370 exit(1);
10371 }
10372 if (gethostname(hostname, sizeof(hostname)) < 0) {
10373 perror("gethostname");
10374 exit(1);
10375 }
10376 while ((opt = BSDgetopt(argc, argv, "ABHLQXceghiklopquvxy" "C:D:F:G:I:J:K:M:N:O:P:R:S:T:V:W:Z:a:b:f:g:j:m:n:r:s:t:z:")
10377 ) != -1) {
10378 switch (opt) {
10379 case 'A':
10380 gen_all_hostkeys = 1;
10381 break;
10382 case 'b':
10383 bits = (u_int32_t)strtonum(BSDoptarg, 256, 32768, &errstr);
10384 if (errstr)
10385 fatal("Bits has bad value %s (%s)",
10386 BSDoptarg, errstr);
10387 break;
10388 case 'F':
10389 find_host = 1;
10390 rr_hostname = BSDoptarg;
10391 break;
10392 case 'H':
10393 hash_hosts = 1;
10394 break;
10395 case 'I':
10396 cert_key_id = BSDoptarg;
10397 break;
10398 case 'J':
10399 lines_to_process = strtoul(BSDoptarg, ((void *)0), 10);
10400 break;
10401 case 'j':
10402 start_lineno = strtoul(BSDoptarg, ((void *)0), 10);
10403 break;
10404 case 'R':
10405 delete_host = 1;
10406 rr_hostname = BSDoptarg;
10407 break;
10408 case 'L':
10409 show_cert = 1;
10410 break;
10411 case 'l':
10412 print_fingerprint = 1;
10413 break;
10414 case 'B':
10415 print_bubblebabble = 1;
10416 break;
10417 case 'm':
10418 if (strcasecmp(BSDoptarg, "RFC4716") == 0 ||
10419 strcasecmp(BSDoptarg, "ssh2") == 0) {
10420 convert_format = FMT_RFC4716;
10421 break;
10422 }
10423 if (strcasecmp(BSDoptarg, "PKCS8") == 0) {
10424 convert_format = FMT_PKCS8;
10425 break;
10426 }
10427 if (strcasecmp(BSDoptarg, "PEM") == 0) {
10428 convert_format = FMT_PEM;
10429 break;
10430 }
10431 fatal("Unsupported conversion format \"%s\"", BSDoptarg);
10432 case 'n':
10433 cert_principals = BSDoptarg;
10434 break;
10435 case 'o':
10436 use_new_format = 1;
10437 break;
10438 case 'p':
10439 change_passphrase = 1;
10440 break;
10441 case 'c':
10442 change_comment = 1;
10443 break;
10444 case 'f':
10445 if (strlcpy(identity_file, BSDoptarg, sizeof(identity_file)) >=
10446 sizeof(identity_file))
10447 fatal("Identity filename too long");
10448 have_identity = 1;
10449 break;
10450 case 'g':
10451 print_generic = 1;
10452 break;
10453 case 'P':
10454 identity_passphrase = BSDoptarg;
10455 break;
10456 case 'N':
10457 identity_new_passphrase = BSDoptarg;
10458 break;
10459 case 'Q':
10460 check_krl = 1;
10461 break;
10462 case 'O':
10463 add_cert_option(BSDoptarg);
10464 break;
10465 case 'Z':
10466 new_format_cipher = BSDoptarg;
10467 break;
10468 case 'C':
10469 identity_comment = BSDoptarg;
10470 break;
10471 case 'q':
10472 quiet = 1;
10473 break;
10474 case 'e':
10475 case 'x':
10476 convert_to = 1;
10477 break;
10478 case 'h':
10479 cert_key_type = 2;
10480 certflags_flags = 0;
10481 break;
10482 case 'k':
10483 gen_krl = 1;
10484 break;
10485 case 'i':
10486 case 'X':
10487 convert_from = 1;
10488 break;
10489 case 'y':
10490 print_public = 1;
10491 break;
10492 case 's':
10493 ca_key_path = BSDoptarg;
10494 break;
10495 case 't':
10496 key_type_name = BSDoptarg;
10497 break;
10498 case 'D':
10499 pkcs11provider = BSDoptarg;
10500 break;
10501 case 'u':
10502 update_krl = 1;
10503 break;
10504 case 'v':
10505 if (log_level == SYSLOG_LEVEL_INFO)
10506 log_level = SYSLOG_LEVEL_DEBUG1;
10507 else {
10508 if (log_level >= SYSLOG_LEVEL_DEBUG1 &&
10509 log_level < SYSLOG_LEVEL_DEBUG3)
10510 log_level++;
10511 }
10512 break;
10513 case 'r':
10514 rr_hostname = BSDoptarg;
10515 break;
10516 case 'W':
10517 generator_wanted = (u_int32_t)strtonum(BSDoptarg, 1,
10518 (2147483647 * 2U + 1U), &errstr);
10519 if (errstr)
10520 fatal("Desired generator has bad value: %s (%s)",
10521 BSDoptarg, errstr);
10522 break;
10523 case 'a':
10524 rounds = (int)strtonum(BSDoptarg, 1, 2147483647, &errstr);
10525 if (errstr)
10526 fatal("Invalid number: %s (%s)",
10527 BSDoptarg, errstr);
10528 break;
10529 case 'M':
10530 memory = (u_int32_t)strtonum(BSDoptarg, 1, (2147483647 * 2U + 1U), &errstr);
10531 if (errstr)
10532 fatal("Memory limit is %s: %s", errstr, BSDoptarg);
10533 break;
10534 case 'G':
10535 do_gen_candidates = 1;
10536 if (strlcpy(out_file, BSDoptarg, sizeof(out_file)) >=
10537 sizeof(out_file))
10538 fatal("Output filename too long");
10539 break;
10540 case 'T':
10541 do_screen_candidates = 1;
10542 if (strlcpy(out_file, BSDoptarg, sizeof(out_file)) >=
10543 sizeof(out_file))
10544 fatal("Output filename too long");
10545 break;
10546 case 'K':
10547 if (strlen(BSDoptarg) >= 4096)
10548 fatal("Checkpoint filename too long");
10549 checkpoint = xstrdup(BSDoptarg);
10550 break;
10551 case 'S':
10552 if (BN_hex2bn(&start, BSDoptarg) == 0)
10553 fatal("Invalid start point.");
10554 break;
10555 case 'V':
10556 parse_cert_times(BSDoptarg);
10557 break;
10558 case 'z':
10559 (*__errno_location ()) = 0;
10560 cert_serial = strtoull(BSDoptarg, &ep, 10);
10561 if (*BSDoptarg < '0' || *BSDoptarg > '9' || *ep != '\0' ||
10562 ((*__errno_location ()) == 34 && cert_serial == (9223372036854775807LL * 2ULL + 1)))
10563 fatal("Invalid serial number \"%s\"", BSDoptarg);
10564 break;
10565 case '?':
10566 default:
10567 usage();
10568 }
10569 }
10570 log_init(argv[0], log_level, SYSLOG_FACILITY_USER, 1);
10571 argv += BSDoptind;
10572 argc -= BSDoptind;
10573 if (ca_key_path != ((void *)0)) {
10574 if (argc < 1 && !gen_krl) {
10575 printf("Too few arguments.\n");
10576 usage();
10577 }
10578 } else if (argc > 0 && !gen_krl && !check_krl) {
10579 printf("Too many arguments.\n");
10580 usage();
10581 }
10582 if (change_passphrase && change_comment) {
10583 printf("Can only have one of -p and -c.\n");
10584 usage();
10585 }
10586 if (print_fingerprint && (delete_host || hash_hosts)) {
10587 printf("Cannot use -l with -H or -R.\n");
10588 usage();
10589 }
10590 if (gen_krl) {
10591 do_gen_krl(pw, update_krl, argc, argv);
10592 return (0);
10593 }
10594 if (check_krl) {
10595 do_check_krl(pw, argc, argv);
10596 return (0);
10597 }
10598 if (ca_key_path != ((void *)0)) {
10599 if (cert_key_id == ((void *)0))
10600 fatal("Must specify key id (-I) when certifying");
10601 do_ca_sign(pw, argc, argv);
10602 }
10603 if (show_cert)
10604 do_show_cert(pw);
10605 if (delete_host || hash_hosts || find_host)
10606 do_known_hosts(pw, rr_hostname);
10607 if (pkcs11provider != ((void *)0))
10608 do_download(pw);
10609 if (print_fingerprint || print_bubblebabble)
10610 do_fingerprint(pw);
10611 if (change_passphrase)
10612 do_change_passphrase(pw);
10613 if (change_comment)
10614 do_change_comment(pw);
10615 if (convert_to)
10616 do_convert_to(pw);
10617 if (convert_from)
10618 do_convert_from(pw);
10619 if (print_public)
10620 do_print_public(pw);
10621 if (rr_hostname != ((void *)0)) {
10622 unsigned int n = 0;
10623 if (have_identity) {
10624 n = do_print_resource_record(pw,
10625 identity_file, rr_hostname);
10626 if (n == 0) {
10627 perror(identity_file);
10628 exit(1);
10629 }
10630 exit(0);
10631 } else {
10632 n += do_print_resource_record(pw,
10633 "/etc/ssh" "/ssh_host_rsa_key", rr_hostname);
10634 n += do_print_resource_record(pw,
10635 "/etc/ssh" "/ssh_host_dsa_key", rr_hostname);
10636 n += do_print_resource_record(pw,
10637 "/etc/ssh" "/ssh_host_ecdsa_key", rr_hostname);
10638 if (n == 0)
10639 fatal("no keys found.");
10640 exit(0);
10641 }
10642 }
10643 if (do_gen_candidates) {
10644 FILE *out = fopen(out_file, "w");
10645 if (out == ((void *)0)) {
10646 error("Couldn't open modulus candidate file \"%s\": %s",
10647 out_file, strerror((*__errno_location ())));
10648 return (1);
10649 }
10650 if (bits == 0)
10651 bits = 2048;
10652 if (gen_candidates(out, memory, bits, start) != 0)
10653 fatal("modulus candidate generation failed");
10654 return (0);
10655 }
10656 if (do_screen_candidates) {
10657 FILE *in;
10658 FILE *out = fopen(out_file, "a");
10659 if (have_identity && __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (identity_file) && __builtin_constant_p ("-") && (__s1_len = strlen (identity_file), __s2_len = strlen ("-"), (!((size_t)(const void *)((identity_file) + 1) - (size_t)(const void *)(identity_file) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (identity_file, "-") : (__builtin_constant_p (identity_file) && ((size_t)(const void *)((identity_file) + 1) - (size_t)(const void *)(identity_file) == 1) && (__s1_len = strlen (identity_file), __s1_len < 4) ? (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) ? __builtin_strcmp (identity_file, "-") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("-"); register int __result = (((const unsigned char *) (const char *) (identity_file))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (identity_file))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (identity_file))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (identity_file))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) && (__s2_len = strlen ("-"), __s2_len < 4) ? (__builtin_constant_p (identity_file) && ((size_t)(const void *)((identity_file) + 1) - (size_t)(const void *)(identity_file) == 1) ? __builtin_strcmp (identity_file, "-") : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (identity_file); register int __result = __s1[0] - ((const unsigned char *) (const char *) ("-"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) ("-"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) ("-"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) ("-"))[3]); } } __result; }))) : __builtin_strcmp (identity_file, "-")))); }) != 0) {
10660 if ((in = fopen(identity_file, "r")) == ((void *)0)) {
10661 fatal("Couldn't open modulus candidate "
10662 "file \"%s\": %s", identity_file,
10663 strerror((*__errno_location ())));
10664 }
10665 } else
10666 in = stdin;
10667 if (out == ((void *)0)) {
10668 fatal("Couldn't open moduli file \"%s\": %s",
10669 out_file, strerror((*__errno_location ())));
10670 }
10671 if (prime_test(in, out, rounds == 0 ? 100 : rounds,
10672 generator_wanted, checkpoint,
10673 start_lineno, lines_to_process) != 0)
10674 fatal("modulus screening failed");
10675 return (0);
10676 }
10677 if (gen_all_hostkeys) {
10678 do_gen_all_hostkeys(pw);
10679 return (0);
10680 }
10681 if (key_type_name == ((void *)0))
10682 key_type_name = "rsa";
10683 type = key_type_from_name(key_type_name);
10684 type_bits_valid(type, &bits);
10685 if (!quiet)
10686 printf("Generating public/private %s key pair.\n", key_type_name);
10687 private = key_generate(type, bits);
10688 if (private == ((void *)0)) {
10689 fprintf(stderr, "key_generate failed\n");
10690 exit(1);
10691 }
10692 public = key_from_private(private);
10693 if (!have_identity)
10694 ask_filename(pw, "Enter file in which to save the key");
10695 snprintf(dotsshdir, sizeof dotsshdir, "%s/%s",
10696 pw->pw_dir, ".ssh");
10697 if (strstr(identity_file, dotsshdir) != ((void *)0)) {
10698 if (stat(dotsshdir, &st) < 0) {
10699 if ((*__errno_location ()) != 2) {
10700 error("Could not stat %s: %s", dotsshdir,
10701 strerror((*__errno_location ())));
10702 } else if (mkdir(dotsshdir, 0700) < 0) {
10703 error("Could not create directory '%s': %s",
10704 dotsshdir, strerror((*__errno_location ())));
10705 } else if (!quiet)
10706 printf("Created directory '%s'.\n", dotsshdir);
10707 }
10708 }
10709 if (stat(identity_file, &st) >= 0) {
10710 char yesno[3];
10711 printf("%s already exists.\n", identity_file);
10712 printf("Overwrite (y/n)? ");
10713 fflush(stdout);
10714 if (fgets(yesno, sizeof(yesno), stdin) == ((void *)0))
10715 exit(1);
10716 if (yesno[0] != 'y' && yesno[0] != 'Y')
10717 exit(1);
10718 }
10719 if (identity_passphrase)
10720 passphrase1 = xstrdup(identity_passphrase);
10721 else if (identity_new_passphrase)
10722 passphrase1 = xstrdup(identity_new_passphrase);
10723 else {
10724 passphrase_again:
10725 passphrase1 =
10726 read_passphrase("Enter passphrase (empty for no "
10727 "passphrase): ", 0x0002);
10728 passphrase2 = read_passphrase("Enter same passphrase again: ",
10729 0x0002);
10730 if (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (passphrase1) && __builtin_constant_p (passphrase2) && (__s1_len = strlen (passphrase1), __s2_len = strlen (passphrase2), (!((size_t)(const void *)((passphrase1) + 1) - (size_t)(const void *)(passphrase1) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((passphrase2) + 1) - (size_t)(const void *)(passphrase2) == 1) || __s2_len >= 4)) ? __builtin_strcmp (passphrase1, passphrase2) : (__builtin_constant_p (passphrase1) && ((size_t)(const void *)((passphrase1) + 1) - (size_t)(const void *)(passphrase1) == 1) && (__s1_len = strlen (passphrase1), __s1_len < 4) ? (__builtin_constant_p (passphrase2) && ((size_t)(const void *)((passphrase2) + 1) - (size_t)(const void *)(passphrase2) == 1) ? __builtin_strcmp (passphrase1, passphrase2) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (passphrase2); register int __result = (((const unsigned char *) (const char *) (passphrase1))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (passphrase1))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (passphrase1))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (passphrase1))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (passphrase2) && ((size_t)(const void *)((passphrase2) + 1) - (size_t)(const void *)(passphrase2) == 1) && (__s2_len = strlen (passphrase2), __s2_len < 4) ? (__builtin_constant_p (passphrase1) && ((size_t)(const void *)((passphrase1) + 1) - (size_t)(const void *)(passphrase1) == 1) ? __builtin_strcmp (passphrase1, passphrase2) : (__extension__ ({ const unsigned char *__s1 = (const unsigned char *) (const char *) (passphrase1); register int __result = __s1[0] - ((const unsigned char *) (const char *) (passphrase2))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((const unsigned char *) (const char *) (passphrase2))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((const unsigned char *) (const char *) (passphrase2))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((const unsigned char *) (const char *) (passphrase2))[3]); } } __result; }))) : __builtin_strcmp (passphrase1, passphrase2)))); }) != 0) {
10731 explicit_bzero(passphrase1, strlen(passphrase1));
10732 explicit_bzero(passphrase2, strlen(passphrase2));
10733 free(passphrase1);
10734 free(passphrase2);
10735 printf("Passphrases do not match. Try again.\n");
10736 goto passphrase_again;
10737 }
10738 explicit_bzero(passphrase2, strlen(passphrase2));
10739 free(passphrase2);
10740 }
10741 if (identity_comment) {
10742 strlcpy(comment, identity_comment, sizeof(comment));
10743 } else {
10744 snprintf(comment, sizeof comment, "%s@%s", pw->pw_name, hostname);
10745 }
10746 if (!key_save_private(private, identity_file, passphrase1, comment,
10747 use_new_format, new_format_cipher, rounds)) {
10748 printf("Saving the key failed: %s.\n", identity_file);
10749 explicit_bzero(passphrase1, strlen(passphrase1));
10750 free(passphrase1);
10751 exit(1);
10752 }
10753 explicit_bzero(passphrase1, strlen(passphrase1));
10754 free(passphrase1);
10755 key_free(private);
10756 if (!quiet)
10757 printf("Your identification has been saved in %s.\n", identity_file);
10758 strlcat(identity_file, ".pub", sizeof(identity_file));
10759 fd = open(identity_file, 01 | 00000400 | 01000, 0644);
10760 if (fd == -1) {
10761 printf("Could not save your public key in %s\n", identity_file);
10762 exit(1);
10763 }
10764 f = fdopen(fd, "w");
10765 if (f == ((void *)0)) {
10766 printf("fdopen %s failed\n", identity_file);
10767 exit(1);
10768 }
10769 if (!key_write(public, f))
10770 fprintf(stderr, "write key failed\n");
10771 fprintf(f, " %s\n", comment);
10772 fclose(f);
10773 if (!quiet) {
10774 char *fp = key_fingerprint(public, SSH_FP_MD5, SSH_FP_HEX);
10775 char *ra = key_fingerprint(public, SSH_FP_MD5,
10776 SSH_FP_RANDOMART);
10777 printf("Your public key has been saved in %s.\n",
10778 identity_file);
10779 printf("The key fingerprint is:\n");
10780 printf("%s %s\n", fp, comment);
10781 printf("The key's randomart image is:\n");
10782 printf("%s\n", ra);
10783 free(ra);
10784 free(fp);
10785 }
10786 key_free(public);
10787 exit(0);
10788 }