Some more changes to crypto/external/bsd/netpgp missed in last commit

This commit is contained in:
Sevan Janiyan 2018-11-06 01:26:35 +00:00
parent f9f0ad010f
commit f238ccc5e5
14 changed files with 818 additions and 667 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.13 2014/12/05 04:42:36 agc Exp $ # $NetBSD: Makefile,v 1.15 2017/04/17 19:50:27 agc Exp $
PROG=netpgpverify PROG=netpgpverify
BINDIR= /usr/bin BINDIR= /usr/bin
@ -9,7 +9,7 @@ SRCS+= pgpsum.c rsa.c
SRCS+= bzlib.c zlib.c SRCS+= bzlib.c zlib.c
SRCS+= md5c.c rmd160.c sha1.c sha2.c tiger.c SRCS+= md5c.c rmd160.c sha1.c sha2.c
CPPFLAGS+=-I${.CURDIR} -I${EXTDIST}/src/netpgpverify CPPFLAGS+=-I${.CURDIR} -I${EXTDIST}/src/netpgpverify
COPTS.libverify.c+= -Wno-format-nonliteral COPTS.libverify.c+= -Wno-format-nonliteral
@ -36,3 +36,5 @@ t tst: ${PROG}
./${PROG} -S ${EXTDIST}/src/netpgpverify/sshtest-20140202.pub ${EXTDIST}/src/netpgpverify/data.sig ./${PROG} -S ${EXTDIST}/src/netpgpverify/sshtest-20140202.pub ${EXTDIST}/src/netpgpverify/data.sig
@echo "expected failure, to check bad signatures fail to verify" @echo "expected failure, to check bad signatures fail to verify"
-sed -e 's|A|B|' ${EXTDIST}/src/netpgpverify/data.gpg | ./${PROG} -S ${EXTDIST}/src/netpgpverify/sshtest-20140202.pub -sed -e 's|A|B|' ${EXTDIST}/src/netpgpverify/data.gpg | ./${PROG} -S ${EXTDIST}/src/netpgpverify/sshtest-20140202.pub
@echo "testing signatures with no version"
./${PROG} -k ${EXTDIST}/src/netpgpverify/pubring.gpg ${EXTDIST}/src/netpgpverify/noversion.asc

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +1,40 @@
#! /bin/sh #! /bin/sh
# Configuration validation subroutine script. # Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # Copyright 1992-2017 Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
# Free Software Foundation, Inc.
timestamp='2008-09-08' timestamp='2017-01-01'
# This file is (in principle) common to ALL GNU software. # This file is free software; you can redistribute it and/or modify it
# The presence of a machine in this file suggests that SOME GNU software # under the terms of the GNU General Public License as published by
# can handle that machine. It does not imply ALL GNU software can. # the Free Software Foundation; either version 3 of the License, or
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful, but
# but WITHOUT ANY WARRANTY; without even the implied warranty of # WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# GNU General Public License for more details. # General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, see <http://www.gnu.org/licenses/>.
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
# #
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under # configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program. # the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches to <config-patches@gnu.org>. Submit a context # Please send patches to <config-patches@gnu.org>.
# diff and a properly formatted ChangeLog entry.
# #
# Configuration subroutine to validate and canonicalize a configuration type. # Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument. # Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1. # If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed. # Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
# This file is supposed to be the same for all GNU packages # This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases # and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software. # that are meaningful with *any* GNU software.
@ -57,8 +53,7 @@ timestamp='2008-09-08'
me=`echo "$0" | sed -e 's,.*/,,'` me=`echo "$0" | sed -e 's,.*/,,'`
usage="\ usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
$0 [OPTION] ALIAS
Canonicalize a configuration name. Canonicalize a configuration name.
@ -72,8 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\ version="\
GNU config.sub ($timestamp) GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, Copyright 1992-2017 Free Software Foundation, Inc.
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -120,12 +114,18 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations. # Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | cloudabi*-eabi* | \
storm-chaos* | os2-emx* | rtmk-nova*) storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;; ;;
android-linux)
os=-linux-android
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*) *)
basic_machine=`echo $1 | sed 's/-[^-]*$//'` basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ] if [ $basic_machine != $1 ]
@ -148,10 +148,13 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray) -apple | -axis | -knuth | -cray | -microblaze*)
os= os=
basic_machine=$1 basic_machine=$1
;; ;;
-bluegene*)
os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond) -sim | -cisco | -oki | -wec | -winbond)
os= os=
basic_machine=$1 basic_machine=$1
@ -214,6 +217,12 @@ case $os in
-isc*) -isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;; ;;
-lynx*178)
os=-lynxos178
;;
-lynx*5)
os=-lynxos5
;;
-lynx*) -lynx*)
os=-lynxos os=-lynxos
;; ;;
@ -238,19 +247,29 @@ case $basic_machine in
# Some are omitted here because they have special meanings below. # Some are omitted here because they have special meanings below.
1750a | 580 \ 1750a | 580 \
| a29k \ | a29k \
| aarch64 | aarch64_be \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \ | am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| ba \
| be32 | be64 \
| bfin \ | bfin \
| c4x | clipper \ | c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \ | d10v | d30v | dlx | dsp16xx \
| fido | fr30 | frv \ | e2k | epiphany \
| fido | fr30 | frv | ft32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \ | i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \ | ip2k | iq2000 \
| k1om \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \ | m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \ | mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \ | mips16 \
| mips64 | mips64el \ | mips64 | mips64el \
@ -264,35 +283,56 @@ case $basic_machine in
| mips64vr5900 | mips64vr5900el \ | mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \ | mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \ | mipsisa32r2 | mipsisa32r2el \
| mipsisa32r6 | mipsisa32r6el \
| mipsisa64 | mipsisa64el \ | mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \ | mipsisa64r2 | mipsisa64r2el \
| mipsisa64r6 | mipsisa64r6el \
| mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \ | mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \ | mipstx39 | mipstx39el \
| mn10200 | mn10300 \ | mn10200 | mn10300 \
| moxie \
| mt \ | mt \
| msp430 \ | msp430 \
| nios | nios2 \ | nds32 | nds32le | nds32be \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \ | ns16k | ns32k \
| or32 \ | open8 | or1k | or1knd | or32 \
| pdp10 | pdp11 | pj | pjl \ | pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | powerpc | powerpc64 | powerpc64le | powerpcle \
| pru \
| pyramid \ | pyramid \
| riscv32 | riscv64 \
| rl78 | rx \
| score \ | score \
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \ | sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \ | spu \
| tahoe | thumb | tic4x | tic80 | tron \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| v850 | v850e \ | ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| visium \
| we32k \ | we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | x86 | xc16x | xstormy16 | xtensa \
| z8k | z80) | z8k | z80)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
;; ;;
m6811 | m68hc11 | m6812 | m68hc12) c54x)
# Motorola 68HC11/12. basic_machine=tic54x-unknown
;;
c55x)
basic_machine=tic55x-unknown
;;
c6x)
basic_machine=tic6x-unknown
;;
leon|leon[3-9])
basic_machine=sparc-$basic_machine
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
os=-none os=-none
;; ;;
@ -302,6 +342,21 @@ case $basic_machine in
basic_machine=mt-unknown basic_machine=mt-unknown
;; ;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
xgate)
basic_machine=$basic_machine-unknown
os=-none
;;
xscaleeb)
basic_machine=armeb-unknown
;;
xscaleel)
basic_machine=armel-unknown
;;
# We use `pc' rather than `unknown' # We use `pc' rather than `unknown'
# because (1) that's what they normally are, and # because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users. # (2) the word "unknown" tends to confuse beginning users.
@ -316,24 +371,32 @@ case $basic_machine in
# Recognize the basic CPU types with company name. # Recognize the basic CPU types with company name.
580-* \ 580-* \
| a29k-* \ | a29k-* \
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \ | avr-* | avr32-* \
| ba-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \ | bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \ | c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \ | d10v-* | d30v-* | dlx-* \
| elxsi-* \ | e2k-* | elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \ | h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \ | i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \ | ip2k-* | iq2000-* \
| k1om-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \ | mips16-* \
| mips64-* | mips64el-* \ | mips64-* | mips64el-* \
@ -347,32 +410,44 @@ case $basic_machine in
| mips64vr5900-* | mips64vr5900el-* \ | mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \ | mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa32r6-* | mipsisa32r6el-* \
| mipsisa64-* | mipsisa64el-* \ | mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64r6-* | mipsisa64r6el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \ | mipstx39-* | mipstx39el-* \
| mmix-* \ | mmix-* \
| mt-* \ | mt-* \
| msp430-* \ | msp430-* \
| nios-* | nios2-* \ | nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \ | none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| or1k*-* \
| orion-* \ | orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pru-* \
| pyramid-* \ | pyramid-* \
| romp-* | rs6000-* \ | riscv32-* | riscv64-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \ | sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
| tahoe-* | thumb-* \ | tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile*-* \
| tron-* \ | tron-* \
| v850-* | v850e-* | vax-* \ | ubicom32-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| visium-* \
| we32k-* \ | we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \ | xstormy16-* | xtensa*-* \
| ymp-* \ | ymp-* \
| z8k-* | z80-*) | z8k-* | z80-*)
@ -443,6 +518,13 @@ case $basic_machine in
basic_machine=m68k-apollo basic_machine=m68k-apollo
os=-bsd os=-bsd
;; ;;
aros)
basic_machine=i386-pc
os=-aros
;;
asmjs)
basic_machine=asmjs-unknown
;;
aux) aux)
basic_machine=m68k-apple basic_machine=m68k-apple
os=-aux os=-aux
@ -459,6 +541,19 @@ case $basic_machine in
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux os=-linux
;; ;;
bluegene*)
basic_machine=powerpc-ibm
os=-cnk
;;
c54x-*)
basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c55x-*)
basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c6x-*)
basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c90) c90)
basic_machine=c90-cray basic_machine=c90-cray
os=-unicos os=-unicos
@ -495,7 +590,7 @@ case $basic_machine in
basic_machine=craynv-cray basic_machine=craynv-cray
os=-unicosmp os=-unicosmp
;; ;;
cr16) cr16 | cr16-*)
basic_machine=cr16-unknown basic_machine=cr16-unknown
os=-elf os=-elf
;; ;;
@ -550,6 +645,14 @@ case $basic_machine in
basic_machine=m68k-bull basic_machine=m68k-bull
os=-sysv3 os=-sysv3
;; ;;
e500v[12])
basic_machine=powerpc-unknown
os=$os"spe"
;;
e500v[12]-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
os=$os"spe"
;;
ebmon29k) ebmon29k)
basic_machine=a29k-amd basic_machine=a29k-amd
os=-ebmon os=-ebmon
@ -653,7 +756,6 @@ case $basic_machine in
i370-ibm* | ibm*) i370-ibm* | ibm*)
basic_machine=i370-ibm basic_machine=i370-ibm
;; ;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32) i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32 os=-sysv32
@ -692,6 +794,9 @@ case $basic_machine in
basic_machine=m68k-isi basic_machine=m68k-isi
os=-sysv os=-sysv
;; ;;
leon-*|leon[3-9]-*)
basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
;;
m68knommu) m68knommu)
basic_machine=m68k-unknown basic_machine=m68k-unknown
os=-linux os=-linux
@ -711,8 +816,15 @@ case $basic_machine in
basic_machine=ns32k-utek basic_machine=ns32k-utek
os=-sysv os=-sysv
;; ;;
microblaze*)
basic_machine=microblaze-xilinx
;;
mingw64)
basic_machine=x86_64-pc
os=-mingw64
;;
mingw32) mingw32)
basic_machine=i386-pc basic_machine=i686-pc
os=-mingw32 os=-mingw32
;; ;;
mingw32ce) mingw32ce)
@ -740,6 +852,10 @@ case $basic_machine in
basic_machine=powerpc-unknown basic_machine=powerpc-unknown
os=-morphos os=-morphos
;; ;;
moxiebox)
basic_machine=moxie-unknown
os=-moxiebox
;;
msdos) msdos)
basic_machine=i386-pc basic_machine=i386-pc
os=-msdos os=-msdos
@ -747,10 +863,18 @@ case $basic_machine in
ms1-*) ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;; ;;
msys)
basic_machine=i686-pc
os=-msys
;;
mvs) mvs)
basic_machine=i370-ibm basic_machine=i370-ibm
os=-mvs os=-mvs
;; ;;
nacl)
basic_machine=le32-unknown
os=-nacl
;;
ncr3000) ncr3000)
basic_machine=i486-ncr basic_machine=i486-ncr
os=-sysv4 os=-sysv4
@ -815,6 +939,12 @@ case $basic_machine in
np1) np1)
basic_machine=np1-gould basic_machine=np1-gould
;; ;;
neo-tandem)
basic_machine=neo-tandem
;;
nse-tandem)
basic_machine=nse-tandem
;;
nsr-tandem) nsr-tandem)
basic_machine=nsr-tandem basic_machine=nsr-tandem
;; ;;
@ -897,11 +1027,12 @@ case $basic_machine in
;; ;;
power) basic_machine=power-ibm power) basic_machine=power-ibm
;; ;;
ppc) basic_machine=powerpc-unknown ppc | ppcbe) basic_machine=powerpc-unknown
;; ;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;; ;;
ppcle | powerpclittle | ppc-le | powerpc-little) ppcle | powerpclittle)
basic_machine=powerpcle-unknown basic_machine=powerpcle-unknown
;; ;;
ppcle-* | powerpclittle-*) ppcle-* | powerpclittle-*)
@ -911,7 +1042,7 @@ case $basic_machine in
;; ;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;; ;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little) ppc64le | powerpc64little)
basic_machine=powerpc64le-unknown basic_machine=powerpc64le-unknown
;; ;;
ppc64le-* | powerpc64little-*) ppc64le-* | powerpc64little-*)
@ -924,7 +1055,11 @@ case $basic_machine in
basic_machine=i586-unknown basic_machine=i586-unknown
os=-pw32 os=-pw32
;; ;;
rdos) rdos | rdos64)
basic_machine=x86_64-pc
os=-rdos
;;
rdos32)
basic_machine=i386-pc basic_machine=i386-pc
os=-rdos os=-rdos
;; ;;
@ -993,6 +1128,9 @@ case $basic_machine in
basic_machine=i860-stratus basic_machine=i860-stratus
os=-sysv4 os=-sysv4
;; ;;
strongarm-* | thumb-*)
basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
sun2) sun2)
basic_machine=m68000-sun basic_machine=m68000-sun
;; ;;
@ -1049,20 +1187,8 @@ case $basic_machine in
basic_machine=t90-cray basic_machine=t90-cray
os=-unicos os=-unicos
;; ;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
tile*) tile*)
basic_machine=tile-unknown basic_machine=$basic_machine-unknown
os=-linux-gnu os=-linux-gnu
;; ;;
tx39) tx39)
@ -1132,6 +1258,9 @@ case $basic_machine in
xps | xps100) xps | xps100)
basic_machine=xps100-honeywell basic_machine=xps100-honeywell
;; ;;
xscale-* | xscalee[bl]-*)
basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
;;
ymp) ymp)
basic_machine=ymp-cray basic_machine=ymp-cray
os=-unicos os=-unicos
@ -1182,7 +1311,7 @@ case $basic_machine in
we32k) we32k)
basic_machine=we32k-att basic_machine=we32k-att
;; ;;
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown basic_machine=sh-unknown
;; ;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
@ -1232,6 +1361,9 @@ case $os in
# First match some system type aliases # First match some system type aliases
# that might get confused with valid system types. # that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception. # -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
;;
-solaris1 | -solaris1.*) -solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'` os=`echo $os | sed -e 's|solaris1|sunos4|'`
;; ;;
@ -1252,29 +1384,32 @@ case $os in
# Each alternative MUST END IN A *, to match a version number. # Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4. # -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \ | -aos* | -aros* | -cloudabi* | -sortix* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -uxpv* | -beos* | -mpeix* | -udk* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*) | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
| -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*)
# Remember, each alternative MUST END IN *, to match a version number. # Remember, each alternative MUST END IN *, to match a version number.
;; ;;
-qnx*) -qnx*)
@ -1398,15 +1533,16 @@ case $os in
-aros*) -aros*)
os=-aros os=-aros
;; ;;
-kaos*)
os=-kaos
;;
-zvmoe) -zvmoe)
os=-zvmoe os=-zvmoe
;; ;;
-dicos*) -dicos*)
os=-dicos os=-dicos
;; ;;
-nacl*)
;;
-ios)
;;
-none) -none)
;; ;;
*) *)
@ -1447,6 +1583,21 @@ case $basic_machine in
c4x-* | tic4x-*) c4x-* | tic4x-*)
os=-coff os=-coff
;; ;;
c8051-*)
os=-elf
;;
hexagon-*)
os=-elf
;;
tic54x-*)
os=-coff
;;
tic55x-*)
os=-coff
;;
tic6x-*)
os=-coff
;;
# This must come before the *-dec entry. # This must come before the *-dec entry.
pdp10-*) pdp10-*)
os=-tops20 os=-tops20
@ -1465,9 +1616,6 @@ case $basic_machine in
;; ;;
m68000-sun) m68000-sun)
os=-sunos3 os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;; ;;
m68*-cisco) m68*-cisco)
os=-aout os=-aout
@ -1490,6 +1638,9 @@ case $basic_machine in
sparc-* | *-sun) sparc-* | *-sun)
os=-sunos4.1.1 os=-sunos4.1.1
;; ;;
pru-*)
os=-elf
;;
*-be) *-be)
os=-beos os=-beos
;; ;;
@ -1604,7 +1755,7 @@ case $basic_machine in
-sunos*) -sunos*)
vendor=sun vendor=sun
;; ;;
-aix*) -cnk*|-aix*)
vendor=ibm vendor=ibm
;; ;;
-beos*) -beos*)

