]> git.wh0rd.org - ICEs.git/blame - 505182/ssh-keygen.i.0
more
[ICEs.git] / 505182 / ssh-keygen.i.0
CommitLineData
bd3239d2
MF
1typedef unsigned char __u_char;
2typedef unsigned short int __u_short;
3typedef unsigned int __u_int;
4typedef unsigned long int __u_long;
5typedef signed char __int8_t;
6typedef unsigned char __uint8_t;
7typedef signed short int __int16_t;
8typedef unsigned short int __uint16_t;
9typedef signed int __int32_t;
10typedef 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;
48typedef __off64_t __loff_t;
49typedef __quad_t *__qaddr_t;
50typedef char *__caddr_t;
51__extension__ typedef int __intptr_t;
52__extension__ typedef unsigned int __socklen_t;
53typedef __u_char u_char;
54typedef __u_short u_short;
55typedef __u_int u_int;
56typedef __u_long u_long;
57typedef __quad_t quad_t;
58typedef __u_quad_t u_quad_t;
59typedef __fsid_t fsid_t;
60typedef __loff_t loff_t;
61typedef __ino64_t ino_t;
62typedef __ino64_t ino64_t;
63typedef __dev_t dev_t;
64typedef __gid_t gid_t;
65typedef __mode_t mode_t;
66typedef __nlink_t nlink_t;
67typedef __uid_t uid_t;
68typedef __off64_t off_t;
69typedef __off64_t off64_t;
70typedef __pid_t pid_t;
71typedef __id_t id_t;
72typedef __ssize_t ssize_t;
73typedef __daddr_t daddr_t;
74typedef __caddr_t caddr_t;
75typedef __key_t key_t;
76typedef __clock_t clock_t;
77typedef __time_t time_t;
78typedef __clockid_t clockid_t;
79typedef __timer_t timer_t;
80typedef __useconds_t useconds_t;
81typedef __suseconds_t suseconds_t;
82typedef unsigned int size_t;
83typedef unsigned long int ulong;
84typedef unsigned short int ushort;
85typedef unsigned int uint;
86typedef int int8_t __attribute__ ((__mode__ (__QI__)));
87typedef int int16_t __attribute__ ((__mode__ (__HI__)));
88typedef int int32_t __attribute__ ((__mode__ (__SI__)));
89typedef int int64_t __attribute__ ((__mode__ (__DI__)));
90typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
91typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
92typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
93typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
94typedef int register_t __attribute__ ((__mode__ (__word__)));
95static __inline unsigned int
96__bswap_32 (unsigned int __bsx)
97{
98 return __builtin_bswap32 (__bsx);
99}
100static __inline __uint64_t
101__bswap_64 (__uint64_t __bsx)
102{
103 return __builtin_bswap64 (__bsx);
104}
105typedef int __sig_atomic_t;
106typedef struct
107 {
108 unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
109 } __sigset_t;
110typedef __sigset_t sigset_t;
111struct timespec
112 {
113 __time_t tv_sec;
114 __syscall_slong_t tv_nsec;
115 };
116struct timeval
117 {
118 __time_t tv_sec;
119 __suseconds_t tv_usec;
120 };
121typedef long int __fd_mask;
122typedef struct
123 {
124 __fd_mask fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];
125 } fd_set;
126typedef __fd_mask fd_mask;
127extern int select (int __nfds, fd_set *__restrict __readfds,
128 fd_set *__restrict __writefds,
129 fd_set *__restrict __exceptfds,
130 struct timeval *__restrict __timeout);
131extern 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);
136extern long int __fdelt_chk (long int __d);
137extern long int __fdelt_warn (long int __d)
138 __attribute__((__warning__ ("bit outside of fd_set selected")));
139__extension__
140extern unsigned int gnu_dev_major (unsigned long long int __dev)
141 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
142__extension__
143extern unsigned int gnu_dev_minor (unsigned long long int __dev)
144 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
145__extension__
146extern 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}
166typedef __blksize_t blksize_t;
167typedef __blkcnt64_t blkcnt_t;
168typedef __fsblkcnt64_t fsblkcnt_t;
169typedef __fsfilcnt64_t fsfilcnt_t;
170typedef __blkcnt64_t blkcnt64_t;
171typedef __fsblkcnt64_t fsblkcnt64_t;
172typedef __fsfilcnt64_t fsfilcnt64_t;
173typedef unsigned long int pthread_t;
174union pthread_attr_t
175{
176 char __size[36];
177 long int __align;
178};
179typedef union pthread_attr_t pthread_attr_t;
180typedef struct __pthread_internal_slist
181{
182 struct __pthread_internal_slist *__next;
183} __pthread_slist_t;
184typedef 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;
205typedef union
206{
207 char __size[4];
208 long int __align;
209} pthread_mutexattr_t;
210typedef 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;
227typedef union
228{
229 char __size[4];
230 long int __align;
231} pthread_condattr_t;
232typedef unsigned int pthread_key_t;
233typedef int pthread_once_t;
234typedef 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;
258typedef union
259{
260 char __size[8];
261 long int __align;
262} pthread_rwlockattr_t;
263typedef volatile int pthread_spinlock_t;
264typedef union
265{
266 char __size[48];
267 long int __align;
268} pthread_barrier_t;
269typedef union
270{
271 char __size[4];
272 int __align;
273} pthread_barrierattr_t;
274struct iovec
275 {
276 void *iov_base;
277 size_t iov_len;
278 };
279extern 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__));
285extern 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__));
291extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count)
292 __attribute__ ((__warn_unused_result__));
293extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count)
294 __attribute__ ((__warn_unused_result__));
295extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __asm__ ("" "preadv64")
296 __attribute__ ((__warn_unused_result__));
297extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __asm__ ("" "pwritev64")
298 __attribute__ ((__warn_unused_result__));
299extern ssize_t preadv64 (int __fd, const struct iovec *__iovec, int __count,
300 __off64_t __offset) __attribute__ ((__warn_unused_result__));
301extern ssize_t pwritev64 (int __fd, const struct iovec *__iovec, int __count,
302 __off64_t __offset) __attribute__ ((__warn_unused_result__));
303typedef __socklen_t socklen_t;
304enum __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};
316typedef unsigned short int sa_family_t;
317struct sockaddr
318 {
319 sa_family_t sa_family;
320 char sa_data[14];
321 };
322struct 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 };
328enum
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 };
350struct 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 };
360struct cmsghdr
361 {
362 size_t cmsg_len;
363 int cmsg_level;
364 int cmsg_type;
365 __extension__ unsigned char __cmsg_data [];
366 };
367extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
368 struct cmsghdr *__cmsg) __attribute__ ((__nothrow__ , __leaf__));
369extern __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}
383enum
384 {
385 SCM_RIGHTS = 0x01
386 , SCM_CREDENTIALS = 0x02
387 };
388struct ucred
389{
390 pid_t pid;
391 uid_t uid;
392 gid_t gid;
393};
394struct linger
395 {
396 int l_onoff;
397 int l_linger;
398 };
399struct osockaddr
400 {
401 unsigned short int sa_family;
402 unsigned char sa_data[14];
403 };
404enum
405{
406 SHUT_RD = 0,
407 SHUT_WR,
408 SHUT_RDWR
409};
410typedef 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__));
412typedef 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__));
414struct mmsghdr
415 {
416 struct msghdr msg_hdr;
417 unsigned int msg_len;
418 };
419extern int socket (int __domain, int __type, int __protocol) __attribute__ ((__nothrow__ , __leaf__));
420extern int socketpair (int __domain, int __type, int __protocol,
421 int __fds[2]) __attribute__ ((__nothrow__ , __leaf__));
422extern int bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
423 __attribute__ ((__nothrow__ , __leaf__));
424extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
425 socklen_t *__restrict __len) __attribute__ ((__nothrow__ , __leaf__));
426extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
427extern int getpeername (int __fd, __SOCKADDR_ARG __addr,
428 socklen_t *__restrict __len) __attribute__ ((__nothrow__ , __leaf__));
429extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags);
430extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);
431extern ssize_t sendto (int __fd, const void *__buf, size_t __n,
432 int __flags, __CONST_SOCKADDR_ARG __addr,
433 socklen_t __addr_len);
434extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
435 int __flags, __SOCKADDR_ARG __addr,
436 socklen_t *__restrict __addr_len);
437extern ssize_t sendmsg (int __fd, const struct msghdr *__message,
438 int __flags);
439extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
440 unsigned int __vlen, int __flags);
441extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
442extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
443 unsigned int __vlen, int __flags,
444 const struct timespec *__tmo);
445extern int getsockopt (int __fd, int __level, int __optname,
446 void *__restrict __optval,
447 socklen_t *__restrict __optlen) __attribute__ ((__nothrow__ , __leaf__));
448extern int setsockopt (int __fd, int __level, int __optname,
449 const void *__optval, socklen_t __optlen) __attribute__ ((__nothrow__ , __leaf__));
450extern int listen (int __fd, int __n) __attribute__ ((__nothrow__ , __leaf__));
451extern int accept (int __fd, __SOCKADDR_ARG __addr,
452 socklen_t *__restrict __addr_len);
453extern int accept4 (int __fd, __SOCKADDR_ARG __addr,
454 socklen_t *__restrict __addr_len, int __flags);
455extern int shutdown (int __fd, int __how) __attribute__ ((__nothrow__ , __leaf__));
456extern int sockatmark (int __fd) __attribute__ ((__nothrow__ , __leaf__));
457extern int isfdtype (int __fd, int __fdtype) __attribute__ ((__nothrow__ , __leaf__));
458extern ssize_t __recv_chk (int __fd, void *__buf, size_t __n, size_t __buflen,
459 int __flags);
460extern ssize_t __recv_alias (int __fd, void *__buf, size_t __n, int __flags) __asm__ ("" "recv")
461 ;
462extern 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 ;
465extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) ssize_t
466recv (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}
477extern 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);
481extern 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 ;
483extern 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 ;
486extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) ssize_t
487recvfrom (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}
501struct 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};
509extern struct ttyent *getttyent (void) __attribute__ ((__nothrow__ , __leaf__));
510extern struct ttyent *getttynam (const char *__tty) __attribute__ ((__nothrow__ , __leaf__));
511extern int setttyent (void) __attribute__ ((__nothrow__ , __leaf__));
512extern int endttyent (void) __attribute__ ((__nothrow__ , __leaf__));
513struct utimbuf
514 {
515 __time_t actime;
516 __time_t modtime;
517 };
518extern int utime (const char *__file,
519 const struct utimbuf *__file_times)
520 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
521extern int bcmp (const void *__s1, const void *__s2, size_t __n)
522 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__));
523extern void bcopy (const void *__src, void *__dest, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
524extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
525extern char *index (const char *__s, int __c)
526 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
527extern char *rindex (const char *__s, int __c)
528 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
529extern int ffs (int __i) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((const));
530extern int strcasecmp (const char *__s1, const char *__s2)
531 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__));
532extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
533 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__));
534typedef 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;
542typedef __locale_t locale_t;
543extern int strcasecmp_l (const char *__s1, const char *__s2, __locale_t __loc)
544 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
545extern 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)));
548struct timezone
549 {
550 int tz_minuteswest;
551 int tz_dsttime;
552 };
553typedef struct timezone *__restrict __timezone_ptr_t;
554extern int gettimeofday (struct timeval *__restrict __tv,
555 __timezone_ptr_t __tz) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
556extern int settimeofday (const struct timeval *__tv,
557 const struct timezone *__tz)
558 __attribute__ ((__nothrow__ , __leaf__));
559extern int adjtime (const struct timeval *__delta,
560 struct timeval *__olddelta) __attribute__ ((__nothrow__ , __leaf__));
561enum __itimer_which
562 {
563 ITIMER_REAL = 0,
564 ITIMER_VIRTUAL = 1,
565 ITIMER_PROF = 2
566 };
567struct itimerval
568 {
569 struct timeval it_interval;
570 struct timeval it_value;
571 };
572typedef enum __itimer_which __itimer_which_t;
573extern int getitimer (__itimer_which_t __which,
574 struct itimerval *__value) __attribute__ ((__nothrow__ , __leaf__));
575extern int setitimer (__itimer_which_t __which,
576 const struct itimerval *__restrict __new,
577 struct itimerval *__restrict __old) __attribute__ ((__nothrow__ , __leaf__));
578extern int utimes (const char *__file, const struct timeval __tvp[2])
579 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
580extern int lutimes (const char *__file, const struct timeval __tvp[2])
581 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
582extern int futimes (int __fd, const struct timeval __tvp[2]) __attribute__ ((__nothrow__ , __leaf__));
583extern int futimesat (int __fd, const char *__file,
584 const struct timeval __tvp[2]) __attribute__ ((__nothrow__ , __leaf__));
585struct lastlog
586 {
587 __time_t ll_time;
588 char ll_line[32];
589 char ll_host[256];
590 };
591struct exit_status
592 {
593 short int e_termination;
594 short int e_exit;
595 };
596struct 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};
610extern int login_tty (int __fd) __attribute__ ((__nothrow__ , __leaf__));
611extern void login (const struct utmp *__entry) __attribute__ ((__nothrow__ , __leaf__));
612extern int logout (const char *__ut_line) __attribute__ ((__nothrow__ , __leaf__));
613extern void logwtmp (const char *__ut_line, const char *__ut_name,
614 const char *__ut_host) __attribute__ ((__nothrow__ , __leaf__));
615extern void updwtmp (const char *__wtmp_file, const struct utmp *__utmp)
616 __attribute__ ((__nothrow__ , __leaf__));
617extern int utmpname (const char *__file) __attribute__ ((__nothrow__ , __leaf__));
618extern struct utmp *getutent (void) __attribute__ ((__nothrow__ , __leaf__));
619extern void setutent (void) __attribute__ ((__nothrow__ , __leaf__));
620extern void endutent (void) __attribute__ ((__nothrow__ , __leaf__));
621extern struct utmp *getutid (const struct utmp *__id) __attribute__ ((__nothrow__ , __leaf__));
622extern struct utmp *getutline (const struct utmp *__line) __attribute__ ((__nothrow__ , __leaf__));
623extern struct utmp *pututline (const struct utmp *__utmp_ptr) __attribute__ ((__nothrow__ , __leaf__));
624extern int getutent_r (struct utmp *__buffer, struct utmp **__result) __attribute__ ((__nothrow__ , __leaf__));
625extern int getutid_r (const struct utmp *__id, struct utmp *__buffer,
626 struct utmp **__result) __attribute__ ((__nothrow__ , __leaf__));
627extern int getutline_r (const struct utmp *__line,
628 struct utmp *__buffer, struct utmp **__result) __attribute__ ((__nothrow__ , __leaf__));
629struct __exit_status
630 {
631 short int e_termination;
632 short int e_exit;
633 };
634struct 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};
648struct utmp;
649extern void setutxent (void);
650extern void endutxent (void);
651extern struct utmpx *getutxent (void);
652extern struct utmpx *getutxid (const struct utmpx *__id);
653extern struct utmpx *getutxline (const struct utmpx *__line);
654extern struct utmpx *pututxline (const struct utmpx *__utmpx);
655extern int utmpxname (const char *__file);
656extern void updwtmpx (const char *__wtmpx_file,
657 const struct utmpx *__utmpx);
658extern void getutmp (const struct utmpx *__utmpx,
659 struct utmp *__utmp);
660extern void getutmpx (const struct utmp *__utmp, struct utmpx *__utmpx);
661typedef unsigned char uint8_t;
662typedef unsigned short int uint16_t;
663typedef unsigned int uint32_t;
664__extension__
665typedef unsigned long long int uint64_t;
666typedef signed char int_least8_t;
667typedef short int int_least16_t;
668typedef int int_least32_t;
669__extension__
670typedef long long int int_least64_t;
671typedef unsigned char uint_least8_t;
672typedef unsigned short int uint_least16_t;
673typedef unsigned int uint_least32_t;
674__extension__
675typedef unsigned long long int uint_least64_t;
676typedef signed char int_fast8_t;
677typedef int int_fast16_t;
678typedef int int_fast32_t;
679__extension__
680typedef long long int int_fast64_t;
681typedef unsigned char uint_fast8_t;
682typedef unsigned int uint_fast16_t;
683typedef unsigned int uint_fast32_t;
684__extension__
685typedef unsigned long long int uint_fast64_t;
686typedef int intptr_t;
687typedef unsigned int uintptr_t;
688__extension__
689typedef long long int intmax_t;
690__extension__
691typedef unsigned long long int uintmax_t;
692typedef unsigned char cc_t;
693typedef unsigned int speed_t;
694typedef unsigned int tcflag_t;
695struct 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 };
706extern speed_t cfgetospeed (const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
707extern speed_t cfgetispeed (const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
708extern int cfsetospeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));
709extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));
710extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));
711extern int tcgetattr (int __fd, struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
712extern int tcsetattr (int __fd, int __optional_actions,
713 const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
714extern void cfmakeraw (struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));
715extern int tcsendbreak (int __fd, int __duration) __attribute__ ((__nothrow__ , __leaf__));
716extern int tcdrain (int __fd);
717extern int tcflush (int __fd, int __queue_selector) __attribute__ ((__nothrow__ , __leaf__));
718extern int tcflow (int __fd, int __action) __attribute__ ((__nothrow__ , __leaf__));
719extern __pid_t tcgetsid (int __fd) __attribute__ ((__nothrow__ , __leaf__));
720struct 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 };
739struct 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 };
758extern int stat (const char *__restrict __file, struct stat *__restrict __buf) __asm__ ("" "stat64") __attribute__ ((__nothrow__ , __leaf__))
759 __attribute__ ((__nonnull__ (1, 2)));
760extern int fstat (int __fd, struct stat *__buf) __asm__ ("" "fstat64") __attribute__ ((__nothrow__ , __leaf__))
761 __attribute__ ((__nonnull__ (2)));
762extern int stat64 (const char *__restrict __file,
763 struct stat64 *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
764extern int fstat64 (int __fd, struct stat64 *__buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
765extern int fstatat (int __fd, const char *__restrict __file, struct stat *__restrict __buf, int __flag) __asm__ ("" "fstatat64") __attribute__ ((__nothrow__ , __leaf__))
766 __attribute__ ((__nonnull__ (2, 3)));
767extern int fstatat64 (int __fd, const char *__restrict __file,
768 struct stat64 *__restrict __buf, int __flag)
769 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
770extern int lstat (const char *__restrict __file, struct stat *__restrict __buf) __asm__ ("" "lstat64") __attribute__ ((__nothrow__ , __leaf__))
771 __attribute__ ((__nonnull__ (1, 2)));
772extern int lstat64 (const char *__restrict __file,
773 struct stat64 *__restrict __buf)
774 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
775extern int chmod (const char *__file, __mode_t __mode)
776 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
777extern int lchmod (const char *__file, __mode_t __mode)
778 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
779extern int fchmod (int __fd, __mode_t __mode) __attribute__ ((__nothrow__ , __leaf__));
780extern int fchmodat (int __fd, const char *__file, __mode_t __mode,
781 int __flag)
782 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
783extern __mode_t umask (__mode_t __mask) __attribute__ ((__nothrow__ , __leaf__));
784extern __mode_t getumask (void) __attribute__ ((__nothrow__ , __leaf__));
785extern int mkdir (const char *__path, __mode_t __mode)
786 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
787extern int mkdirat (int __fd, const char *__path, __mode_t __mode)
788 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
789extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev)
790 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
791extern int mknodat (int __fd, const char *__path, __mode_t __mode,
792 __dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
793extern int mkfifo (const char *__path, __mode_t __mode)
794 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
795extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
796 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
797extern int utimensat (int __fd, const char *__path,
798 const struct timespec __times[2],
799 int __flags)
800 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
801extern int futimens (int __fd, const struct timespec __times[2]) __attribute__ ((__nothrow__ , __leaf__));
802extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf) __asm__ ("" "__fxstat64") __attribute__ ((__nothrow__ , __leaf__))
803 __attribute__ ((__nonnull__ (3)));
804extern int __xstat (int __ver, const char *__filename, struct stat *__stat_buf) __asm__ ("" "__xstat64") __attribute__ ((__nothrow__ , __leaf__))
805 __attribute__ ((__nonnull__ (2, 3)));
806extern int __lxstat (int __ver, const char *__filename, struct stat *__stat_buf) __asm__ ("" "__lxstat64") __attribute__ ((__nothrow__ , __leaf__))
807 __attribute__ ((__nonnull__ (2, 3)));
808extern 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)));
810extern int __fxstat64 (int __ver, int __fildes, struct stat64 *__stat_buf)
811 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3)));
812extern int __xstat64 (int __ver, const char *__filename,
813 struct stat64 *__stat_buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
814extern int __lxstat64 (int __ver, const char *__filename,
815 struct stat64 *__stat_buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
816extern int __fxstatat64 (int __ver, int __fildes, const char *__filename,
817 struct stat64 *__stat_buf, int __flag)
818 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4)));
819extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
820 __dev_t *__dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));
821extern int __xmknodat (int __ver, int __fd, const char *__path,
822 __mode_t __mode, __dev_t *__dev)
823 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 5)));
824extern __inline int
825__attribute__ ((__nothrow__ , __leaf__)) stat (const char *__path, struct stat *__statbuf)
826{
827 return __xstat (3, __path, __statbuf);
828}
829extern __inline int
830__attribute__ ((__nothrow__ , __leaf__)) lstat (const char *__path, struct stat *__statbuf)
831{
832 return __lxstat (3, __path, __statbuf);
833}
834extern __inline int
835__attribute__ ((__nothrow__ , __leaf__)) fstat (int __fd, struct stat *__statbuf)
836{
837 return __fxstat (3, __fd, __statbuf);
838}
839extern __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}
844extern __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}
849extern __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}
854extern __inline int
855__attribute__ ((__nothrow__ , __leaf__)) stat64 (const char *__path, struct stat64 *__statbuf)
856{
857 return __xstat64 (3, __path, __statbuf);
858}
859extern __inline int
860__attribute__ ((__nothrow__ , __leaf__)) lstat64 (const char *__path, struct stat64 *__statbuf)
861{
862 return __lxstat64 (3, __path, __statbuf);
863}
864extern __inline int
865__attribute__ ((__nothrow__ , __leaf__)) fstat64 (int __fd, struct stat64 *__statbuf)
866{
867 return __fxstat64 (3, __fd, __statbuf);
868}
869extern __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}
874extern void * mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset) __asm__ ("" "mmap64") __attribute__ ((__nothrow__ , __leaf__))
875 ;
876extern void *mmap64 (void *__addr, size_t __len, int __prot,
877 int __flags, int __fd, __off64_t __offset) __attribute__ ((__nothrow__ , __leaf__));
878extern int munmap (void *__addr, size_t __len) __attribute__ ((__nothrow__ , __leaf__));
879extern int mprotect (void *__addr, size_t __len, int __prot) __attribute__ ((__nothrow__ , __leaf__));
880extern int msync (void *__addr, size_t __len, int __flags);
881extern int madvise (void *__addr, size_t __len, int __advice) __attribute__ ((__nothrow__ , __leaf__));
882extern int posix_madvise (void *__addr, size_t __len, int __advice) __attribute__ ((__nothrow__ , __leaf__));
883extern int mlock (const void *__addr, size_t __len) __attribute__ ((__nothrow__ , __leaf__));
884extern int munlock (const void *__addr, size_t __len) __attribute__ ((__nothrow__ , __leaf__));
885extern int mlockall (int __flags) __attribute__ ((__nothrow__ , __leaf__));
886extern int munlockall (void) __attribute__ ((__nothrow__ , __leaf__));
887extern int mincore (void *__start, size_t __len, unsigned char *__vec)
888 __attribute__ ((__nothrow__ , __leaf__));
889extern void *mremap (void *__addr, size_t __old_len, size_t __new_len,
890 int __flags, ...) __attribute__ ((__nothrow__ , __leaf__));
891extern int remap_file_pages (void *__start, size_t __size, int __prot,
892 size_t __pgoff, int __flags) __attribute__ ((__nothrow__ , __leaf__));
893extern int shm_open (const char *__name, int __oflag, mode_t __mode);
894extern int shm_unlink (const char *__name);
895enum
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 };
928typedef uint16_t in_port_t;
929enum
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 };
958typedef uint32_t in_addr_t;
959struct in_addr
960 {
961 in_addr_t s_addr;
962 };
963struct 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 };
972extern const struct in6_addr in6addr_any;
973extern const struct in6_addr in6addr_loopback;
974struct 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 };
984struct 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 };
992struct ip_mreq
993 {
994 struct in_addr imr_multiaddr;
995 struct in_addr imr_interface;
996 };
997struct ip_mreq_source
998 {
999 struct in_addr imr_multiaddr;
1000 struct in_addr imr_interface;
1001 struct in_addr imr_sourceaddr;
1002 };
1003struct ipv6_mreq
1004 {
1005 struct in6_addr ipv6mr_multiaddr;
1006 unsigned int ipv6mr_interface;
1007 };
1008struct group_req
1009 {
1010 uint32_t gr_interface;
1011 struct sockaddr_storage gr_group;
1012 };
1013struct group_source_req
1014 {
1015 uint32_t gsr_interface;
1016 struct sockaddr_storage gsr_group;
1017 struct sockaddr_storage gsr_source;
1018 };
1019struct 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 };
1027struct 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};
1035struct ip_opts
1036 {
1037 struct in_addr ip_dst;
1038 char ip_opts[40];
1039 };
1040struct ip_mreqn
1041 {
1042 struct in_addr imr_multiaddr;
1043 struct in_addr imr_address;
1044 int imr_ifindex;
1045 };
1046struct in_pktinfo
1047 {
1048 int ipi_ifindex;
1049 struct in_addr ipi_spec_dst;
1050 struct in_addr ipi_addr;
1051 };
1052extern uint32_t ntohl (uint32_t __netlong) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1053extern uint16_t ntohs (uint16_t __netshort)
1054 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1055extern uint32_t htonl (uint32_t __hostlong)
1056 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1057extern uint16_t htons (uint16_t __hostshort)
1058 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1059extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __attribute__ ((__nothrow__ , __leaf__));
1060extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
1061 __attribute__ ((__nothrow__ , __leaf__));
1062struct cmsghdr;
1063struct in6_pktinfo
1064 {
1065 struct in6_addr ipi6_addr;
1066 unsigned int ipi6_ifindex;
1067 };
1068struct ip6_mtuinfo
1069 {
1070 struct sockaddr_in6 ip6m_addr;
1071 uint32_t ip6m_mtu;
1072 };
1073extern int inet6_option_space (int __nbytes)
1074 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1075extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp,
1076 int __type) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1077extern int inet6_option_append (struct cmsghdr *__cmsg,
1078 const uint8_t *__typep, int __multx,
1079 int __plusy) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1080extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen,
1081 int __multx, int __plusy)
1082 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1083extern int inet6_option_next (const struct cmsghdr *__cmsg,
1084 uint8_t **__tptrp)
1085 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1086extern int inet6_option_find (const struct cmsghdr *__cmsg,
1087 uint8_t **__tptrp, int __type)
1088 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1089extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __attribute__ ((__nothrow__ , __leaf__));
1090extern 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__));
1093extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __offset)
1094 __attribute__ ((__nothrow__ , __leaf__));
1095extern int inet6_opt_set_val (void *__databuf, int __offset, void *__val,
1096 socklen_t __vallen) __attribute__ ((__nothrow__ , __leaf__));
1097extern int inet6_opt_next (void *__extbuf, socklen_t __extlen, int __offset,
1098 uint8_t *__typep, socklen_t *__lenp,
1099 void **__databufp) __attribute__ ((__nothrow__ , __leaf__));
1100extern int inet6_opt_find (void *__extbuf, socklen_t __extlen, int __offset,
1101 uint8_t __type, socklen_t *__lenp,
1102 void **__databufp) __attribute__ ((__nothrow__ , __leaf__));
1103extern int inet6_opt_get_val (void *__databuf, int __offset, void *__val,
1104 socklen_t __vallen) __attribute__ ((__nothrow__ , __leaf__));
1105extern socklen_t inet6_rth_space (int __type, int __segments) __attribute__ ((__nothrow__ , __leaf__));
1106extern void *inet6_rth_init (void *__bp, socklen_t __bp_len, int __type,
1107 int __segments) __attribute__ ((__nothrow__ , __leaf__));
1108extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __attribute__ ((__nothrow__ , __leaf__));
1109extern int inet6_rth_reverse (const void *__in, void *__out) __attribute__ ((__nothrow__ , __leaf__));
1110extern int inet6_rth_segments (const void *__bp) __attribute__ ((__nothrow__ , __leaf__));
1111extern struct in6_addr *inet6_rth_getaddr (const void *__bp, int __index)
1112 __attribute__ ((__nothrow__ , __leaf__));
1113extern 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__));
1117extern 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__));
1122extern 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__));
1127extern 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__));
1132typedef u_int16_t n_short;
1133typedef u_int32_t n_long;
1134typedef u_int32_t n_time;
1135typedef int bool_t;
1136typedef int enum_t;
1137typedef unsigned long rpcprog_t;
1138typedef unsigned long rpcvers_t;
1139typedef unsigned long rpcproc_t;
1140typedef unsigned long rpcprot_t;
1141typedef unsigned long rpcport_t;
1142typedef long int wchar_t;
1143union 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 };
1160typedef union
1161 {
1162 union wait *__uptr;
1163 int *__iptr;
1164 } __WAIT_STATUS __attribute__ ((__transparent_union__));
1165typedef struct
1166 {
1167 int quot;
1168 int rem;
1169 } div_t;
1170typedef 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;
1180extern size_t __ctype_get_mb_cur_max (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1181extern double atof (const char *__nptr)
1182 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1183extern int atoi (const char *__nptr)
1184 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1185extern 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__));
1189extern double strtod (const char *__restrict __nptr,
1190 char **__restrict __endptr)
1191 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1192extern float strtof (const char *__restrict __nptr,
1193 char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1194extern long double strtold (const char *__restrict __nptr,
1195 char **__restrict __endptr)
1196 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1197extern long int strtol (const char *__restrict __nptr,
1198 char **__restrict __endptr, int __base)
1199 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1200extern unsigned long int strtoul (const char *__restrict __nptr,
1201 char **__restrict __endptr, int __base)
1202 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1203__extension__
1204extern long long int strtoq (const char *__restrict __nptr,
1205 char **__restrict __endptr, int __base)
1206 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1207__extension__
1208extern unsigned long long int strtouq (const char *__restrict __nptr,
1209 char **__restrict __endptr, int __base)
1210 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1211__extension__
1212extern long long int strtoll (const char *__restrict __nptr,
1213 char **__restrict __endptr, int __base)
1214 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1215__extension__
1216extern unsigned long long int strtoull (const char *__restrict __nptr,
1217 char **__restrict __endptr, int __base)
1218 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1219extern 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)));
1222extern 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__
1227extern 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__
1232extern 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)));
1236extern double strtod_l (const char *__restrict __nptr,
1237 char **__restrict __endptr, __locale_t __loc)
1238 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3)));
1239extern float strtof_l (const char *__restrict __nptr,
1240 char **__restrict __endptr, __locale_t __loc)
1241 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3)));
1242extern long double strtold_l (const char *__restrict __nptr,
1243 char **__restrict __endptr,
1244 __locale_t __loc)
1245 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3)));
1246extern __inline int
1247__attribute__ ((__nothrow__ , __leaf__)) atoi (const char *__nptr)
1248{
1249 return (int) strtol (__nptr, (char **) ((void *)0), 10);
1250}
1251extern __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}
1261extern char *l64a (long int __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1262extern long int a64l (const char *__s)
1263 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1264extern long int random (void) __attribute__ ((__nothrow__ , __leaf__));
1265extern void srandom (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));
1266extern char *initstate (unsigned int __seed, char *__statebuf,
1267 size_t __statelen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1268extern char *setstate (char *__statebuf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1269struct 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 };
1279extern int random_r (struct random_data *__restrict __buf,
1280 int32_t *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1281extern int srandom_r (unsigned int __seed, struct random_data *__buf)
1282 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1283extern 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)));
1287extern int setstate_r (char *__restrict __statebuf,
1288 struct random_data *__restrict __buf)
1289 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1290extern int rand (void) __attribute__ ((__nothrow__ , __leaf__));
1291extern void srand (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));
1292extern int rand_r (unsigned int *__seed) __attribute__ ((__nothrow__ , __leaf__));
1293extern double drand48 (void) __attribute__ ((__nothrow__ , __leaf__));
1294extern double erand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1295extern long int lrand48 (void) __attribute__ ((__nothrow__ , __leaf__));
1296extern long int nrand48 (unsigned short int __xsubi[3])
1297 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1298extern long int mrand48 (void) __attribute__ ((__nothrow__ , __leaf__));
1299extern long int jrand48 (unsigned short int __xsubi[3])
1300 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1301extern void srand48 (long int __seedval) __attribute__ ((__nothrow__ , __leaf__));
1302extern unsigned short int *seed48 (unsigned short int __seed16v[3])
1303 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1304extern void lcong48 (unsigned short int __param[7]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1305struct 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 };
1313extern int drand48_r (struct drand48_data *__restrict __buffer,
1314 double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1315extern 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)));
1318extern int lrand48_r (struct drand48_data *__restrict __buffer,
1319 long int *__restrict __result)
1320 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1321extern 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)));
1325extern int mrand48_r (struct drand48_data *__restrict __buffer,
1326 long int *__restrict __result)
1327 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1328extern 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)));
1332extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
1333 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1334extern int seed48_r (unsigned short int __seed16v[3],
1335 struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1336extern int lcong48_r (unsigned short int __param[7],
1337 struct drand48_data *__buffer)
1338 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1339extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
1340extern void *calloc (size_t __nmemb, size_t __size)
1341 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
1342extern void *realloc (void *__ptr, size_t __size)
1343 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1344extern void free (void *__ptr) __attribute__ ((__nothrow__ , __leaf__));
1345extern void cfree (void *__ptr) __attribute__ ((__nothrow__ , __leaf__));
1346extern void *alloca (size_t __size) __attribute__ ((__nothrow__ , __leaf__));
1347extern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
1348extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
1349 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1350extern void *aligned_alloc (size_t __alignment, size_t __size)
1351 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__)) __attribute__ ((__malloc__, __alloc_size__ (2)));
1352extern void abort (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
1353extern int atexit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1354extern int at_quick_exit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1355extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
1356 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1357extern void exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
1358extern void quick_exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
1359extern void _Exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
1360extern char *getenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1361extern char *secure_getenv (const char *__name)
1362 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1363extern int putenv (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1364extern int setenv (const char *__name, const char *__value, int __replace)
1365 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1366extern int unsetenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1367extern int clearenv (void) __attribute__ ((__nothrow__ , __leaf__));
1368extern char *mktemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1369extern int mkstemp (char *__template) __asm__ ("" "mkstemp64")
1370 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1371extern int mkstemp64 (char *__template) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1372extern int mkstemps (char *__template, int __suffixlen) __asm__ ("" "mkstemps64")
1373 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1374extern int mkstemps64 (char *__template, int __suffixlen)
1375 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1376extern char *mkdtemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1377extern int mkostemp (char *__template, int __flags) __asm__ ("" "mkostemp64")
1378 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1379extern int mkostemp64 (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1380extern int mkostemps (char *__template, int __suffixlen, int __flags) __asm__ ("" "mkostemps64")
1381 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1382extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
1383 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1384extern int system (const char *__command) __attribute__ ((__warn_unused_result__));
1385extern char *canonicalize_file_name (const char *__name)
1386 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1387extern char *realpath (const char *__restrict __name,
1388 char *__restrict __resolved) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1389typedef int (*__compar_fn_t) (const void *, const void *);
1390typedef __compar_fn_t comparison_fn_t;
1391typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
1392extern 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__));
1395extern void qsort (void *__base, size_t __nmemb, size_t __size,
1396 __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
1397extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
1398 __compar_d_fn_t __compar, void *__arg)
1399 __attribute__ ((__nonnull__ (1, 4)));
1400extern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
1401extern 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__));
1404extern div_t div (int __numer, int __denom)
1405 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
1406extern 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__));
1411extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
1412 int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
1413extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
1414 int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
1415extern char *gcvt (double __value, int __ndigit, char *__buf)
1416 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) __attribute__ ((__warn_unused_result__));
1417extern 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__));
1420extern 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__));
1423extern char *qgcvt (long double __value, int __ndigit, char *__buf)
1424 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) __attribute__ ((__warn_unused_result__));
1425extern 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)));
1428extern 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)));
1431extern 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)));
1435extern 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)));
1439extern int mblen (const char *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1440extern int mbtowc (wchar_t *__restrict __pwc,
1441 const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1442extern int wctomb (char *__s, wchar_t __wchar) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1443extern size_t mbstowcs (wchar_t *__restrict __pwcs,
1444 const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
1445extern size_t wcstombs (char *__restrict __s,
1446 const wchar_t *__restrict __pwcs, size_t __n)
1447 __attribute__ ((__nothrow__ , __leaf__));
1448extern int rpmatch (const char *__response) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1449extern 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__));
1453extern void setkey (const char *__key) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1454extern int posix_openpt (int __oflag) __attribute__ ((__warn_unused_result__));
1455extern int grantpt (int __fd) __attribute__ ((__nothrow__ , __leaf__));
1456extern int unlockpt (int __fd) __attribute__ ((__nothrow__ , __leaf__));
1457extern char *ptsname (int __fd) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1458extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
1459 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1460extern int getpt (void);
1461extern int getloadavg (double __loadavg[], int __nelem)
1462 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1463extern __inline double
1464__attribute__ ((__nothrow__ , __leaf__)) atof (const char *__nptr)
1465{
1466 return strtod (__nptr, (char **) ((void *)0));
1467}
1468extern char *__realpath_chk (const char *__restrict __name,
1469 char *__restrict __resolved,
1470 size_t __resolvedlen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1471extern char *__realpath_alias (const char *__restrict __name, char *__restrict __resolved) __asm__ ("" "realpath") __attribute__ ((__nothrow__ , __leaf__))
1472 __attribute__ ((__warn_unused_result__));
1473extern 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 ;
1477extern __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}
1488extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen,
1489 size_t __nreal) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
1490extern int __ptsname_r_alias (int __fd, char *__buf, size_t __buflen) __asm__ ("" "ptsname_r") __attribute__ ((__nothrow__ , __leaf__))
1491 __attribute__ ((__nonnull__ (2)));
1492extern 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 ;
1495extern __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}
1507extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen)
1508 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1509extern int __wctomb_alias (char *__s, wchar_t __wchar) __asm__ ("" "wctomb") __attribute__ ((__nothrow__ , __leaf__))
1510 __attribute__ ((__warn_unused_result__));
1511extern __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}
1518extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
1519 const char *__restrict __src,
1520 size_t __len, size_t __dstlen) __attribute__ ((__nothrow__ , __leaf__));
1521extern size_t __mbstowcs_alias (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len) __asm__ ("" "mbstowcs") __attribute__ ((__nothrow__ , __leaf__))
1522 ;
1523extern 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 ;
1526extern __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}
1540extern size_t __wcstombs_chk (char *__restrict __dst,
1541 const wchar_t *__restrict __src,
1542 size_t __len, size_t __dstlen) __attribute__ ((__nothrow__ , __leaf__));
1543extern size_t __wcstombs_alias (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len) __asm__ ("" "wcstombs") __attribute__ ((__nothrow__ , __leaf__))
1544 ;
1545extern 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")));
1547extern __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}
1559extern int __sigismember (const __sigset_t *, int);
1560extern int __sigaddset (__sigset_t *, int);
1561extern int __sigdelset (__sigset_t *, int);
1562extern __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; }
1563extern __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); }
1564extern __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); }
1565typedef __sig_atomic_t sig_atomic_t;
1566typedef union sigval
1567 {
1568 int sival_int;
1569 void *sival_ptr;
1570 } sigval_t;
1571typedef 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;
1621enum
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};
1633enum
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};
1644enum
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};
1655enum
1656{
1657 SEGV_MAPERR = 1,
1658 SEGV_ACCERR
1659};
1660enum
1661{
1662 BUS_ADRALN = 1,
1663 BUS_ADRERR,
1664 BUS_OBJERR
1665};
1666enum
1667{
1668 TRAP_BRKPT = 1,
1669 TRAP_TRACE
1670};
1671enum
1672{
1673 CLD_EXITED = 1,
1674 CLD_KILLED,
1675 CLD_DUMPED,
1676 CLD_TRAPPED,
1677 CLD_STOPPED,
1678 CLD_CONTINUED
1679};
1680enum
1681{
1682 POLL_IN = 1,
1683 POLL_OUT,
1684 POLL_MSG,
1685 POLL_ERR,
1686 POLL_PRI,
1687 POLL_HUP
1688};
1689typedef 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;
1705enum
1706{
1707 SIGEV_SIGNAL = 0,
1708 SIGEV_NONE,
1709 SIGEV_THREAD,
1710 SIGEV_THREAD_ID = 4
1711};
1712typedef void (*__sighandler_t) (int);
1713extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
1714 __attribute__ ((__nothrow__ , __leaf__));
1715extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
1716 __attribute__ ((__nothrow__ , __leaf__));
1717extern __sighandler_t signal (int __sig, __sighandler_t __handler)
1718 __attribute__ ((__nothrow__ , __leaf__));
1719extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
1720 __attribute__ ((__nothrow__ , __leaf__));
1721extern int kill (__pid_t __pid, int __sig) __attribute__ ((__nothrow__ , __leaf__));
1722extern int killpg (__pid_t __pgrp, int __sig) __attribute__ ((__nothrow__ , __leaf__));
1723extern int raise (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1724extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
1725 __attribute__ ((__nothrow__ , __leaf__));
1726extern int gsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1727extern void psignal (int __sig, const char *__s);
1728extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
1729extern int __sigpause (int __sig_or_mask, int __is_sig);
1730extern int sigpause (int __sig) __asm__ ("__xpg_sigpause");
1731extern int sigblock (int __mask) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1732extern int sigsetmask (int __mask) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1733extern int siggetmask (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1734typedef __sighandler_t sighandler_t;
1735typedef __sighandler_t sig_t;
1736extern int sigemptyset (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1737extern int sigfillset (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1738extern int sigaddset (sigset_t *__set, int __signo) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1739extern int sigdelset (sigset_t *__set, int __signo) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1740extern int sigismember (const sigset_t *__set, int __signo)
1741 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1742extern int sigisemptyset (const sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1743extern int sigandset (sigset_t *__set, const sigset_t *__left,
1744 const sigset_t *__right) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3)));
1745extern int sigorset (sigset_t *__set, const sigset_t *__left,
1746 const sigset_t *__right) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3)));
1747struct 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 };
1758extern int sigprocmask (int __how, const sigset_t *__restrict __set,
1759 sigset_t *__restrict __oset) __attribute__ ((__nothrow__ , __leaf__));
1760extern int sigsuspend (const sigset_t *__set) __attribute__ ((__nonnull__ (1)));
1761extern int sigaction (int __sig, const struct sigaction *__restrict __act,
1762 struct sigaction *__restrict __oact) __attribute__ ((__nothrow__ , __leaf__));
1763extern int sigpending (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
1764extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
1765 __attribute__ ((__nonnull__ (1, 2)));
1766extern int sigwaitinfo (const sigset_t *__restrict __set,
1767 siginfo_t *__restrict __info) __attribute__ ((__nonnull__ (1)));
1768extern int sigtimedwait (const sigset_t *__restrict __set,
1769 siginfo_t *__restrict __info,
1770 const struct timespec *__restrict __timeout)
1771 __attribute__ ((__nonnull__ (1)));
1772extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
1773 __attribute__ ((__nothrow__ , __leaf__));
1774extern const char *const _sys_siglist[65];
1775extern const char *const sys_siglist[65];
1776struct sigvec
1777 {
1778 __sighandler_t sv_handler;
1779 int sv_mask;
1780 int sv_flags;
1781 };
1782extern int sigvec (int __sig, const struct sigvec *__vec,
1783 struct sigvec *__ovec) __attribute__ ((__nothrow__ , __leaf__));
1784struct 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};
1792extern int sigreturn (struct sigcontext *__scp) __attribute__ ((__nothrow__ , __leaf__));
1793extern int siginterrupt (int __sig, int __interrupt) __attribute__ ((__nothrow__ , __leaf__));
1794struct sigstack
1795 {
1796 void *ss_sp;
1797 int ss_onstack;
1798 };
1799enum
1800{
1801 SS_ONSTACK = 1,
1802 SS_DISABLE
1803};
1804typedef struct sigaltstack
1805 {
1806 void *ss_sp;
1807 int ss_flags;
1808 size_t ss_size;
1809 } stack_t;
1810typedef unsigned long int greg_t;
1811typedef 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;
1818typedef struct fpregset
1819 {
1820 double fp_dregs[32];
1821 } fpregset_t;
1822typedef struct sigcontext mcontext_t;
1823typedef 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;
1831extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
1832 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
1833extern int sigaltstack (const struct sigaltstack *__restrict __ss,
1834 struct sigaltstack *__restrict __oss) __attribute__ ((__nothrow__ , __leaf__));
1835extern int sighold (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1836extern int sigrelse (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1837extern int sigignore (int __sig) __attribute__ ((__nothrow__ , __leaf__));
1838extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __attribute__ ((__nothrow__ , __leaf__));
1839extern int pthread_sigmask (int __how,
1840 const __sigset_t *__restrict __newmask,
1841 __sigset_t *__restrict __oldmask)__attribute__ ((__nothrow__ , __leaf__));
1842extern int pthread_kill (pthread_t __threadid, int __signo) __attribute__ ((__nothrow__ , __leaf__));
1843extern int pthread_sigqueue (pthread_t __threadid, int __signo,
1844 const union sigval __value) __attribute__ ((__nothrow__ , __leaf__));
1845extern int __libc_current_sigrtmin (void) __attribute__ ((__nothrow__ , __leaf__));
1846extern int __libc_current_sigrtmax (void) __attribute__ ((__nothrow__ , __leaf__));
1847extern int *__errno_location (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1848extern char *program_invocation_name, *program_invocation_short_name;
1849typedef int error_t;
1850struct 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 };
1858struct 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 };
1872struct 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 };
1885struct 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 };
1894struct 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};
1904struct _IO_FILE;
1905typedef struct _IO_FILE FILE;
1906extern void setpwent (void);
1907extern void endpwent (void);
1908extern struct passwd *getpwent (void);
1909extern struct passwd *fgetpwent (FILE *__stream);
1910extern int putpwent (const struct passwd *__restrict __p,
1911 FILE *__restrict __f);
1912extern struct passwd *getpwuid (__uid_t __uid);
1913extern struct passwd *getpwnam (const char *__name);
1914extern int getpwent_r (struct passwd *__restrict __resultbuf,
1915 char *__restrict __buffer, size_t __buflen,
1916 struct passwd **__restrict __result);
1917extern int getpwuid_r (__uid_t __uid,
1918 struct passwd *__restrict __resultbuf,
1919 char *__restrict __buffer, size_t __buflen,
1920 struct passwd **__restrict __result);
1921extern int getpwnam_r (const char *__restrict __name,
1922 struct passwd *__restrict __resultbuf,
1923 char *__restrict __buffer, size_t __buflen,
1924 struct passwd **__restrict __result);
1925extern int fgetpwent_r (FILE *__restrict __stream,
1926 struct passwd *__restrict __resultbuf,
1927 char *__restrict __buffer, size_t __buflen,
1928 struct passwd **__restrict __result);
1929extern int getpw (__uid_t __uid, char *__buffer);
1930void platform_pre_listen(void);
1931void platform_pre_fork(void);
1932void platform_pre_restart(void);
1933void platform_post_fork_parent(pid_t child_pid);
1934void platform_post_fork_child(void);
1935int platform_privileged_uidswap(void);
1936void platform_setusercontext(struct passwd *);
1937void platform_setusercontext_post_groups(struct passwd *);
1938char *platform_get_krb5_client(const char *);
1939char *platform_krb5_get_principal_name(const char *);
1940int platform_sys_dir_uid(uid_t);
1941int b64_ntop(u_char const *src, size_t srclength, char *target,
1942 size_t targsize);
1943int b64_pton(char const *src, u_char *target, size_t targsize);
1944struct stat;
1945typedef 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;
1959int glob(const char *, int, int (*)(const char *, int), glob_t *);
1960void globfree(glob_t *);
1961char * readpassphrase(const char *, char *, size_t, int);
1962char *vis(char *, int, int, int);
1963int strvis(char *, const char *, int);
1964int strnvis(char *, const char *, size_t, int)
1965 __attribute__ (());
1966int strvisx(char *, const char *, size_t, int)
1967 __attribute__ (());
1968int strunvis(char *, const char *);
1969int unvis(char *, char, int *, int);
1970ssize_t strnunvis(char *, const char *, size_t)
1971 __attribute__ (());
1972typedef 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;
1982typedef 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;
1990struct _ns_flagdata { int mask, shift; };
1991extern const struct _ns_flagdata _ns_flagdata[];
1992typedef 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;
2000typedef 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;
2013typedef 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;
2021typedef 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;
2039typedef enum __ns_update_operation {
2040 ns_uop_delete = 0,
2041 ns_uop_add = 1,
2042 ns_uop_max = 2
2043} ns_update_operation;
2044struct ns_tsig_key {
2045 char name[1025], alg[1025];
2046 unsigned char *data;
2047 int len;
2048};
2049typedef struct ns_tsig_key ns_tsig_key;
2050struct ns_tcp_tsig_state {
2051 int counter;
2052 struct dst_key *key;
2053 void *ctx;
2054 unsigned char sig[512];
2055 int siglen;
2056};
2057typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
2058typedef 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;
2112typedef 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;
2122typedef 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;
2128typedef 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;
2135int ns_msg_getflag (ns_msg, int) __attribute__ ((__nothrow__ , __leaf__));
2136u_int ns_get16 (const u_char *) __attribute__ ((__nothrow__ , __leaf__));
2137u_long ns_get32 (const u_char *) __attribute__ ((__nothrow__ , __leaf__));
2138void ns_put16 (u_int, u_char *) __attribute__ ((__nothrow__ , __leaf__));
2139void ns_put32 (u_long, u_char *) __attribute__ ((__nothrow__ , __leaf__));
2140int ns_initparse (const u_char *, int, ns_msg *) __attribute__ ((__nothrow__ , __leaf__));
2141int ns_skiprr (const u_char *, const u_char *, ns_sect, int)
2142 __attribute__ ((__nothrow__ , __leaf__));
2143int ns_parserr (ns_msg *, ns_sect, int, ns_rr *) __attribute__ ((__nothrow__ , __leaf__));
2144int ns_sprintrr (const ns_msg *, const ns_rr *,
2145 const char *, const char *, char *, size_t)
2146 __attribute__ ((__nothrow__ , __leaf__));
2147int 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__));
2151int ns_format_ttl (u_long, char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2152int ns_parse_ttl (const char *, u_long *) __attribute__ ((__nothrow__ , __leaf__));
2153u_int32_t ns_datetosecs (const char *, int *) __attribute__ ((__nothrow__ , __leaf__));
2154int ns_name_ntol (const u_char *, u_char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2155int ns_name_ntop (const u_char *, char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2156int ns_name_pton (const char *, u_char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2157int ns_name_unpack (const u_char *, const u_char *,
2158 const u_char *, u_char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2159int ns_name_pack (const u_char *, u_char *, int,
2160 const u_char **, const u_char **) __attribute__ ((__nothrow__ , __leaf__));
2161int ns_name_uncompress (const u_char *, const u_char *,
2162 const u_char *, char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2163int ns_name_compress (const char *, u_char *, size_t,
2164 const u_char **, const u_char **) __attribute__ ((__nothrow__ , __leaf__));
2165int ns_name_skip (const u_char **, const u_char *) __attribute__ ((__nothrow__ , __leaf__));
2166void ns_name_rollback (const u_char *, const u_char **,
2167 const u_char **) __attribute__ ((__nothrow__ , __leaf__));
2168int ns_sign (u_char *, int *, int, int, void *,
2169 const u_char *, int, u_char *, int *, time_t) __attribute__ ((__nothrow__ , __leaf__));
2170int 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__));
2173int ns_sign_tcp (u_char *, int *, int, int,
2174 ns_tcp_tsig_state *, int) __attribute__ ((__nothrow__ , __leaf__));
2175int ns_sign_tcp2 (u_char *, int *, int, int,
2176 ns_tcp_tsig_state *, int,
2177 u_char **, u_char **) __attribute__ ((__nothrow__ , __leaf__));
2178int ns_sign_tcp_init (void *, const u_char *, int,
2179 ns_tcp_tsig_state *) __attribute__ ((__nothrow__ , __leaf__));
2180u_char *ns_find_tsig (u_char *, u_char *) __attribute__ ((__nothrow__ , __leaf__));
2181int ns_verify (u_char *, int *, void *, const u_char *, int,
2182 u_char *, int *, time_t *, int) __attribute__ ((__nothrow__ , __leaf__));
2183int ns_verify_tcp (u_char *, int *, ns_tcp_tsig_state *, int)
2184 __attribute__ ((__nothrow__ , __leaf__));
2185int ns_verify_tcp_init (void *, const u_char *, int,
2186 ns_tcp_tsig_state *) __attribute__ ((__nothrow__ , __leaf__));
2187int ns_samedomain (const char *, const char *) __attribute__ ((__nothrow__ , __leaf__));
2188int ns_subdomain (const char *, const char *) __attribute__ ((__nothrow__ , __leaf__));
2189int ns_makecanon (const char *, char *, size_t) __attribute__ ((__nothrow__ , __leaf__));
2190int ns_samename (const char *, const char *) __attribute__ ((__nothrow__ , __leaf__));
2191typedef 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;
2208struct rpcent
2209{
2210 char *r_name;
2211 char **r_aliases;
2212 int r_number;
2213};
2214extern void setrpcent (int __stayopen) __attribute__ ((__nothrow__ , __leaf__));
2215extern void endrpcent (void) __attribute__ ((__nothrow__ , __leaf__));
2216extern struct rpcent *getrpcbyname (const char *__name) __attribute__ ((__nothrow__ , __leaf__));
2217extern struct rpcent *getrpcbynumber (int __number) __attribute__ ((__nothrow__ , __leaf__));
2218extern struct rpcent *getrpcent (void) __attribute__ ((__nothrow__ , __leaf__));
2219extern int getrpcbyname_r (const char *__name, struct rpcent *__result_buf,
2220 char *__buffer, size_t __buflen,
2221 struct rpcent **__result) __attribute__ ((__nothrow__ , __leaf__));
2222extern int getrpcbynumber_r (int __number, struct rpcent *__result_buf,
2223 char *__buffer, size_t __buflen,
2224 struct rpcent **__result) __attribute__ ((__nothrow__ , __leaf__));
2225extern int getrpcent_r (struct rpcent *__result_buf, char *__buffer,
2226 size_t __buflen, struct rpcent **__result) __attribute__ ((__nothrow__ , __leaf__));
2227struct netent
2228{
2229 char *n_name;
2230 char **n_aliases;
2231 int n_addrtype;
2232 uint32_t n_net;
2233};
2234extern int *__h_errno_location (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
2235extern void herror (const char *__str) __attribute__ ((__nothrow__ , __leaf__));
2236extern const char *hstrerror (int __err_num) __attribute__ ((__nothrow__ , __leaf__));
2237struct hostent
2238{
2239 char *h_name;
2240 char **h_aliases;
2241 int h_addrtype;
2242 int h_length;
2243 char **h_addr_list;
2244};
2245extern void sethostent (int __stay_open);
2246extern void endhostent (void);
2247extern struct hostent *gethostent (void);
2248extern struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len,
2249 int __type);
2250extern struct hostent *gethostbyname (const char *__name);
2251extern struct hostent *gethostbyname2 (const char *__name, int __af);
2252extern 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);
2256extern 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);
2262extern 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);
2267extern 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);
2272extern void setnetent (int __stay_open);
2273extern void endnetent (void);
2274extern struct netent *getnetent (void);
2275extern struct netent *getnetbyaddr (uint32_t __net, int __type);
2276extern struct netent *getnetbyname (const char *__name);
2277extern 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);
2281extern 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);
2286extern 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);
2291struct servent
2292{
2293 char *s_name;
2294 char **s_aliases;
2295 int s_port;
2296 char *s_proto;
2297};
2298extern void setservent (int __stay_open);
2299extern void endservent (void);
2300extern struct servent *getservent (void);
2301extern struct servent *getservbyname (const char *__name, const char *__proto);
2302extern struct servent *getservbyport (int __port, const char *__proto);
2303extern int getservent_r (struct servent *__restrict __result_buf,
2304 char *__restrict __buf, size_t __buflen,
2305 struct servent **__restrict __result);
2306extern 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);
2311extern 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);
2315struct protoent
2316{
2317 char *p_name;
2318 char **p_aliases;
2319 int p_proto;
2320};
2321extern void setprotoent (int __stay_open);
2322extern void endprotoent (void);
2323extern struct protoent *getprotoent (void);
2324extern struct protoent *getprotobyname (const char *__name);
2325extern struct protoent *getprotobynumber (int __proto);
2326extern int getprotoent_r (struct protoent *__restrict __result_buf,
2327 char *__restrict __buf, size_t __buflen,
2328 struct protoent **__restrict __result);
2329extern 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);
2333extern int getprotobynumber_r (int __proto,
2334 struct protoent *__restrict __result_buf,
2335 char *__restrict __buf, size_t __buflen,
2336 struct protoent **__restrict __result);
2337extern int setnetgrent (const char *__netgroup);
2338extern void endnetgrent (void);
2339extern int getnetgrent (char **__restrict __hostp,
2340 char **__restrict __userp,
2341 char **__restrict __domainp);
2342extern int innetgr (const char *__netgroup, const char *__host,
2343 const char *__user, const char *__domain);
2344extern int getnetgrent_r (char **__restrict __hostp,
2345 char **__restrict __userp,
2346 char **__restrict __domainp,
2347 char *__restrict __buffer, size_t __buflen);
2348extern 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);
2352extern 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);
2357extern 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);
2361extern 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);
2366extern int ruserok (const char *__rhost, int __suser,
2367 const char *__remuser, const char *__locuser);
2368extern int ruserok_af (const char *__rhost, int __suser,
2369 const char *__remuser, const char *__locuser,
2370 sa_family_t __af);
2371extern int iruserok (uint32_t __raddr, int __suser,
2372 const char *__remuser, const char *__locuser);
2373extern int iruserok_af (const void *__raddr, int __suser,
2374 const char *__remuser, const char *__locuser,
2375 sa_family_t __af);
2376extern int rresvport (int *__alport);
2377extern int rresvport_af (int *__alport, sa_family_t __af);
2378struct 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};
2389struct 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};
2398extern int getaddrinfo (const char *__restrict __name,
2399 const char *__restrict __service,
2400 const struct addrinfo *__restrict __req,
2401 struct addrinfo **__restrict __pai);
2402extern void freeaddrinfo (struct addrinfo *__ai) __attribute__ ((__nothrow__ , __leaf__));
2403extern const char *gai_strerror (int __ecode) __attribute__ ((__nothrow__ , __leaf__));
2404extern 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);
2408extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict],
2409 int __ent, struct sigevent *__restrict __sig);
2410extern int gai_suspend (const struct gaicb *const __list[], int __ent,
2411 const struct timespec *__timeout);
2412extern int gai_error (struct gaicb *__req) __attribute__ ((__nothrow__ , __leaf__));
2413extern int gai_cancel (struct gaicb *__gaicbp) __attribute__ ((__nothrow__ , __leaf__));
2414typedef struct _IO_FILE __FILE;
2415typedef struct
2416{
2417 int __count;
2418 union
2419 {
2420 unsigned int __wch;
2421 char __wchb[4];
2422 } __value;
2423} __mbstate_t;
2424typedef struct
2425{
2426 __off_t __pos;
2427 __mbstate_t __state;
2428} _G_fpos_t;
2429typedef struct
2430{
2431 __off64_t __pos;
2432 __mbstate_t __state;
2433} _G_fpos64_t;
2434typedef __builtin_va_list __gnuc_va_list;
2435struct _IO_jump_t; struct _IO_FILE;
2436typedef void _IO_lock_t;
2437struct _IO_marker {
2438 struct _IO_marker *_next;
2439 struct _IO_FILE *_sbuf;
2440 int _pos;
2441};
2442enum __codecvt_result
2443{
2444 __codecvt_ok,
2445 __codecvt_partial,
2446 __codecvt_error,
2447 __codecvt_noconv
2448};
2449struct _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};
2480typedef struct _IO_FILE _IO_FILE;
2481struct _IO_FILE_plus;
2482extern struct _IO_FILE_plus _IO_2_1_stdin_;
2483extern struct _IO_FILE_plus _IO_2_1_stdout_;
2484extern struct _IO_FILE_plus _IO_2_1_stderr_;
2485typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
2486typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,
2487 size_t __n);
2488typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
2489typedef int __io_close_fn (void *__cookie);
2490typedef __io_read_fn cookie_read_function_t;
2491typedef __io_write_fn cookie_write_function_t;
2492typedef __io_seek_fn cookie_seek_function_t;
2493typedef __io_close_fn cookie_close_function_t;
2494typedef 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;
2501typedef _IO_cookie_io_functions_t cookie_io_functions_t;
2502struct _IO_cookie_file;
2503extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
2504 void *__cookie, _IO_cookie_io_functions_t __fns);
2505extern int __underflow (_IO_FILE *);
2506extern int __uflow (_IO_FILE *);
2507extern int __overflow (_IO_FILE *, int);
2508extern int _IO_getc (_IO_FILE *__fp);
2509extern int _IO_putc (int __c, _IO_FILE *__fp);
2510extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
2511extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
2512extern int _IO_peekc_locked (_IO_FILE *__fp);
2513extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
2514extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
2515extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
2516extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
2517 __gnuc_va_list, int *__restrict);
2518extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
2519 __gnuc_va_list);
2520extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
2521extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
2522extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
2523extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
2524extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
2525typedef __gnuc_va_list va_list;
2526typedef _G_fpos64_t fpos_t;
2527typedef _G_fpos64_t fpos64_t;
2528extern struct _IO_FILE *stdin;
2529extern struct _IO_FILE *stdout;
2530extern struct _IO_FILE *stderr;
2531extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__));
2532extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));
2533extern int renameat (int __oldfd, const char *__old, int __newfd,
2534 const char *__new) __attribute__ ((__nothrow__ , __leaf__));
2535extern FILE *tmpfile (void) __asm__ ("" "tmpfile64") __attribute__ ((__warn_unused_result__));
2536extern FILE *tmpfile64 (void) __attribute__ ((__warn_unused_result__));
2537extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2538extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2539extern char *tempnam (const char *__dir, const char *__pfx)
2540 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
2541extern int fclose (FILE *__stream);
2542extern int fflush (FILE *__stream);
2543extern int fflush_unlocked (FILE *__stream);
2544extern int fcloseall (void);
2545extern FILE *fopen (const char *__restrict __filename, const char *__restrict __modes) __asm__ ("" "fopen64")
2546 __attribute__ ((__warn_unused_result__));
2547extern FILE *freopen (const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream) __asm__ ("" "freopen64")
2548 __attribute__ ((__warn_unused_result__));
2549extern FILE *fopen64 (const char *__restrict __filename,
2550 const char *__restrict __modes) __attribute__ ((__warn_unused_result__));
2551extern FILE *freopen64 (const char *__restrict __filename,
2552 const char *__restrict __modes,
2553 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2554extern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2555extern 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__));
2558extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
2559 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2560extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2561extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
2562extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
2563 int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
2564extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
2565 size_t __size) __attribute__ ((__nothrow__ , __leaf__));
2566extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2567extern int fprintf (FILE *__restrict __stream,
2568 const char *__restrict __format, ...);
2569extern int printf (const char *__restrict __format, ...);
2570extern int sprintf (char *__restrict __s,
2571 const char *__restrict __format, ...) __attribute__ ((__nothrow__));
2572extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
2573 __gnuc_va_list __arg);
2574extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
2575extern int vsprintf (char *__restrict __s, const char *__restrict __format,
2576 __gnuc_va_list __arg) __attribute__ ((__nothrow__));
2577extern int snprintf (char *__restrict __s, size_t __maxlen,
2578 const char *__restrict __format, ...)
2579 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));
2580extern 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)));
2583extern 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__));
2586extern int __asprintf (char **__restrict __ptr,
2587 const char *__restrict __fmt, ...)
2588 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__ ((__warn_unused_result__));
2589extern int asprintf (char **__restrict __ptr,
2590 const char *__restrict __fmt, ...)
2591 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__ ((__warn_unused_result__));
2592extern int vdprintf (int __fd, const char *__restrict __fmt,
2593 __gnuc_va_list __arg)
2594 __attribute__ ((__format__ (__printf__, 2, 0)));
2595extern int dprintf (int __fd, const char *__restrict __fmt, ...)
2596 __attribute__ ((__format__ (__printf__, 2, 3)));
2597extern int fscanf (FILE *__restrict __stream,
2598 const char *__restrict __format, ...) __attribute__ ((__warn_unused_result__));
2599extern int scanf (const char *__restrict __format, ...) __attribute__ ((__warn_unused_result__));
2600extern int sscanf (const char *__restrict __s,
2601 const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));
2602extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
2603 __gnuc_va_list __arg)
2604 __attribute__ ((__format__ (__scanf__, 2, 0))) __attribute__ ((__warn_unused_result__));
2605extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
2606 __attribute__ ((__format__ (__scanf__, 1, 0))) __attribute__ ((__warn_unused_result__));
2607extern int vsscanf (const char *__restrict __s,
2608 const char *__restrict __format, __gnuc_va_list __arg)
2609 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0)));
2610extern int fgetc (FILE *__stream);
2611extern int getc (FILE *__stream);
2612extern int getchar (void);
2613extern int getc_unlocked (FILE *__stream);
2614extern int getchar_unlocked (void);
2615extern int fgetc_unlocked (FILE *__stream);
2616extern int fputc (int __c, FILE *__stream);
2617extern int putc (int __c, FILE *__stream);
2618extern int putchar (int __c);
2619extern int fputc_unlocked (int __c, FILE *__stream);
2620extern int putc_unlocked (int __c, FILE *__stream);
2621extern int putchar_unlocked (int __c);
2622extern int getw (FILE *__stream);
2623extern int putw (int __w, FILE *__stream);
2624extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
2625 __attribute__ ((__warn_unused_result__));
2626extern char *fgets_unlocked (char *__restrict __s, int __n,
2627 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2628extern __ssize_t __getdelim (char **__restrict __lineptr,
2629 size_t *__restrict __n, int __delimiter,
2630 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2631extern __ssize_t getdelim (char **__restrict __lineptr,
2632 size_t *__restrict __n, int __delimiter,
2633 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2634extern __ssize_t getline (char **__restrict __lineptr,
2635 size_t *__restrict __n,
2636 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2637extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
2638extern int puts (const char *__s);
2639extern int ungetc (int __c, FILE *__stream);
2640extern size_t fread (void *__restrict __ptr, size_t __size,
2641 size_t __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2642extern size_t fwrite (const void *__restrict __ptr, size_t __size,
2643 size_t __n, FILE *__restrict __s);
2644extern int fputs_unlocked (const char *__restrict __s,
2645 FILE *__restrict __stream);
2646extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
2647 size_t __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2648extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
2649 size_t __n, FILE *__restrict __stream);
2650extern int fseek (FILE *__stream, long int __off, int __whence);
2651extern long int ftell (FILE *__stream) __attribute__ ((__warn_unused_result__));
2652extern void rewind (FILE *__stream);
2653extern int fseeko (FILE *__stream, __off64_t __off, int __whence) __asm__ ("" "fseeko64")
2654 ;
2655extern __off64_t ftello (FILE *__stream) __asm__ ("" "ftello64");
2656extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos) __asm__ ("" "fgetpos64")
2657 ;
2658extern int fsetpos (FILE *__stream, const fpos_t *__pos) __asm__ ("" "fsetpos64")
2659 ;
2660extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
2661extern __off64_t ftello64 (FILE *__stream) __attribute__ ((__warn_unused_result__));
2662extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
2663extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
2664extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2665extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2666extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2667extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2668extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2669extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2670extern void perror (const char *__s);
2671extern int sys_nerr;
2672extern const char *const sys_errlist[];
2673extern int _sys_nerr;
2674extern const char *const _sys_errlist[];
2675extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2676extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2677extern FILE *popen (const char *__command, const char *__modes) __attribute__ ((__warn_unused_result__));
2678extern int pclose (FILE *__stream);
2679extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));
2680extern char *cuserid (char *__s);
2681struct obstack;
2682extern int obstack_printf (struct obstack *__restrict __obstack,
2683 const char *__restrict __format, ...)
2684 __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 2, 3)));
2685extern 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)));
2689extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2690extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
2691extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
2692extern __inline int
2693getchar (void)
2694{
2695 return _IO_getc (stdin);
2696}
2697extern __inline int
2698fgetc_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}
2702extern __inline int
2703getc_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}
2707extern __inline int
2708getchar_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}
2712extern __inline int
2713putchar (int __c)
2714{
2715 return _IO_putc (__c, stdout);
2716}
2717extern __inline int
2718fputc_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}
2722extern __inline int
2723putc_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}
2727extern __inline int
2728putchar_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}
2732extern __inline __ssize_t
2733getline (char **__lineptr, size_t *__n, FILE *__stream)
2734{
2735 return __getdelim (__lineptr, __n, '\n', __stream);
2736}
2737extern __inline int
2738__attribute__ ((__nothrow__ , __leaf__)) feof_unlocked (FILE *__stream)
2739{
2740 return (((__stream)->_flags & 0x10) != 0);
2741}
2742extern __inline int
2743__attribute__ ((__nothrow__ , __leaf__)) ferror_unlocked (FILE *__stream)
2744{
2745 return (((__stream)->_flags & 0x20) != 0);
2746}
2747extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen,
2748 const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));
2749extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
2750 const char *__restrict __format,
2751 __gnuc_va_list __ap) __attribute__ ((__nothrow__ , __leaf__));
2752extern __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}
2758extern __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}
2764extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag,
2765 size_t __slen, const char *__restrict __format,
2766 ...) __attribute__ ((__nothrow__ , __leaf__));
2767extern 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__));
2770extern __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}
2776extern __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}
2782extern int __fprintf_chk (FILE *__restrict __stream, int __flag,
2783 const char *__restrict __format, ...);
2784extern int __printf_chk (int __flag, const char *__restrict __format, ...);
2785extern int __vfprintf_chk (FILE *__restrict __stream, int __flag,
2786 const char *__restrict __format, __gnuc_va_list __ap);
2787extern int __vprintf_chk (int __flag, const char *__restrict __format,
2788 __gnuc_va_list __ap);
2789extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2790fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
2791{
2792 return __fprintf_chk (__stream, 2 - 1, __fmt,
2793 __builtin_va_arg_pack ());
2794}
2795extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2796printf (const char *__restrict __fmt, ...)
2797{
2798 return __printf_chk (2 - 1, __fmt, __builtin_va_arg_pack ());
2799}
2800extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2801vprintf (const char *__restrict __fmt, __gnuc_va_list __ap)
2802{
2803 return __vfprintf_chk (stdout, 2 - 1, __fmt, __ap);
2804}
2805extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2806vfprintf (FILE *__restrict __stream,
2807 const char *__restrict __fmt, __gnuc_va_list __ap)
2808{
2809 return __vfprintf_chk (__stream, 2 - 1, __fmt, __ap);
2810}
2811extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt,
2812 ...) __attribute__ ((__format__ (__printf__, 3, 4)));
2813extern int __vdprintf_chk (int __fd, int __flag,
2814 const char *__restrict __fmt, __gnuc_va_list __arg)
2815 __attribute__ ((__format__ (__printf__, 3, 0)));
2816extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2817dprintf (int __fd, const char *__restrict __fmt, ...)
2818{
2819 return __dprintf_chk (__fd, 2 - 1, __fmt,
2820 __builtin_va_arg_pack ());
2821}
2822extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
2823vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap)
2824{
2825 return __vdprintf_chk (__fd, 2 - 1, __fmt, __ap);
2826}
2827extern 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__));
2830extern 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__));
2833extern 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)));
2837extern 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)));
2842extern __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}
2848extern __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}
2854extern __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}
2860extern __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}
2865extern __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}
2871extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n,
2872 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2873extern char *__fgets_alias (char *__restrict __s, int __n, FILE *__restrict __stream) __asm__ ("" "fgets")
2874 __attribute__ ((__warn_unused_result__));
2875extern 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 ;
2878extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
2879fgets (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}
2890extern 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__));
2893extern size_t __fread_alias (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "fread")
2894 __attribute__ ((__warn_unused_result__));
2895extern 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 ;
2898extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) size_t
2899fread (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}
2913extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size,
2914 int __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
2915extern char *__fgets_unlocked_alias (char *__restrict __s, int __n, FILE *__restrict __stream) __asm__ ("" "fgets_unlocked")
2916 __attribute__ ((__warn_unused_result__));
2917extern 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 ;
2920extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
2921fgets_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}
2932extern 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__));
2935extern 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__));
2937extern 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 ;
2940extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) size_t
2941fread_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}
2975typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
2976 res_sendhookact;
2977typedef 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);
2983typedef 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);
2989struct __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};
3026typedef struct __res_state *res_state;
3027struct res_sym {
3028 int number;
3029 char * name;
3030 char * humanname;
3031};
3032extern struct __res_state *__res_state(void) __attribute__ ((__const__));
3033void __fp_nquery (const u_char *, int, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3034void __fp_query (const u_char *, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3035const char * __hostalias (const char *) __attribute__ ((__nothrow__ , __leaf__));
3036void __p_query (const u_char *) __attribute__ ((__nothrow__ , __leaf__));
3037void __res_close (void) __attribute__ ((__nothrow__ , __leaf__));
3038int __res_init (void) __attribute__ ((__nothrow__ , __leaf__));
3039int __res_isourserver (const struct sockaddr_in *) __attribute__ ((__nothrow__ , __leaf__));
3040int __res_mkquery (int, const char *, int, int, const u_char *,
3041 int, const u_char *, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3042int __res_query (const char *, int, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3043int __res_querydomain (const char *, const char *, int, int,
3044 u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3045int __res_search (const char *, int, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3046int __res_send (const u_char *, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3047int __res_hnok (const char *) __attribute__ ((__nothrow__ , __leaf__));
3048int __res_ownok (const char *) __attribute__ ((__nothrow__ , __leaf__));
3049int __res_mailok (const char *) __attribute__ ((__nothrow__ , __leaf__));
3050int __res_dnok (const char *) __attribute__ ((__nothrow__ , __leaf__));
3051int __sym_ston (const struct res_sym *, const char *, int *) __attribute__ ((__nothrow__ , __leaf__));
3052const char * __sym_ntos (const struct res_sym *, int, int *) __attribute__ ((__nothrow__ , __leaf__));
3053const char * __sym_ntop (const struct res_sym *, int, int *) __attribute__ ((__nothrow__ , __leaf__));
3054int __b64_ntop(u_char const *,size_t,char *,size_t) __attribute__ ((__nothrow__ , __leaf__));
3055int __b64_pton(char const *,u_char *,size_t) __attribute__ ((__nothrow__ , __leaf__));
3056int __loc_aton (const char *__ascii, u_char *__binary) __attribute__ ((__nothrow__ , __leaf__));
3057const char * __loc_ntoa (const u_char *__binary, char *__ascii) __attribute__ ((__nothrow__ , __leaf__));
3058int __dn_skipname (const u_char *, const u_char *) __attribute__ ((__nothrow__ , __leaf__));
3059void __putlong (u_int32_t, u_char *) __attribute__ ((__nothrow__ , __leaf__));
3060void __putshort (u_int16_t, u_char *) __attribute__ ((__nothrow__ , __leaf__));
3061const char * __p_class (int) __attribute__ ((__nothrow__ , __leaf__));
3062const char * __p_time (u_int32_t) __attribute__ ((__nothrow__ , __leaf__));
3063const char * __p_type (int) __attribute__ ((__nothrow__ , __leaf__));
3064const char * __p_rcode (int) __attribute__ ((__nothrow__ , __leaf__));
3065const u_char * __p_cdnname (const u_char *, const u_char *, int, FILE *)
3066 __attribute__ ((__nothrow__ , __leaf__));
3067const u_char * __p_cdname (const u_char *, const u_char *, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3068const u_char * __p_fqnname (const u_char *__cp, const u_char *__msg,
3069 int, char *, int) __attribute__ ((__nothrow__ , __leaf__));
3070const u_char * __p_fqname (const u_char *, const u_char *, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3071const char * __p_option (u_long __option) __attribute__ ((__nothrow__ , __leaf__));
3072char * __p_secstodate (u_long) __attribute__ ((__nothrow__ , __leaf__));
3073int __dn_count_labels (const char *) __attribute__ ((__nothrow__ , __leaf__));
3074int __dn_comp (const char *, u_char *, int, u_char **, u_char **)
3075 __attribute__ ((__nothrow__ , __leaf__));
3076int __dn_expand (const u_char *, const u_char *, const u_char *,
3077 char *, int) __attribute__ ((__nothrow__ , __leaf__));
3078u_int __res_randomid (void) __attribute__ ((__nothrow__ , __leaf__));
3079int __res_nameinquery (const char *, int, int,
3080 const u_char *, const u_char *) __attribute__ ((__nothrow__ , __leaf__));
3081int __res_queriesmatch (const u_char *, const u_char *,
3082 const u_char *, const u_char *) __attribute__ ((__nothrow__ , __leaf__));
3083const char * __p_section (int __section, int __opcode) __attribute__ ((__nothrow__ , __leaf__));
3084int __res_ninit (res_state) __attribute__ ((__nothrow__ , __leaf__));
3085int __res_nisourserver (const res_state,
3086 const struct sockaddr_in *) __attribute__ ((__nothrow__ , __leaf__));
3087void __fp_resstat (const res_state, FILE *) __attribute__ ((__nothrow__ , __leaf__));
3088void __res_npquery (const res_state, const u_char *, int, FILE *)
3089 __attribute__ ((__nothrow__ , __leaf__));
3090const char * __res_hostalias (const res_state, const char *, char *, size_t)
3091 __attribute__ ((__nothrow__ , __leaf__));
3092int __res_nquery (res_state, const char *, int, int, u_char *, int)
3093 __attribute__ ((__nothrow__ , __leaf__));
3094int __res_nsearch (res_state, const char *, int, int, u_char *, int)
3095 __attribute__ ((__nothrow__ , __leaf__));
3096int __res_nquerydomain (res_state, const char *, const char *, int,
3097 int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
3098int __res_nmkquery (res_state, int, const char *, int, int,
3099 const u_char *, int, const u_char *, u_char *,
3100 int) __attribute__ ((__nothrow__ , __leaf__));
3101int __res_nsend (res_state, const u_char *, int, u_char *, int)
3102 __attribute__ ((__nothrow__ , __leaf__));
3103void __res_nclose (res_state) __attribute__ ((__nothrow__ , __leaf__));
3104struct rdatainfo {
3105 unsigned int rdi_length;
3106 unsigned char *rdi_data;
3107};
3108struct 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};
3119int getrrsetbyname(const char *, unsigned int, unsigned int, unsigned int, struct rrsetinfo **);
3120void freerrset(struct rrsetinfo *);
3121typedef struct BlowfishContext {
3122 u_int32_t S[4][256];
3123 u_int32_t P[16 + 2];
3124} blf_ctx;
3125void Blowfish_encipher(blf_ctx *, u_int32_t *, u_int32_t *);
3126void Blowfish_decipher(blf_ctx *, u_int32_t *, u_int32_t *);
3127void Blowfish_initstate(blf_ctx *);
3128void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t);
3129void Blowfish_expandstate
3130(blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t);
3131void blf_key(blf_ctx *, const u_int8_t *, u_int16_t);
3132void blf_enc(blf_ctx *, u_int32_t *, u_int16_t);
3133void blf_dec(blf_ctx *, u_int32_t *, u_int16_t);
3134void blf_ecb_encrypt(blf_ctx *, u_int8_t *, u_int32_t);
3135void blf_ecb_decrypt(blf_ctx *, u_int8_t *, u_int32_t);
3136void blf_cbc_encrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t);
3137void blf_cbc_decrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t);
3138u_int32_t Blowfish_stream2word(const u_int8_t *, u_int16_t , u_int16_t *);
3139int bindresvport_sa(int sd, struct sockaddr *sa);
3140void closefrom(int);
3141size_t strlcpy(char *dst, const char *src, size_t siz);
3142size_t strlcat(char *dst, const char *src, size_t siz);
3143void strmode(int mode, char *p);
3144int mkstemps(char *path, int slen);
3145int mkstemp(char *path);
3146char *mkdtemp(char *path);
3147int fmt_scaled(long long number, char *result);
3148int scan_scaled(char *, long long *);
3149void setproctitle(const char *fmt, ...);
3150void compat_init_setproctitle(int argc, char *argv[]);
3151int BSDgetopt(int argc, char * const *argv, const char *opts);
3152struct option {
3153 const char *name;
3154 int has_arg;
3155 int *flag;
3156 int val;
3157};
3158int getopt_long(int, char * const *, const char *,
3159 const struct option *, int *);
3160int getopt_long_only(int, char * const *, const char *,
3161 const struct option *, int *);
3162int BSDgetopt(int, char * const *, const char *);
3163int getsubopt(char **, char * const *, char **);
3164extern char *BSDoptarg;
3165extern int BSDopterr;
3166extern int BSDoptind;
3167extern int BSDoptopt;
3168extern int BSDoptreset;
3169extern char *suboptarg;
3170char *ssh_get_progname(char *);
3171int setlogin(const char *);
3172typedef void (*mysig_t)(int);
3173mysig_t mysignal(int sig, mysig_t act);
3174int getpeereid(int , uid_t *, gid_t *);
3175unsigned int arc4random(void);
3176void arc4random_stir(void);
3177void arc4random_buf(void *, size_t);
3178u_int32_t arc4random_uniform(u_int32_t);
3179long long strtonum(const char *, long long, long long, const char **);
3180char *user_from_uid(uid_t, int);
3181char *group_from_gid(gid_t, int);
3182int timingsafe_bcmp(const void *, const void *, size_t);
3183int bcrypt_pbkdf(const char *, size_t, const u_int8_t *, size_t,
3184 u_int8_t *, size_t, unsigned int);
3185void explicit_bzero(void *p, size_t n);
3186void *xmmap(size_t size);
3187char *xcrypt(const char *password, const char *salt);
3188char *shadow_pw(struct passwd *pw);
3189void oom_adjust_restore(void);
3190void oom_adjust_setup(void);
3191void solaris_contract_pre_fork(void);
3192void solaris_contract_post_fork_child(void);
3193void solaris_contract_post_fork_parent(pid_t pid);
3194void solaris_set_default_project(struct passwd *);
3195struct Channel;
3196int sys_tun_open(int, int);
3197int sys_tun_infilter(struct Channel *, char *, int);
3198u_char *sys_tun_outfilter(struct Channel *, u_char **, u_int *);
3199typedef struct {
3200 u_char *buf;
3201 u_int alloc;
3202 u_int offset;
3203 u_int end;
3204} Buffer;
3205void buffer_init(Buffer *);
3206void buffer_clear(Buffer *);
3207void buffer_free(Buffer *);
3208u_int buffer_len(const Buffer *);
3209void *buffer_ptr(const Buffer *);
3210void buffer_append(Buffer *, const void *, u_int);
3211void *buffer_append_space(Buffer *, u_int);
3212int buffer_check_alloc(Buffer *, u_int);
3213void buffer_get(Buffer *, void *, u_int);
3214void buffer_consume(Buffer *, u_int);
3215void buffer_consume_end(Buffer *, u_int);
3216void buffer_dump(const Buffer *);
3217int buffer_get_ret(Buffer *, void *, u_int);
3218int buffer_consume_ret(Buffer *, u_int);
3219int buffer_consume_end_ret(Buffer *, u_int);
3220typedef struct asn1_string_st ASN1_INTEGER;
3221typedef struct asn1_string_st ASN1_ENUMERATED;
3222typedef struct asn1_string_st ASN1_BIT_STRING;
3223typedef struct asn1_string_st ASN1_OCTET_STRING;
3224typedef struct asn1_string_st ASN1_PRINTABLESTRING;
3225typedef struct asn1_string_st ASN1_T61STRING;
3226typedef struct asn1_string_st ASN1_IA5STRING;
3227typedef struct asn1_string_st ASN1_GENERALSTRING;
3228typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
3229typedef struct asn1_string_st ASN1_BMPSTRING;
3230typedef struct asn1_string_st ASN1_UTCTIME;
3231typedef struct asn1_string_st ASN1_TIME;
3232typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
3233typedef struct asn1_string_st ASN1_VISIBLESTRING;
3234typedef struct asn1_string_st ASN1_UTF8STRING;
3235typedef struct asn1_string_st ASN1_STRING;
3236typedef int ASN1_BOOLEAN;
3237typedef int ASN1_NULL;
3238typedef struct ASN1_ITEM_st ASN1_ITEM;
3239typedef struct asn1_pctx_st ASN1_PCTX;
3240typedef struct bignum_st BIGNUM;
3241typedef struct bignum_ctx BN_CTX;
3242typedef struct bn_blinding_st BN_BLINDING;
3243typedef struct bn_mont_ctx_st BN_MONT_CTX;
3244typedef struct bn_recp_ctx_st BN_RECP_CTX;
3245typedef struct bn_gencb_st BN_GENCB;
3246typedef struct buf_mem_st BUF_MEM;
3247typedef struct evp_cipher_st EVP_CIPHER;
3248typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
3249typedef struct env_md_st EVP_MD;
3250typedef struct env_md_ctx_st EVP_MD_CTX;
3251typedef struct evp_pkey_st EVP_PKEY;
3252typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
3253typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
3254typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
3255typedef struct dh_st DH;
3256typedef struct dh_method DH_METHOD;
3257typedef struct dsa_st DSA;
3258typedef struct dsa_method DSA_METHOD;
3259typedef struct rsa_st RSA;
3260typedef struct rsa_meth_st RSA_METHOD;
3261typedef struct rand_meth_st RAND_METHOD;
3262typedef struct ecdh_method ECDH_METHOD;
3263typedef struct ecdsa_method ECDSA_METHOD;
3264typedef struct x509_st X509;
3265typedef struct X509_algor_st X509_ALGOR;
3266typedef struct X509_crl_st X509_CRL;
3267typedef struct x509_crl_method_st X509_CRL_METHOD;
3268typedef struct x509_revoked_st X509_REVOKED;
3269typedef struct X509_name_st X509_NAME;
3270typedef struct X509_pubkey_st X509_PUBKEY;
3271typedef struct x509_store_st X509_STORE;
3272typedef struct x509_store_ctx_st X509_STORE_CTX;
3273typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;
3274typedef struct v3_ext_ctx X509V3_CTX;
3275typedef struct conf_st CONF;
3276typedef struct store_st STORE;
3277typedef struct store_method_st STORE_METHOD;
3278typedef struct ui_st UI;
3279typedef struct ui_method_st UI_METHOD;
3280typedef struct st_ERR_FNS ERR_FNS;
3281typedef struct engine_st ENGINE;
3282typedef struct ssl_st SSL;
3283typedef struct ssl_ctx_st SSL_CTX;
3284typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
3285typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
3286typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
3287typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
3288typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;
3289typedef struct DIST_POINT_st DIST_POINT;
3290typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
3291typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
3292typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
3293typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
3294 int idx, long argl, void *argp);
3295typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
3296 int idx, long argl, void *argp);
3297typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
3298 int idx, long argl, void *argp);
3299typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
3300typedef struct ocsp_response_st OCSP_RESPONSE;
3301typedef struct ocsp_responder_id_st OCSP_RESPID;
3302typedef 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;
3310int sk_num(const _STACK *);
3311void *sk_value(const _STACK *, int);
3312void *sk_set(_STACK *, int, void *);
3313_STACK *sk_new(int (*cmp)(const void *, const void *));
3314_STACK *sk_new_null(void);
3315void sk_free(_STACK *);
3316void sk_pop_free(_STACK *st, void (*func)(void *));
3317int sk_insert(_STACK *sk, void *data, int where);
3318void *sk_delete(_STACK *st, int loc);
3319void *sk_delete_ptr(_STACK *st, void *p);
3320int sk_find(_STACK *st, void *data);
3321int sk_find_ex(_STACK *st, void *data);
3322int sk_push(_STACK *st, void *data);
3323int sk_unshift(_STACK *st, void *data);
3324void *sk_shift(_STACK *st);
3325void *sk_pop(_STACK *st);
3326void sk_zero(_STACK *st);
3327int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))
3328 (const void *, const void *);
3329_STACK *sk_dup(_STACK *st);
3330void sk_sort(_STACK *st);
3331int sk_is_sorted(const _STACK *st);
3332typedef char *OPENSSL_STRING;
3333typedef const char *OPENSSL_CSTRING;
3334struct stack_st_OPENSSL_STRING { _STACK stack; };
3335typedef void *OPENSSL_BLOCK;
3336struct stack_st_OPENSSL_BLOCK { _STACK stack; };
3337typedef struct openssl_item_st
3338 {
3339 int code;
3340 void *value;
3341 size_t value_size;
3342 size_t *value_length;
3343 } OPENSSL_ITEM;
3344typedef struct
3345 {
3346 int references;
3347 struct CRYPTO_dynlock_value *data;
3348 } CRYPTO_dynlock;
3349typedef struct bio_st BIO_dummy;
3350struct crypto_ex_data_st
3351 {
3352 struct stack_st_void *sk;
3353 int dummy;
3354 };
3355struct stack_st_void { _STACK stack; };
3356typedef 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;
3364struct stack_st_CRYPTO_EX_DATA_FUNCS { _STACK stack; };
3365int CRYPTO_mem_ctrl(int mode);
3366int CRYPTO_is_mem_check_on(void);
3367const char *SSLeay_version(int type);
3368unsigned long SSLeay(void);
3369int OPENSSL_issetugid(void);
3370typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
3371const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
3372int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
3373int CRYPTO_ex_data_new_class(void);
3374int 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);
3377int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
3378int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
3379 CRYPTO_EX_DATA *from);
3380void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
3381int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
3382void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
3383void CRYPTO_cleanup_all_ex_data(void);
3384int CRYPTO_get_new_lockid(char *name);
3385int CRYPTO_num_locks(void);
3386void CRYPTO_lock(int mode, int type,const char *file,int line);
3387void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
3388 const char *file,int line));
3389void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
3390 int line);
3391void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
3392 const char *file, int line));
3393int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
3394 const char *file,int line);
3395typedef struct crypto_threadid_st
3396 {
3397 void *ptr;
3398 unsigned long val;
3399 } CRYPTO_THREADID;
3400void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
3401void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
3402int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID *));
3403void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *);
3404void CRYPTO_THREADID_current(CRYPTO_THREADID *id);
3405int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);
3406void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);
3407unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);
3408void CRYPTO_set_id_callback(unsigned long (*func)(void));
3409unsigned long (*CRYPTO_get_id_callback(void))(void);
3410unsigned long CRYPTO_thread_id(void);
3411const char *CRYPTO_get_lock_name(int type);
3412int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
3413 int line);
3414int CRYPTO_get_new_dynlockid(void);
3415void CRYPTO_destroy_dynlockid(int i);
3416struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
3417void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
3418void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
3419void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
3420struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
3421void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
3422void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
3423int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
3424int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
3425int 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 *));
3428int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
3429 void (*free_func)(void *));
3430int 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));
3435void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
3436void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
3437void 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 *));
3440void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
3441 void (**f)(void *));
3442void 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));
3447void *CRYPTO_malloc_locked(int num, const char *file, int line);
3448void CRYPTO_free_locked(void *ptr);
3449void *CRYPTO_malloc(int num, const char *file, int line);
3450char *CRYPTO_strdup(const char *str, const char *file, int line);
3451void CRYPTO_free(void *ptr);
3452void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
3453void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
3454 int line);
3455void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
3456void OPENSSL_cleanse(void *ptr, size_t len);
3457void CRYPTO_set_mem_debug_options(long bits);
3458long CRYPTO_get_mem_debug_options(void);
3459int CRYPTO_push_info_(const char *info, const char *file, int line);
3460int CRYPTO_pop_info(void);
3461int CRYPTO_remove_all_info(void);
3462void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
3463void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
3464void CRYPTO_dbg_free(void *addr,int before_p);
3465void CRYPTO_dbg_set_options(long bits);
3466long CRYPTO_dbg_get_options(void);
3467void CRYPTO_mem_leaks_fp(FILE *);
3468void CRYPTO_mem_leaks(struct bio_st *bio);
3469typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
3470void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
3471void OpenSSLDie(const char *file,int line,const char *assertion);
3472unsigned long *OPENSSL_ia32cap_loc(void);
3473int OPENSSL_isservice(void);
3474int FIPS_mode(void);
3475int FIPS_mode_set(int r);
3476void OPENSSL_init(void);
3477int CRYPTO_memcmp(const void *a, const void *b, size_t len);
3478void ERR_load_CRYPTO_strings(void);
3479struct bignum_st
3480 {
3481 unsigned int *d;
3482 int top;
3483 int dmax;
3484 int neg;
3485 int flags;
3486 };
3487struct 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 };
3496struct bn_recp_ctx_st
3497 {
3498 BIGNUM N;
3499 BIGNUM Nr;
3500 int num_bits;
3501 int shift;
3502 int flags;
3503 };
3504struct 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 };
3514int BN_GENCB_call(BN_GENCB *cb, int a, int b);
3515const BIGNUM *BN_value_one(void);
3516char * BN_options(void);
3517BN_CTX *BN_CTX_new(void);
3518void BN_CTX_init(BN_CTX *c);
3519void BN_CTX_free(BN_CTX *c);
3520void BN_CTX_start(BN_CTX *ctx);
3521BIGNUM *BN_CTX_get(BN_CTX *ctx);
3522void BN_CTX_end(BN_CTX *ctx);
3523int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
3524int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
3525int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
3526int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
3527int BN_num_bits(const BIGNUM *a);
3528int BN_num_bits_word(unsigned int);
3529BIGNUM *BN_new(void);
3530void BN_init(BIGNUM *);
3531void BN_clear_free(BIGNUM *a);
3532BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
3533void BN_swap(BIGNUM *a, BIGNUM *b);
3534BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
3535int BN_bn2bin(const BIGNUM *a, unsigned char *to);
3536BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
3537int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
3538int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3539int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3540int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3541int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3542int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
3543int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx);
3544void BN_set_negative(BIGNUM *b, int n);
3545int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
3546 BN_CTX *ctx);
3547int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
3548int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
3549int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
3550int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
3551int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
3552int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3553 const BIGNUM *m, BN_CTX *ctx);
3554int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
3555int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
3556int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
3557int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx);
3558int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
3559unsigned int BN_mod_word(const BIGNUM *a, unsigned int w);
3560unsigned int BN_div_word(BIGNUM *a, unsigned int w);
3561int BN_mul_word(BIGNUM *a, unsigned int w);
3562int BN_add_word(BIGNUM *a, unsigned int w);
3563int BN_sub_word(BIGNUM *a, unsigned int w);
3564int BN_set_word(BIGNUM *a, unsigned int w);
3565unsigned int BN_get_word(const BIGNUM *a);
3566int BN_cmp(const BIGNUM *a, const BIGNUM *b);
3567void BN_free(BIGNUM *a);
3568int BN_is_bit_set(const BIGNUM *a, int n);
3569int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
3570int BN_lshift1(BIGNUM *r, const BIGNUM *a);
3571int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx);
3572int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3573 const BIGNUM *m,BN_CTX *ctx);
3574int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3575 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
3576int 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);
3578int 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);
3580int 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);
3583int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3584 const BIGNUM *m,BN_CTX *ctx);
3585int BN_mask_bits(BIGNUM *a,int n);
3586int BN_print_fp(FILE *fp, const BIGNUM *a);
3587int BN_print(void *fp, const BIGNUM *a);
3588int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
3589int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
3590int BN_rshift1(BIGNUM *r, const BIGNUM *a);
3591void BN_clear(BIGNUM *a);
3592BIGNUM *BN_dup(const BIGNUM *a);
3593int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
3594int BN_set_bit(BIGNUM *a, int n);
3595int BN_clear_bit(BIGNUM *a, int n);
3596char * BN_bn2hex(const BIGNUM *a);
3597char * BN_bn2dec(const BIGNUM *a);
3598int BN_hex2bn(BIGNUM **a, const char *str);
3599int BN_dec2bn(BIGNUM **a, const char *str);
3600int BN_asc2bn(BIGNUM **a, const char *str);
3601int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
3602int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
3603BIGNUM *BN_mod_inverse(BIGNUM *ret,
3604 const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
3605BIGNUM *BN_mod_sqrt(BIGNUM *ret,
3606 const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
3607BIGNUM *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);
3610int BN_is_prime(const BIGNUM *p,int nchecks,
3611 void (*callback)(int,int,void *),
3612 BN_CTX *ctx,void *cb_arg);
3613int 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);
3616int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add,
3617 const BIGNUM *rem, BN_GENCB *cb);
3618int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
3619int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
3620 int do_trial_division, BN_GENCB *cb);
3621int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
3622int 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);
3625int 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);
3630BN_MONT_CTX *BN_MONT_CTX_new(void );
3631void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
3632int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
3633 BN_MONT_CTX *mont, BN_CTX *ctx);
3634int BN_from_montgomery(BIGNUM *r,const BIGNUM *a,
3635 BN_MONT_CTX *mont, BN_CTX *ctx);
3636void BN_MONT_CTX_free(BN_MONT_CTX *mont);
3637int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx);
3638BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
3639BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
3640 const BIGNUM *mod, BN_CTX *ctx);
3641BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
3642void BN_BLINDING_free(BN_BLINDING *b);
3643int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
3644int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
3645int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
3646int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
3647int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
3648unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
3649void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
3650CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
3651unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
3652void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
3653BN_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);
3658void BN_set_params(int mul,int high,int low,int mont);
3659int BN_get_params(int which);
3660void BN_RECP_CTX_init(BN_RECP_CTX *recp);
3661BN_RECP_CTX *BN_RECP_CTX_new(void);
3662void BN_RECP_CTX_free(BN_RECP_CTX *recp);
3663int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
3664int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
3665 BN_RECP_CTX *recp,BN_CTX *ctx);
3666int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3667 const BIGNUM *m, BN_CTX *ctx);
3668int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
3669 BN_RECP_CTX *recp, BN_CTX *ctx);
3670int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
3671int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);
3672int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3673 const BIGNUM *p, BN_CTX *ctx);
3674int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3675 BN_CTX *ctx);
3676int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p,
3677 BN_CTX *ctx);
3678int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3679 const BIGNUM *p, BN_CTX *ctx);
3680int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3681 const BIGNUM *p, BN_CTX *ctx);
3682int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3683 BN_CTX *ctx);
3684int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
3685 BN_CTX *ctx);
3686int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
3687int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3688 const int p[], BN_CTX *ctx);
3689int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
3690 BN_CTX *ctx);
3691int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
3692 BN_CTX *ctx);
3693int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3694 const int p[], BN_CTX *ctx);
3695int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
3696 const int p[], BN_CTX *ctx);
3697int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
3698 const int p[], BN_CTX *ctx);
3699int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
3700 const int p[], BN_CTX *ctx);
3701int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
3702int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
3703int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3704int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3705int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3706int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3707int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
3708const BIGNUM *BN_get0_nist_prime_192(void);
3709const BIGNUM *BN_get0_nist_prime_224(void);
3710const BIGNUM *BN_get0_nist_prime_256(void);
3711const BIGNUM *BN_get0_nist_prime_384(void);
3712const BIGNUM *BN_get0_nist_prime_521(void);
3713BIGNUM *bn_expand2(BIGNUM *a, int words);
3714BIGNUM *bn_dup_expand(const BIGNUM *a, int words);
3715unsigned int bn_mul_add_words(unsigned int *rp, const unsigned int *ap, int num, unsigned int w);
3716unsigned int bn_mul_words(unsigned int *rp, const unsigned int *ap, int num, unsigned int w);
3717void bn_sqr_words(unsigned int *rp, const unsigned int *ap, int num);
3718unsigned int bn_div_words(unsigned int h, unsigned int l, unsigned int d);
3719unsigned int bn_add_words(unsigned int *rp, const unsigned int *ap, const unsigned int *bp,int num);
3720unsigned int bn_sub_words(unsigned int *rp, const unsigned int *ap, const unsigned int *bp,int num);
3721BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
3722BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);
3723BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);
3724BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);
3725BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);
3726BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
3727BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
3728BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
3729int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
3730void ERR_load_BN_strings(void);
3731void buffer_put_bignum(Buffer *, const BIGNUM *);
3732void buffer_put_bignum2(Buffer *, const BIGNUM *);
3733void buffer_get_bignum(Buffer *, BIGNUM *);
3734void buffer_get_bignum2(Buffer *, BIGNUM *);
3735u_short buffer_get_short(Buffer *);
3736void buffer_put_short(Buffer *, u_short);
3737u_int buffer_get_int(Buffer *);
3738void buffer_put_int(Buffer *, u_int);
3739u_int64_t buffer_get_int64(Buffer *);
3740void buffer_put_int64(Buffer *, u_int64_t);
3741int buffer_get_char(Buffer *);
3742void buffer_put_char(Buffer *, int);
3743void *buffer_get_string(Buffer *, u_int *);
3744void *buffer_get_string_ptr(Buffer *, u_int *);
3745void buffer_put_string(Buffer *, const void *, u_int);
3746char *buffer_get_cstring(Buffer *, u_int *);
3747void buffer_put_cstring(Buffer *, const char *);
3748int buffer_put_bignum_ret(Buffer *, const BIGNUM *);
3749int buffer_get_bignum_ret(Buffer *, BIGNUM *);
3750int buffer_put_bignum2_ret(Buffer *, const BIGNUM *);
3751int buffer_get_bignum2_ret(Buffer *, BIGNUM *);
3752int buffer_get_short_ret(u_short *, Buffer *);
3753int buffer_get_int_ret(u_int *, Buffer *);
3754int buffer_get_int64_ret(u_int64_t *, Buffer *);
3755void *buffer_get_string_ret(Buffer *, u_int *);
3756char *buffer_get_cstring_ret(Buffer *, u_int *);
3757void *buffer_get_string_ptr_ret(Buffer *, u_int *);
3758int buffer_get_char_ret(u_char *, Buffer *);
3759void *buffer_get_bignum2_as_string_ret(Buffer *, u_int *);
3760void *buffer_get_bignum2_as_string(Buffer *, u_int *);
3761void buffer_put_bignum2_from_string(Buffer *, const u_char *, u_int);
3762struct 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};
3788extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __attribute__ ((__nothrow__ , __leaf__));
3789struct 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};
3803struct itimerspec
3804 {
3805 struct timespec it_interval;
3806 struct timespec it_value;
3807 };
3808struct sigevent;
3809extern clock_t clock (void) __attribute__ ((__nothrow__ , __leaf__));
3810extern time_t time (time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
3811extern double difftime (time_t __time1, time_t __time0)
3812 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
3813extern time_t mktime (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
3814extern size_t strftime (char *__restrict __s, size_t __maxsize,
3815 const char *__restrict __format,
3816 const struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
3817extern char *strptime (const char *__restrict __s,
3818 const char *__restrict __fmt, struct tm *__tp)
3819 __attribute__ ((__nothrow__ , __leaf__));
3820extern 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__));
3824extern char *strptime_l (const char *__restrict __s,
3825 const char *__restrict __fmt, struct tm *__tp,
3826 __locale_t __loc) __attribute__ ((__nothrow__ , __leaf__));
3827extern struct tm *gmtime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
3828extern struct tm *localtime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
3829extern struct tm *gmtime_r (const time_t *__restrict __timer,
3830 struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
3831extern struct tm *localtime_r (const time_t *__restrict __timer,
3832 struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
3833extern char *asctime (const struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
3834extern char *ctime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
3835extern char *asctime_r (const struct tm *__restrict __tp,
3836 char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
3837extern char *ctime_r (const time_t *__restrict __timer,
3838 char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
3839extern char *__tzname[2];
3840extern int __daylight;
3841extern long int __timezone;
3842extern char *tzname[2];
3843extern void tzset (void) __attribute__ ((__nothrow__ , __leaf__));
3844extern int daylight;
3845extern long int timezone;
3846extern int stime (const time_t *__when) __attribute__ ((__nothrow__ , __leaf__));
3847extern time_t timegm (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
3848extern time_t timelocal (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
3849extern int dysize (int __year) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
3850extern int nanosleep (const struct timespec *__requested_time,
3851 struct timespec *__remaining);
3852extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __attribute__ ((__nothrow__ , __leaf__));
3853extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __attribute__ ((__nothrow__ , __leaf__));
3854extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
3855 __attribute__ ((__nothrow__ , __leaf__));
3856extern int clock_nanosleep (clockid_t __clock_id, int __flags,
3857 const struct timespec *__req,
3858 struct timespec *__rem);
3859extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __attribute__ ((__nothrow__ , __leaf__));
3860extern int timer_create (clockid_t __clock_id,
3861 struct sigevent *__restrict __evp,
3862 timer_t *__restrict __timerid) __attribute__ ((__nothrow__ , __leaf__));
3863extern int timer_delete (timer_t __timerid) __attribute__ ((__nothrow__ , __leaf__));
3864extern int timer_settime (timer_t __timerid, int __flags,
3865 const struct itimerspec *__restrict __value,
3866 struct itimerspec *__restrict __ovalue) __attribute__ ((__nothrow__ , __leaf__));
3867extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
3868 __attribute__ ((__nothrow__ , __leaf__));
3869extern int timer_getoverrun (timer_t __timerid) __attribute__ ((__nothrow__ , __leaf__));
3870extern int timespec_get (struct timespec *__ts, int __base)
3871 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
3872extern int getdate_err;
3873extern struct tm *getdate (const char *__string);
3874extern int getdate_r (const char *__restrict __string,
3875 struct tm *__restrict __resbufp);
3876typedef struct bio_st BIO;
3877void BIO_set_flags(BIO *b, int flags);
3878int BIO_test_flags(const BIO *b, int flags);
3879void BIO_clear_flags(BIO *b, int flags);
3880long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long);
3881void BIO_set_callback(BIO *b,
3882 long (*callback)(struct bio_st *,int,const char *,int, long,long));
3883char *BIO_get_callback_arg(const BIO *b);
3884void BIO_set_callback_arg(BIO *b, char *arg);
3885const char * BIO_method_name(const BIO *b);
3886int BIO_method_type(const BIO *b);
3887typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
3888typedef 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;
3901struct 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 };
3919struct stack_st_BIO { _STACK stack; };
3920typedef 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;
3931typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg);
3932size_t BIO_ctrl_pending(BIO *b);
3933size_t BIO_ctrl_wpending(BIO *b);
3934size_t BIO_ctrl_get_write_guarantee(BIO *b);
3935size_t BIO_ctrl_get_read_request(BIO *b);
3936int BIO_ctrl_reset_read_request(BIO *b);
3937int BIO_set_ex_data(BIO *bio,int idx,void *data);
3938void *BIO_get_ex_data(BIO *bio,int idx);
3939int 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);
3941unsigned long BIO_number_read(BIO *bio);
3942unsigned long BIO_number_written(BIO *bio);
3943int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
3944 asn1_ps_func *prefix_free);
3945int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
3946 asn1_ps_func **pprefix_free);
3947int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
3948 asn1_ps_func *suffix_free);
3949int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
3950 asn1_ps_func **psuffix_free);
3951BIO_METHOD *BIO_s_file(void );
3952BIO *BIO_new_file(const char *filename, const char *mode);
3953BIO *BIO_new_fp(FILE *stream, int close_flag);
3954BIO * BIO_new(BIO_METHOD *type);
3955int BIO_set(BIO *a,BIO_METHOD *type);
3956int BIO_free(BIO *a);
3957void BIO_vfree(BIO *a);
3958int BIO_read(BIO *b, void *data, int len);
3959int BIO_gets(BIO *bp,char *buf, int size);
3960int BIO_write(BIO *b, const void *data, int len);
3961int BIO_puts(BIO *bp,const char *buf);
3962int BIO_indent(BIO *b,int indent,int max);
3963long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
3964long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
3965char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
3966long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
3967BIO * BIO_push(BIO *b,BIO *append);
3968BIO * BIO_pop(BIO *b);
3969void BIO_free_all(BIO *a);
3970BIO * BIO_find_type(BIO *b,int bio_type);
3971BIO * BIO_next(BIO *b);
3972BIO * BIO_get_retry_BIO(BIO *bio, int *reason);
3973int BIO_get_retry_reason(BIO *bio);
3974BIO * BIO_dup_chain(BIO *in);
3975int BIO_nread0(BIO *bio, char **buf);
3976int BIO_nread(BIO *bio, char **buf, int num);
3977int BIO_nwrite0(BIO *bio, char **buf);
3978int BIO_nwrite(BIO *bio, char **buf, int num);
3979long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
3980 long argl,long ret);
3981BIO_METHOD *BIO_s_mem(void);
3982BIO *BIO_new_mem_buf(void *buf, int len);
3983BIO_METHOD *BIO_s_socket(void);
3984BIO_METHOD *BIO_s_connect(void);
3985BIO_METHOD *BIO_s_accept(void);
3986BIO_METHOD *BIO_s_fd(void);
3987BIO_METHOD *BIO_s_log(void);
3988BIO_METHOD *BIO_s_bio(void);
3989BIO_METHOD *BIO_s_null(void);
3990BIO_METHOD *BIO_f_null(void);
3991BIO_METHOD *BIO_f_buffer(void);
3992BIO_METHOD *BIO_f_nbio_test(void);
3993BIO_METHOD *BIO_s_datagram(void);
3994int BIO_sock_should_retry(int i);
3995int BIO_sock_non_fatal_error(int error);
3996int BIO_dgram_non_fatal_error(int error);
3997int BIO_fd_should_retry(int i);
3998int BIO_fd_non_fatal_error(int error);
3999int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u),
4000 void *u, const char *s, int len);
4001int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
4002 void *u, const char *s, int len, int indent);
4003int BIO_dump(BIO *b,const char *bytes,int len);
4004int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
4005int BIO_dump_fp(FILE *fp, const char *s, int len);
4006int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
4007struct hostent *BIO_gethostbyname(const char *name);
4008int BIO_sock_error(int sock);
4009int BIO_socket_ioctl(int fd, long type, void *arg);
4010int BIO_socket_nbio(int fd,int mode);
4011int BIO_get_port(const char *str, unsigned short *port_ptr);
4012int BIO_get_host_ip(const char *str, unsigned char *ip);
4013int BIO_get_accept_socket(char *host_port,int mode);
4014int BIO_accept(int sock,char **ip_port);
4015int BIO_sock_init(void );
4016void BIO_sock_cleanup(void);
4017int BIO_set_tcp_ndelay(int sock,int turn_on);
4018BIO *BIO_new_socket(int sock, int close_flag);
4019BIO *BIO_new_dgram(int fd, int close_flag);
4020BIO *BIO_new_fd(int fd, int close_flag);
4021BIO *BIO_new_connect(char *host_port);
4022BIO *BIO_new_accept(char *host_port);
4023int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
4024 BIO **bio2, size_t writebuf2);
4025void BIO_copy_next_retry(BIO *b);
4026int BIO_printf(BIO *bio, const char *format, ...)
4027 __attribute__((__format__(__printf__,2,3)));
4028int BIO_vprintf(BIO *bio, const char *format, va_list args)
4029 __attribute__((__format__(__printf__,2,0)));
4030int BIO_snprintf(char *buf, size_t n, const char *format, ...)
4031 __attribute__((__format__(__printf__,3,4)));
4032int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
4033 __attribute__((__format__(__printf__,3,0)));
4034void ERR_load_BIO_strings(void);
4035struct X509_algor_st;
4036struct stack_st_X509_ALGOR { _STACK stack; };
4037typedef 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;
4051typedef 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;
4065typedef 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;
4073struct asn1_string_st
4074 {
4075 int length;
4076 int type;
4077 unsigned char *data;
4078 long flags;
4079 };
4080typedef struct ASN1_ENCODING_st
4081 {
4082 unsigned char *enc;
4083 long len;
4084 int modified;
4085 } ASN1_ENCODING;
4086typedef 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;
4093struct stack_st_ASN1_STRING_TABLE { _STACK stack; };
4094typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
4095typedef struct ASN1_TLC_st ASN1_TLC;
4096typedef struct ASN1_VALUE_st ASN1_VALUE;
4097typedef void *d2i_of_void(void **,const unsigned char **,long); typedef int i2d_of_void(void *,unsigned char **);
4098typedef const ASN1_ITEM ASN1_ITEM_EXP;
4099struct stack_st_ASN1_INTEGER { _STACK stack; };
4100struct stack_st_ASN1_GENERALSTRING { _STACK stack; };
4101typedef 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;
4128struct stack_st_ASN1_TYPE { _STACK stack; };
4129typedef struct stack_st_ASN1_TYPE ASN1_SEQUENCE_ANY;
4130ASN1_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;
4131ASN1_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;
4132typedef struct NETSCAPE_X509_st
4133 {
4134 ASN1_OCTET_STRING *header;
4135 X509 *cert;
4136 } NETSCAPE_X509;
4137typedef struct BIT_STRING_BITNAME_st {
4138 int bitnum;
4139 const char *lname;
4140 const char *sname;
4141} BIT_STRING_BITNAME;
4142ASN1_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;
4143int ASN1_TYPE_get(ASN1_TYPE *a);
4144void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
4145int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
4146int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b);
4147ASN1_OBJECT * ASN1_OBJECT_new(void );
4148void ASN1_OBJECT_free(ASN1_OBJECT *a);
4149int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
4150ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
4151 long length);
4152ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
4153 long length);
4154extern const ASN1_ITEM ASN1_OBJECT_it;
4155struct stack_st_ASN1_OBJECT { _STACK stack; };
4156ASN1_STRING * ASN1_STRING_new(void);
4157void ASN1_STRING_free(ASN1_STRING *a);
4158int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);
4159ASN1_STRING * ASN1_STRING_dup(const ASN1_STRING *a);
4160ASN1_STRING * ASN1_STRING_type_new(int type );
4161int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
4162int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
4163void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
4164int ASN1_STRING_length(const ASN1_STRING *x);
4165void ASN1_STRING_length_set(ASN1_STRING *x, int n);
4166int ASN1_STRING_type(ASN1_STRING *x);
4167unsigned char * ASN1_STRING_data(ASN1_STRING *x);
4168ASN1_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;
4169int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
4170ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp,
4171 long length);
4172int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
4173 int length );
4174int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
4175int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
4176int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
4177 unsigned char *flags, int flags_len);
4178int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
4179 BIT_STRING_BITNAME *tbl, int indent);
4180int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
4181int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
4182 BIT_STRING_BITNAME *tbl);
4183int i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
4184int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length);
4185ASN1_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;
4186int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
4187ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp,
4188 long length);
4189ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp,
4190 long length);
4191ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x);
4192int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
4193ASN1_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;
4194int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
4195ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
4196ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
4197 int offset_day, long offset_sec);
4198int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
4199int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
4200int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
4201ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
4202ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
4203 time_t t, int offset_day, long offset_sec);
4204int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
4205ASN1_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;
4206ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
4207int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b);
4208int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len);
4209ASN1_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;
4210ASN1_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;
4211ASN1_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;
4212ASN1_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;
4213ASN1_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;
4214int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
4215int UTF8_putc(unsigned char *str, int len, unsigned long value);
4216ASN1_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;
4217ASN1_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;
4218ASN1_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;
4219ASN1_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;
4220ASN1_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;
4221ASN1_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;
4222ASN1_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;
4223ASN1_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;
4224ASN1_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;
4225ASN1_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;
4226extern const ASN1_ITEM ASN1_OCTET_STRING_NDEF_it;
4227ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
4228ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s,time_t t,
4229 int offset_day, long offset_sec);
4230int ASN1_TIME_check(ASN1_TIME *t);
4231ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
4232int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
4233int 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);
4236struct 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);
4241int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
4242int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
4243int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
4244int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size);
4245int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a);
4246int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size);
4247int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
4248int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a);
4249int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num);
4250ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
4251 const char *sn, const char *ln);
4252int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
4253long ASN1_INTEGER_get(const ASN1_INTEGER *a);
4254ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
4255BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai,BIGNUM *bn);
4256int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
4257long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);
4258ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);
4259BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn);
4260int ASN1_PRINTABLE_type(const unsigned char *s, int max);
4261int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
4262ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
4263 long length, int Ptag, int Pclass);
4264unsigned long ASN1_tag2bit(int tag);
4265ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp,
4266 long length,int type);
4267int asn1_Finish(ASN1_CTX *c);
4268int asn1_const_Finish(ASN1_const_CTX *c);
4269int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
4270 int *pclass, long omax);
4271int ASN1_check_infinite_end(unsigned char **p,long len);
4272int ASN1_const_check_infinite_end(const unsigned char **p,long len);
4273void ASN1_put_object(unsigned char **pp, int constructed, int length,
4274 int tag, int xclass);
4275int ASN1_put_eoc(unsigned char **pp);
4276int ASN1_object_size(int constructed, int length, int tag);
4277void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);
4278void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
4279void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x);
4280void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
4281int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x);
4282int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
4283int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
4284int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
4285void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x);
4286void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
4287int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x);
4288int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
4289int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);
4290int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);
4291int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);
4292int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
4293int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
4294int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
4295 unsigned char *buf, int off);
4296int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent);
4297int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump);
4298const char *ASN1_tag2str(int tag);
4299NETSCAPE_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;
4300int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
4301int ASN1_TYPE_set_octetstring(ASN1_TYPE *a,
4302 unsigned char *data, int len);
4303int ASN1_TYPE_get_octetstring(ASN1_TYPE *a,
4304 unsigned char *data, int max_len);
4305int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
4306 unsigned char *data, int len);
4307int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
4308 unsigned char *data, int max_len);
4309struct stack_st_OPENSSL_BLOCK *ASN1_seq_unpack(const unsigned char *buf, int len,
4310 d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK));
4311unsigned char *ASN1_seq_pack(struct stack_st_OPENSSL_BLOCK *safes, i2d_of_void *i2d,
4312 unsigned char **buf, int *len );
4313void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
4314void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
4315ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
4316 ASN1_OCTET_STRING **oct);
4317ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct);
4318void ASN1_STRING_set_default_mask(unsigned long mask);
4319int ASN1_STRING_set_default_mask_asc(const char *p);
4320unsigned long ASN1_STRING_get_default_mask(void);
4321int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
4322 int inform, unsigned long mask);
4323int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
4324 int inform, unsigned long mask,
4325 long minsize, long maxsize);
4326ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
4327 const unsigned char *in, int inlen, int inform, int nid);
4328ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
4329int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
4330void ASN1_STRING_TABLE_cleanup(void);
4331ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
4332void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
4333ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it);
4334int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
4335int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
4336void ASN1_add_oid_module(void);
4337ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);
4338ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);
4339int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
4340 const ASN1_ITEM *it, const ASN1_PCTX *pctx);
4341ASN1_PCTX *ASN1_PCTX_new(void);
4342void ASN1_PCTX_free(ASN1_PCTX *p);
4343unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p);
4344void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);
4345unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p);
4346void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);
4347unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p);
4348void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);
4349unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p);
4350void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);
4351unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p);
4352void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);
4353BIO_METHOD *BIO_f_asn1(void);
4354BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);
4355int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
4356 const ASN1_ITEM *it);
4357int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
4358 const char *hdr,
4359 const ASN1_ITEM *it);
4360int 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);
4364ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
4365int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
4366int SMIME_text(BIO *in, BIO *out);
4367void ERR_load_ASN1_strings(void);
4368typedef enum {
4369 POINT_CONVERSION_COMPRESSED = 2,
4370 POINT_CONVERSION_UNCOMPRESSED = 4,
4371 POINT_CONVERSION_HYBRID = 6
4372} point_conversion_form_t;
4373typedef struct ec_method_st EC_METHOD;
4374typedef struct ec_group_st
4375 EC_GROUP;
4376typedef struct ec_point_st EC_POINT;
4377const EC_METHOD *EC_GFp_simple_method(void);
4378const EC_METHOD *EC_GFp_mont_method(void);
4379const EC_METHOD *EC_GFp_nist_method(void);
4380const EC_METHOD *EC_GF2m_simple_method(void);
4381EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
4382void EC_GROUP_free(EC_GROUP *group);
4383void EC_GROUP_clear_free(EC_GROUP *group);
4384int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
4385EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
4386const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
4387int EC_METHOD_get_field_type(const EC_METHOD *meth);
4388int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
4389const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
4390int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
4391int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
4392void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
4393int EC_GROUP_get_curve_name(const EC_GROUP *group);
4394void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
4395int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
4396void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form);
4397point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
4398unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
4399size_t EC_GROUP_get_seed_len(const EC_GROUP *);
4400size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
4401int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
4402int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
4403int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
4404int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
4405int EC_GROUP_get_degree(const EC_GROUP *group);
4406int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
4407int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
4408int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
4409EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
4410EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
4411EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
4412typedef struct {
4413 int nid;
4414 const char *comment;
4415 } EC_builtin_curve;
4416size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
4417EC_POINT *EC_POINT_new(const EC_GROUP *group);
4418void EC_POINT_free(EC_POINT *point);
4419void EC_POINT_clear_free(EC_POINT *point);
4420int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
4421EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
4422const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
4423int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
4424int 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);
4426int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
4427 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
4428int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
4429 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
4430int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
4431 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
4432int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
4433 const BIGNUM *x, int y_bit, BN_CTX *ctx);
4434int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
4435 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
4436int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
4437 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
4438int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
4439 const BIGNUM *x, int y_bit, BN_CTX *ctx);
4440size_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);
4443int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
4444 const unsigned char *buf, size_t len, BN_CTX *ctx);
4445BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
4446 point_conversion_form_t form, BIGNUM *, BN_CTX *);
4447EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
4448 EC_POINT *, BN_CTX *);
4449char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
4450 point_conversion_form_t form, BN_CTX *);
4451EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
4452 EC_POINT *, BN_CTX *);
4453int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
4454int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
4455int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
4456int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
4457int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
4458int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
4459int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
4460int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx);
4461int 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);
4462int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
4463int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
4464int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
4465int EC_GROUP_get_basis_type(const EC_GROUP *);
4466int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
4467int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
4468 unsigned int *k2, unsigned int *k3);
4469typedef struct ecpk_parameters_st ECPKPARAMETERS;
4470EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
4471int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
4472int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
4473int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
4474typedef struct ec_key_st EC_KEY;
4475EC_KEY *EC_KEY_new(void);
4476int EC_KEY_get_flags(const EC_KEY *key);
4477void EC_KEY_set_flags(EC_KEY *key, int flags);
4478void EC_KEY_clear_flags(EC_KEY *key, int flags);
4479EC_KEY *EC_KEY_new_by_curve_name(int nid);
4480void EC_KEY_free(EC_KEY *key);
4481EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
4482EC_KEY *EC_KEY_dup(const EC_KEY *src);
4483int EC_KEY_up_ref(EC_KEY *key);
4484const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
4485int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
4486const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
4487int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
4488const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
4489int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
4490unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
4491void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);
4492point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
4493void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
4494void *EC_KEY_get_key_method_data(EC_KEY *key,
4495 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
4496void *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 *));
4498void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
4499int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
4500int EC_KEY_generate_key(EC_KEY *key);
4501int EC_KEY_check_key(const EC_KEY *key);
4502int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);
4503EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
4504int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
4505EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
4506int i2d_ECParameters(EC_KEY *key, unsigned char **out);
4507EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
4508int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
4509int ECParameters_print(BIO *bp, const EC_KEY *key);
4510int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
4511int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
4512int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
4513void ERR_load_EC_strings(void);
4514int buffer_put_ecpoint_ret(Buffer *, const EC_GROUP *, const EC_POINT *);
4515void buffer_put_ecpoint(Buffer *, const EC_GROUP *, const EC_POINT *);
4516int buffer_get_ecpoint_ret(Buffer *, const EC_GROUP *, EC_POINT *);
4517void buffer_get_ecpoint(Buffer *, const EC_GROUP *, EC_POINT *);
4518void seed_rng(void);
4519void rexec_send_rng_seed(Buffer *);
4520void rexec_recv_rng_seed(Buffer *);
4521typedef struct obj_name_st
4522 {
4523 int type;
4524 int alias;
4525 const char *name;
4526 const char *data;
4527 } OBJ_NAME;
4528int OBJ_NAME_init(void);
4529int 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 *));
4532const char *OBJ_NAME_get(const char *name,int type);
4533int OBJ_NAME_add(const char *name,int type,const char *data);
4534int OBJ_NAME_remove(const char *name,int type);
4535void OBJ_NAME_cleanup(int type);
4536void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),
4537 void *arg);
4538void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
4539 void *arg);
4540ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
4541ASN1_OBJECT * OBJ_nid2obj(int n);
4542const char * OBJ_nid2ln(int n);
4543const char * OBJ_nid2sn(int n);
4544int OBJ_obj2nid(const ASN1_OBJECT *o);
4545ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
4546int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
4547int OBJ_txt2nid(const char *s);
4548int OBJ_ln2nid(const char *s);
4549int OBJ_sn2nid(const char *s);
4550int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
4551const void * OBJ_bsearch_(const void *key,const void *base,int num,int size,
4552 int (*cmp)(const void *, const void *));
4553const 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);
4557int OBJ_new_nid(int num);
4558int OBJ_add_object(const ASN1_OBJECT *obj);
4559int OBJ_create(const char *oid,const char *sn,const char *ln);
4560void OBJ_cleanup(void );
4561int OBJ_create_objects(BIO *in);
4562int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);
4563int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);
4564int OBJ_add_sigid(int signid, int dig_id, int pkey_id);
4565void OBJ_sigid_free(void);
4566extern int obj_cleanup_defer;
4567void check_defer(int nid);
4568void ERR_load_OBJ_strings(void);
4569struct 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 } ;
4586struct 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 } ;
4607typedef int evp_sign_method(int type,const unsigned char *m,
4608 unsigned int m_length,unsigned char *sigret,
4609 unsigned int *siglen, void *key);
4610typedef 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);
4613struct 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 } ;
4622struct 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 } ;
4640typedef struct evp_cipher_info_st
4641 {
4642 const EVP_CIPHER *cipher;
4643 unsigned char iv[16];
4644 } EVP_CIPHER_INFO;
4645struct 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 } ;
4663typedef 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;
4671typedef 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);
4674int EVP_MD_type(const EVP_MD *md);
4675int EVP_MD_pkey_type(const EVP_MD *md);
4676int EVP_MD_size(const EVP_MD *md);
4677int EVP_MD_block_size(const EVP_MD *md);
4678unsigned long EVP_MD_flags(const EVP_MD *md);
4679const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
4680int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
4681int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
4682int EVP_CIPHER_key_length(const EVP_CIPHER *cipher);
4683int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);
4684unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);
4685const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
4686int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);
4687int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);
4688int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);
4689int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);
4690int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
4691void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
4692void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
4693unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);
4694int EVP_Cipher(EVP_CIPHER_CTX *c,
4695 unsigned char *out,
4696 const unsigned char *in,
4697 unsigned int inl);
4698void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
4699int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
4700EVP_MD_CTX *EVP_MD_CTX_create(void);
4701void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
4702int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
4703void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
4704void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
4705int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx,int flags);
4706int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
4707int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
4708 size_t cnt);
4709int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
4710int EVP_Digest(const void *data, size_t count,
4711 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
4712int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);
4713int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
4714int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
4715int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
4716int EVP_read_pw_string_min(char *buf,int minlen,int maxlen,const char *prompt,int verify);
4717void EVP_set_pw_prompt(const char *prompt);
4718char * EVP_get_pw_prompt(void);
4719int 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);
4722void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
4723void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
4724int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx,int flags);
4725int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
4726 const unsigned char *key, const unsigned char *iv);
4727int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
4728 const unsigned char *key, const unsigned char *iv);
4729int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
4730 int *outl, const unsigned char *in, int inl);
4731int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
4732int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
4733int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
4734 const unsigned char *key, const unsigned char *iv);
4735int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
4736 const unsigned char *key, const unsigned char *iv);
4737int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
4738 int *outl, const unsigned char *in, int inl);
4739int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
4740int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
4741int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
4742 const unsigned char *key,const unsigned char *iv,
4743 int enc);
4744int 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);
4747int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
4748 int *outl, const unsigned char *in, int inl);
4749int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
4750int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
4751int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
4752 EVP_PKEY *pkey);
4753int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf,
4754 unsigned int siglen,EVP_PKEY *pkey);
4755int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
4756 const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
4757int EVP_DigestSignFinal(EVP_MD_CTX *ctx,
4758 unsigned char *sigret, size_t *siglen);
4759int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
4760 const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
4761int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx,
4762 unsigned char *sig, size_t siglen);
4763int 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);
4766int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
4767int 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);
4770int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
4771void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
4772void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
4773 const unsigned char *in,int inl);
4774void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
4775int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
4776void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
4777int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
4778 const unsigned char *in, int inl);
4779int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
4780 char *out, int *outl);
4781int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
4782void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
4783int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
4784EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
4785void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
4786int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
4787int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
4788int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
4789int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
4790BIO_METHOD *BIO_f_md(void);
4791BIO_METHOD *BIO_f_base64(void);
4792BIO_METHOD *BIO_f_cipher(void);
4793BIO_METHOD *BIO_f_reliable(void);
4794void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k,
4795 const unsigned char *i, int enc);
4796const EVP_MD *EVP_md_null(void);
4797const EVP_MD *EVP_md4(void);
4798const EVP_MD *EVP_md5(void);
4799const EVP_MD *EVP_sha(void);
4800const EVP_MD *EVP_sha1(void);
4801const EVP_MD *EVP_dss(void);
4802const EVP_MD *EVP_dss1(void);
4803const EVP_MD *EVP_ecdsa(void);
4804const EVP_MD *EVP_sha224(void);
4805const EVP_MD *EVP_sha256(void);
4806const EVP_MD *EVP_sha384(void);
4807const EVP_MD *EVP_sha512(void);
4808const EVP_MD *EVP_mdc2(void);
4809const EVP_MD *EVP_ripemd160(void);
4810const EVP_MD *EVP_whirlpool(void);
4811const EVP_CIPHER *EVP_enc_null(void);
4812const EVP_CIPHER *EVP_des_ecb(void);
4813const EVP_CIPHER *EVP_des_ede(void);
4814const EVP_CIPHER *EVP_des_ede3(void);
4815const EVP_CIPHER *EVP_des_ede_ecb(void);
4816const EVP_CIPHER *EVP_des_ede3_ecb(void);
4817const EVP_CIPHER *EVP_des_cfb64(void);
4818const EVP_CIPHER *EVP_des_cfb1(void);
4819const EVP_CIPHER *EVP_des_cfb8(void);
4820const EVP_CIPHER *EVP_des_ede_cfb64(void);
4821const EVP_CIPHER *EVP_des_ede3_cfb64(void);
4822const EVP_CIPHER *EVP_des_ede3_cfb1(void);
4823const EVP_CIPHER *EVP_des_ede3_cfb8(void);
4824const EVP_CIPHER *EVP_des_ofb(void);
4825const EVP_CIPHER *EVP_des_ede_ofb(void);
4826const EVP_CIPHER *EVP_des_ede3_ofb(void);
4827const EVP_CIPHER *EVP_des_cbc(void);
4828const EVP_CIPHER *EVP_des_ede_cbc(void);
4829const EVP_CIPHER *EVP_des_ede3_cbc(void);
4830const EVP_CIPHER *EVP_desx_cbc(void);
4831const EVP_CIPHER *EVP_rc4(void);
4832const EVP_CIPHER *EVP_rc4_40(void);
4833const EVP_CIPHER *EVP_rc4_hmac_md5(void);
4834const EVP_CIPHER *EVP_idea_ecb(void);
4835const EVP_CIPHER *EVP_idea_cfb64(void);
4836const EVP_CIPHER *EVP_idea_ofb(void);
4837const EVP_CIPHER *EVP_idea_cbc(void);
4838const EVP_CIPHER *EVP_rc2_ecb(void);
4839const EVP_CIPHER *EVP_rc2_cbc(void);
4840const EVP_CIPHER *EVP_rc2_40_cbc(void);
4841const EVP_CIPHER *EVP_rc2_64_cbc(void);
4842const EVP_CIPHER *EVP_rc2_cfb64(void);
4843const EVP_CIPHER *EVP_rc2_ofb(void);
4844const EVP_CIPHER *EVP_bf_ecb(void);
4845const EVP_CIPHER *EVP_bf_cbc(void);
4846const EVP_CIPHER *EVP_bf_cfb64(void);
4847const EVP_CIPHER *EVP_bf_ofb(void);
4848const EVP_CIPHER *EVP_cast5_ecb(void);
4849const EVP_CIPHER *EVP_cast5_cbc(void);
4850const EVP_CIPHER *EVP_cast5_cfb64(void);
4851const EVP_CIPHER *EVP_cast5_ofb(void);
4852const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
4853const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
4854const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);
4855const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
4856const EVP_CIPHER *EVP_aes_128_ecb(void);
4857const EVP_CIPHER *EVP_aes_128_cbc(void);
4858const EVP_CIPHER *EVP_aes_128_cfb1(void);
4859const EVP_CIPHER *EVP_aes_128_cfb8(void);
4860const EVP_CIPHER *EVP_aes_128_cfb128(void);
4861const EVP_CIPHER *EVP_aes_128_ofb(void);
4862const EVP_CIPHER *EVP_aes_128_ctr(void);
4863const EVP_CIPHER *EVP_aes_128_ccm(void);
4864const EVP_CIPHER *EVP_aes_128_gcm(void);
4865const EVP_CIPHER *EVP_aes_128_xts(void);
4866const EVP_CIPHER *EVP_aes_192_ecb(void);
4867const EVP_CIPHER *EVP_aes_192_cbc(void);
4868const EVP_CIPHER *EVP_aes_192_cfb1(void);
4869const EVP_CIPHER *EVP_aes_192_cfb8(void);
4870const EVP_CIPHER *EVP_aes_192_cfb128(void);
4871const EVP_CIPHER *EVP_aes_192_ofb(void);
4872const EVP_CIPHER *EVP_aes_192_ctr(void);
4873const EVP_CIPHER *EVP_aes_192_ccm(void);
4874const EVP_CIPHER *EVP_aes_192_gcm(void);
4875const EVP_CIPHER *EVP_aes_256_ecb(void);
4876const EVP_CIPHER *EVP_aes_256_cbc(void);
4877const EVP_CIPHER *EVP_aes_256_cfb1(void);
4878const EVP_CIPHER *EVP_aes_256_cfb8(void);
4879const EVP_CIPHER *EVP_aes_256_cfb128(void);
4880const EVP_CIPHER *EVP_aes_256_ofb(void);
4881const EVP_CIPHER *EVP_aes_256_ctr(void);
4882const EVP_CIPHER *EVP_aes_256_ccm(void);
4883const EVP_CIPHER *EVP_aes_256_gcm(void);
4884const EVP_CIPHER *EVP_aes_256_xts(void);
4885const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
4886const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
4887const EVP_CIPHER *EVP_camellia_128_ecb(void);
4888const EVP_CIPHER *EVP_camellia_128_cbc(void);
4889const EVP_CIPHER *EVP_camellia_128_cfb1(void);
4890const EVP_CIPHER *EVP_camellia_128_cfb8(void);
4891const EVP_CIPHER *EVP_camellia_128_cfb128(void);
4892const EVP_CIPHER *EVP_camellia_128_ofb(void);
4893const EVP_CIPHER *EVP_camellia_192_ecb(void);
4894const EVP_CIPHER *EVP_camellia_192_cbc(void);
4895const EVP_CIPHER *EVP_camellia_192_cfb1(void);
4896const EVP_CIPHER *EVP_camellia_192_cfb8(void);
4897const EVP_CIPHER *EVP_camellia_192_cfb128(void);
4898const EVP_CIPHER *EVP_camellia_192_ofb(void);
4899const EVP_CIPHER *EVP_camellia_256_ecb(void);
4900const EVP_CIPHER *EVP_camellia_256_cbc(void);
4901const EVP_CIPHER *EVP_camellia_256_cfb1(void);
4902const EVP_CIPHER *EVP_camellia_256_cfb8(void);
4903const EVP_CIPHER *EVP_camellia_256_cfb128(void);
4904const EVP_CIPHER *EVP_camellia_256_ofb(void);
4905const EVP_CIPHER *EVP_seed_ecb(void);
4906const EVP_CIPHER *EVP_seed_cbc(void);
4907const EVP_CIPHER *EVP_seed_cfb128(void);
4908const EVP_CIPHER *EVP_seed_ofb(void);
4909void OPENSSL_add_all_algorithms_noconf(void);
4910void OPENSSL_add_all_algorithms_conf(void);
4911void OpenSSL_add_all_ciphers(void);
4912void OpenSSL_add_all_digests(void);
4913int EVP_add_cipher(const EVP_CIPHER *cipher);
4914int EVP_add_digest(const EVP_MD *digest);
4915const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
4916const EVP_MD *EVP_get_digestbyname(const char *name);
4917void EVP_cleanup(void);
4918void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph,
4919 const char *from, const char *to, void *x), void *arg);
4920void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph,
4921 const char *from, const char *to, void *x), void *arg);
4922void EVP_MD_do_all(void (*fn)(const EVP_MD *ciph,
4923 const char *from, const char *to, void *x), void *arg);
4924void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *ciph,
4925 const char *from, const char *to, void *x), void *arg);
4926int EVP_PKEY_decrypt_old(unsigned char *dec_key,
4927 const unsigned char *enc_key,int enc_key_len,
4928 EVP_PKEY *private_key);
4929int EVP_PKEY_encrypt_old(unsigned char *enc_key,
4930 const unsigned char *key,int key_len,
4931 EVP_PKEY *pub_key);
4932int EVP_PKEY_type(int type);
4933int EVP_PKEY_id(const EVP_PKEY *pkey);
4934int EVP_PKEY_base_id(const EVP_PKEY *pkey);
4935int EVP_PKEY_bits(EVP_PKEY *pkey);
4936int EVP_PKEY_size(EVP_PKEY *pkey);
4937int EVP_PKEY_set_type(EVP_PKEY *pkey,int type);
4938int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
4939int EVP_PKEY_assign(EVP_PKEY *pkey,int type,void *key);
4940void * EVP_PKEY_get0(EVP_PKEY *pkey);
4941struct rsa_st;
4942int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key);
4943struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
4944struct dsa_st;
4945int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key);
4946struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
4947struct dh_st;
4948int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key);
4949struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
4950struct ec_key_st;
4951int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key);
4952struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
4953EVP_PKEY * EVP_PKEY_new(void);
4954void EVP_PKEY_free(EVP_PKEY *pkey);
4955EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp,
4956 long length);
4957int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
4958EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp,
4959 long length);
4960EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
4961 long length);
4962int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
4963int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
4964int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
4965int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
4966int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
4967int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
4968int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,
4969 int indent, ASN1_PCTX *pctx);
4970int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,
4971 int indent, ASN1_PCTX *pctx);
4972int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,
4973 int indent, ASN1_PCTX *pctx);
4974int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
4975int EVP_CIPHER_type(const EVP_CIPHER *ctx);
4976int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
4977int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
4978int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
4979int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
4980int 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);
4983int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
4984 const unsigned char *salt, int saltlen, int iter,
4985 int keylen, unsigned char *out);
4986int 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);
4990int 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);
4993void PKCS5_PBE_add(void);
4994int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
4995 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
4996int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
4997 EVP_PBE_KEYGEN *keygen);
4998int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
4999 EVP_PBE_KEYGEN *keygen);
5000int EVP_PBE_find(int type, int pbe_nid,
5001 int *pcnid, int *pmnid, EVP_PBE_KEYGEN **pkeygen);
5002void EVP_PBE_cleanup(void);
5003int EVP_PKEY_asn1_get_count(void);
5004const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
5005const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);
5006const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
5007 const char *str, int len);
5008int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);
5009int EVP_PKEY_asn1_add_alias(int to, int from);
5010int 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);
5013const EVP_PKEY_ASN1_METHOD* EVP_PKEY_get0_asn1(EVP_PKEY *pkey);
5014EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
5015 const char *pem_str, const char *info);
5016void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
5017 const EVP_PKEY_ASN1_METHOD *src);
5018void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);
5019void 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));
5027void 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));
5032void 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));
5041void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
5042 void (*pkey_free)(EVP_PKEY *pkey));
5043void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
5044 int (*pkey_ctrl)(EVP_PKEY *pkey, int op,
5045 long arg1, void *arg2));
5046const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
5047EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags);
5048void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,
5049 const EVP_PKEY_METHOD *meth);
5050void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
5051void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
5052int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
5053EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
5054EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
5055EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);
5056void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
5057int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
5058 int cmd, int p1, void *p2);
5059int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
5060 const char *value);
5061int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
5062void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);
5063EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,
5064 const unsigned char *key, int keylen);
5065void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);
5066void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);
5067EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
5068EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);
5069void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);
5070void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);
5071int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
5072int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
5073 unsigned char *sig, size_t *siglen,
5074 const unsigned char *tbs, size_t tbslen);
5075int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
5076int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
5077 const unsigned char *sig, size_t siglen,
5078 const unsigned char *tbs, size_t tbslen);
5079int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
5080int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
5081 unsigned char *rout, size_t *routlen,
5082 const unsigned char *sig, size_t siglen);
5083int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
5084int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
5085 unsigned char *out, size_t *outlen,
5086 const unsigned char *in, size_t inlen);
5087int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);
5088int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
5089 unsigned char *out, size_t *outlen,
5090 const unsigned char *in, size_t inlen);
5091int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);
5092int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);
5093int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
5094typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
5095int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
5096int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
5097int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
5098int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
5099void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
5100EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);
5101int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);
5102void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
5103 int (*init)(EVP_PKEY_CTX *ctx));
5104void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
5105 int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src));
5106void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
5107 void (*cleanup)(EVP_PKEY_CTX *ctx));
5108void 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));
5111void 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));
5114void 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));
5118void 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));
5122void 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));
5127void 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));
5131void 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));
5135void 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));
5139void 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));
5143void 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));
5146void 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));
5150void EVP_add_alg_module(void);
5151void ERR_load_EVP_strings(void);
5152typedef int ptrdiff_t;
5153struct buf_mem_st
5154 {
5155 size_t length;
5156 char *data;
5157 size_t max;
5158 };
5159BUF_MEM *BUF_MEM_new(void);
5160void BUF_MEM_free(BUF_MEM *a);
5161int BUF_MEM_grow(BUF_MEM *str, size_t len);
5162int BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
5163char * BUF_strdup(const char *str);
5164char * BUF_strndup(const char *str, size_t siz);
5165void * BUF_memdup(const void *data, size_t siz);
5166void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
5167size_t BUF_strlcpy(char *dst,const char *src,size_t siz);
5168size_t BUF_strlcat(char *dst,const char *src,size_t siz);
5169void ERR_load_BUF_strings(void);
5170typedef struct ECDSA_SIG_st
5171 {
5172 BIGNUM *r;
5173 BIGNUM *s;
5174 } ECDSA_SIG;
5175ECDSA_SIG *ECDSA_SIG_new(void);
5176void ECDSA_SIG_free(ECDSA_SIG *sig);
5177int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);
5178ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);
5179ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey);
5180ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
5181 const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
5182int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
5183 const ECDSA_SIG *sig, EC_KEY* eckey);
5184const ECDSA_METHOD *ECDSA_OpenSSL(void);
5185void ECDSA_set_default_method(const ECDSA_METHOD *meth);
5186const ECDSA_METHOD *ECDSA_get_default_method(void);
5187int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);
5188int ECDSA_size(const EC_KEY *eckey);
5189int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv,
5190 BIGNUM **rp);
5191int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
5192 unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
5193int 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);
5196int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
5197 const unsigned char *sig, int siglen, EC_KEY *eckey);
5198int 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);
5200int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);
5201void *ECDSA_get_ex_data(EC_KEY *d, int idx);
5202void ERR_load_ECDSA_strings(void);
5203const ECDH_METHOD *ECDH_OpenSSL(void);
5204void ECDH_set_default_method(const ECDH_METHOD *);
5205const ECDH_METHOD *ECDH_get_default_method(void);
5206int ECDH_set_method(EC_KEY *, const ECDH_METHOD *);
5207int 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));
5209int 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);
5211int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);
5212void *ECDH_get_ex_data(EC_KEY *d, int idx);
5213void ERR_load_ECDH_strings(void);
5214struct 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 };
5246struct 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 };
5270RSA * RSA_new(void);
5271RSA * RSA_new_method(ENGINE *engine);
5272int RSA_size(const RSA *rsa);
5273RSA * RSA_generate_key(int bits, unsigned long e,void
5274 (*callback)(int,int,void *),void *cb_arg);
5275int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
5276int RSA_check_key(const RSA *);
5277int RSA_public_encrypt(int flen, const unsigned char *from,
5278 unsigned char *to, RSA *rsa,int padding);
5279int RSA_private_encrypt(int flen, const unsigned char *from,
5280 unsigned char *to, RSA *rsa,int padding);
5281int RSA_public_decrypt(int flen, const unsigned char *from,
5282 unsigned char *to, RSA *rsa,int padding);
5283int RSA_private_decrypt(int flen, const unsigned char *from,
5284 unsigned char *to, RSA *rsa,int padding);
5285void RSA_free (RSA *r);
5286int RSA_up_ref(RSA *r);
5287int RSA_flags(const RSA *r);
5288void RSA_set_default_method(const RSA_METHOD *meth);
5289const RSA_METHOD *RSA_get_default_method(void);
5290const RSA_METHOD *RSA_get_method(const RSA *rsa);
5291int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
5292int RSA_memory_lock(RSA *r);
5293const RSA_METHOD *RSA_PKCS1_SSLeay(void);
5294const RSA_METHOD *RSA_null_method(void);
5295RSA *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;
5296RSA *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;
5297typedef 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;
5304RSA_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;
5305int RSA_print_fp(FILE *fp, const RSA *r,int offset);
5306int RSA_print(BIO *bp, const RSA *r,int offset);
5307int i2d_RSA_NET(const RSA *a, unsigned char **pp,
5308 int (*cb)(char *buf, int len, const char *prompt, int verify),
5309 int sgckey);
5310RSA *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);
5313int i2d_Netscape_RSA(const RSA *a, unsigned char **pp,
5314 int (*cb)(char *buf, int len, const char *prompt,
5315 int verify));
5316RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,
5317 int (*cb)(char *buf, int len, const char *prompt,
5318 int verify));
5319int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
5320 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
5321int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
5322 const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
5323int 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);
5326int 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);
5329int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
5330void RSA_blinding_off(RSA *rsa);
5331BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
5332int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen,
5333 const unsigned char *f,int fl);
5334int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen,
5335 const unsigned char *f,int fl,int rsa_len);
5336int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen,
5337 const unsigned char *f,int fl);
5338int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen,
5339 const unsigned char *f,int fl,int rsa_len);
5340int PKCS1_MGF1(unsigned char *mask, long len,
5341 const unsigned char *seed, long seedlen, const EVP_MD *dgst);
5342int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen,
5343 const unsigned char *f,int fl,
5344 const unsigned char *p,int pl);
5345int 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);
5348int RSA_padding_add_SSLv23(unsigned char *to,int tlen,
5349 const unsigned char *f,int fl);
5350int RSA_padding_check_SSLv23(unsigned char *to,int tlen,
5351 const unsigned char *f,int fl,int rsa_len);
5352int RSA_padding_add_none(unsigned char *to,int tlen,
5353 const unsigned char *f,int fl);
5354int RSA_padding_check_none(unsigned char *to,int tlen,
5355 const unsigned char *f,int fl,int rsa_len);
5356int RSA_padding_add_X931(unsigned char *to,int tlen,
5357 const unsigned char *f,int fl);
5358int RSA_padding_check_X931(unsigned char *to,int tlen,
5359 const unsigned char *f,int fl,int rsa_len);
5360int RSA_X931_hash_id(int nid);
5361int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
5362 const EVP_MD *Hash, const unsigned char *EM, int sLen);
5363int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
5364 const unsigned char *mHash,
5365 const EVP_MD *Hash, int sLen);
5366int 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);
5369int 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);
5372int 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);
5374int RSA_set_ex_data(RSA *r,int idx,void *arg);
5375void *RSA_get_ex_data(const RSA *r, int idx);
5376RSA *RSAPublicKey_dup(RSA *rsa);
5377RSA *RSAPrivateKey_dup(RSA *rsa);
5378void ERR_load_RSA_strings(void);
5379struct 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 };
5393struct 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 };
5414DH *DHparams_dup(DH *);
5415const DH_METHOD *DH_OpenSSL(void);
5416void DH_set_default_method(const DH_METHOD *meth);
5417const DH_METHOD *DH_get_default_method(void);
5418int DH_set_method(DH *dh, const DH_METHOD *meth);
5419DH *DH_new_method(ENGINE *engine);
5420DH * DH_new(void);
5421void DH_free(DH *dh);
5422int DH_up_ref(DH *dh);
5423int DH_size(const DH *dh);
5424int 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);
5426int DH_set_ex_data(DH *d, int idx, void *arg);
5427void *DH_get_ex_data(DH *d, int idx);
5428DH * DH_generate_parameters(int prime_len,int generator,
5429 void (*callback)(int,int,void *),void *cb_arg);
5430int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb);
5431int DH_check(const DH *dh,int *codes);
5432int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes);
5433int DH_generate_key(DH *dh);
5434int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
5435DH * d2i_DHparams(DH **a,const unsigned char **pp, long length);
5436int i2d_DHparams(const DH *a,unsigned char **pp);
5437int DHparams_print_fp(FILE *fp, const DH *x);
5438int DHparams_print(BIO *bp, const DH *x);
5439void ERR_load_DH_strings(void);
5440typedef struct DSA_SIG_st
5441 {
5442 BIGNUM *r;
5443 BIGNUM *s;
5444 } DSA_SIG;
5445struct 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 };
5469struct 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 };
5488DSA *DSAparams_dup(DSA *x);
5489DSA_SIG * DSA_SIG_new(void);
5490void DSA_SIG_free(DSA_SIG *a);
5491int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
5492DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
5493DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
5494int DSA_do_verify(const unsigned char *dgst,int dgst_len,
5495 DSA_SIG *sig,DSA *dsa);
5496const DSA_METHOD *DSA_OpenSSL(void);
5497void DSA_set_default_method(const DSA_METHOD *);
5498const DSA_METHOD *DSA_get_default_method(void);
5499int DSA_set_method(DSA *dsa, const DSA_METHOD *);
5500DSA * DSA_new(void);
5501DSA * DSA_new_method(ENGINE *engine);
5502void DSA_free (DSA *r);
5503int DSA_up_ref(DSA *r);
5504int DSA_size(const DSA *);
5505int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
5506int DSA_sign(int type,const unsigned char *dgst,int dlen,
5507 unsigned char *sig, unsigned int *siglen, DSA *dsa);
5508int DSA_verify(int type,const unsigned char *dgst,int dgst_len,
5509 const unsigned char *sigbuf, int siglen, DSA *dsa);
5510int 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);
5512int DSA_set_ex_data(DSA *d, int idx, void *arg);
5513void *DSA_get_ex_data(DSA *d, int idx);
5514DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
5515DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
5516DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
5517DSA * 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);
5521int 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);
5524int DSA_generate_key(DSA *a);
5525int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
5526int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
5527int i2d_DSAparams(const DSA *a,unsigned char **pp);
5528int DSAparams_print(BIO *bp, const DSA *x);
5529int DSA_print(BIO *bp, const DSA *x, int off);
5530int DSAparams_print_fp(FILE *fp, const DSA *x);
5531int DSA_print_fp(FILE *bp, const DSA *x, int off);
5532DH *DSA_dup_DH(const DSA *r);
5533void ERR_load_DSA_strings(void);
5534typedef 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;
5541int SHA_Init(SHA_CTX *c);
5542int SHA_Update(SHA_CTX *c, const void *data, size_t len);
5543int SHA_Final(unsigned char *md, SHA_CTX *c);
5544unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md);
5545void SHA_Transform(SHA_CTX *c, const unsigned char *data);
5546int SHA1_Init(SHA_CTX *c);
5547int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
5548int SHA1_Final(unsigned char *md, SHA_CTX *c);
5549unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
5550void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
5551typedef 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;
5558int SHA224_Init(SHA256_CTX *c);
5559int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
5560int SHA224_Final(unsigned char *md, SHA256_CTX *c);
5561unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md);
5562int SHA256_Init(SHA256_CTX *c);
5563int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
5564int SHA256_Final(unsigned char *md, SHA256_CTX *c);
5565unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md);
5566void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
5567typedef 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;
5577int SHA384_Init(SHA512_CTX *c);
5578int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
5579int SHA384_Final(unsigned char *md, SHA512_CTX *c);
5580unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md);
5581int SHA512_Init(SHA512_CTX *c);
5582int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
5583int SHA512_Final(unsigned char *md, SHA512_CTX *c);
5584unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md);
5585void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
5586typedef struct X509_objects_st
5587 {
5588 int nid;
5589 int (*a2i)(void);
5590 int (*i2a)(void);
5591 } X509_OBJECTS;
5592struct X509_algor_st
5593 {
5594 ASN1_OBJECT *algorithm;
5595 ASN1_TYPE *parameter;
5596 } ;
5597typedef struct stack_st_X509_ALGOR X509_ALGORS;
5598typedef struct X509_val_st
5599 {
5600 ASN1_TIME *notBefore;
5601 ASN1_TIME *notAfter;
5602 } X509_VAL;
5603struct X509_pubkey_st
5604 {
5605 X509_ALGOR *algor;
5606 ASN1_BIT_STRING *public_key;
5607 EVP_PKEY *pkey;
5608 };
5609typedef struct X509_sig_st
5610 {
5611 X509_ALGOR *algor;
5612 ASN1_OCTET_STRING *digest;
5613 } X509_SIG;
5614typedef struct X509_name_entry_st
5615 {
5616 ASN1_OBJECT *object;
5617 ASN1_STRING *value;
5618 int set;
5619 int size;
5620 } X509_NAME_ENTRY;
5621struct stack_st_X509_NAME_ENTRY { _STACK stack; };
5622struct 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 } ;
5630struct stack_st_X509_NAME { _STACK stack; };
5631typedef struct X509_extension_st
5632 {
5633 ASN1_OBJECT *object;
5634 ASN1_BOOLEAN critical;
5635 ASN1_OCTET_STRING *value;
5636 } X509_EXTENSION;
5637typedef struct stack_st_X509_EXTENSION X509_EXTENSIONS;
5638struct stack_st_X509_EXTENSION { _STACK stack; };
5639typedef 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;
5649struct stack_st_X509_ATTRIBUTE { _STACK stack; };
5650typedef 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;
5658typedef 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;
5665typedef 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;
5679typedef 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;
5687struct 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 } ;
5711struct stack_st_X509 { _STACK stack; };
5712typedef 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;
5720struct stack_st_X509_TRUST { _STACK stack; };
5721typedef struct x509_cert_pair_st {
5722 X509 *forward;
5723 X509 *reverse;
5724} X509_CERT_PAIR;
5725struct 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 };
5734struct stack_st_X509_REVOKED { _STACK stack; };
5735typedef 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;
5746struct 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 } ;
5764struct stack_st_X509_CRL { _STACK stack; };
5765typedef 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;
5777typedef 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;
5787struct stack_st_X509_INFO { _STACK stack; };
5788typedef struct Netscape_spkac_st
5789 {
5790 X509_PUBKEY *pubkey;
5791 ASN1_IA5STRING *challenge;
5792 } NETSCAPE_SPKAC;
5793typedef struct Netscape_spki_st
5794 {
5795 NETSCAPE_SPKAC *spkac;
5796 X509_ALGOR *sig_algor;
5797 ASN1_BIT_STRING *signature;
5798 } NETSCAPE_SPKI;
5799typedef struct Netscape_certificate_sequence
5800 {
5801 ASN1_OBJECT *type;
5802 struct stack_st_X509 *certs;
5803 } NETSCAPE_CERT_SEQUENCE;
5804typedef struct PBEPARAM_st {
5805ASN1_OCTET_STRING *salt;
5806ASN1_INTEGER *iter;
5807} PBEPARAM;
5808typedef struct PBE2PARAM_st {
5809X509_ALGOR *keyfunc;
5810X509_ALGOR *encryption;
5811} PBE2PARAM;
5812typedef struct PBKDF2PARAM_st {
5813ASN1_TYPE *salt;
5814ASN1_INTEGER *iter;
5815ASN1_INTEGER *keylength;
5816X509_ALGOR *prf;
5817} PBKDF2PARAM;
5818struct 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 };
5826typedef struct lhash_node_st
5827 {
5828 void *data;
5829 struct lhash_node_st *next;
5830 unsigned long hash;
5831 } LHASH_NODE;
5832typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
5833typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
5834typedef void (*LHASH_DOALL_FN_TYPE)(void *);
5835typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);
5836typedef 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);
5864void lh_free(_LHASH *lh);
5865void *lh_insert(_LHASH *lh, void *data);
5866void *lh_delete(_LHASH *lh, const void *data);
5867void *lh_retrieve(_LHASH *lh, const void *data);
5868void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);
5869void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
5870unsigned long lh_strhash(const char *c);
5871unsigned long lh_num_items(const _LHASH *lh);
5872void lh_stats(const _LHASH *lh, FILE *out);
5873void lh_node_stats(const _LHASH *lh, FILE *out);
5874void lh_node_usage_stats(const _LHASH *lh, FILE *out);
5875void lh_stats_bio(const _LHASH *lh, BIO *out);
5876void lh_node_stats_bio(const _LHASH *lh, BIO *out);
5877void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);
5878struct lhash_st_OPENSSL_STRING { int dummy; };
5879struct lhash_st_OPENSSL_CSTRING { int dummy; };
5880typedef 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;
5887typedef 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;
5897typedef struct x509_lookup_st X509_LOOKUP;
5898struct stack_st_X509_LOOKUP { _STACK stack; };
5899struct stack_st_X509_OBJECT { _STACK stack; };
5900typedef 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;
5919typedef 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;
5930struct stack_st_X509_VERIFY_PARAM { _STACK stack; };
5931struct 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 } ;
5951int X509_STORE_set_depth(X509_STORE *store, int depth);
5952struct 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 } ;
5960struct 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 } ;
5996void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
5997int X509_OBJECT_idx_by_subject(struct stack_st_X509_OBJECT *h, int type,
5998 X509_NAME *name);
5999X509_OBJECT *X509_OBJECT_retrieve_by_subject(struct stack_st_X509_OBJECT *h,int type,X509_NAME *name);
6000X509_OBJECT *X509_OBJECT_retrieve_match(struct stack_st_X509_OBJECT *h, X509_OBJECT *x);
6001void X509_OBJECT_up_ref_count(X509_OBJECT *a);
6002void X509_OBJECT_free_contents(X509_OBJECT *a);
6003X509_STORE *X509_STORE_new(void );
6004void X509_STORE_free(X509_STORE *v);
6005struct stack_st_X509* X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);
6006struct stack_st_X509_CRL* X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);
6007int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
6008int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
6009int X509_STORE_set_trust(X509_STORE *ctx, int trust);
6010int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);
6011void X509_STORE_set_verify_cb(X509_STORE *ctx,
6012 int (*verify_cb)(int, X509_STORE_CTX *));
6013X509_STORE_CTX *X509_STORE_CTX_new(void);
6014int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
6015void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
6016int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
6017 X509 *x509, struct stack_st_X509 *chain);
6018void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, struct stack_st_X509 *sk);
6019void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
6020X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
6021X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
6022X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
6023int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
6024int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
6025int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name,
6026 X509_OBJECT *ret);
6027int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
6028 long argl, char **ret);
6029int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
6030int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
6031int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
6032X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
6033void X509_LOOKUP_free(X509_LOOKUP *ctx);
6034int X509_LOOKUP_init(X509_LOOKUP *ctx);
6035int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,
6036 X509_OBJECT *ret);
6037int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,
6038 ASN1_INTEGER *serial, X509_OBJECT *ret);
6039int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,
6040 unsigned char *bytes, int len, X509_OBJECT *ret);
6041int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str,
6042 int len, X509_OBJECT *ret);
6043int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
6044int X509_STORE_load_locations (X509_STORE *ctx,
6045 const char *file, const char *dir);
6046int X509_STORE_set_default_paths(X509_STORE *ctx);
6047int 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);
6049int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data);
6050void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx);
6051int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
6052void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
6053int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
6054X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
6055X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);
6056X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);
6057X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);
6058struct stack_st_X509 *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
6059struct stack_st_X509 *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
6060void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
6061void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,struct stack_st_X509 *sk);
6062void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,struct stack_st_X509_CRL *sk);
6063int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
6064int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
6065int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
6066 int purpose, int trust);
6067void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
6068void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
6069 time_t t);
6070void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
6071 int (*verify_cb)(int, X509_STORE_CTX *));
6072X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);
6073int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);
6074X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
6075void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
6076int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
6077X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);
6078void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);
6079int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,
6080 const X509_VERIFY_PARAM *from);
6081int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,
6082 const X509_VERIFY_PARAM *from);
6083int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);
6084int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags);
6085int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,
6086 unsigned long flags);
6087unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);
6088int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);
6089int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);
6090void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);
6091void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);
6092int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
6093 ASN1_OBJECT *policy);
6094int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,
6095 struct stack_st_ASN1_OBJECT *policies);
6096int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);
6097int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);
6098const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);
6099void X509_VERIFY_PARAM_table_cleanup(void);
6100int 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);
6104void X509_policy_tree_free(X509_POLICY_TREE *tree);
6105int X509_policy_tree_level_count(const X509_POLICY_TREE *tree);
6106X509_POLICY_LEVEL *
6107 X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i);
6108struct stack_st_X509_POLICY_NODE *
6109 X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree);
6110struct stack_st_X509_POLICY_NODE *
6111 X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree);
6112int X509_policy_level_node_count(X509_POLICY_LEVEL *level);
6113X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i);
6114const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);
6115struct stack_st_POLICYQUALINFO *
6116 X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node);
6117const X509_POLICY_NODE *
6118 X509_policy_node_get0_parent(const X509_POLICY_NODE *node);
6119typedef struct pkcs7_issuer_and_serial_st
6120 {
6121 X509_NAME *issuer;
6122 ASN1_INTEGER *serial;
6123 } PKCS7_ISSUER_AND_SERIAL;
6124typedef 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;
6135struct stack_st_PKCS7_SIGNER_INFO { _STACK stack; };
6136typedef 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;
6144struct stack_st_PKCS7_RECIP_INFO { _STACK stack; };
6145typedef 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;
6154typedef 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;
6161typedef 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;
6167typedef 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;
6177typedef 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;
6184typedef struct pkcs7_encrypted_st
6185 {
6186 ASN1_INTEGER *version;
6187 PKCS7_ENC_CONTENT *enc_data;
6188 } PKCS7_ENCRYPT;
6189typedef 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;
6207struct stack_st_PKCS7 { _STACK stack; };
6208PKCS7_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;
6209int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type,
6210 unsigned char *md,unsigned int *len);
6211PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7);
6212int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7);
6213PKCS7 *PKCS7_dup(PKCS7 *p7);
6214PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7);
6215int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7);
6216int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
6217int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
6218PKCS7_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;
6219PKCS7_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;
6220PKCS7_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;
6221PKCS7_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;
6222PKCS7_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;
6223PKCS7_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;
6224PKCS7_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;
6225PKCS7_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;
6226PKCS7 *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;
6227extern const ASN1_ITEM PKCS7_ATTR_SIGN_it;
6228extern const ASN1_ITEM PKCS7_ATTR_VERIFY_it;
6229int i2d_PKCS7_NDEF(PKCS7 *a, unsigned char **out);
6230int PKCS7_print_ctx(BIO *out, PKCS7 *x, int indent, const ASN1_PCTX *pctx);
6231long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);
6232int PKCS7_set_type(PKCS7 *p7, int type);
6233int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);
6234int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
6235int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
6236 const EVP_MD *dgst);
6237int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);
6238int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
6239int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
6240int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
6241int PKCS7_content_new(PKCS7 *p7, int nid);
6242int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,
6243 BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);
6244int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
6245 X509 *x509);
6246BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);
6247int PKCS7_dataFinal(PKCS7 *p7, BIO *bio);
6248BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);
6249PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
6250 EVP_PKEY *pkey, const EVP_MD *dgst);
6251X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
6252int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);
6253struct stack_st_PKCS7_SIGNER_INFO *PKCS7_get_signer_info(PKCS7 *p7);
6254PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);
6255void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,
6256 X509_ALGOR **pdig, X509_ALGOR **psig);
6257void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);
6258int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);
6259int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);
6260int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);
6261int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);
6262PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);
6263ASN1_OCTET_STRING *PKCS7_digest_from_attributes(struct stack_st_X509_ATTRIBUTE *sk);
6264int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si,int nid,int type,
6265 void *data);
6266int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
6267 void *value);
6268ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);
6269ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);
6270int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,
6271 struct stack_st_X509_ATTRIBUTE *sk);
6272int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,struct stack_st_X509_ATTRIBUTE *sk);
6273PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, struct stack_st_X509 *certs,
6274 BIO *data, int flags);
6275PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,
6276 X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md,
6277 int flags);
6278int PKCS7_final(PKCS7 *p7, BIO *data, int flags);
6279int PKCS7_verify(PKCS7 *p7, struct stack_st_X509 *certs, X509_STORE *store,
6280 BIO *indata, BIO *out, int flags);
6281struct stack_st_X509 *PKCS7_get0_signers(PKCS7 *p7, struct stack_st_X509 *certs, int flags);
6282PKCS7 *PKCS7_encrypt(struct stack_st_X509 *certs, BIO *in, const EVP_CIPHER *cipher,
6283 int flags);
6284int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
6285int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
6286 struct stack_st_X509_ALGOR *cap);
6287struct stack_st_X509_ALGOR *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
6288int PKCS7_simple_smimecap(struct stack_st_X509_ALGOR *sk, int nid, int arg);
6289int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);
6290int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);
6291int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
6292 const unsigned char *md, int mdlen);
6293int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
6294PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);
6295BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);
6296void ERR_load_PKCS7_strings(void);
6297void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
6298X509_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));
6304void X509_CRL_METHOD_free(X509_CRL_METHOD *m);
6305void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
6306void *X509_CRL_get_meth_data(X509_CRL *crl);
6307const char *X509_verify_cert_error_string(long n);
6308int X509_verify(X509 *a, EVP_PKEY *r);
6309int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
6310int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
6311int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
6312NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
6313char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
6314EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
6315int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
6316int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
6317int X509_signature_dump(BIO *bp,const ASN1_STRING *sig, int indent);
6318int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig);
6319int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
6320int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
6321int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
6322int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
6323int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
6324int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
6325int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
6326int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
6327 unsigned char *md, unsigned int *len);
6328int X509_digest(const X509 *data,const EVP_MD *type,
6329 unsigned char *md, unsigned int *len);
6330int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
6331 unsigned char *md, unsigned int *len);
6332int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type,
6333 unsigned char *md, unsigned int *len);
6334int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
6335 unsigned char *md, unsigned int *len);
6336X509 *d2i_X509_fp(FILE *fp, X509 **x509);
6337int i2d_X509_fp(FILE *fp,X509 *x509);
6338X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
6339int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
6340X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
6341int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
6342RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
6343int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
6344RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
6345int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
6346RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
6347int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
6348DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
6349int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
6350DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
6351int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
6352EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
6353int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);
6354EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
6355int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);
6356X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
6357int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
6358PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
6359 PKCS8_PRIV_KEY_INFO **p8inf);
6360int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
6361int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
6362int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
6363EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
6364int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
6365EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
6366X509 *d2i_X509_bio(BIO *bp,X509 **x509);
6367int i2d_X509_bio(BIO *bp,X509 *x509);
6368X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
6369int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
6370X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
6371int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
6372RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
6373int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
6374RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
6375int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
6376RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
6377int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
6378DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
6379int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
6380DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
6381int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
6382EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
6383int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);
6384EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
6385int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);
6386X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8);
6387int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
6388PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
6389 PKCS8_PRIV_KEY_INFO **p8inf);
6390int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
6391int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
6392int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
6393EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
6394int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
6395EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
6396X509 *X509_dup(X509 *x509);
6397X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
6398X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
6399X509_CRL *X509_CRL_dup(X509_CRL *crl);
6400X509_REQ *X509_REQ_dup(X509_REQ *req);
6401X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
6402int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
6403void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
6404 X509_ALGOR *algor);
6405void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
6406X509_NAME *X509_NAME_dup(X509_NAME *xn);
6407X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
6408int X509_cmp_time(const ASN1_TIME *s, time_t *t);
6409int X509_cmp_current_time(const ASN1_TIME *s);
6410ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
6411ASN1_TIME * X509_time_adj_ex(ASN1_TIME *s,
6412 int offset_day, long offset_sec, time_t *t);
6413ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj);
6414const char * X509_get_default_cert_area(void );
6415const char * X509_get_default_cert_dir(void );
6416const char * X509_get_default_cert_file(void );
6417const char * X509_get_default_cert_dir_env(void );
6418const char * X509_get_default_cert_file_env(void );
6419const char * X509_get_default_private_dir(void );
6420X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
6421X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
6422X509_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;
6423X509_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;
6424X509_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;
6425X509_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;
6426int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
6427EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key);
6428int X509_get_pubkey_parameters(EVP_PKEY *pkey,
6429 struct stack_st_X509 *chain);
6430int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
6431EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp,
6432 long length);
6433int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
6434RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp,
6435 long length);
6436int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
6437DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp,
6438 long length);
6439int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
6440EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp,
6441 long length);
6442X509_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;
6443X509_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;
6444X509_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;
6445X509_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;
6446X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
6447X509_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;
6448X509_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;
6449X509_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;
6450X509_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;
6451int X509_NAME_set(X509_NAME **xn, X509_NAME *name);
6452X509_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;
6453X509 *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;
6454X509_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;
6455X509_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;
6456int 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);
6458int X509_set_ex_data(X509 *r, int idx, void *arg);
6459void *X509_get_ex_data(X509 *r, int idx);
6460int i2d_X509_AUX(X509 *a,unsigned char **pp);
6461X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length);
6462int X509_alias_set1(X509 *x, unsigned char *name, int len);
6463int X509_keyid_set1(X509 *x, unsigned char *id, int len);
6464unsigned char * X509_alias_get0(X509 *x, int *len);
6465unsigned char * X509_keyid_get0(X509 *x, int *len);
6466int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
6467int X509_TRUST_set(int *t, int trust);
6468int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
6469int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
6470void X509_trust_clear(X509 *x);
6471void X509_reject_clear(X509 *x);
6472X509_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;
6473X509_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;
6474X509_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;
6475int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
6476int X509_CRL_get0_by_serial(X509_CRL *crl,
6477 X509_REVOKED **ret, ASN1_INTEGER *serial);
6478int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
6479X509_PKEY * X509_PKEY_new(void );
6480void X509_PKEY_free(X509_PKEY *a);
6481int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp);
6482X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length);
6483NETSCAPE_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;
6484NETSCAPE_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;
6485NETSCAPE_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;
6486X509_INFO * X509_INFO_new(void);
6487void X509_INFO_free(X509_INFO *a);
6488char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
6489int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
6490 ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey);
6491int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data,
6492 unsigned char *md,unsigned int *len);
6493int 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);
6496int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
6497 unsigned char *md,unsigned int *len);
6498int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
6499 ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);
6500int 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);
6503int 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);
6506int X509_set_version(X509 *x,long version);
6507int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
6508ASN1_INTEGER * X509_get_serialNumber(X509 *x);
6509int X509_set_issuer_name(X509 *x, X509_NAME *name);
6510X509_NAME * X509_get_issuer_name(X509 *a);
6511int X509_set_subject_name(X509 *x, X509_NAME *name);
6512X509_NAME * X509_get_subject_name(X509 *a);
6513int X509_set_notBefore(X509 *x, const ASN1_TIME *tm);
6514int X509_set_notAfter(X509 *x, const ASN1_TIME *tm);
6515int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
6516EVP_PKEY * X509_get_pubkey(X509 *x);
6517ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
6518int X509_certificate_type(X509 *x,EVP_PKEY *pubkey );
6519int X509_REQ_set_version(X509_REQ *x,long version);
6520int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
6521int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
6522EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req);
6523int X509_REQ_extension_nid(int nid);
6524int * X509_REQ_get_extension_nids(void);
6525void X509_REQ_set_extension_nids(int *nids);
6526struct stack_st_X509_EXTENSION *X509_REQ_get_extensions(X509_REQ *req);
6527int X509_REQ_add_extensions_nid(X509_REQ *req, struct stack_st_X509_EXTENSION *exts,
6528 int nid);
6529int X509_REQ_add_extensions(X509_REQ *req, struct stack_st_X509_EXTENSION *exts);
6530int X509_REQ_get_attr_count(const X509_REQ *req);
6531int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
6532 int lastpos);
6533int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
6534 int lastpos);
6535X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
6536X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
6537int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
6538int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
6539 const ASN1_OBJECT *obj, int type,
6540 const unsigned char *bytes, int len);
6541int X509_REQ_add1_attr_by_NID(X509_REQ *req,
6542 int nid, int type,
6543 const unsigned char *bytes, int len);
6544int X509_REQ_add1_attr_by_txt(X509_REQ *req,
6545 const char *attrname, int type,
6546 const unsigned char *bytes, int len);
6547int X509_CRL_set_version(X509_CRL *x, long version);
6548int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
6549int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
6550int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
6551int X509_CRL_sort(X509_CRL *crl);
6552int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
6553int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
6554int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey);
6555int X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
6556int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
6557unsigned long X509_issuer_and_serial_hash(X509 *a);
6558int X509_issuer_name_cmp(const X509 *a, const X509 *b);
6559unsigned long X509_issuer_name_hash(X509 *a);
6560int X509_subject_name_cmp(const X509 *a, const X509 *b);
6561unsigned long X509_subject_name_hash(X509 *x);
6562unsigned long X509_issuer_name_hash_old(X509 *a);
6563unsigned long X509_subject_name_hash_old(X509 *x);
6564int X509_cmp(const X509 *a, const X509 *b);
6565int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
6566unsigned long X509_NAME_hash(X509_NAME *x);
6567unsigned long X509_NAME_hash_old(X509_NAME *x);
6568int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
6569int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
6570int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
6571int X509_print_fp(FILE *bp,X509 *x);
6572int X509_CRL_print_fp(FILE *bp,X509_CRL *x);
6573int X509_REQ_print_fp(FILE *bp,X509_REQ *req);
6574int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);
6575int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
6576int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
6577int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
6578int X509_print(BIO *bp,X509 *x);
6579int X509_ocspid_print(BIO *bp,X509 *x);
6580int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
6581int X509_CRL_print(BIO *bp,X509_CRL *x);
6582int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
6583int X509_REQ_print(BIO *bp,X509_REQ *req);
6584int X509_NAME_entry_count(X509_NAME *name);
6585int X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
6586 char *buf,int len);
6587int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
6588 char *buf,int len);
6589int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
6590int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
6591 int lastpos);
6592X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
6593X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
6594int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
6595 int loc, int set);
6596int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
6597 unsigned char *bytes, int len, int loc, int set);
6598int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
6599 unsigned char *bytes, int len, int loc, int set);
6600X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
6601 const char *field, int type, const unsigned char *bytes, int len);
6602X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
6603 int type,unsigned char *bytes, int len);
6604int 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);
6606X509_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);
6609int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
6610 ASN1_OBJECT *obj);
6611int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
6612 const unsigned char *bytes, int len);
6613ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
6614ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
6615int X509v3_get_ext_count(const struct stack_st_X509_EXTENSION *x);
6616int X509v3_get_ext_by_NID(const struct stack_st_X509_EXTENSION *x,
6617 int nid, int lastpos);
6618int X509v3_get_ext_by_OBJ(const struct stack_st_X509_EXTENSION *x,
6619 ASN1_OBJECT *obj,int lastpos);
6620int X509v3_get_ext_by_critical(const struct stack_st_X509_EXTENSION *x,
6621 int crit, int lastpos);
6622X509_EXTENSION *X509v3_get_ext(const struct stack_st_X509_EXTENSION *x, int loc);
6623X509_EXTENSION *X509v3_delete_ext(struct stack_st_X509_EXTENSION *x, int loc);
6624struct stack_st_X509_EXTENSION *X509v3_add_ext(struct stack_st_X509_EXTENSION **x,
6625 X509_EXTENSION *ex, int loc);
6626int X509_get_ext_count(X509 *x);
6627int X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
6628int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos);
6629int X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
6630X509_EXTENSION *X509_get_ext(X509 *x, int loc);
6631X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
6632int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
6633void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
6634int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
6635 unsigned long flags);
6636int X509_CRL_get_ext_count(X509_CRL *x);
6637int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
6638int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos);
6639int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
6640X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
6641X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
6642int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
6643void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
6644int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
6645 unsigned long flags);
6646int X509_REVOKED_get_ext_count(X509_REVOKED *x);
6647int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
6648int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos);
6649int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
6650X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
6651X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
6652int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
6653void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
6654int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
6655 unsigned long flags);
6656X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
6657 int nid, int crit, ASN1_OCTET_STRING *data);
6658X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
6659 ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data);
6660int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj);
6661int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
6662int X509_EXTENSION_set_data(X509_EXTENSION *ex,
6663 ASN1_OCTET_STRING *data);
6664ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex);
6665ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
6666int X509_EXTENSION_get_critical(X509_EXTENSION *ex);
6667int X509at_get_attr_count(const struct stack_st_X509_ATTRIBUTE *x);
6668int X509at_get_attr_by_NID(const struct stack_st_X509_ATTRIBUTE *x, int nid,
6669 int lastpos);
6670int X509at_get_attr_by_OBJ(const struct stack_st_X509_ATTRIBUTE *sk, ASN1_OBJECT *obj,
6671 int lastpos);
6672X509_ATTRIBUTE *X509at_get_attr(const struct stack_st_X509_ATTRIBUTE *x, int loc);
6673X509_ATTRIBUTE *X509at_delete_attr(struct stack_st_X509_ATTRIBUTE *x, int loc);
6674struct stack_st_X509_ATTRIBUTE *X509at_add1_attr(struct stack_st_X509_ATTRIBUTE **x,
6675 X509_ATTRIBUTE *attr);
6676struct 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);
6679struct 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);
6682struct 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);
6685void *X509at_get0_data_by_OBJ(struct stack_st_X509_ATTRIBUTE *x,
6686 ASN1_OBJECT *obj, int lastpos, int type);
6687X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
6688 int atrtype, const void *data, int len);
6689X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
6690 const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
6691X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
6692 const char *atrname, int type, const unsigned char *bytes, int len);
6693int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
6694int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
6695void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
6696 int atrtype, void *data);
6697int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
6698ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
6699ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
6700int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
6701int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid,
6702 int lastpos);
6703int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,
6704 int lastpos);
6705X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
6706X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
6707int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
6708int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
6709 const ASN1_OBJECT *obj, int type,
6710 const unsigned char *bytes, int len);
6711int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
6712 int nid, int type,
6713 const unsigned char *bytes, int len);
6714int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
6715 const char *attrname, int type,
6716 const unsigned char *bytes, int len);
6717int X509_verify_cert(X509_STORE_CTX *ctx);
6718X509 *X509_find_by_issuer_and_serial(struct stack_st_X509 *sk,X509_NAME *name,
6719 ASN1_INTEGER *serial);
6720X509 *X509_find_by_subject(struct stack_st_X509 *sk,X509_NAME *name);
6721PBEPARAM *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;
6722PBE2PARAM *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;
6723PBKDF2PARAM *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;
6724int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
6725 const unsigned char *salt, int saltlen);
6726X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
6727 const unsigned char *salt, int saltlen);
6728X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
6729 unsigned char *salt, int saltlen);
6730X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
6731 unsigned char *salt, int saltlen,
6732 unsigned char *aiv, int prf_nid);
6733X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
6734 int prf_nid, int keylen);
6735PKCS8_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;
6736EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
6737PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
6738PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
6739PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
6740int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
6741 int version, int ptype, void *pval,
6742 unsigned char *penc, int penclen);
6743int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,
6744 const unsigned char **pk, int *ppklen,
6745 X509_ALGOR **pa,
6746 PKCS8_PRIV_KEY_INFO *p8);
6747int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
6748 int ptype, void *pval,
6749 unsigned char *penc, int penclen);
6750int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
6751 const unsigned char **pk, int *ppklen,
6752 X509_ALGOR **pa,
6753 X509_PUBKEY *pub);
6754int X509_check_trust(X509 *x, int id, int flags);
6755int X509_TRUST_get_count(void);
6756X509_TRUST * X509_TRUST_get0(int idx);
6757int X509_TRUST_get_by_id(int id);
6758int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
6759 char *name, int arg1, void *arg2);
6760void X509_TRUST_cleanup(void);
6761int X509_TRUST_get_flags(X509_TRUST *xp);
6762char *X509_TRUST_get0_name(X509_TRUST *xp);
6763int X509_TRUST_get_trust(X509_TRUST *xp);
6764void ERR_load_X509_strings(void);
6765typedef 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;
6771typedef struct pem_recip_st
6772 {
6773 char *name;
6774 X509_NAME *dn;
6775 int cipher;
6776 int key_enc;
6777 } PEM_USER;
6778typedef 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;
6803typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
6804int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
6805int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
6806 pem_password_cb *callback,void *u);
6807int PEM_read_bio(BIO *bp, char **name, char **header,
6808 unsigned char **data,long *len);
6809int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data,
6810 long len);
6811int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp,
6812 pem_password_cb *cb, void *u);
6813void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
6814 void **x, pem_password_cb *cb, void *u);
6815int 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);
6818struct stack_st_X509_INFO * PEM_X509_INFO_read_bio(BIO *bp, struct stack_st_X509_INFO *sk, pem_password_cb *cb, void *u);
6819int 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);
6821int PEM_read(FILE *fp, char **name, char **header,
6822 unsigned char **data,long *len);
6823int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
6824void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
6825 pem_password_cb *cb, void *u);
6826int 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);
6829struct stack_st_X509_INFO * PEM_X509_INFO_read(FILE *fp, struct stack_st_X509_INFO *sk,
6830 pem_password_cb *cb, void *u);
6831int 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);
6834void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
6835 unsigned char *in, int inl);
6836int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
6837 unsigned char *out, int *outl, EVP_PKEY *priv);
6838void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
6839void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
6840int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
6841 unsigned int *siglen, EVP_PKEY *pkey);
6842int PEM_def_callback(char *buf, int num, int w, void *key);
6843void PEM_proc_type(char *buf, int type);
6844void PEM_dek_info(char *buf, const char *type, int len, char *str);
6845X509 *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);
6846X509 *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);
6847X509_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);
6848X509_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);
6849int PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x); int PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x);
6850X509_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);
6851PKCS7 *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);
6852NETSCAPE_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);
6853X509_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);
6854PKCS8_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);
6855RSA *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);
6856RSA *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);
6857RSA *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);
6858DSA *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);
6859DSA *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);
6860DSA *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);
6861EC_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);
6862EC_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);
6863EC_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);
6864DH *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);
6865EVP_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);
6866EVP_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);
6867int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
6868 char *kstr, int klen,
6869 pem_password_cb *cb, void *u);
6870int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
6871 char *, int, pem_password_cb *, void *);
6872int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
6873 char *kstr, int klen,
6874 pem_password_cb *cb, void *u);
6875int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
6876 char *kstr, int klen,
6877 pem_password_cb *cb, void *u);
6878EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
6879int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
6880 char *kstr, int klen,
6881 pem_password_cb *cb, void *u);
6882int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
6883 char *kstr, int klen,
6884 pem_password_cb *cb, void *u);
6885int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
6886 char *kstr, int klen,
6887 pem_password_cb *cb, void *u);
6888EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
6889int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
6890 char *kstr,int klen, pem_password_cb *cd, void *u);
6891EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
6892int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
6893EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
6894EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
6895EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
6896EVP_PKEY *b2i_PublicKey_bio(BIO *in);
6897int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
6898int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
6899EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
6900int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
6901 pem_password_cb *cb, void *u);
6902void ERR_load_PEM_strings(void);
6903int EVP_DigestFinal_ex(EVP_MD_CTX *, unsigned char *, unsigned int *);
6904int EVP_MD_CTX_copy_ex(EVP_MD_CTX *, const EVP_MD_CTX *);
6905int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *,
6906 unsigned char *, int);
6907int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int);
6908int ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *);
6909void ssh_OpenSSL_add_all_algorithms(void);
6910struct 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 };
6918struct 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 };
6926enum __pid_type
6927 {
6928 F_OWNER_TID = 0,
6929 F_OWNER_PID,
6930 F_OWNER_PGRP,
6931 F_OWNER_GID = F_OWNER_PGRP
6932 };
6933struct f_owner_ex
6934 {
6935 enum __pid_type type;
6936 __pid_t pid;
6937 };
6938struct file_handle
6939{
6940 unsigned int handle_bytes;
6941 int handle_type;
6942 unsigned char f_handle[0];
6943};
6944extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
6945 __attribute__ ((__nothrow__ , __leaf__));
6946extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count,
6947 unsigned int __flags);
6948extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
6949 size_t __count, unsigned int __flags);
6950extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
6951 __off64_t *__offout, size_t __len,
6952 unsigned int __flags);
6953extern ssize_t tee (int __fdin, int __fdout, size_t __len,
6954 unsigned int __flags);
6955extern int fallocate (int __fd, int __mode, __off64_t __offset, __off64_t __len) __asm__ ("" "fallocate64")
6956 ;
6957extern int fallocate64 (int __fd, int __mode, __off64_t __offset,
6958 __off64_t __len);
6959extern int name_to_handle_at (int __dfd, const char *__name,
6960 struct file_handle *__handle, int *__mnt_id,
6961 int __flags) __attribute__ ((__nothrow__ , __leaf__));
6962extern int open_by_handle_at (int __mountdirfd, struct file_handle *__handle,
6963 int __flags);
6964extern int fcntl (int __fd, int __cmd, ...);
6965extern int open (const char *__file, int __oflag, ...) __asm__ ("" "open64")
6966 __attribute__ ((__nonnull__ (1)));
6967extern int open64 (const char *__file, int __oflag, ...) __attribute__ ((__nonnull__ (1)));
6968extern int openat (int __fd, const char *__file, int __oflag, ...) __asm__ ("" "openat64")
6969 __attribute__ ((__nonnull__ (2)));
6970extern int openat64 (int __fd, const char *__file, int __oflag, ...)
6971 __attribute__ ((__nonnull__ (2)));
6972extern int creat (const char *__file, mode_t __mode) __asm__ ("" "creat64")
6973 __attribute__ ((__nonnull__ (1)));
6974extern int creat64 (const char *__file, mode_t __mode) __attribute__ ((__nonnull__ (1)));
6975extern int lockf (int __fd, int __cmd, __off64_t __len) __asm__ ("" "lockf64");
6976extern int lockf64 (int __fd, int __cmd, off64_t __len);
6977extern int posix_fadvise (int __fd, __off64_t __offset, __off64_t __len, int __advise) __asm__ ("" "posix_fadvise64") __attribute__ ((__nothrow__ , __leaf__))
6978 ;
6979extern int posix_fadvise64 (int __fd, off64_t __offset, off64_t __len,
6980 int __advise) __attribute__ ((__nothrow__ , __leaf__));
6981extern int posix_fallocate (int __fd, __off64_t __offset, __off64_t __len) __asm__ ("" "posix_fallocate64")
6982 ;
6983extern int posix_fallocate64 (int __fd, off64_t __offset, off64_t __len);
6984extern int __open_2 (const char *__path, int __oflag) __asm__ ("" "__open64_2")
6985 __attribute__ ((__nonnull__ (1)));
6986extern int __open_alias (const char *__path, int __oflag, ...) __asm__ ("" "open64")
6987 __attribute__ ((__nonnull__ (1)));
6988extern void __open_too_many_args (void) __attribute__((__error__ ("open can be called either with 2 or 3 arguments, not more")))
6989 ;
6990extern void __open_missing_mode (void) __attribute__((__error__ ("open with O_CREAT in second argument needs 3 arguments")))
6991 ;
6992extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
6993open (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}
7010extern int __open64_2 (const char *__path, int __oflag) __attribute__ ((__nonnull__ (1)));
7011extern int __open64_alias (const char *__path, int __oflag, ...) __asm__ ("" "open64")
7012 __attribute__ ((__nonnull__ (1)));
7013extern void __open64_too_many_args (void) __attribute__((__error__ ("open64 can be called either with 2 or 3 arguments, not more")))
7014 ;
7015extern void __open64_missing_mode (void) __attribute__((__error__ ("open64 with O_CREAT in second argument needs 3 arguments")))
7016 ;
7017extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
7018open64 (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}
7035extern int __openat_2 (int __fd, const char *__path, int __oflag) __asm__ ("" "__openat64_2")
7036 __attribute__ ((__nonnull__ (2)));
7037extern int __openat_alias (int __fd, const char *__path, int __oflag, ...) __asm__ ("" "openat64")
7038 __attribute__ ((__nonnull__ (2)));
7039extern void __openat_too_many_args (void) __attribute__((__error__ ("openat can be called either with 3 or 4 arguments, not more")))
7040 ;
7041extern void __openat_missing_mode (void) __attribute__((__error__ ("openat with O_CREAT in third argument needs 4 arguments")))
7042 ;
7043extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
7044openat (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}
7061extern int __openat64_2 (int __fd, const char *__path, int __oflag)
7062 __attribute__ ((__nonnull__ (2)));
7063extern int __openat64_alias (int __fd, const char *__path, int __oflag, ...) __asm__ ("" "openat64")
7064 __attribute__ ((__nonnull__ (2)));
7065extern void __openat64_too_many_args (void) __attribute__((__error__ ("openat64 can be called either with 3 or 4 arguments, not more")))
7066 ;
7067extern void __openat64_missing_mode (void) __attribute__((__error__ ("openat64 with O_CREAT in third argument needs 4 arguments")))
7068 ;
7069extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
7070openat64 (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}
7087extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
7088 size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7089extern void *memmove (void *__dest, const void *__src, size_t __n)
7090 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7091extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
7092 int __c, size_t __n)
7093 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7094extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7095extern int memcmp (const void *__s1, const void *__s2, size_t __n)
7096 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7097extern void *memchr (const void *__s, int __c, size_t __n)
7098 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7099extern void *rawmemchr (const void *__s, int __c)
7100 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7101extern void *memrchr (const void *__s, int __c, size_t __n)
7102 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7103extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
7104 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7105extern char *strncpy (char *__restrict __dest,
7106 const char *__restrict __src, size_t __n)
7107 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7108extern char *strcat (char *__restrict __dest, const char *__restrict __src)
7109 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7110extern char *strncat (char *__restrict __dest, const char *__restrict __src,
7111 size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7112extern int strcmp (const char *__s1, const char *__s2)
7113 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7114extern int strncmp (const char *__s1, const char *__s2, size_t __n)
7115 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7116extern int strcoll (const char *__s1, const char *__s2)
7117 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7118extern size_t strxfrm (char *__restrict __dest,
7119 const char *__restrict __src, size_t __n)
7120 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
7121extern int strcoll_l (const char *__s1, const char *__s2, __locale_t __l)
7122 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
7123extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
7124 __locale_t __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));
7125extern char *strdup (const char *__s)
7126 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
7127extern char *strndup (const char *__string, size_t __n)
7128 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
7129extern char *strchr (const char *__s, int __c)
7130 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7131extern char *strrchr (const char *__s, int __c)
7132 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7133extern char *strchrnul (const char *__s, int __c)
7134 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7135extern size_t strcspn (const char *__s, const char *__reject)
7136 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7137extern size_t strspn (const char *__s, const char *__accept)
7138 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7139extern char *strpbrk (const char *__s, const char *__accept)
7140 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7141extern char *strstr (const char *__haystack, const char *__needle)
7142 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7143extern char *strtok (char *__restrict __s, const char *__restrict __delim)
7144 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
7145extern char *__strtok_r (char *__restrict __s,
7146 const char *__restrict __delim,
7147 char **__restrict __save_ptr)
7148 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
7149extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
7150 char **__restrict __save_ptr)
7151 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
7152extern char *strcasestr (const char *__haystack, const char *__needle)
7153 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7154extern 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)));
7157extern void *__mempcpy (void *__restrict __dest,
7158 const void *__restrict __src, size_t __n)
7159 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7160extern void *mempcpy (void *__restrict __dest,
7161 const void *__restrict __src, size_t __n)
7162 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7163extern size_t strlen (const char *__s)
7164 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7165extern size_t strnlen (const char *__string, size_t __maxlen)
7166 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7167extern char *strerror (int __errnum) __attribute__ ((__nothrow__ , __leaf__));
7168extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
7169 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
7170extern char *strerror_l (int __errnum, __locale_t __l) __attribute__ ((__nothrow__ , __leaf__));
7171extern void __bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7172extern void bcopy (const void *__src, void *__dest, size_t __n)
7173 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7174extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7175extern int bcmp (const void *__s1, const void *__s2, size_t __n)
7176 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7177extern char *index (const char *__s, int __c)
7178 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7179extern char *rindex (const char *__s, int __c)
7180 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
7181extern int ffs (int __i) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
7182extern 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__));
7185extern int strcasecmp (const char *__s1, const char *__s2)
7186 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7187extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
7188 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7189extern int strcasecmp_l (const char *__s1, const char *__s2,
7190 __locale_t __loc)
7191 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
7192extern 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)));
7195extern char *strsep (char **__restrict __stringp,
7196 const char *__restrict __delim)
7197 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7198extern char *strsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__));
7199extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
7200 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7201extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
7202 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7203extern char *__stpncpy (char *__restrict __dest,
7204 const char *__restrict __src, size_t __n)
7205 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7206extern char *stpncpy (char *__restrict __dest,
7207 const char *__restrict __src, size_t __n)
7208 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7209extern int strverscmp (const char *__s1, const char *__s2)
7210 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
7211extern char *strfry (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7212extern void *memfrob (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7213extern char *basename (const char *__filename) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7214typedef struct { unsigned char __arr[2]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR2;
7215typedef struct { unsigned char __arr[3]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR3;
7216typedef struct { unsigned char __arr[4]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR4;
7217typedef struct { unsigned char __arr[5]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR5;
7218typedef struct { unsigned char __arr[6]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR6;
7219typedef struct { unsigned char __arr[7]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR7;
7220typedef struct { unsigned char __arr[8]; } __attribute__ ((__packed__)) __STRING2_COPY_ARR8;
7221extern void *__rawmemchr (const void *__s, int __c);
7222extern __inline size_t __strcspn_c1 (const char *__s, int __reject);
7223extern __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}
7231extern __inline size_t __strcspn_c2 (const char *__s, int __reject1,
7232 int __reject2);
7233extern __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}
7242extern __inline size_t __strcspn_c3 (const char *__s, int __reject1,
7243 int __reject2, int __reject3);
7244extern __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}
7254extern __inline size_t __strspn_c1 (const char *__s, int __accept);
7255extern __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}
7263extern __inline size_t __strspn_c2 (const char *__s, int __accept1,
7264 int __accept2);
7265extern __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}
7273extern __inline size_t __strspn_c3 (const char *__s, int __accept1,
7274 int __accept2, int __accept3);
7275extern __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}
7284extern __inline char *__strpbrk_c2 (const char *__s, int __accept1,
7285 int __accept2);
7286extern __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}
7293extern __inline char *__strpbrk_c3 (const char *__s, int __accept1,
7294 int __accept2, int __accept3);
7295extern __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}
7303extern __inline char *__strtok_r_1c (char *__s, char __sep, char **__nextp);
7304extern __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}
7326extern char *__strsep_g (char **__stringp, const char *__delim);
7327extern __inline char *__strsep_1c (char **__s, char __reject);
7328extern __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}
7336extern __inline char *__strsep_2c (char **__s, char __reject1, char __reject2);
7337extern __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}
7362extern __inline char *__strsep_3c (char **__s, char __reject1, char __reject2,
7363 char __reject3);
7364extern __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}
7389extern char *__strdup (const char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__));
7390extern char *__strndup (const char *__string, size_t __n)
7391 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__));
7392extern void __warn_memset_zero_len (void) __attribute__((__warning__ ("memset used with constant zero length parameter; this could be due to transposed parameters")))
7393 ;
7394extern __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}
7399extern __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}
7404extern __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}
7409extern __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}
7420extern __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}
7425extern __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}
7430extern __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}
7435extern __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}
7440extern __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}
7445extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
7446 size_t __destlen) __attribute__ ((__nothrow__ , __leaf__));
7447extern char *__stpncpy_alias (char *__dest, const char *__src, size_t __n) __asm__ ("" "stpncpy") __attribute__ ((__nothrow__ , __leaf__))
7448 ;
7449extern __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}
7457extern __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}
7462extern __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}
7467extern int access (const char *__name, int __type) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7468extern int euidaccess (const char *__name, int __type)
7469 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7470extern int eaccess (const char *__name, int __type)
7471 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7472extern int faccessat (int __fd, const char *__file, int __type, int __flag)
7473 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
7474extern __off64_t lseek (int __fd, __off64_t __offset, int __whence) __asm__ ("" "lseek64") __attribute__ ((__nothrow__ , __leaf__))
7475 ;
7476extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
7477 __attribute__ ((__nothrow__ , __leaf__));
7478extern int close (int __fd);
7479extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __attribute__ ((__warn_unused_result__));
7480extern ssize_t write (int __fd, const void *__buf, size_t __n) __attribute__ ((__warn_unused_result__));
7481extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pread64")
7482 __attribute__ ((__warn_unused_result__));
7483extern ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pwrite64")
7484 __attribute__ ((__warn_unused_result__));
7485extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
7486 __off64_t __offset) __attribute__ ((__warn_unused_result__));
7487extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n,
7488 __off64_t __offset) __attribute__ ((__warn_unused_result__));
7489extern int pipe (int __pipedes[2]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7490extern int pipe2 (int __pipedes[2], int __flags) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7491extern unsigned int alarm (unsigned int __seconds) __attribute__ ((__nothrow__ , __leaf__));
7492extern unsigned int sleep (unsigned int __seconds);
7493extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
7494 __attribute__ ((__nothrow__ , __leaf__));
7495extern int usleep (__useconds_t __useconds);
7496extern int pause (void);
7497extern int chown (const char *__file, __uid_t __owner, __gid_t __group)
7498 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7499extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7500extern int lchown (const char *__file, __uid_t __owner, __gid_t __group)
7501 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7502extern 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__));
7505extern int chdir (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7506extern int fchdir (int __fd) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7507extern char *getcwd (char *__buf, size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7508extern char *get_current_dir_name (void) __attribute__ ((__nothrow__ , __leaf__));
7509extern char *getwd (char *__buf)
7510 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)) __attribute__ ((__warn_unused_result__));
7511extern int dup (int __fd) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7512extern int dup2 (int __fd, int __fd2) __attribute__ ((__nothrow__ , __leaf__));
7513extern int dup3 (int __fd, int __fd2, int __flags) __attribute__ ((__nothrow__ , __leaf__));
7514extern char **__environ;
7515extern char **environ;
7516extern int execve (const char *__path, char *const __argv[],
7517 char *const __envp[]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7518extern int fexecve (int __fd, char *const __argv[], char *const __envp[])
7519 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
7520extern int execv (const char *__path, char *const __argv[])
7521 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7522extern int execle (const char *__path, const char *__arg, ...)
7523 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7524extern int execl (const char *__path, const char *__arg, ...)
7525 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7526extern int execvp (const char *__file, char *const __argv[])
7527 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7528extern int execlp (const char *__file, const char *__arg, ...)
7529 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7530extern int execvpe (const char *__file, char *const __argv[],
7531 char *const __envp[])
7532 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7533extern int nice (int __inc) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7534extern void _exit (int __status) __attribute__ ((__noreturn__));
7535enum
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 };
7559enum
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 };
7777enum
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 };
7844extern long int pathconf (const char *__path, int __name)
7845 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7846extern long int fpathconf (int __fd, int __name) __attribute__ ((__nothrow__ , __leaf__));
7847extern long int sysconf (int __name) __attribute__ ((__nothrow__ , __leaf__));
7848extern size_t confstr (int __name, char *__buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__));
7849extern __pid_t getpid (void) __attribute__ ((__nothrow__ , __leaf__));
7850extern __pid_t getppid (void) __attribute__ ((__nothrow__ , __leaf__));
7851extern __pid_t getpgrp (void) __attribute__ ((__nothrow__ , __leaf__));
7852extern __pid_t __getpgid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));
7853extern __pid_t getpgid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));
7854extern int setpgid (__pid_t __pid, __pid_t __pgid) __attribute__ ((__nothrow__ , __leaf__));
7855extern int setpgrp (void) __attribute__ ((__nothrow__ , __leaf__));
7856extern __pid_t setsid (void) __attribute__ ((__nothrow__ , __leaf__));
7857extern __pid_t getsid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));
7858extern __uid_t getuid (void) __attribute__ ((__nothrow__ , __leaf__));
7859extern __uid_t geteuid (void) __attribute__ ((__nothrow__ , __leaf__));
7860extern __gid_t getgid (void) __attribute__ ((__nothrow__ , __leaf__));
7861extern __gid_t getegid (void) __attribute__ ((__nothrow__ , __leaf__));
7862extern int getgroups (int __size, __gid_t __list[]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7863extern int group_member (__gid_t __gid) __attribute__ ((__nothrow__ , __leaf__));
7864extern int setuid (__uid_t __uid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7865extern int setreuid (__uid_t __ruid, __uid_t __euid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7866extern int seteuid (__uid_t __uid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7867extern int setgid (__gid_t __gid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7868extern int setregid (__gid_t __rgid, __gid_t __egid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7869extern int setegid (__gid_t __gid) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7870extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid)
7871 __attribute__ ((__nothrow__ , __leaf__));
7872extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid)
7873 __attribute__ ((__nothrow__ , __leaf__));
7874extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid)
7875 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7876extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
7877 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7878extern __pid_t fork (void) __attribute__ ((__nothrow__));
7879extern __pid_t vfork (void) __attribute__ ((__nothrow__ , __leaf__));
7880extern char *ttyname (int __fd) __attribute__ ((__nothrow__ , __leaf__));
7881extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
7882 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
7883extern int isatty (int __fd) __attribute__ ((__nothrow__ , __leaf__));
7884extern int ttyslot (void) __attribute__ ((__nothrow__ , __leaf__));
7885extern int link (const char *__from, const char *__to)
7886 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__));
7887extern 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__));
7890extern int symlink (const char *__from, const char *__to)
7891 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__warn_unused_result__));
7892extern 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__));
7895extern int symlinkat (const char *__from, int __tofd,
7896 const char *__to) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3))) __attribute__ ((__warn_unused_result__));
7897extern 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__));
7900extern int unlink (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7901extern int unlinkat (int __fd, const char *__name, int __flag)
7902 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
7903extern int rmdir (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7904extern __pid_t tcgetpgrp (int __fd) __attribute__ ((__nothrow__ , __leaf__));
7905extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __attribute__ ((__nothrow__ , __leaf__));
7906extern char *getlogin (void);
7907extern int getlogin_r (char *__name, size_t __name_len) __attribute__ ((__nonnull__ (1)));
7908extern int setlogin (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7909extern char *BSDoptarg;
7910extern int BSDoptind;
7911extern int BSDopterr;
7912extern int BSDoptopt;
7913extern int BSDgetopt(int ___argc, char *const *___argv, const char *__shortopts)
7914 __attribute__ ((__nothrow__ , __leaf__));
7915extern int gethostname (char *__name, size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7916extern int sethostname (const char *__name, size_t __len)
7917 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7918extern int sethostid (long int __id) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7919extern int getdomainname (char *__name, size_t __len)
7920 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7921extern int setdomainname (const char *__name, size_t __len)
7922 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7923extern int vhangup (void) __attribute__ ((__nothrow__ , __leaf__));
7924extern int revoke (const char *__file) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7925extern int profil (unsigned short int *__sample_buffer, size_t __size,
7926 size_t __offset, unsigned int __scale)
7927 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7928extern int acct (const char *__name) __attribute__ ((__nothrow__ , __leaf__));
7929extern char *getusershell (void) __attribute__ ((__nothrow__ , __leaf__));
7930extern void endusershell (void) __attribute__ ((__nothrow__ , __leaf__));
7931extern void setusershell (void) __attribute__ ((__nothrow__ , __leaf__));
7932extern int daemon (int __nochdir, int __noclose) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7933extern int chroot (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7934extern char *getpass (const char *__prompt) __attribute__ ((__nonnull__ (1)));
7935extern int fsync (int __fd);
7936extern int syncfs (int __fd) __attribute__ ((__nothrow__ , __leaf__));
7937extern long int gethostid (void);
7938extern void sync (void) __attribute__ ((__nothrow__ , __leaf__));
7939extern int getpagesize (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
7940extern int getdtablesize (void) __attribute__ ((__nothrow__ , __leaf__));
7941extern int truncate (const char *__file, __off64_t __length) __asm__ ("" "truncate64") __attribute__ ((__nothrow__ , __leaf__))
7942 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7943extern int truncate64 (const char *__file, __off64_t __length)
7944 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
7945extern int ftruncate (int __fd, __off64_t __length) __asm__ ("" "ftruncate64") __attribute__ ((__nothrow__ , __leaf__))
7946 __attribute__ ((__warn_unused_result__));
7947extern int ftruncate64 (int __fd, __off64_t __length) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7948extern int brk (void *__addr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
7949extern void *sbrk (intptr_t __delta) __attribute__ ((__nothrow__ , __leaf__));
7950extern long int syscall (long int __sysno, ...) __attribute__ ((__nothrow__ , __leaf__));
7951extern int fdatasync (int __fildes);
7952extern char *crypt (const char *__key, const char *__salt)
7953 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7954extern void encrypt (char *__block, int __edflag) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
7955extern void swab (const void *__restrict __from, void *__restrict __to,
7956 ssize_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
7957extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
7958 size_t __buflen) __attribute__ ((__warn_unused_result__));
7959extern ssize_t __read_alias (int __fd, void *__buf, size_t __nbytes) __asm__ ("" "read")
7960 __attribute__ ((__warn_unused_result__));
7961extern 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 ;
7964extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) ssize_t
7965read (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}
7976extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
7977 __off_t __offset, size_t __bufsize) __attribute__ ((__warn_unused_result__));
7978extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes,
7979 __off64_t __offset, size_t __bufsize) __attribute__ ((__warn_unused_result__));
7980extern ssize_t __pread_alias (int __fd, void *__buf, size_t __nbytes, __off_t __offset) __asm__ ("" "pread")
7981 __attribute__ ((__warn_unused_result__));
7982extern ssize_t __pread64_alias (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pread64")
7983 __attribute__ ((__warn_unused_result__));
7984extern 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 ;
7987extern 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 ;
7990extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) ssize_t
7991pread (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}
8003extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) ssize_t
8004pread64 (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}
8016extern 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__));
8020extern 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__));
8022extern 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 ;
8025extern __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}
8037extern 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__));
8041extern 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__));
8043extern 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 ;
8046extern __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}
8059extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
8060 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
8061extern char *__getcwd_alias (char *__buf, size_t __size) __asm__ ("" "getcwd") __attribute__ ((__nothrow__ , __leaf__))
8062 __attribute__ ((__warn_unused_result__));
8063extern 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 ;
8066extern __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}
8078extern char *__getwd_chk (char *__buf, size_t buflen)
8079 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
8080extern 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 ;
8083extern __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}
8090extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
8091 size_t __buflen) __attribute__ ((__nothrow__ , __leaf__));
8092extern size_t __confstr_alias (int __name, char *__buf, size_t __len) __asm__ ("" "confstr") __attribute__ ((__nothrow__ , __leaf__))
8093 ;
8094extern 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 ;
8097extern __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}
8109extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen)
8110 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
8111extern int __getgroups_alias (int __size, __gid_t __list[]) __asm__ ("" "getgroups") __attribute__ ((__nothrow__ , __leaf__))
8112 __attribute__ ((__warn_unused_result__));
8113extern 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 ;
8116extern __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}
8128extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
8129 size_t __nreal) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
8130extern int __ttyname_r_alias (int __fd, char *__buf, size_t __buflen) __asm__ ("" "ttyname_r") __attribute__ ((__nothrow__ , __leaf__))
8131 __attribute__ ((__nonnull__ (2)));
8132extern 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 ;
8135extern __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}
8147extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
8148 __attribute__ ((__nonnull__ (1)));
8149extern int __getlogin_r_alias (char *__buf, size_t __buflen) __asm__ ("" "getlogin_r")
8150 __attribute__ ((__nonnull__ (1)));
8151extern 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 ;
8154extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) int
8155getlogin_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}
8166extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
8167 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
8168extern int __gethostname_alias (char *__buf, size_t __buflen) __asm__ ("" "gethostname") __attribute__ ((__nothrow__ , __leaf__))
8169 __attribute__ ((__nonnull__ (1)));
8170extern 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 ;
8173extern __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}
8185extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
8186 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
8187extern int __getdomainname_alias (char *__buf, size_t __buflen) __asm__ ("" "getdomainname") __attribute__ ((__nothrow__ , __leaf__))
8188 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
8189extern 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 ;
8192extern __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}
8204void *xmalloc(size_t);
8205void *xcalloc(size_t, size_t);
8206void *xrealloc(void *, size_t, size_t);
8207char *xstrdup(const char *);
8208int xasprintf(char **, const char *, ...)
8209 __attribute__((__format__ (printf, 2, 3)))
8210 __attribute__((__nonnull__ (2)));
8211typedef struct Key Key;
8212enum 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};
8226enum fp_type {
8227 SSH_FP_SHA1,
8228 SSH_FP_MD5,
8229 SSH_FP_SHA256
8230};
8231enum fp_rep {
8232 SSH_FP_HEX,
8233 SSH_FP_BUBBLEBABBLE,
8234 SSH_FP_RANDOMART
8235};
8236struct 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};
8248struct 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};
8259Key *key_new(int);
8260void key_add_private(Key *);
8261Key *key_new_private(int);
8262void key_free(Key *);
8263Key *key_demote(const Key *);
8264int key_equal_public(const Key *, const Key *);
8265int key_equal(const Key *, const Key *);
8266char *key_fingerprint(const Key *, enum fp_type, enum fp_rep);
8267u_char *key_fingerprint_raw(const Key *, enum fp_type, u_int *);
8268const char *key_type(const Key *);
8269const char *key_cert_type(const Key *);
8270int key_write(const Key *, FILE *);
8271int key_read(Key *, char **);
8272u_int key_size(const Key *);
8273Key *key_generate(int, u_int);
8274Key *key_from_private(const Key *);
8275int key_type_from_name(char *);
8276int key_is_cert(const Key *);
8277int key_type_is_cert(int);
8278int key_type_plain(int);
8279int key_to_certified(Key *, int);
8280int key_drop_cert(Key *);
8281int key_certify(Key *, Key *);
8282void key_cert_copy(const Key *, struct Key *);
8283int key_cert_check_authority(const Key *, int, int, const char *,
8284 const char **);
8285int key_cert_is_legacy(const Key *);
8286int key_ecdsa_nid_from_name(const char *);
8287int key_curve_name_to_nid(const char *);
8288const char *key_curve_nid_to_name(int);
8289u_int key_curve_nid_to_bits(int);
8290int key_ecdsa_bits_to_nid(int);
8291int key_ecdsa_key_to_nid(EC_KEY *);
8292int key_ec_nid_to_hash_alg(int nid);
8293int key_ec_validate_public(const EC_GROUP *, const EC_POINT *);
8294int key_ec_validate_private(const EC_KEY *);
8295char *key_alg_list(int, int);
8296Key *key_from_blob(const u_char *, u_int);
8297int key_to_blob(const Key *, u_char **, u_int *);
8298const char *key_ssh_name(const Key *);
8299const char *key_ssh_name_plain(const Key *);
8300int key_names_valid2(const char *);
8301int key_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8302int key_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8303int ssh_dss_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8304int ssh_dss_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8305int ssh_ecdsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8306int ssh_ecdsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8307int ssh_rsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8308int ssh_rsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8309int ssh_ed25519_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
8310int ssh_ed25519_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8311void key_private_serialize(const Key *, Buffer *);
8312Key *key_private_deserialize(Buffer *);
8313void rsa_public_encrypt(BIGNUM *, BIGNUM *, RSA *);
8314int rsa_private_decrypt(BIGNUM *, BIGNUM *, RSA *);
8315void rsa_generate_additional_parameters(RSA *);
8316int key_save_private(Key *, const char *, const char *, const char *,
8317 int, const char *, int);
8318int key_load_file(int, const char *, Buffer *);
8319Key *key_load_cert(const char *);
8320Key *key_load_public(const char *, char **);
8321Key *key_load_public_type(int, const char *, char **);
8322Key *key_parse_private(Buffer *, const char *, const char *, char **);
8323Key *key_load_private(const char *, const char *, char **);
8324Key *key_load_private_cert(int, const char *, const char *, int *);
8325Key *key_load_private_type(int, const char *, const char *, char **, int *);
8326Key *key_load_private_pem(int, int, const char *, char **);
8327int key_perm_ok(int, const char *);
8328int key_in_file(Key *, const char *, int);
8329int uuencode(const u_char *, u_int, char *, size_t);
8330int uudecode(const char *, u_char *, size_t);
8331void dump_base64(FILE *, const u_char *, u_int);
8332typedef 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;
8346typedef 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;
8357typedef void (log_handler_fn)(LogLevel, const char *, void *);
8358void log_init(char *, LogLevel, SyslogFacility, int);
8359void log_change_level(LogLevel);
8360int log_is_on_stderr(void);
8361void log_redirect_stderr_to(const char *);
8362SyslogFacility log_facility_number(char *);
8363const char * log_facility_name(SyslogFacility);
8364LogLevel log_level_number(char *);
8365const char * log_level_name(LogLevel);
8366void fatal(const char *, ...) __attribute__((noreturn))
8367 __attribute__((format(printf, 1, 2)));
8368void error(const char *, ...) __attribute__((format(printf, 1, 2)));
8369void sigdie(const char *, ...) __attribute__((noreturn))
8370 __attribute__((format(printf, 1, 2)));
8371void logit(const char *, ...) __attribute__((format(printf, 1, 2)));
8372void verbose(const char *, ...) __attribute__((format(printf, 1, 2)));
8373void debug(const char *, ...) __attribute__((format(printf, 1, 2)));
8374void debug2(const char *, ...) __attribute__((format(printf, 1, 2)));
8375void debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
8376void set_log_handler(log_handler_fn *, void *);
8377void do_log2(LogLevel, const char *, ...)
8378 __attribute__((format(printf, 2, 3)));
8379void do_log(LogLevel, const char *, va_list);
8380void cleanup_exit(int) __attribute__((noreturn));
8381char *chop(char *);
8382char *strdelim(char **);
8383int set_nonblock(int);
8384int unset_nonblock(int);
8385void set_nodelay(int);
8386int a2port(const char *);
8387int a2tun(const char *, int *);
8388char *put_host_port(const char *, u_short);
8389char *hpdelim(char **);
8390char *cleanhostname(char *);
8391char *colon(char *);
8392long convtime(const char *);
8393char *tilde_expand_filename(const char *, uid_t);
8394char *percent_expand(const char *, ...) __attribute__(());
8395char *tohex(const void *, size_t);
8396void sanitise_stdfd(void);
8397void ms_subtract_diff(struct timeval *, int *);
8398void ms_to_timeval(struct timeval *, int);
8399time_t monotime(void);
8400void lowercase(char *s);
8401void sock_set_v6only(int);
8402struct passwd *pwcopy(struct passwd *);
8403const char *ssh_gai_strerror(int);
8404typedef struct arglist arglist;
8405struct arglist {
8406 char **list;
8407 u_int num;
8408 u_int nalloc;
8409};
8410void addargs(arglist *, char *, ...)
8411 __attribute__((format(printf, 2, 3)));
8412void replacearg(arglist *, u_int, char *, ...)
8413 __attribute__((format(printf, 3, 4)));
8414void freeargs(arglist *);
8415int tun_open(int, int);
8416u_int64_t get_u64(const void *)
8417 __attribute__(());
8418u_int32_t get_u32(const void *)
8419 __attribute__(());
8420u_int16_t get_u16(const void *)
8421 __attribute__(());
8422void put_u64(void *, u_int64_t)
8423 __attribute__(());
8424void put_u32(void *, u_int32_t)
8425 __attribute__(());
8426void put_u16(void *, u_int16_t)
8427 __attribute__(());
8428struct bwlimit {
8429 size_t buflen;
8430 u_int64_t rate, thresh, lamt;
8431 struct timeval bwstart, bwend;
8432};
8433void bandwidth_limit_init(struct bwlimit *, u_int64_t, size_t);
8434void bandwidth_limit(struct bwlimit *, size_t);
8435int parse_ipqos(const char *);
8436const char *iptos2str(int);
8437void mktemp_proto(char *, size_t);
8438char *read_passphrase(const char *, int);
8439int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
8440int read_keyfile_line(FILE *, const char *, char *, size_t, u_long *);
8441int match_pattern(const char *, const char *);
8442int match_pattern_list(const char *, const char *, u_int, int);
8443int match_hostname(const char *, const char *, u_int);
8444int match_host_and_ip(const char *, const char *, const char *);
8445int match_user(const char *, const char *, const char *, const char *);
8446char *match_list(const char *, const char *, u_int *);
8447int addr_match_list(const char *, const char *);
8448int addr_match_cidr_list(const char *, const char *);
8449typedef enum {
8450 HOST_OK, HOST_NEW, HOST_CHANGED, HOST_REVOKED, HOST_FOUND
8451} HostStatus;
8452typedef enum {
8453 MRK_ERROR, MRK_NONE, MRK_REVOKE, MRK_CA
8454} HostkeyMarker;
8455struct hostkey_entry {
8456 char *host;
8457 char *file;
8458 u_long line;
8459 Key *key;
8460 HostkeyMarker marker;
8461};
8462struct hostkeys;
8463struct hostkeys *init_hostkeys(void);
8464void load_hostkeys(struct hostkeys *, const char *, const char *);
8465void free_hostkeys(struct hostkeys *);
8466HostStatus check_key_in_hostkeys(struct hostkeys *, Key *,
8467 const struct hostkey_entry **);
8468int lookup_key_in_hostkeys_by_type(struct hostkeys *, int,
8469 const struct hostkey_entry **);
8470int hostfile_read_key(char **, int *, Key *);
8471int add_host_to_hostfile(const char *, const char *, const Key *, int);
8472char *host_hash(const char *, const char *, u_int);
8473enum sshfp_types {
8474 SSHFP_KEY_RESERVED = 0,
8475 SSHFP_KEY_RSA = 1,
8476 SSHFP_KEY_DSA = 2,
8477 SSHFP_KEY_ECDSA = 3
8478};
8479enum sshfp_hashes {
8480 SSHFP_HASH_RESERVED = 0,
8481 SSHFP_HASH_SHA1 = 1,
8482 SSHFP_HASH_SHA256 = 2,
8483 SSHFP_HASH_MAX = 3
8484};
8485int verify_host_key_dns(const char *, struct sockaddr *, Key *, int *);
8486int export_dns_rr(const char *, Key *, FILE *, int);
8487int pkcs11_init(int);
8488void pkcs11_terminate(void);
8489int pkcs11_add_provider(char *, char *, Key ***);
8490int pkcs11_del_provider(char *);
8491size_t
8492atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
8493 int (*cb)(void *, size_t), void *);
8494size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
8495size_t
8496atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
8497 const struct iovec *_iov, int iovcnt, int (*cb)(void *, size_t), void *);
8498size_t atomiciov(ssize_t (*)(int, const struct iovec *, int),
8499 int, const struct iovec *, int);
8500struct ssh_krl;
8501struct ssh_krl *ssh_krl_init(void);
8502void ssh_krl_free(struct ssh_krl *krl);
8503void ssh_krl_set_version(struct ssh_krl *krl, u_int64_t version);
8504void ssh_krl_set_sign_key(struct ssh_krl *krl, const Key *sign_key);
8505void ssh_krl_set_comment(struct ssh_krl *krl, const char *comment);
8506int ssh_krl_revoke_cert_by_serial(struct ssh_krl *krl, const Key *ca_key,
8507 u_int64_t serial);
8508int ssh_krl_revoke_cert_by_serial_range(struct ssh_krl *krl, const Key *ca_key,
8509 u_int64_t lo, u_int64_t hi);
8510int ssh_krl_revoke_cert_by_key_id(struct ssh_krl *krl, const Key *ca_key,
8511 const char *key_id);
8512int ssh_krl_revoke_key_explicit(struct ssh_krl *krl, const Key *key);
8513int ssh_krl_revoke_key_sha1(struct ssh_krl *krl, const Key *key);
8514int ssh_krl_revoke_key(struct ssh_krl *krl, const Key *key);
8515int ssh_krl_to_blob(struct ssh_krl *krl, Buffer *buf, const Key **sign_keys,
8516 u_int nsign_keys);
8517int ssh_krl_from_blob(Buffer *buf, struct ssh_krl **krlp,
8518 const Key **sign_ca_keys, u_int nsign_ca_keys);
8519int ssh_krl_check_key(struct ssh_krl *krl, const Key *key);
8520int ssh_krl_file_contains_key(const char *path, const Key *key);
8521u_int32_t bits = 0;
8522int change_passphrase = 0;
8523int change_comment = 0;
8524int quiet = 0;
8525int log_level = SYSLOG_LEVEL_INFO;
8526int hash_hosts = 0;
8527int find_host = 0;
8528int delete_host = 0;
8529int show_cert = 0;
8530int print_fingerprint = 0;
8531int print_bubblebabble = 0;
8532char identity_file[1024];
8533int have_identity = 0;
8534char *identity_passphrase = ((void *)0);
8535char *identity_new_passphrase = ((void *)0);
8536char *identity_comment = ((void *)0);
8537char *ca_key_path = ((void *)0);
8538unsigned long long cert_serial = 0;
8539u_int cert_key_type = 1;
8540char *cert_key_id = ((void *)0);
8541char *cert_principals = ((void *)0);
8542u_int64_t cert_valid_from = 0;
8543u_int64_t cert_valid_to = ~0ULL;
8544u_int32_t certflags_flags = ((1)|(1<<1)| (1<<2)|(1<<3)|(1<<4));
8545char *certflags_command = ((void *)0);
8546char *certflags_src_addr = ((void *)0);
8547int convert_to = 0;
8548int convert_from = 0;
8549enum {
8550 FMT_RFC4716,
8551 FMT_PKCS8,
8552 FMT_PEM
8553} convert_format = FMT_RFC4716;
8554int print_public = 0;
8555int print_generic = 0;
8556char *key_type_name = ((void *)0);
8557char *pkcs11provider = ((void *)0);
8558int use_new_format = 0;
8559char *new_format_cipher = ((void *)0);
8560int rounds = 0;
8561extern char *__progname;
8562char hostname[64];
8563int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *);
8564int prime_test(FILE *, FILE *, u_int32_t, u_int32_t, char *, unsigned long,
8565 unsigned long);
8566static void
8567type_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}
8596static void
8597ask_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}
8641static Key *
8642load_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}
8659static void
8660do_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}
8685static void
8686do_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}
8707static void
8708do_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}
8721static void
8722do_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}
8751static void
8752buffer_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}
8763static Key *
8764do_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}
8849static int
8850get_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}
8876static void
8877do_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}
8927static void
8928do_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}
8963static void
8964do_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}
8979static void
8980do_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}
9032static void
9033do_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}
9054static void
9055do_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}
9089static void
9090do_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}
9189static void
9190do_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}
9276static void
9277printhost(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}
9302static void
9303do_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}
9500static void
9501do_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}
9567static int
9568do_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}
9593static void
9594do_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}
9678static const char *
9679fmt_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}
9709static void
9710add_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}
9716static void
9717add_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}
9727static void
9728prepare_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}
9753static Key *
9754load_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}
9775static void
9776do_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}
9877static u_int64_t
9878parse_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}
9888static u_int64_t
9889parse_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}
9914static void
9915parse_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}
9944static void
9945add_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}
9989static void
9990show_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}
10029static void
10030do_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}
10088static void
10089load_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}
10104static void
10105update_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}
10218static void
10219do_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}
10266static void
10267do_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}
10291static void
10292usage(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}
10343int
10344main(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 {
10724passphrase_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}