Update netpgpverify to version 20141204 Changes since 20141129: + bring over lint changes from src/crypto version of this utility + add a helper function to get an element from a cursor + added a small compile and test script, which uses BSD makefiles + change WARNS level in BSD Makefile from 6 to 5 - changes to make WARNS=6 compile are way too intrusive and distracting to be useful + bump version to 20141204diff -r1.9 -r1.10 pkgsrc/security/netpgpverify/Makefile
(agc)
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | # $NetBSD: Makefile,v 1.9 2014/11/29 20:19:46 agc Exp $ | 1 | # $NetBSD: Makefile,v 1.10 2014/12/04 20:08:47 agc Exp $ | |
2 | 2 | |||
3 | DISTNAME= netpgpverify-20141129 | 3 | DISTNAME= netpgpverify-20141204 | |
4 | CATEGORIES= security | 4 | CATEGORIES= security | |
5 | MASTER_SITES= # empty | 5 | MASTER_SITES= # empty | |
6 | DISTFILES= # empty | 6 | DISTFILES= # empty | |
7 | 7 | |||
8 | MAINTAINER= agc@NetBSD.org | 8 | MAINTAINER= agc@NetBSD.org | |
9 | HOMEPAGE= http://www.NetBSD.org/ | 9 | HOMEPAGE= http://www.NetBSD.org/ | |
10 | COMMENT= Standalone PGP and ssh signature verification utility | 10 | COMMENT= Standalone PGP and ssh signature verification utility | |
11 | LICENSE= modified-bsd | 11 | LICENSE= modified-bsd | |
12 | 12 | |||
13 | AUTO_MKDIRS= yes | 13 | AUTO_MKDIRS= yes | |
14 | GNU_CONFIGURE= yes | 14 | GNU_CONFIGURE= yes | |
15 | 15 | |||
16 | do-extract: | 16 | do-extract: |
@@ -1,32 +1,32 @@ | @@ -1,32 +1,32 @@ | |||
1 | # $NetBSD: Makefile.bsd,v 1.2 2014/02/04 02:11:18 agc Exp $ | 1 | # $NetBSD: Makefile.bsd,v 1.3 2014/12/04 20:08:47 agc Exp $ | |
2 | 2 | |||
3 | PROG=netpgpverify | 3 | PROG=netpgpverify | |
4 | 4 | |||
5 | SRCS= b64.c bignum.c bufgap.c digest.c | 5 | SRCS= b64.c bignum.c bufgap.c digest.c | |
6 | SRCS+= libverify.c main.c misc.c | 6 | SRCS+= libverify.c main.c misc.c | |
7 | SRCS+= pgpsum.c rsa.c | 7 | SRCS+= pgpsum.c rsa.c | |
8 | 8 | |||
9 | SRCS+= bzlib.c zlib.c | 9 | SRCS+= bzlib.c zlib.c | |
10 | 10 | |||
11 | SRCS+= md5c.c rmd160.c sha1.c sha2.c tiger.c | 11 | SRCS+= md5c.c rmd160.c sha1.c sha2.c tiger.c | |
12 | 12 | |||
13 | CPPFLAGS+=-I. | 13 | CPPFLAGS+=-I. | |
14 | 14 | |||
15 | .ifndef PRODUCTION | 15 | .ifndef PRODUCTION | |
16 | CPPFLAGS+=-g -O0 | 16 | CPPFLAGS+=-g -O0 | |
17 | LDFLAGS+=-g -O0 | 17 | LDFLAGS+=-g -O0 | |
18 | .endif | 18 | .endif | |
19 | 19 | |||
20 | MAN= netpgpverify.1 | 20 | MAN= netpgpverify.1 | |
21 | WARNS= 6 | 21 | WARNS= 5 | |
22 | 22 | |||
23 | .include <bsd.prog.mk> | 23 | .include <bsd.prog.mk> | |
24 | 24 | |||
25 | tst: | 25 | tst: | |
26 | ./${PROG} -k pubring.gpg NetBSD-6.0_RC1_hashes.asc | 26 | ./${PROG} -k pubring.gpg NetBSD-6.0_RC1_hashes.asc | |
27 | ./${PROG} -k pubring.gpg NetBSD-6.0_RC1_hashes.gpg | 27 | ./${PROG} -k pubring.gpg NetBSD-6.0_RC1_hashes.gpg | |
28 | ./${PROG} -v | 28 | ./${PROG} -v | |
29 | ./${PROG} -S sshtest-20140202.pub data.gpg | 29 | ./${PROG} -S sshtest-20140202.pub data.gpg | |
30 | ./${PROG} -S sshtest-20140202.pub data.sig | 30 | ./${PROG} -S sshtest-20140202.pub data.sig | |
31 | @echo "expected failure, to check bad signatures fail to verify" | 31 | @echo "expected failure, to check bad signatures fail to verify" | |
32 | -sed -e 's|A|B|' data.gpg | ./${PROG} -S sshtest-20140202.pub | 32 | -sed -e 's|A|B|' data.gpg | ./${PROG} -S sshtest-20140202.pub |
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bzlib.c,v 1.2 2014/03/05 04:51:37 agc Exp $ */ | 1 | /* $NetBSD: bzlib.c,v 1.3 2014/12/04 20:08:47 agc Exp $ */ | |
2 | 2 | |||
3 | 3 | |||
4 | /*-------------------------------------------------------------*/ | 4 | /*-------------------------------------------------------------*/ | |
5 | /*--- Library top-level functions. ---*/ | 5 | /*--- Library top-level functions. ---*/ | |
6 | /*--- bzlib.c ---*/ | 6 | /*--- bzlib.c ---*/ | |
7 | /*-------------------------------------------------------------*/ | 7 | /*-------------------------------------------------------------*/ | |
8 | 8 | |||
9 | /* ------------------------------------------------------------------ | 9 | /* ------------------------------------------------------------------ | |
10 | This file is part of bzip2/libbzip2, a program and library for | 10 | This file is part of bzip2/libbzip2, a program and library for | |
11 | lossless, block-sorting data compression. | 11 | lossless, block-sorting data compression. | |
12 | 12 | |||
13 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | 13 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | |
14 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | 14 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | 0.9.0a/b -- no changes in this file. | 25 | 0.9.0a/b -- no changes in this file. | |
26 | 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress(). | 26 | 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress(). | |
27 | fixed bzWrite/bzRead to ignore zero-length requests. | 27 | fixed bzWrite/bzRead to ignore zero-length requests. | |
28 | fixed bzread to correctly handle read requests after EOF. | 28 | fixed bzread to correctly handle read requests after EOF. | |
29 | wrong parameter order in call to bzDecompressInit in | 29 | wrong parameter order in call to bzDecompressInit in | |
30 | bzBuffToBuffDecompress. Fixed. | 30 | bzBuffToBuffDecompress. Fixed. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include "config.h" | 33 | #include "config.h" | |
34 | 34 | |||
35 | #include "bzlib_private.h" | 35 | #include "bzlib_private.h" | |
36 | 36 | |||
37 | 37 | |||
38 | /* $NetBSD: bzlib.c,v 1.2 2014/03/05 04:51:37 agc Exp $ */ | 38 | /* $NetBSD: bzlib.c,v 1.3 2014/12/04 20:08:47 agc Exp $ */ | |
39 | 39 | |||
40 | 40 | |||
41 | /*-------------------------------------------------------------*/ | 41 | /*-------------------------------------------------------------*/ | |
42 | /*--- Table for randomising repetitive blocks ---*/ | 42 | /*--- Table for randomising repetitive blocks ---*/ | |
43 | /*--- randtable.c ---*/ | 43 | /*--- randtable.c ---*/ | |
44 | /*-------------------------------------------------------------*/ | 44 | /*-------------------------------------------------------------*/ | |
45 | 45 | |||
46 | /* ------------------------------------------------------------------ | 46 | /* ------------------------------------------------------------------ | |
47 | This file is part of bzip2/libbzip2, a program and library for | 47 | This file is part of bzip2/libbzip2, a program and library for | |
48 | lossless, block-sorting data compression. | 48 | lossless, block-sorting data compression. | |
49 | 49 | |||
50 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | 50 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | |
51 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | 51 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | |
@@ -920,26 +920,28 @@ BZFILE * bzopen_or_bzdopen | @@ -920,26 +920,28 @@ BZFILE * bzopen_or_bzdopen | |||
920 | int open_mode) /* bzopen: 0, bzdopen:1 */ | 920 | int open_mode) /* bzopen: 0, bzdopen:1 */ | |
921 | { | 921 | { | |
922 | int bzerr; | 922 | int bzerr; | |
923 | char unused[BZ_MAX_UNUSED]; | 923 | char unused[BZ_MAX_UNUSED]; | |
924 | int blockSize100k = 9; | 924 | int blockSize100k = 9; | |
925 | int writing = 0; | 925 | int writing = 0; | |
926 | char mode2[10] = ""; | 926 | char mode2[10] = ""; | |
927 | FILE *fp = NULL; | 927 | FILE *fp = NULL; | |
928 | BZFILE *bzfp = NULL; | 928 | BZFILE *bzfp = NULL; | |
929 | int verbosity = 0; | 929 | int verbosity = 0; | |
930 | int smallMode = 0; | 930 | int smallMode = 0; | |
931 | int nUnused = 0; | 931 | int nUnused = 0; | |
932 | 932 | |||
933 | __USE(blockSize100k); | |||
934 | ||||
933 | if (mode == NULL) return NULL; | 935 | if (mode == NULL) return NULL; | |
934 | while (*mode) { | 936 | while (*mode) { | |
935 | switch (*mode) { | 937 | switch (*mode) { | |
936 | case 'r': | 938 | case 'r': | |
937 | writing = 0; break; | 939 | writing = 0; break; | |
938 | case 'w': | 940 | case 'w': | |
939 | writing = 1; break; | 941 | writing = 1; break; | |
940 | case 's': | 942 | case 's': | |
941 | smallMode = 1; break; | 943 | smallMode = 1; break; | |
942 | default: | 944 | default: | |
943 | if (isdigit((unsigned char)(*mode))) { | 945 | if (isdigit((unsigned char)(*mode))) { | |
944 | blockSize100k = *mode-BZ_HDR_0; | 946 | blockSize100k = *mode-BZ_HDR_0; | |
945 | } | 947 | } | |
@@ -1070,27 +1072,27 @@ const char * BZ_API(BZ2_bzerror) (BZFILE | @@ -1070,27 +1072,27 @@ const char * BZ_API(BZ2_bzerror) (BZFILE | |||
1070 | { | 1072 | { | |
1071 | int err = ((bzFile *)b)->lastErr; | 1073 | int err = ((bzFile *)b)->lastErr; | |
1072 | 1074 | |||
1073 | if(err>0) err = 0; | 1075 | if(err>0) err = 0; | |
1074 | *errnum = err; | 1076 | *errnum = err; | |
1075 | return bzerrorstrings[err*-1]; | 1077 | return bzerrorstrings[err*-1]; | |
1076 | } | 1078 | } | |
1077 | #endif | 1079 | #endif | |
1078 | 1080 | |||
1079 | 1081 | |||
1080 | /*-------------------------------------------------------------*/ | 1082 | /*-------------------------------------------------------------*/ | |
1081 | /*--- end bzlib.c ---*/ | 1083 | /*--- end bzlib.c ---*/ | |
1082 | /*-------------------------------------------------------------*/ | 1084 | /*-------------------------------------------------------------*/ | |
1083 | /* $NetBSD: bzlib.c,v 1.2 2014/03/05 04:51:37 agc Exp $ */ | 1085 | /* $NetBSD: bzlib.c,v 1.3 2014/12/04 20:08:47 agc Exp $ */ | |
1084 | 1086 | |||
1085 | 1087 | |||
1086 | /*-------------------------------------------------------------*/ | 1088 | /*-------------------------------------------------------------*/ | |
1087 | /*--- Decompression machinery ---*/ | 1089 | /*--- Decompression machinery ---*/ | |
1088 | /*--- decompress.c ---*/ | 1090 | /*--- decompress.c ---*/ | |
1089 | /*-------------------------------------------------------------*/ | 1091 | /*-------------------------------------------------------------*/ | |
1090 | 1092 | |||
1091 | /* ------------------------------------------------------------------ | 1093 | /* ------------------------------------------------------------------ | |
1092 | This file is part of bzip2/libbzip2, a program and library for | 1094 | This file is part of bzip2/libbzip2, a program and library for | |
1093 | lossless, block-sorting data compression. | 1095 | lossless, block-sorting data compression. | |
1094 | 1096 | |||
1095 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | 1097 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | |
1096 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | 1098 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | |
@@ -1716,27 +1718,27 @@ Int32 BZ2_decompress ( DState* s ) | @@ -1716,27 +1718,27 @@ Int32 BZ2_decompress ( DState* s ) | |||
1716 | s->save_gSel = gSel; | 1718 | s->save_gSel = gSel; | |
1717 | s->save_gMinlen = gMinlen; | 1719 | s->save_gMinlen = gMinlen; | |
1718 | s->save_gLimit = gLimit; | 1720 | s->save_gLimit = gLimit; | |
1719 | s->save_gBase = gBase; | 1721 | s->save_gBase = gBase; | |
1720 | s->save_gPerm = gPerm; | 1722 | s->save_gPerm = gPerm; | |
1721 | 1723 | |||
1722 | return retVal; | 1724 | return retVal; | |
1723 | } | 1725 | } | |
1724 | 1726 | |||
1725 | 1727 | |||
1726 | /*-------------------------------------------------------------*/ | 1728 | /*-------------------------------------------------------------*/ | |
1727 | /*--- end decompress.c ---*/ | 1729 | /*--- end decompress.c ---*/ | |
1728 | /*-------------------------------------------------------------*/ | 1730 | /*-------------------------------------------------------------*/ | |
1729 | /* $NetBSD: bzlib.c,v 1.2 2014/03/05 04:51:37 agc Exp $ */ | 1731 | /* $NetBSD: bzlib.c,v 1.3 2014/12/04 20:08:47 agc Exp $ */ | |
1730 | 1732 | |||
1731 | 1733 | |||
1732 | /*-------------------------------------------------------------*/ | 1734 | /*-------------------------------------------------------------*/ | |
1733 | /*--- Table for doing CRCs ---*/ | 1735 | /*--- Table for doing CRCs ---*/ | |
1734 | /*--- crctable.c ---*/ | 1736 | /*--- crctable.c ---*/ | |
1735 | /*-------------------------------------------------------------*/ | 1737 | /*-------------------------------------------------------------*/ | |
1736 | 1738 | |||
1737 | /* ------------------------------------------------------------------ | 1739 | /* ------------------------------------------------------------------ | |
1738 | This file is part of bzip2/libbzip2, a program and library for | 1740 | This file is part of bzip2/libbzip2, a program and library for | |
1739 | lossless, block-sorting data compression. | 1741 | lossless, block-sorting data compression. | |
1740 | 1742 | |||
1741 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | 1743 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | |
1742 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | 1744 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | |
@@ -1820,27 +1822,27 @@ UInt32 BZ2_crc32Table[256] = { | @@ -1820,27 +1822,27 @@ UInt32 BZ2_crc32Table[256] = { | |||
1820 | 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL, | 1822 | 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL, | |
1821 | 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L, | 1823 | 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L, | |
1822 | 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L, | 1824 | 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L, | |
1823 | 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L, | 1825 | 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L, | |
1824 | 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL, | 1826 | 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL, | |
1825 | 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L, | 1827 | 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L, | |
1826 | 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L | 1828 | 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L | |
1827 | }; | 1829 | }; | |
1828 | 1830 | |||
1829 | 1831 | |||
1830 | /*-------------------------------------------------------------*/ | 1832 | /*-------------------------------------------------------------*/ | |
1831 | /*--- end crctable.c ---*/ | 1833 | /*--- end crctable.c ---*/ | |
1832 | /*-------------------------------------------------------------*/ | 1834 | /*-------------------------------------------------------------*/ | |
1833 | /* $NetBSD: bzlib.c,v 1.2 2014/03/05 04:51:37 agc Exp $ */ | 1835 | /* $NetBSD: bzlib.c,v 1.3 2014/12/04 20:08:47 agc Exp $ */ | |
1834 | 1836 | |||
1835 | 1837 | |||
1836 | /*-------------------------------------------------------------*/ | 1838 | /*-------------------------------------------------------------*/ | |
1837 | /*--- Huffman coding low-level stuff ---*/ | 1839 | /*--- Huffman coding low-level stuff ---*/ | |
1838 | /*--- huffman.c ---*/ | 1840 | /*--- huffman.c ---*/ | |
1839 | /*-------------------------------------------------------------*/ | 1841 | /*-------------------------------------------------------------*/ | |
1840 | 1842 | |||
1841 | /* ------------------------------------------------------------------ | 1843 | /* ------------------------------------------------------------------ | |
1842 | This file is part of bzip2/libbzip2, a program and library for | 1844 | This file is part of bzip2/libbzip2, a program and library for | |
1843 | lossless, block-sorting data compression. | 1845 | lossless, block-sorting data compression. | |
1844 | 1846 | |||
1845 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | 1847 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | |
1846 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | 1848 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> |
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bzlib_private.h,v 1.1 2013/03/16 07:32:34 agc Exp $ */ | 1 | /* $NetBSD: bzlib_private.h,v 1.2 2014/12/04 20:08:47 agc Exp $ */ | |
2 | 2 | |||
3 | 3 | |||
4 | /*-------------------------------------------------------------*/ | 4 | /*-------------------------------------------------------------*/ | |
5 | /*--- Private header file for the library. ---*/ | 5 | /*--- Private header file for the library. ---*/ | |
6 | /*--- bzlib_private.h ---*/ | 6 | /*--- bzlib_private.h ---*/ | |
7 | /*-------------------------------------------------------------*/ | 7 | /*-------------------------------------------------------------*/ | |
8 | 8 | |||
9 | /* ------------------------------------------------------------------ | 9 | /* ------------------------------------------------------------------ | |
10 | This file is part of bzip2/libbzip2, a program and library for | 10 | This file is part of bzip2/libbzip2, a program and library for | |
11 | lossless, block-sorting data compression. | 11 | lossless, block-sorting data compression. | |
12 | 12 | |||
13 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | 13 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 | |
14 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | 14 | Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> | |
@@ -47,27 +47,27 @@ typedef int Int32; | @@ -47,27 +47,27 @@ typedef int Int32; | |||
47 | typedef unsigned int UInt32; | 47 | typedef unsigned int UInt32; | |
48 | typedef short Int16; | 48 | typedef short Int16; | |
49 | typedef unsigned short UInt16; | 49 | typedef unsigned short UInt16; | |
50 | 50 | |||
51 | #define True ((Bool)1) | 51 | #define True ((Bool)1) | |
52 | #define False ((Bool)0) | 52 | #define False ((Bool)0) | |
53 | 53 | |||
54 | #ifndef __GNUC__ | 54 | #ifndef __GNUC__ | |
55 | #define __inline__ /* */ | 55 | #define __inline__ /* */ | |
56 | #endif | 56 | #endif | |
57 | 57 | |||
58 | #ifndef BZ_NO_STDIO | 58 | #ifndef BZ_NO_STDIO | |
59 | 59 | |||
60 | void BZ2_bz__AssertH__fail ( int errcode ); | 60 | void BZ2_bz__AssertH__fail ( int errcode ) __dead; | |
61 | #define AssertH(cond,errcode) \ | 61 | #define AssertH(cond,errcode) \ | |
62 | { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } | 62 | { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } | |
63 | 63 | |||
64 | #if BZ_DEBUG | 64 | #if BZ_DEBUG | |
65 | #define AssertD(cond,msg) \ | 65 | #define AssertD(cond,msg) \ | |
66 | { if (!(cond)) { \ | 66 | { if (!(cond)) { \ | |
67 | fprintf ( stderr, \ | 67 | fprintf ( stderr, \ | |
68 | "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ | 68 | "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ | |
69 | exit(1); \ | 69 | exit(1); \ | |
70 | }} | 70 | }} | |
71 | #else | 71 | #else | |
72 | #define AssertD(cond,msg) /* */ | 72 | #define AssertD(cond,msg) /* */ | |
73 | #endif | 73 | #endif |
@@ -55,28 +55,13 @@ netpgp_allocate(size_t n, size_t nels) | @@ -55,28 +55,13 @@ netpgp_allocate(size_t n, size_t nels) | |||
55 | #endif | 55 | #endif | |
56 | } | 56 | } | |
57 | 57 | |||
58 | void | 58 | void | |
59 | netpgp_deallocate(void *ptr, size_t size) | 59 | netpgp_deallocate(void *ptr, size_t size) | |
60 | { | 60 | { | |
61 | #ifdef _KERNEL | 61 | #ifdef _KERNEL | |
62 | kmem_free(ptr, size); | 62 | kmem_free(ptr, size); | |
63 | #else | 63 | #else | |
64 | USE_ARG(size); | 64 | USE_ARG(size); | |
65 | free(ptr); | 65 | free(ptr); | |
66 | #endif | 66 | #endif | |
67 | } | 67 | } | |
68 | ||||
69 | #ifndef _KERNEL | |||
70 | void | |||
71 | logmessage(const int level, const char *fmt, ...) | |||
72 | { | |||
73 | va_list args; | |||
74 | ||||
75 | USE_ARG(level); | |||
76 | if (fmt != NULL) { | |||
77 | va_start(args, fmt); | |||
78 | vfprintf(stderr, fmt, args); | |||
79 | va_end(args); | |||
80 | } | |||
81 | } | |||
82 | #endif |
@@ -34,20 +34,16 @@ | @@ -34,20 +34,16 @@ | |||
34 | # define __BEGIN_DECLS extern "C" { | 34 | # define __BEGIN_DECLS extern "C" { | |
35 | # define __END_DECLS } | 35 | # define __END_DECLS } | |
36 | # else | 36 | # else | |
37 | # define __BEGIN_DECLS | 37 | # define __BEGIN_DECLS | |
38 | # define __END_DECLS | 38 | # define __END_DECLS | |
39 | # endif | 39 | # endif | |
40 | #endif | 40 | #endif | |
41 | 41 | |||
42 | __BEGIN_DECLS | 42 | __BEGIN_DECLS | |
43 | 43 | |||
44 | void *netpgp_allocate(size_t /*n*/, size_t /*nels*/); | 44 | void *netpgp_allocate(size_t /*n*/, size_t /*nels*/); | |
45 | void netpgp_deallocate(void */*ptr*/, size_t /*size*/); | 45 | void netpgp_deallocate(void */*ptr*/, size_t /*size*/); | |
46 | 46 | |||
47 | #ifndef _KERNEL | |||
48 | void logmessage(const int /*level*/, const char */*fmt*/, ...); | |||
49 | #endif | |||
50 | ||||
51 | __END_DECLS | 47 | __END_DECLS | |
52 | 48 | |||
53 | #endif | 49 | #endif |
@@ -19,27 +19,26 @@ | @@ -19,27 +19,26 @@ | |||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | */ | 24 | */ | |
25 | #include "config.h" | 25 | #include "config.h" | |
26 | 26 | |||
27 | #include <sys/types.h> | 27 | #include <sys/types.h> | |
28 | #include <sys/syslog.h> | 28 | #include <sys/syslog.h> | |
29 | 29 | |||
30 | #ifdef _KERNEL | 30 | #ifdef _KERNEL | |
31 | # include <sys/kmem.h> | 31 | # include <sys/kmem.h> | |
32 | # define logmessage log | |||
33 | #else | 32 | #else | |
34 | # include <stdio.h> | 33 | # include <stdio.h> | |
35 | # include <stdlib.h> | 34 | # include <stdlib.h> | |
36 | # include <string.h> | 35 | # include <string.h> | |
37 | # include <unistd.h> | 36 | # include <unistd.h> | |
38 | #endif | 37 | #endif | |
39 | 38 | |||
40 | #include "misc.h" | 39 | #include "misc.h" | |
41 | #include "digest.h" | 40 | #include "digest.h" | |
42 | #include "rsa.h" | 41 | #include "rsa.h" | |
43 | 42 | |||
44 | #ifndef USE_ARG | 43 | #ifndef USE_ARG | |
45 | #define USE_ARG(x) /*LINTED*/(void)&(x) | 44 | #define USE_ARG(x) /*LINTED*/(void)&(x) |
@@ -46,26 +46,34 @@ | @@ -46,26 +46,34 @@ | |||
46 | #include "b64.h" | 46 | #include "b64.h" | |
47 | #include "bn.h" | 47 | #include "bn.h" | |
48 | #include "bufgap.h" | 48 | #include "bufgap.h" | |
49 | #include "digest.h" | 49 | #include "digest.h" | |
50 | #include "misc.h" | 50 | #include "misc.h" | |
51 | #include "pgpsum.h" | 51 | #include "pgpsum.h" | |
52 | #include "rsa.h" | 52 | #include "rsa.h" | |
53 | #include "verify.h" | 53 | #include "verify.h" | |
54 | 54 | |||
55 | #ifndef USE_ARG | 55 | #ifndef USE_ARG | |
56 | #define USE_ARG(x) /*LINTED*/(void)&(x) | 56 | #define USE_ARG(x) /*LINTED*/(void)&(x) | |
57 | #endif | 57 | #endif | |
58 | 58 | |||
59 | #ifndef __dead | |||
60 | #define __dead __attribute__((__noreturn__)) | |||
61 | #endif | |||
62 | ||||
63 | #ifndef __printflike | |||
64 | #define __printflike(n, m) __attribute__((format(printf,n,m))) | |||
65 | #endif | |||
66 | ||||
59 | #define BITS_TO_BYTES(b) (((b) + (CHAR_BIT - 1)) / CHAR_BIT) | 67 | #define BITS_TO_BYTES(b) (((b) + (CHAR_BIT - 1)) / CHAR_BIT) | |
60 | 68 | |||
61 | /* packet types */ | 69 | /* packet types */ | |
62 | #define SIGNATURE_PKT 2 | 70 | #define SIGNATURE_PKT 2 | |
63 | #define ONEPASS_SIGNATURE_PKT 4 | 71 | #define ONEPASS_SIGNATURE_PKT 4 | |
64 | #define PUBKEY_PKT 6 | 72 | #define PUBKEY_PKT 6 | |
65 | #define COMPRESSED_DATA_PKT 8 | 73 | #define COMPRESSED_DATA_PKT 8 | |
66 | #define MARKER_PKT 10 | 74 | #define MARKER_PKT 10 | |
67 | #define LITDATA_PKT 11 | 75 | #define LITDATA_PKT 11 | |
68 | #define TRUST_PKT 12 | 76 | #define TRUST_PKT 12 | |
69 | #define USERID_PKT 13 | 77 | #define USERID_PKT 13 | |
70 | #define PUB_SUBKEY_PKT 14 | 78 | #define PUB_SUBKEY_PKT 14 | |
71 | #define USER_ATTRIBUTE_PKT 17 | 79 | #define USER_ATTRIBUTE_PKT 17 | |
@@ -141,27 +149,27 @@ | @@ -141,27 +149,27 @@ | |||
141 | #define SIGTYPE_SUBKEY_BINDING 0x18 /* Subkey Binding Signature */ | 149 | #define SIGTYPE_SUBKEY_BINDING 0x18 /* Subkey Binding Signature */ | |
142 | #define SIGTYPE_PRIMARY_KEY_BINDING 0x19 /* Primary Key Binding Signature */ | 150 | #define SIGTYPE_PRIMARY_KEY_BINDING 0x19 /* Primary Key Binding Signature */ | |
143 | #define SIGTYPE_DIRECT_KEY 0x1f /* Signature directly on a key */ | 151 | #define SIGTYPE_DIRECT_KEY 0x1f /* Signature directly on a key */ | |
144 | 152 | |||
145 | #define SIGTYPE_KEY_REVOCATION 0x20 /* Key revocation signature */ | 153 | #define SIGTYPE_KEY_REVOCATION 0x20 /* Key revocation signature */ | |
146 | #define SIGTYPE_SUBKEY_REVOCATION 0x28 /* Subkey revocation signature */ | 154 | #define SIGTYPE_SUBKEY_REVOCATION 0x28 /* Subkey revocation signature */ | |
147 | #define SIGTYPE_CERT_REVOCATION 0x30 /* Certification revocation signature */ | 155 | #define SIGTYPE_CERT_REVOCATION 0x30 /* Certification revocation signature */ | |
148 | 156 | |||
149 | #define SIGTYPE_TIMESTAMP_SIG 0x40 /* Timestamp signature */ | 157 | #define SIGTYPE_TIMESTAMP_SIG 0x40 /* Timestamp signature */ | |
150 | #define SIGTYPE_3RDPARTY 0x50 /* Third-Party Confirmation signature */ | 158 | #define SIGTYPE_3RDPARTY 0x50 /* Third-Party Confirmation signature */ | |
151 | 159 | |||
152 | /* Forward declarations */ | 160 | /* Forward declarations */ | |
153 | static int read_all_packets(pgpv_t */*pgp*/, pgpv_mem_t */*mem*/, const char */*op*/); | 161 | static int read_all_packets(pgpv_t */*pgp*/, pgpv_mem_t */*mem*/, const char */*op*/); | |
154 | static int read_binary_file(pgpv_t */*pgp*/, const char */*op*/, const char */*fmt*/, ...); | 162 | static int read_binary_file(pgpv_t */*pgp*/, const char */*op*/, const char */*fmt*/, ...) __printflike(3, 4); | |
155 | static int read_binary_memory(pgpv_t */*pgp*/, const char */*op*/, const void */*memory*/, size_t /*size*/); | 163 | static int read_binary_memory(pgpv_t */*pgp*/, const char */*op*/, const void */*memory*/, size_t /*size*/); | |
156 | 164 | |||
157 | /* read a file into the pgpv_mem_t struct */ | 165 | /* read a file into the pgpv_mem_t struct */ | |
158 | static int | 166 | static int | |
159 | read_file(pgpv_t *pgp, const char *f) | 167 | read_file(pgpv_t *pgp, const char *f) | |
160 | { | 168 | { | |
161 | struct stat st; | 169 | struct stat st; | |
162 | pgpv_mem_t *mem; | 170 | pgpv_mem_t *mem; | |
163 | 171 | |||
164 | ARRAY_EXPAND(pgp->areas); | 172 | ARRAY_EXPAND(pgp->areas); | |
165 | ARRAY_COUNT(pgp->areas) += 1; | 173 | ARRAY_COUNT(pgp->areas) += 1; | |
166 | mem = &ARRAY_LAST(pgp->areas); | 174 | mem = &ARRAY_LAST(pgp->areas); | |
167 | memset(mem, 0x0, sizeof(*mem)); | 175 | memset(mem, 0x0, sizeof(*mem)); | |
@@ -1984,27 +1992,27 @@ setup_data(pgpv_cursor_t *cursor, pgpv_t | @@ -1984,27 +1992,27 @@ setup_data(pgpv_cursor_t *cursor, pgpv_t | |||
1984 | /* we have a file name in p */ | 1992 | /* we have a file name in p */ | |
1985 | if ((fp = fopen(p, "r")) == NULL) { | 1993 | if ((fp = fopen(p, "r")) == NULL) { | |
1986 | snprintf(cursor->why, sizeof(cursor->why), "No such file '%s'", (const char *)p); | 1994 | snprintf(cursor->why, sizeof(cursor->why), "No such file '%s'", (const char *)p); | |
1987 | return 0; | 1995 | return 0; | |
1988 | } | 1996 | } | |
1989 | if (fgets(buf, (int)sizeof(buf), fp) == NULL) { | 1997 | if (fgets(buf, (int)sizeof(buf), fp) == NULL) { | |
1990 | fclose(fp); | 1998 | fclose(fp); | |
1991 | snprintf(cursor->why, sizeof(cursor->why), "can't read file '%s'", (const char *)p); | 1999 | snprintf(cursor->why, sizeof(cursor->why), "can't read file '%s'", (const char *)p); | |
1992 | return 0; | 2000 | return 0; | |
1993 | } | 2001 | } | |
1994 | if (is_armored(buf, sizeof(buf))) { | 2002 | if (is_armored(buf, sizeof(buf))) { | |
1995 | read_ascii_armor_file(cursor, p); | 2003 | read_ascii_armor_file(cursor, p); | |
1996 | } else { | 2004 | } else { | |
1997 | read_binary_file(pgp, "signature", "%s", p); | 2005 | read_binary_file(pgp, "signature", "%s", (const char *)p); | |
1998 | } | 2006 | } | |
1999 | fclose(fp); | 2007 | fclose(fp); | |
2000 | } else { | 2008 | } else { | |
2001 | if (is_armored(p, (size_t)size)) { | 2009 | if (is_armored(p, (size_t)size)) { | |
2002 | read_ascii_armor_memory(cursor, p, (size_t)size); | 2010 | read_ascii_armor_memory(cursor, p, (size_t)size); | |
2003 | } else { | 2011 | } else { | |
2004 | read_binary_memory(pgp, "signature", p, (size_t)size); | 2012 | read_binary_memory(pgp, "signature", p, (size_t)size); | |
2005 | } | 2013 | } | |
2006 | } | 2014 | } | |
2007 | return 1; | 2015 | return 1; | |
2008 | } | 2016 | } | |
2009 | 2017 | |||
2010 | /* get the data and size from litdata packet */ | 2018 | /* get the data and size from litdata packet */ | |
@@ -2211,27 +2219,27 @@ static int | @@ -2211,27 +2219,27 @@ static int | |||
2211 | findstr(str_t *array, const char *name) | 2219 | findstr(str_t *array, const char *name) | |
2212 | { | 2220 | { | |
2213 | str_t *sp; | 2221 | str_t *sp; | |
2214 | 2222 | |||
2215 | for (sp = array ; sp->s ; sp++) { | 2223 | for (sp = array ; sp->s ; sp++) { | |
2216 | if (strncmp(name, sp->s, sp->len) == 0) { | 2224 | if (strncmp(name, sp->s, sp->len) == 0) { | |
2217 | return sp->type; | 2225 | return sp->type; | |
2218 | } | 2226 | } | |
2219 | } | 2227 | } | |
2220 | return -1; | 2228 | return -1; | |
2221 | } | 2229 | } | |
2222 | 2230 | |||
2223 | /* read public key from the ssh pubkey file */ | 2231 | /* read public key from the ssh pubkey file */ | |
2224 | static int | 2232 | static __printflike(3, 4) int | |
2225 | read_ssh_file(pgpv_t *pgp, pgpv_primarykey_t *primary, const char *fmt, ...) | 2233 | read_ssh_file(pgpv_t *pgp, pgpv_primarykey_t *primary, const char *fmt, ...) | |
2226 | { | 2234 | { | |
2227 | pgpv_signed_userid_t userid; | 2235 | pgpv_signed_userid_t userid; | |
2228 | pgpv_pubkey_t *pubkey; | 2236 | pgpv_pubkey_t *pubkey; | |
2229 | struct stat st; | 2237 | struct stat st; | |
2230 | bufgap_t bg; | 2238 | bufgap_t bg; | |
2231 | uint32_t len; | 2239 | uint32_t len; | |
2232 | int64_t off; | 2240 | int64_t off; | |
2233 | va_list args; | 2241 | va_list args; | |
2234 | char hostname[256]; | 2242 | char hostname[256]; | |
2235 | char owner[256]; | 2243 | char owner[256]; | |
2236 | char *space; | 2244 | char *space; | |
2237 | char *buf; | 2245 | char *buf; | |
@@ -2579,26 +2587,36 @@ static int | @@ -2579,26 +2587,36 @@ static int | |||
2579 | match_sig_id(pgpv_cursor_t *cursor, pgpv_signature_t *signature, pgpv_litdata_t *litdata, unsigned primary) | 2587 | match_sig_id(pgpv_cursor_t *cursor, pgpv_signature_t *signature, pgpv_litdata_t *litdata, unsigned primary) | |
2580 | { | 2588 | { | |
2581 | pgpv_pubkey_t *pubkey; | 2589 | pgpv_pubkey_t *pubkey; | |
2582 | uint8_t *data; | 2590 | uint8_t *data; | |
2583 | size_t insize; | 2591 | size_t insize; | |
2584 | 2592 | |||
2585 | pubkey = &ARRAY_ELEMENT(cursor->pgp->primaries, primary).primary; | 2593 | pubkey = &ARRAY_ELEMENT(cursor->pgp->primaries, primary).primary; | |
2586 | cursor->sigtime = signature->birth; | 2594 | cursor->sigtime = signature->birth; | |
2587 | /* calc hash on data packet */ | 2595 | /* calc hash on data packet */ | |
2588 | data = get_literal_data(cursor, litdata, &insize); | 2596 | data = get_literal_data(cursor, litdata, &insize); | |
2589 | return match_sig(cursor, signature, pubkey, data, insize); | 2597 | return match_sig(cursor, signature, pubkey, data, insize); | |
2590 | } | 2598 | } | |
2591 | 2599 | |||
2600 | /* get an element from the found array */ | |||
2601 | int | |||
2602 | pgpv_get_cursor_element(pgpv_cursor_t *cursor, size_t element) | |||
2603 | { | |||
2604 | if (cursor && element < ARRAY_COUNT(cursor->found)) { | |||
2605 | return (int)ARRAY_ELEMENT(cursor->found, element); | |||
2606 | } | |||
2607 | return -1; | |||
2608 | } | |||
2609 | ||||
2592 | /* verify the signed packets we have */ | 2610 | /* verify the signed packets we have */ | |
2593 | size_t | 2611 | size_t | |
2594 | pgpv_verify(pgpv_cursor_t *cursor, pgpv_t *pgp, const void *p, ssize_t size) | 2612 | pgpv_verify(pgpv_cursor_t *cursor, pgpv_t *pgp, const void *p, ssize_t size) | |
2595 | { | 2613 | { | |
2596 | pgpv_signature_t *signature; | 2614 | pgpv_signature_t *signature; | |
2597 | pgpv_onepass_t *onepass; | 2615 | pgpv_onepass_t *onepass; | |
2598 | pgpv_litdata_t *litdata; | 2616 | pgpv_litdata_t *litdata; | |
2599 | size_t pkt; | 2617 | size_t pkt; | |
2600 | char strkeyid[PGPV_STR_KEYID_LEN]; | 2618 | char strkeyid[PGPV_STR_KEYID_LEN]; | |
2601 | int j; | 2619 | int j; | |
2602 | 2620 | |||
2603 | if (cursor == NULL || pgp == NULL || p == NULL) { | 2621 | if (cursor == NULL || pgp == NULL || p == NULL) { | |
2604 | return 0; | 2622 | return 0; | |
@@ -2662,45 +2680,45 @@ pgpv_verify(pgpv_cursor_t *cursor, pgpv_ | @@ -2662,45 +2680,45 @@ pgpv_verify(pgpv_cursor_t *cursor, pgpv_ | |||
2662 | return pkt + 1; | 2680 | return pkt + 1; | |
2663 | } | 2681 | } | |
2664 | 2682 | |||
2665 | /* set up the pubkey keyring */ | 2683 | /* set up the pubkey keyring */ | |
2666 | int | 2684 | int | |
2667 | pgpv_read_pubring(pgpv_t *pgp, const void *keyring, ssize_t size) | 2685 | pgpv_read_pubring(pgpv_t *pgp, const void *keyring, ssize_t size) | |
2668 | { | 2686 | { | |
2669 | if (pgp == NULL) { | 2687 | if (pgp == NULL) { | |
2670 | return 0; | 2688 | return 0; | |
2671 | } | 2689 | } | |
2672 | if (keyring) { | 2690 | if (keyring) { | |
2673 | return (size > 0) ? | 2691 | return (size > 0) ? | |
2674 | read_binary_memory(pgp, "pubring", keyring, (size_t)size) : | 2692 | read_binary_memory(pgp, "pubring", keyring, (size_t)size) : | |
2675 | read_binary_file(pgp, "pubring", "%s", keyring); | 2693 | read_binary_file(pgp, "pubring", "%s", (const char *)keyring); | |
2676 | } | 2694 | } | |
2677 | return read_binary_file(pgp, "pubring", "%s/%s", nonnull_getenv("HOME"), ".gnupg/pubring.gpg"); | 2695 | return read_binary_file(pgp, "pubring", "%s/%s", nonnull_getenv("HOME"), ".gnupg/pubring.gpg"); | |
2678 | } | 2696 | } | |
2679 | 2697 | |||
2680 | /* set up the pubkey keyring from ssh pub key */ | 2698 | /* set up the pubkey keyring from ssh pub key */ | |
2681 | int | 2699 | int | |
2682 | pgpv_read_ssh_pubkeys(pgpv_t *pgp, const void *keyring, ssize_t size) | 2700 | pgpv_read_ssh_pubkeys(pgpv_t *pgp, const void *keyring, ssize_t size) | |
2683 | { | 2701 | { | |
2684 | pgpv_primarykey_t primary; | 2702 | pgpv_primarykey_t primary; | |
2685 | 2703 | |||
2686 | if (pgp == NULL) { | 2704 | if (pgp == NULL) { | |
2687 | return 0; | 2705 | return 0; | |
2688 | } | 2706 | } | |
2689 | if (keyring) { | 2707 | if (keyring) { | |
2690 | if (!read_ssh_file(pgp, &primary, "%s", keyring)) { | 2708 | if (!read_ssh_file(pgp, &primary, "%s", (const char *)keyring)) { | |
2691 | return 0; | 2709 | return 0; | |
2692 | } | 2710 | } | |
2693 | } else if (!read_ssh_file(pgp, &primary, "pubring", "%s/%s", nonnull_getenv("HOME"), ".ssh/id_rsa.pub")) { | 2711 | } else if (!read_ssh_file(pgp, &primary, "%s/%s", nonnull_getenv("HOME"), ".ssh/id_rsa.pub")) { | |
2694 | return 0; | 2712 | return 0; | |
2695 | } | 2713 | } | |
2696 | ARRAY_APPEND(pgp->primaries, primary); | 2714 | ARRAY_APPEND(pgp->primaries, primary); | |
2697 | pgp->ssh = 1; | 2715 | pgp->ssh = 1; | |
2698 | return 1; | 2716 | return 1; | |
2699 | } | 2717 | } | |
2700 | 2718 | |||
2701 | /* get verified data as a string, return its size */ | 2719 | /* get verified data as a string, return its size */ | |
2702 | size_t | 2720 | size_t | |
2703 | pgpv_get_verified(pgpv_cursor_t *cursor, size_t cookie, char **ret) | 2721 | pgpv_get_verified(pgpv_cursor_t *cursor, size_t cookie, char **ret) | |
2704 | { | 2722 | { | |
2705 | pgpv_litdata_t *litdata; | 2723 | pgpv_litdata_t *litdata; | |
2706 | uint8_t *data; | 2724 | uint8_t *data; |
@@ -25,28 +25,26 @@ | @@ -25,28 +25,26 @@ | |||
25 | #include "config.h" | 25 | #include "config.h" | |
26 | 26 | |||
27 | #include <sys/types.h> | 27 | #include <sys/types.h> | |
28 | 28 | |||
29 | #include <inttypes.h> | 29 | #include <inttypes.h> | |
30 | #include <stdio.h> | 30 | #include <stdio.h> | |
31 | #include <stdlib.h> | 31 | #include <stdlib.h> | |
32 | #include <string.h> | 32 | #include <string.h> | |
33 | #include <time.h> | 33 | #include <time.h> | |
34 | #include <unistd.h> | 34 | #include <unistd.h> | |
35 | 35 | |||
36 | #include "verify.h" | 36 | #include "verify.h" | |
37 | 37 | |||
38 | #include "array.h" | |||
39 | ||||
40 | /* print the time nicely */ | 38 | /* print the time nicely */ | |
41 | static void | 39 | static void | |
42 | ptime(int64_t secs) | 40 | ptime(int64_t secs) | |
43 | { | 41 | { | |
44 | time_t t; | 42 | time_t t; | |
45 | 43 | |||
46 | t = (time_t)secs; | 44 | t = (time_t)secs; | |
47 | printf("%s", ctime(&t)); | 45 | printf("%s", ctime(&t)); | |
48 | } | 46 | } | |
49 | 47 | |||
50 | /* print entry n */ | 48 | /* print entry n */ | |
51 | static void | 49 | static void | |
52 | pentry(pgpv_t *pgp, int n, const char *modifiers) | 50 | pentry(pgpv_t *pgp, int n, const char *modifiers) | |
@@ -85,70 +83,70 @@ getstdin(ssize_t *cc, size_t *size) | @@ -85,70 +83,70 @@ getstdin(ssize_t *cc, size_t *size) | |||
85 | } while (rc > 0); | 83 | } while (rc > 0); | |
86 | return in; | 84 | return in; | |
87 | } | 85 | } | |
88 | 86 | |||
89 | /* verify memory or file */ | 87 | /* verify memory or file */ | |
90 | static int | 88 | static int | |
91 | verify_data(pgpv_t *pgp, const char *cmd, const char *inname, char *in, ssize_t cc) | 89 | verify_data(pgpv_t *pgp, const char *cmd, const char *inname, char *in, ssize_t cc) | |
92 | { | 90 | { | |
93 | pgpv_cursor_t cursor; | 91 | pgpv_cursor_t cursor; | |
94 | const char *modifiers; | 92 | const char *modifiers; | |
95 | size_t size; | 93 | size_t size; | |
96 | size_t cookie; | 94 | size_t cookie; | |
97 | char *data; | 95 | char *data; | |
96 | int el; | |||
98 | 97 | |||
99 | memset(&cursor, 0x0, sizeof(cursor)); | 98 | memset(&cursor, 0x0, sizeof(cursor)); | |
100 | if (strcasecmp(cmd, "cat") == 0) { | 99 | if (strcasecmp(cmd, "cat") == 0) { | |
101 | if ((cookie = pgpv_verify(&cursor, pgp, in, cc)) != 0) { | 100 | if ((cookie = pgpv_verify(&cursor, pgp, in, cc)) != 0) { | |
102 | if ((size = pgpv_get_verified(&cursor, cookie, &data)) > 0) { | 101 | if ((size = pgpv_get_verified(&cursor, cookie, &data)) > 0) { | |
103 | write(STDOUT_FILENO, data, size); | 102 | write(STDOUT_FILENO, data, size); | |
104 | } | 103 | } | |
105 | return 1; | 104 | return 1; | |
106 | } | 105 | } | |
107 | } else if (strcasecmp(cmd, "verify") == 0 || strcasecmp(cmd, "trust") == 0) { | 106 | } else if (strcasecmp(cmd, "verify") == 0 || strcasecmp(cmd, "trust") == 0) { | |
108 | modifiers = (strcasecmp(cmd, "trust") == 0) ? "trust" : NULL; | 107 | modifiers = (strcasecmp(cmd, "trust") == 0) ? "trust" : NULL; | |
109 | if (pgpv_verify(&cursor, pgp, in, cc)) { | 108 | if (pgpv_verify(&cursor, pgp, in, cc)) { | |
110 | printf("Good signature for %s made ", inname); | 109 | printf("Good signature for %s made ", inname); | |
111 | ptime(cursor.sigtime); | 110 | ptime(cursor.sigtime); | |
112 | pentry(pgp, ARRAY_ELEMENT(cursor.found, 0), modifiers); | 111 | el = pgpv_get_cursor_element(&cursor, 0); | |
112 | pentry(pgp, el, modifiers); | |||
113 | return 1; | 113 | return 1; | |
114 | } | 114 | } | |
115 | fprintf(stderr, "Signature did not match contents -- %s\n", cursor.why); | 115 | fprintf(stderr, "Signature did not match contents -- %s\n", cursor.why); | |
116 | } else { | 116 | } else { | |
117 | fprintf(stderr, "unrecognised command \"%s\"\n", cmd); | 117 | fprintf(stderr, "unrecognised command \"%s\"\n", cmd); | |
118 | } | 118 | } | |
119 | return 0; | 119 | return 0; | |
120 | } | 120 | } | |
121 | 121 | |||
122 | int | 122 | int | |
123 | main(int argc, char **argv) | 123 | main(int argc, char **argv) | |
124 | { | 124 | { | |
125 | const char *modifiers; | |||
126 | const char *keyring; | 125 | const char *keyring; | |
127 | const char *cmd; | 126 | const char *cmd; | |
128 | ssize_t cc; | 127 | ssize_t cc; | |
129 | size_t size; | 128 | size_t size; | |
130 | pgpv_t pgp; | 129 | pgpv_t pgp; | |
131 | char *in; | 130 | char *in; | |
132 | int ssh; | 131 | int ssh; | |
133 | int ok; | 132 | int ok; | |
134 | int i; | 133 | int i; | |
135 | 134 | |||
136 | memset(&pgp, 0x0, sizeof(pgp)); | 135 | memset(&pgp, 0x0, sizeof(pgp)); | |
137 | keyring = NULL; | 136 | keyring = NULL; | |
138 | ssh = 0; | 137 | ssh = 0; | |
139 | ok = 1; | 138 | ok = 1; | |
140 | cmd = "verify"; | 139 | cmd = "verify"; | |
141 | modifiers = NULL; | |||
142 | while ((i = getopt(argc, argv, "S:c:k:v")) != -1) { | 140 | while ((i = getopt(argc, argv, "S:c:k:v")) != -1) { | |
143 | switch(i) { | 141 | switch(i) { | |
144 | case 'S': | 142 | case 'S': | |
145 | ssh = 1; | 143 | ssh = 1; | |
146 | keyring = optarg; | 144 | keyring = optarg; | |
147 | break; | 145 | break; | |
148 | case 'c': | 146 | case 'c': | |
149 | cmd = optarg; | 147 | cmd = optarg; | |
150 | break; | 148 | break; | |
151 | case 'k': | 149 | case 'k': | |
152 | keyring = optarg; | 150 | keyring = optarg; | |
153 | break; | 151 | break; | |
154 | case 'v': | 152 | case 'v': |
#! /bin/sh
tmp=$(mktemp -d ../netpgpverify-test.XXXXXX)
mkdir ${tmp}
pax -rwpp . ${tmp}
cat > ${tmp}/config.h <<EOF
#ifndef CONFIG_H_
#define CONFIG_H_ 20141204
#ifndef __UNCONST
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
#endif /* __UNCONST */
#ifndef USE_ARG
#define USE_ARG(x) /*LINTED*/(void)&(x)
#endif /* USE_ARG */
#endif /* CONFIG_H_ */
EOF
(cd ${tmp} && make -f Makefile.bsd && make -f Makefile.bsd tst)
rm -rf ${tmp}
@@ -15,27 +15,27 @@ | @@ -15,27 +15,27 @@ | |||
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | */ | 24 | */ | |
25 | #ifndef NETPGP_VERIFY_H_ | 25 | #ifndef NETPGP_VERIFY_H_ | |
26 | #define NETPGP_VERIFY_H_ 20140304 | 26 | #define NETPGP_VERIFY_H_ 20140304 | |
27 | 27 | |||
28 | #define NETPGPVERIFY_VERSION "netpgpverify portable 20141129" | 28 | #define NETPGPVERIFY_VERSION "netpgpverify portable 20141204" | |
29 | 29 | |||
30 | #include <sys/types.h> | 30 | #include <sys/types.h> | |
31 | 31 | |||
32 | #include <inttypes.h> | 32 | #include <inttypes.h> | |
33 | 33 | |||
34 | #ifndef PGPV_ARRAY | 34 | #ifndef PGPV_ARRAY | |
35 | /* creates 2 unsigned vars called "name"c and "name"size in current scope */ | 35 | /* creates 2 unsigned vars called "name"c and "name"size in current scope */ | |
36 | /* also creates an array called "name"s in current scope */ | 36 | /* also creates an array called "name"s in current scope */ | |
37 | #define PGPV_ARRAY(type, name) \ | 37 | #define PGPV_ARRAY(type, name) \ | |
38 | unsigned name##c; unsigned name##vsize; type *name##s | 38 | unsigned name##c; unsigned name##vsize; type *name##s | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | /* 64bit key ids */ | 41 | /* 64bit key ids */ | |
@@ -276,21 +276,22 @@ typedef struct pgpv_cursor_t { | @@ -276,21 +276,22 @@ typedef struct pgpv_cursor_t { | |||
276 | # else | 276 | # else | |
277 | # define __BEGIN_DECLS | 277 | # define __BEGIN_DECLS | |
278 | # define __END_DECLS | 278 | # define __END_DECLS | |
279 | # endif | 279 | # endif | |
280 | #endif | 280 | #endif | |
281 | 281 | |||
282 | __BEGIN_DECLS | 282 | __BEGIN_DECLS | |
283 | 283 | |||
284 | int pgpv_read_pubring(pgpv_t */*pgp*/, const void */*keyringfile/mem*/, ssize_t /*size*/); | 284 | int pgpv_read_pubring(pgpv_t */*pgp*/, const void */*keyringfile/mem*/, ssize_t /*size*/); | |
285 | int pgpv_read_ssh_pubkeys(pgpv_t */*pgp*/, const void */*keyring*/, ssize_t /*size*/); | 285 | int pgpv_read_ssh_pubkeys(pgpv_t */*pgp*/, const void */*keyring*/, ssize_t /*size*/); | |
286 | 286 | |||
287 | size_t pgpv_verify(pgpv_cursor_t */*cursor*/, pgpv_t */*pgp*/, const void */*mem/file*/, ssize_t /*size*/); | 287 | size_t pgpv_verify(pgpv_cursor_t */*cursor*/, pgpv_t */*pgp*/, const void */*mem/file*/, ssize_t /*size*/); | |
288 | size_t pgpv_get_verified(pgpv_cursor_t */*cursor*/, size_t /*cookie*/, char **/*ret*/); | 288 | size_t pgpv_get_verified(pgpv_cursor_t */*cursor*/, size_t /*cookie*/, char **/*ret*/); | |
289 | int pgpv_get_cursor_element(pgpv_cursor_t */*cursor*/, size_t /*element*/); | |||
289 | 290 | |||
290 | size_t pgpv_get_entry(pgpv_t */*pgp*/, unsigned /*ent*/, char **/*ret*/, const char */*modifiers*/); | 291 | size_t pgpv_get_entry(pgpv_t */*pgp*/, unsigned /*ent*/, char **/*ret*/, const char */*modifiers*/); | |
291 | 292 | |||
292 | int pgpv_close(pgpv_t */*pgp*/); | 293 | int pgpv_close(pgpv_t */*pgp*/); | |
293 | 294 | |||
294 | __END_DECLS | 295 | __END_DECLS | |
295 | 296 | |||
296 | #endif | 297 | #endif |