View File

@ -57,7 +57,7 @@
#if defined(__NetBSD__) #if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved."); __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: keyring.c,v 1.50 2011/06/25 00:37:44 agc Exp $"); __RCSID("$NetBSD: keyring.c,v 1.55 2017/03/27 21:19:12 khorben Exp $");
#endif #endif
#ifdef HAVE_FCNTL_H #ifdef HAVE_FCNTL_H
@ -214,7 +214,7 @@ pgp_get_writable_seckey(pgp_key_t *data)
/* utility function to zero out memory */ /* utility function to zero out memory */
void void
pgp_forget(void *vp, unsigned size) pgp_forget(void *vp, size_t size)
{ {
(void) memset(vp, 0x0, size); (void) memset(vp, 0x0, size);
} }
@ -244,9 +244,11 @@ decrypt_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
break; break;
case PGP_GET_PASSPHRASE: case PGP_GET_PASSPHRASE:
(void) pgp_getpassphrase(decrypt->passfp, pass, sizeof(pass)); if (pgp_getpassphrase(decrypt->passfp, pass, sizeof(pass)) == 0) {
pass[0] = '\0';
}
*content->skey_passphrase.passphrase = netpgp_strdup(pass); *content->skey_passphrase.passphrase = netpgp_strdup(pass);
pgp_forget(pass, (unsigned)sizeof(pass)); pgp_forget(pass, sizeof(pass));
return PGP_KEEP_MEMORY; return PGP_KEEP_MEMORY;
case PGP_PARSER_ERRCODE: case PGP_PARSER_ERRCODE:
@ -292,6 +294,20 @@ decrypt_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
return PGP_RELEASE_MEMORY; return PGP_RELEASE_MEMORY;
} }
static pgp_cb_ret_t
decrypt_cb_empty(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
{
const pgp_contents_t *content = &pkt->u;
switch (pkt->tag) {
case PGP_GET_PASSPHRASE:
*content->skey_passphrase.passphrase = netpgp_strdup("");
return PGP_KEEP_MEMORY;
default:
return decrypt_cb(pkt, cbinfo);
}
}
/** /**
\ingroup Core_Keys \ingroup Core_Keys
\brief Decrypts secret key from given keydata with given passphrase \brief Decrypts secret key from given keydata with given passphrase
@ -300,14 +316,24 @@ decrypt_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
\return secret key \return secret key
*/ */
pgp_seckey_t * pgp_seckey_t *
pgp_decrypt_seckey(const pgp_key_t *key, void *passfp) pgp_decrypt_seckey(const pgp_key_t *key, FILE *passfp)
{ {
pgp_stream_t *stream; pgp_stream_t *stream;
const int printerrors = 1; const int printerrors = 1;
decrypt_t decrypt; decrypt_t decrypt;
/* XXX first try with an empty passphrase */
(void) memset(&decrypt, 0x0, sizeof(decrypt)); (void) memset(&decrypt, 0x0, sizeof(decrypt));
decrypt.key = key; decrypt.key = key;
stream = pgp_new(sizeof(*stream));
pgp_keydata_reader_set(stream, key);
pgp_set_callback(stream, decrypt_cb_empty, &decrypt);
stream->readinfo.accumulate = 1;
pgp_parse(stream, !printerrors);
if (decrypt.seckey != NULL) {
return decrypt.seckey;
}
/* ask for a passphrase */
decrypt.passfp = passfp; decrypt.passfp = passfp;
stream = pgp_new(sizeof(*stream)); stream = pgp_new(sizeof(*stream));
pgp_keydata_reader_set(stream, key); pgp_keydata_reader_set(stream, key);
@ -993,9 +1019,12 @@ pgp_keyring_list(pgp_io_t *io, const pgp_keyring_t *keyring, const int psigs)
{ {
pgp_key_t *key; pgp_key_t *key;
unsigned n; unsigned n;
unsigned keyc = (keyring != NULL) ? keyring->keyc : 0;
(void) fprintf(io->res, "%u key%s\n", keyring->keyc, (void) fprintf(io->res, "%u key%s\n", keyc, (keyc == 1) ? "" : "s");
(keyring->keyc == 1) ? "" : "s"); if (keyring == NULL) {
return 1;
}
for (n = 0, key = keyring->keys; n < keyring->keyc; ++n, ++key) { for (n = 0, key = keyring->keys; n < keyring->keyc; ++n, ++key) {
if (pgp_is_key_secret(key)) { if (pgp_is_key_secret(key)) {
pgp_print_keydata(io, keyring, key, "sec", pgp_print_keydata(io, keyring, key, "sec",

View File

@ -53,6 +53,7 @@
#ifndef KEYRING_H_ #ifndef KEYRING_H_
#define KEYRING_H_ #define KEYRING_H_
#include <stdio.h>
#include "packet.h" #include "packet.h"
#include "packet-parse.h" #include "packet-parse.h"
#include "mj.h" #include "mj.h"
@ -91,7 +92,7 @@ const pgp_pubkey_t *pgp_get_pubkey(const pgp_key_t *);
unsigned pgp_is_key_secret(const pgp_key_t *); unsigned pgp_is_key_secret(const pgp_key_t *);
const pgp_seckey_t *pgp_get_seckey(const pgp_key_t *); const pgp_seckey_t *pgp_get_seckey(const pgp_key_t *);
pgp_seckey_t *pgp_get_writable_seckey(pgp_key_t *); pgp_seckey_t *pgp_get_writable_seckey(pgp_key_t *);
pgp_seckey_t *pgp_decrypt_seckey(const pgp_key_t *, void *); pgp_seckey_t *pgp_decrypt_seckey(const pgp_key_t *, FILE *);
unsigned pgp_keyring_fileread(pgp_keyring_t *, const unsigned, unsigned pgp_keyring_fileread(pgp_keyring_t *, const unsigned,
const char *); const char *);
@ -100,7 +101,7 @@ int pgp_keyring_list(pgp_io_t *, const pgp_keyring_t *, const int);
int pgp_keyring_json(pgp_io_t *, const pgp_keyring_t *, mj_t *, const int); int pgp_keyring_json(pgp_io_t *, const pgp_keyring_t *, mj_t *, const int);
void pgp_set_seckey(pgp_contents_t *, const pgp_key_t *); void pgp_set_seckey(pgp_contents_t *, const pgp_key_t *);
void pgp_forget(void *, unsigned); void pgp_forget(void *, size_t);
const uint8_t *pgp_get_key_id(const pgp_key_t *); const uint8_t *pgp_get_key_id(const pgp_key_t *);
unsigned pgp_get_userid_count(const pgp_key_t *); unsigned pgp_get_userid_count(const pgp_key_t *);

View File

@ -1,4 +1,4 @@
.\" $NetBSD: libnetpgp.3,v 1.16 2014/02/17 07:23:18 agc Exp $ .\" $NetBSD: libnetpgp.3,v 1.16.18.1 2018/05/06 09:47:47 martin Exp $
.\" .\"
.\" Copyright (c) 2009,2010 The NetBSD Foundation, Inc. .\" Copyright (c) 2009,2010 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE. .\" POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd February 16, 2014 .Dd April 29, 2018
.Dt LIBNETPGP 3 .Dt LIBNETPGP 3
.Os .Os
.Sh NAME .Sh NAME
@ -79,6 +79,10 @@ The following functions are for variable management:
.Fo netpgp_incvar .Fo netpgp_incvar
.Fa "netpgp_t *netpgp" "const char *name" "const int delta" .Fa "netpgp_t *netpgp" "const char *name" "const int delta"
.Fc .Fc
.Ft int
.Fo netpgp_unsetvar
.Fa "netpgp_t *netpgp" "const char *name"
.Fc
.Pp .Pp
The following function sets the home directory: The following function sets the home directory:
.Ft int .Ft int
@ -92,8 +96,20 @@ The following functions are used for key management:
.Fa "netpgp_t *netpgp" "const int printsigs" .Fa "netpgp_t *netpgp" "const int printsigs"
.Fc .Fc
.Ft int .Ft int
.Fo netpgp_match_list_keys .Fo netpgp_list_keys_json
.Fa "netpgp_t *netpgp" "char *pattern" .Fa "netpgp_t *netpgp" "char **json" "const int psigs"
.Fc
.Ft int
.Fo netpgp_match_keys
.Fa "netpgp_t *netpgp" "char *name" "const char *fmt" "void *vp" "const int psigs"
.Fc
.Ft int
.Fo netpgp_match_keys_json
.Fa "netpgp_t *netpgp" "char **json" "char *name" "const char *fmt" "const int psigs"
.Fc
.Ft int
.Fo netpgp_match_pubkeys
.Fa "netpgp_t *netpgp" "char *name" "void *vp"
.Fc .Fc
.Ft int .Ft int
.Fo netpgp_find_key .Fo netpgp_find_key
@ -101,7 +117,7 @@ The following functions are used for key management:
.Fc .Fc
.Ft char * .Ft char *
.Fo netpgp_get_key .Fo netpgp_get_key
.Fa "netpgp_t *netpgp" "const char *id" .Fa "netpgp_t *netpgp" "const char *name" "const char *fmt"
.Fc .Fc
.Ft int .Ft int
.Fo netpgp_export_key .Fo netpgp_export_key
@ -115,31 +131,39 @@ The following functions are used for key management:
.Fo netpgp_generate_key .Fo netpgp_generate_key
.Fa "netpgp_t *netpgp" "char *userid" "int numbits" .Fa "netpgp_t *netpgp" "char *userid" "int numbits"
.Fc .Fc
.Ft int
.Fo netpgp_validate_sigs
.Fa "netpgp_t *netpgp"
.Fc
.Ft int
.Fo netpgp_format_json
.Fa "void *vp" "const char *json" "const int psigs"
.Fc
.Pp .Pp
The following functions are used for file management: The following functions are used for file management:
.Ft int .Ft int
.Fo netpgp_encrypt_file .Fo netpgp_encrypt_file
.Fa "netpgp_t *netpgp" "char *userid" "char *filename" "char *out" .Fa "netpgp_t *netpgp" "const char *userid" "const char *filename" "char *out"
.Fa "int armored" .Fa "int armored"
.Fc .Fc
.Ft int .Ft int
.Fo netpgp_decrypt_file .Fo netpgp_decrypt_file
.Fa "netpgp_t *netpgp" "char *filename" "char *out" "int armored" .Fa "netpgp_t *netpgp" "const char *filename" "char *out" "int armored"
.Fc .Fc
.Ft int .Ft int
.Fo netpgp_sign_file .Fo netpgp_sign_file
.Fa "netpgp_t *netpgp" "char *userid" "char *filename" "char *out" .Fa "netpgp_t *netpgp" "const char *userid" "const char *filename" "char *out"
.Fa "int armored" "int cleartext" "int detached" .Fa "int armored" "int cleartext" "int detached"
.Fc .Fc
.Ft int .Ft int
.Fo netpgp_verify_file .Fo netpgp_verify_file
.Fa "netpgp_t *netpgp" "char *f" "int armored" .Fa "netpgp_t *netpgp" "const char *in" "const char *out" "int armored"
.Fc .Fc
.Pp .Pp
The following functions are used for memory signing and encryption: The following functions are used for memory signing and encryption:
.Ft int .Ft int
.Fo netpgp_encrypt_memory .Fo netpgp_encrypt_memory
.Fa "netpgp_t *netpgp" "char *userid" "void *in" "const size_t insize" .Fa "netpgp_t *netpgp" "const char *userid" "void *in" "const size_t insize"
.Fa "char *out" "size_t outsize" "int armored" .Fa "char *out" "size_t outsize" "int armored"
.Fc .Fc
.Ft int .Ft int
@ -172,12 +196,13 @@ Normal operation sees the
.Nm .Nm
process be initialised using the process be initialised using the
.Fn netpgp_init .Fn netpgp_init
function, which will set up the public and private keyrings, and set the function, which will set up the public and private keyrings, as well as set the
user identity to the user identity in the
.Ar userid .Ar userid
argument passed stored in the member of the
.Dv netpgp_t .Dv netpgp_t
structure, and set using the structure.
These are set using the
.Fn netpgp_setvar .Fn netpgp_setvar
function. function.
If no public key ring file is set, initial values will be taken from those If no public key ring file is set, initial values will be taken from those
@ -189,6 +214,13 @@ initial values will be taken from those
in the in the
.Pa .gnupg/secring.gpg .Pa .gnupg/secring.gpg
file in the user's home directory. file in the user's home directory.
The user identity is obtained from the
.Ev userid
environment variable, or failing that, the value of the
.Dq default-key
setting from
.Pa .gnupg/gpg.conf
file in the user's home directory is used.
The The
.Fn netpgp_init .Fn netpgp_init
function returns 1 on success, 0 on failure. function returns 1 on success, 0 on failure.
@ -198,13 +230,6 @@ To list all the keys in a keyring, the
function is used. function is used.
The signature subkey fields can also be displayed The signature subkey fields can also be displayed
using this function. using this function.
The
.Fn netpgp_match_list_keys
function is used to match (via regular expression)
a subset of the keys in the keyring.
If the expression to match is NULL,
the search will degenerate into a
listing of all keys in the keyring.
.Pp .Pp
The home directory is specified as an internal variable, The home directory is specified as an internal variable,
and its existence is checked using the and its existence is checked using the
@ -223,13 +248,13 @@ Output is sent to the standard output.
.Pp .Pp
To import a key onto the public keyring, the To import a key onto the public keyring, the
.Fn netpgp_import_key .Fn netpgp_import_key
is used. function is used.
The name of the file containing the key to be imported is provided The name of the file containing the key to be imported is provided
as the filename argument. as the filename argument.
.Pp .Pp
To generate a key, the To generate a key, the
.Fn netpgp_generate_key .Fn netpgp_generate_key
is used. function is used.
It takes an argument of the number of bits to use in the key. It takes an argument of the number of bits to use in the key.
At the time that this manual page was created (April 2009), At the time that this manual page was created (April 2009),
the recommendations are that the bare minimum key size the recommendations are that the bare minimum key size

View File

@ -34,7 +34,7 @@
#if defined(__NetBSD__) #if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved."); __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: netpgp.c,v 1.96 2012/02/22 06:58:54 agc Exp $"); __RCSID("$NetBSD: netpgp.c,v 1.101 2017/03/27 20:55:13 khorben Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -1186,6 +1186,7 @@ netpgp_generate_key(netpgp_t *netpgp, char *id, int numbits)
int passc; int passc;
int fd; int fd;
int cc; int cc;
int rv = 0;
uid = NULL; uid = NULL;
io = netpgp->io; io = netpgp->io;
@ -1212,13 +1213,13 @@ netpgp_generate_key(netpgp_t *netpgp, char *id, int numbits)
netpgp_setvar(netpgp, "generated userid", &dir[cc - 16]); netpgp_setvar(netpgp, "generated userid", &dir[cc - 16]);
if (mkdir(dir, 0700) < 0) { if (mkdir(dir, 0700) < 0) {
(void) fprintf(io->errs, "can't mkdir '%s'\n", dir); (void) fprintf(io->errs, "can't mkdir '%s'\n", dir);
return 0; goto out;
} }
(void) fprintf(io->errs, "netpgp: generated keys in directory %s\n", dir); (void) fprintf(io->errs, "netpgp: generated keys in directory %s\n", dir);
(void) snprintf(ringfile = filename, sizeof(filename), "%s/pubring.gpg", dir); (void) snprintf(ringfile = filename, sizeof(filename), "%s/pubring.gpg", dir);
if (!appendkey(io, key, ringfile)) { if (!appendkey(io, key, ringfile)) {
(void) fprintf(io->errs, "Cannot write pubkey to '%s'\n", ringfile); (void) fprintf(io->errs, "Cannot write pubkey to '%s'\n", ringfile);
return 0; goto out;
} }
if (netpgp->pubring != NULL) { if (netpgp->pubring != NULL) {
pgp_keyring_free(netpgp->pubring); pgp_keyring_free(netpgp->pubring);
@ -1230,7 +1231,7 @@ netpgp_generate_key(netpgp_t *netpgp, char *id, int numbits)
} }
if (fd < 0) { if (fd < 0) {
(void) fprintf(io->errs, "can't append secring '%s'\n", ringfile); (void) fprintf(io->errs, "can't append secring '%s'\n", ringfile);
return 0; goto out;
} }
/* get the passphrase */ /* get the passphrase */
if ((numtries = netpgp_getvar(netpgp, "numtries")) == NULL || if ((numtries = netpgp_getvar(netpgp, "numtries")) == NULL ||
@ -1242,15 +1243,18 @@ netpgp_generate_key(netpgp_t *netpgp, char *id, int numbits)
passc = find_passphrase(netpgp->passfp, &cp[ID_OFFSET], passphrase, sizeof(passphrase), attempts); passc = find_passphrase(netpgp->passfp, &cp[ID_OFFSET], passphrase, sizeof(passphrase), attempts);
if (!pgp_write_xfer_seckey(create, key, (uint8_t *)passphrase, (const unsigned)passc, noarmor)) { if (!pgp_write_xfer_seckey(create, key, (uint8_t *)passphrase, (const unsigned)passc, noarmor)) {
(void) fprintf(io->errs, "Cannot write seckey\n"); (void) fprintf(io->errs, "Cannot write seckey\n");
return 0; goto out1;
} }
rv = 1;
out1:
pgp_teardown_file_write(create, fd); pgp_teardown_file_write(create, fd);
if (netpgp->secring != NULL) { if (netpgp->secring != NULL) {
pgp_keyring_free(netpgp->secring); pgp_keyring_free(netpgp->secring);
} }
out:
pgp_keydata_free(key); pgp_keydata_free(key);
free(cp); free(cp);
return 1; return rv;
} }
/* encrypt a file */ /* encrypt a file */
@ -1407,7 +1411,7 @@ netpgp_sign_file(netpgp_t *netpgp,
(unsigned)armored, (unsigned)cleartext, (unsigned)armored, (unsigned)cleartext,
overwrite); overwrite);
} }
pgp_forget(seckey, (unsigned)sizeof(*seckey)); pgp_forget(seckey, sizeof(*seckey));
return ret; return ret;
} }
@ -1501,11 +1505,18 @@ netpgp_sign_memory(netpgp_t *netpgp,
&pubkey->key.pubkey, 0); &pubkey->key.pubkey, 0);
} }
} }
if (netpgp_getvar(netpgp, "ssh keys") == NULL) {
/* now decrypt key */ /* now decrypt key */
seckey = pgp_decrypt_seckey(keypair, netpgp->passfp); seckey = pgp_decrypt_seckey(keypair, netpgp->passfp);
if (seckey == NULL) { if (seckey == NULL) {
(void) fprintf(io->errs, "Bad passphrase\n"); (void) fprintf(io->errs, "Bad passphrase\n");
} }
} else {
pgp_keyring_t *secring;
secring = netpgp->secring;
seckey = &secring->keys[0].key.seckey;
}
} }
if (seckey == NULL) { if (seckey == NULL) {
(void) fprintf(io->errs, "Bad passphrase\n"); (void) fprintf(io->errs, "Bad passphrase\n");
@ -1531,7 +1542,7 @@ netpgp_sign_memory(netpgp_t *netpgp,
} else { } else {
ret = 0; ret = 0;
} }
pgp_forget(seckey, (unsigned)sizeof(*seckey)); pgp_forget(seckey, sizeof(*seckey));
return ret; return ret;
} }

