Merge from vendor branch OPENSSH:
[dragonfly.git] / usr.sbin / pkg_install / sign / extern.h
1 /*-
2  * Copyright (c) 1999 Marc Espie.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  * 3. All advertising materials mentioning features or use of this software
13  *    must display the following acknowledgement:
14  *      This product includes software developed by Marc Espie for the OpenBSD
15  * Project.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
20  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OPENBSD
21  * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * $OpenBSD: extern.h,v 1.3 1999/10/07 16:30:32 espie Exp $
30  * $FreeBSD: src/usr.sbin/pkg_install/sign/extern.h,v 1.2 2001/05/17 10:12:45 sobomax Exp $
31  * $DragonFly: src/usr.sbin/pkg_install/sign/Attic/extern.h,v 1.4 2004/07/30 04:46:14 dillon Exp $
32  */
33
34 /*
35  * Convention: all functions that operate on a FILE * also take a filename
36  * for diagnostic purposes.  The file can be connected to a pipe, so
37  *      - don't rewind
38  *      - don't reopen from filename.
39  */
40
41 struct mygzip_header;
42 struct signature;
43
44 /* main.c */
45 extern int verbose;
46 extern int quiet;
47 extern char *userkey;
48
49 /* common.c */
50 extern int read_header_and_diagnose (FILE *file, \
51         /*@out@*/struct mygzip_header *h, /*@null@*/struct signature **sign, \
52         const char *filename);
53 extern int reap (pid_t pid);
54
55 /* sign.c */
56 extern int sign (/*@observer@*/const char *filename, int type, \
57         /*@null@*/const char *userid, char *envp[]);
58
59 /* check.c */
60 extern int check_signature (/*@dependent@*/FILE *file, \
61         /*@null@*/const char *userid, char *envp[], \
62         /*@observer@*/const char *filename);
63
64 #define PKG_BADSIG 0
65 #define PKG_GOODSIG 1
66 #define PKG_UNSIGNED 2
67 #define PKG_SIGNED 4
68 #define PKG_SIGERROR 8
69 #define PKG_SIGUNKNOWN  16
70
71 typedef /*@observer@*/char *pchar;
72
73 #define MAXID   512
74 /* sha1.c */
75 #define SHA1_DB_NAME    "/var/db/pkg/SHA1"
76
77 extern void *new_sha1_checker (struct mygzip_header *h, \
78         struct signature *sign, const char *userid, char *envp[], \
79         const char *filename);
80
81 extern void sha1_add (void *arg, const char *buffer, \
82         size_t length);
83
84 extern int sha1_sign_ok (void *arg);
85
86 extern int retrieve_sha1_marker (const char *filename, \
87         struct signature **sign, const char *userid);
88
89 /* x509.c */
90 #define X509_DB_NAME    "/var/db/pkg/X509"
91
92 extern void *new_x509_checker (struct mygzip_header *h, \
93         struct signature *sign, const char *userid, char *envp[], \
94         const char *filename);
95
96 extern void x509_add (void *arg, const char *buffer, \
97         size_t length);
98
99 extern int x509_sign_ok (void *arg);
100
101 extern int retrieve_x509_marker (const char *filename, \
102         struct signature **sign, const char *userid);