View File

@ -54,7 +54,7 @@
#if defined(__NetBSD__) #if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved."); __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: reader.c,v 1.49 2012/03/05 02:20:18 christos Exp $"); __RCSID("$NetBSD: reader.c,v 1.52 2017/03/27 20:50:19 khorben Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -160,6 +160,7 @@ int
pgp_getpassphrase(void *in, char *phrase, size_t size) pgp_getpassphrase(void *in, char *phrase, size_t size)
{ {
char *p; char *p;
size_t len;
if (in == NULL) { if (in == NULL) {
while ((p = getpass("netpgp passphrase: ")) == NULL) { while ((p = getpass("netpgp passphrase: ")) == NULL) {
@ -169,7 +170,10 @@ pgp_getpassphrase(void *in, char *phrase, size_t size)
if (fgets(phrase, (int)size, in) == NULL) { if (fgets(phrase, (int)size, in) == NULL) {
return 0; return 0;
} }
phrase[strlen(phrase) - 1] = 0x0; len = strlen(phrase);
if (len >= 1 && phrase[len - 1] == '\n') {
phrase[len - 1] = '\0';
}
} }
return 1; return 1;
} }

View File

@ -57,7 +57,7 @@
#if defined(__NetBSD__) #if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved."); __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: signature.c,v 1.34 2012/03/05 02:20:18 christos Exp $"); __RCSID("$NetBSD: signature.c,v 1.37 2017/04/09 23:03:50 khorben Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -903,9 +903,13 @@ open_output_file(pgp_output_t **output,
/* setup output file */ /* setup output file */
if (outname) { if (outname) {
fd = pgp_setup_file_write(output, outname, overwrite); if (strcmp(outname, "-") == 0) {
fd = pgp_setup_file_write(output, NULL, overwrite);
} else { } else {
unsigned flen = (unsigned)(strlen(inname) + 4 + 1); fd = pgp_setup_file_write(output, outname, overwrite);
}
} else {
size_t flen = strlen(inname) + 1 + strlen(suffix) + 1;
char *f = NULL; char *f = NULL;
if ((f = calloc(1, flen)) == NULL) { if ((f = calloc(1, flen)) == NULL) {

View File

@ -1,4 +1,4 @@
.\" $NetBSD: libnetpgpbn.3,v 1.4 2014/02/17 07:23:18 agc Exp $ .\" $NetBSD: libnetpgpbn.3,v 1.4.18.1 2018/05/06 09:47:47 martin Exp $
.\" .\"
.\" Copyright (c) 2010 Alistair Crooks <agc@NetBSD.org> .\" Copyright (c) 2010 Alistair Crooks <agc@NetBSD.org>
.\" All rights reserved. .\" All rights reserved.
@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd February 16, 2014 .Dd April 3, 2018
.Dt LIBNETPGPBN 3 .Dt LIBNETPGPBN 3
.Os .Os
.Sh NAME .Sh NAME
@ -257,7 +257,7 @@ in the
buffer called buffer called
.Va buf .Va buf
where where
.Dq USERNAME .Dq USER
is the name of the user taken from the runtime environment. is the name of the user taken from the runtime environment.
The encoded text will be in an allocated buffer called The encoded text will be in an allocated buffer called
.Va s . .Va s .

View File

@ -1,4 +1,4 @@
.\" $NetBSD: libmj.3,v 1.7 2014/02/17 07:23:18 agc Exp $ .\" $NetBSD: libmj.3,v 1.7.18.1 2018/05/06 09:47:47 martin Exp $
.\" .\"
.\" Copyright (c) 2010 Alistair Crooks <agc@NetBSD.org> .\" Copyright (c) 2010 Alistair Crooks <agc@NetBSD.org>
.\" All rights reserved. .\" All rights reserved.
@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd February 16, 2014 .Dd April 3, 2018
.Dt LIBMJ 3 .Dt LIBMJ 3
.Os .Os
.Sh NAME .Sh NAME
@ -227,10 +227,10 @@ in the
buffer called buffer called
.Va buf .Va buf
where where
.Dq USERNAME .Dq USER
is the name of the user taken from the runtime environment. is the name of the user taken from the runtime environment.
The encoded text will be in an allocated buffer called The encoded text will be in an allocated buffer called
.Va s .Va s .
.Bd -literal -offset indent .Bd -literal -offset indent
mj_t atom; mj_t atom;
char buf[BUFSIZ]; char buf[BUFSIZ];

View File

@ -1,4 +1,4 @@
.\" $NetBSD: netpgp.1,v 1.19 2014/02/17 07:23:18 agc Exp $ .\" $NetBSD: netpgp.1,v 1.21 2017/03/27 21:34:32 khorben Exp $
.\" .\"
.\" Copyright (c) 2009 The NetBSD Foundation, Inc. .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
@ -203,7 +203,7 @@ library.
In addition to one of the preceding commands, a number of qualifiers In addition to one of the preceding commands, a number of qualifiers
or options may be given. or options may be given.
.Bl -tag -width Ar .Bl -tag -width Ar
.It Fl Fl armour , Fl armor .It Fl Fl armour , Fl Fl armor
This option, however it is spelled, wraps the signature as an This option, however it is spelled, wraps the signature as an
ASCII-encoded piece of text, for ease of use. ASCII-encoded piece of text, for ease of use.
.It Fl Fl cipher Ar ciphername .It Fl Fl cipher Ar ciphername
@ -216,7 +216,7 @@ access to the cipher used.
The default cipher algorithm is the The default cipher algorithm is the
.Dq CAST5 .Dq CAST5
algorithm. algorithm.
.It Fl Fl detached .It Fl Fl detach , Fl Fl detached
When signing a file, place the resulting signature in a separate When signing a file, place the resulting signature in a separate
file from the one being signed. file from the one being signed.
.It Fl Fl hash-alg Ar hash-algorithm .It Fl Fl hash-alg Ar hash-algorithm

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.8 2015/04/15 19:13:46 mrg Exp $ # $NetBSD: Makefile,v 1.9 2017/04/17 19:50:28 agc Exp $
LIB=netpgpverify LIB=netpgpverify
SRCS+=b64.c SRCS+=b64.c
@ -15,18 +15,9 @@ SRCS+=sha1.c
SRCS+=sha2.c SRCS+=sha2.c
SRCS+=md5c.c SRCS+=md5c.c
SRCS+=rmd160.c SRCS+=rmd160.c
SRCS+=tiger.c
CPPFLAGS+=-I${.CURDIR} -I${EXTDIST}/src/netpgpverify CPPFLAGS+=-I${.CURDIR} -I${EXTDIST}/src/netpgpverify
MAN=libnetpgpverify.3 MAN=libnetpgpverify.3
WARNS=5 WARNS=5
#.if defined(__MINIX)
#LSC: While Compiling with -O3:
#<..>/lib/verify/../../dist/src/netpgpverify/bignum.c:802:5: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow]
# if (olduse > ix) {
# ^
# cc1: all warnings being treated as errors
CWARNFLAGS+= -Wno-strict-overflow
#.endif # defined(__MINIX)
EXTDIST=${.CURDIR}/../../dist EXTDIST=${.CURDIR}/../../dist
.PATH: ${EXTDIST}/src/netpgpverify .PATH: ${EXTDIST}/src/netpgpverify

View File

@ -1,2 +1,2 @@
major=4 major=5
minor=0 minor=0