mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
fixed libtools portability bug, fixed arc4random() portability,
fixed htobe32 and be32toh portability, fixed error handling in main(), fixed invalid type parameter for randomart image in pcppubkey_printshortinfo(), fixed configure search for libsodium.
This commit is contained in:
90
configure.ac
90
configure.ac
@@ -6,7 +6,7 @@ AC_CONFIG_MACRO_DIR(config)
|
|||||||
|
|
||||||
AC_CONFIG_HEADER(libpcp/config.h)
|
AC_CONFIG_HEADER(libpcp/config.h)
|
||||||
AM_INIT_AUTOMAKE
|
AM_INIT_AUTOMAKE
|
||||||
|
LT_INIT
|
||||||
|
|
||||||
ORIG_CFLAGS="${CFLAGS:-none}"
|
ORIG_CFLAGS="${CFLAGS:-none}"
|
||||||
|
|
||||||
@@ -18,26 +18,6 @@ AC_PROG_SED
|
|||||||
AC_PROG_AWK
|
AC_PROG_AWK
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
|
|
||||||
# Allow user to specify flags
|
|
||||||
AC_ARG_WITH([cflags],
|
|
||||||
[ --with-cflags Specify additional flags to pass to compiler],
|
|
||||||
[
|
|
||||||
if test -n "$withval" && test "x$withval" != "xno" && \
|
|
||||||
test "x${withval}" != "xyes"; then
|
|
||||||
CFLAGS="$CFLAGS $withval"
|
|
||||||
fi
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
AC_ARG_WITH([ldflags],
|
|
||||||
[ --with-ldflags Specify additional flags to pass to linker],
|
|
||||||
[
|
|
||||||
if test -n "$withval" && test "x$withval" != "xno" && \
|
|
||||||
test "x${withval}" != "xyes"; then
|
|
||||||
LDFLAGS="$LDFLAGS $withval"
|
|
||||||
fi
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -47,13 +27,14 @@ AC_CANONICAL_HOST
|
|||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS(errno.h err.h stdlib.h string.h unistd.h stdio.h getopt.h\
|
AC_CHECK_HEADERS(errno.h err.h stdlib.h string.h unistd.h stdio.h getopt.h\
|
||||||
limits.h stddef.h stdint.h sys/types.h sys/stat.h termios.h)
|
limits.h stddef.h stdint.h sys/types.h sys/stat.h endian.h sys/endian.h termios.h)
|
||||||
|
|
||||||
AC_TYPE_SIZE_T
|
AC_TYPE_SIZE_T
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_CHECK_FUNCS( \
|
AC_CHECK_FUNCS( \
|
||||||
arc4random_buf \
|
arc4random_buf \
|
||||||
|
bzero \
|
||||||
fread \
|
fread \
|
||||||
fopen \
|
fopen \
|
||||||
free \
|
free \
|
||||||
@@ -71,6 +52,8 @@ AC_CHECK_FUNCS( \
|
|||||||
strtol \
|
strtol \
|
||||||
sizeof \
|
sizeof \
|
||||||
tcgetattr \
|
tcgetattr \
|
||||||
|
be32toh \
|
||||||
|
htobe32 \
|
||||||
umask
|
umask
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -84,6 +67,65 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
|
|||||||
[ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
|
[ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_havenacl=no
|
||||||
|
_ldlib=""
|
||||||
|
|
||||||
|
AC_ARG_WITH([libsodium],
|
||||||
|
[AS_HELP_STRING([--with-libsodium],
|
||||||
|
[Specify libsodium prefix])],
|
||||||
|
[search_libsodium="yes"],
|
||||||
|
[])
|
||||||
|
|
||||||
|
if test "x$search_libsodium" = "xyes"; then
|
||||||
|
if test -r "${with_libsodium}/include/sodium.h"; then
|
||||||
|
CFLAGS="-I${with_libsodium}/include ${CFLAGS}"
|
||||||
|
LDFLAGS="-L${with_libsodium}/lib ${LDFLAGS}"
|
||||||
|
_havenacl=yes
|
||||||
|
_ldlib="${with_libsodium}/lib"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_WITH([libsodium-include-dir],
|
||||||
|
[AS_HELP_STRING([--with-libsodium-include-dir],
|
||||||
|
[Specify libsodium include prefix])],
|
||||||
|
[search_libsodium_include="yes"],
|
||||||
|
[])
|
||||||
|
|
||||||
|
if test "x$search_libsodium_include" = "xyes"; then
|
||||||
|
if test -r "${with_libsodium_include_dir}/sodium.h"; then
|
||||||
|
CFLAGS="-I${with_libsodium_include_dir}/include ${CFLAGS}"
|
||||||
|
_havenacl=yes
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_WITH([libsodium_lib_dir],
|
||||||
|
[AS_HELP_STRING([--with-libsodium-lib-dir],
|
||||||
|
[Specify libsodium library prefix])],
|
||||||
|
[search_libsodium_lib="yes"],
|
||||||
|
[])
|
||||||
|
|
||||||
|
if test "x$search_libsodium_lib" = "xyes"; then
|
||||||
|
if test -r "${with_libsodium_lib_dir}/libsodium.{a|so|dylib}"; then
|
||||||
|
LDFLAGS="-L${with_libsodium}/lib ${LDFLAGS}"
|
||||||
|
_havenacl=yes
|
||||||
|
_ldlib="${with_libsodium}/lib"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "x${_havenacl}" = "xno"; then
|
||||||
|
AC_MSG_CHECKING([pkg-config for libsodium])
|
||||||
|
if pkg-config --exists libsodium; then
|
||||||
|
# found it
|
||||||
|
LDFLAGS=`pkg-config --libs libsodium`
|
||||||
|
CFLAGS=`pkg-config --cflags libsodium`
|
||||||
|
_ldlib=`pkg-config --libs libsodium | cut -d ' ' -f 1 | cut -d L -f 2`
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check for some target-specific stuff
|
# Check for some target-specific stuff
|
||||||
case "$host" in
|
case "$host" in
|
||||||
@@ -127,6 +169,10 @@ esac
|
|||||||
|
|
||||||
AC_CHECK_LIB(sodium, sodium_init, , [AC_MSG_ERROR([cannot link with -lsodium, install libsodium.])])
|
AC_CHECK_LIB(sodium, sodium_init, , [AC_MSG_ERROR([cannot link with -lsodium, install libsodium.])])
|
||||||
|
|
||||||
|
if test -n "$_ldlib"; then
|
||||||
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${_ldlib}"
|
||||||
|
AC_MSG_RESULT([LD_LIBRARY_PATH: $LD_LIBRARY_PATH])
|
||||||
|
fi
|
||||||
AC_MSG_CHECKING([is libsodium compiled correctly])
|
AC_MSG_CHECKING([is libsodium compiled correctly])
|
||||||
AC_RUN_IFELSE([
|
AC_RUN_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <endian.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h> /* uint32_t */
|
#include <inttypes.h> /* uint32_t */
|
||||||
@@ -19,7 +20,6 @@ extern "C" {
|
|||||||
#include <string.h> /* memcmp,strlen */
|
#include <string.h> /* memcmp,strlen */
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/endian.h> // FIXME: put portable thing from scrypt here
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
@@ -340,6 +340,66 @@ void pcp_pad_remove(unsigned char **unpadded, unsigned char *padded,
|
|||||||
#error Need either CONFIG_H_FILE or HAVE_CONFIG_H defined.
|
#error Need either CONFIG_H_FILE or HAVE_CONFIG_H defined.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ENDIAN_H
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_SYS_ENDIAN_H
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_BETOH32
|
||||||
|
// openbsd, use aliases
|
||||||
|
#define be32toh betoh32
|
||||||
|
#define htobe32 hto32be
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
// Copyright (c) 1999 Joseph Samuel Myers. bsd-games
|
||||||
|
#define be32toh(x) ((void)0)
|
||||||
|
#define htobe32(x) ((void)0)
|
||||||
|
#else
|
||||||
|
#define be32toh(x) ((u_int32_t)ntohl((u_int32_t)(x)))
|
||||||
|
#define htobe32(x) ((u_int32_t)htonl((u_int32_t)(x)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // HAVE_BETOH32
|
||||||
|
#endif // HAVE_SYS_ENDIAN_H
|
||||||
|
#endif // HAVE_ENDIAN_H
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HAVE_ARC4RANDOM_BUF
|
||||||
|
// shitty OS. we've got to use other stuff
|
||||||
|
|
||||||
|
|
||||||
|
static inline FILE *__getranddev() {
|
||||||
|
FILE *R;
|
||||||
|
if((R = fopen("/dev/urandom", "rb")) == NULL) {
|
||||||
|
// not even this is here! what a shame
|
||||||
|
if((R = fopen("/dev/random", "rb")) == NULL) {
|
||||||
|
// not available or depleted. that's too bad
|
||||||
|
fprintf(stderr, "ERROR: /dev/urandom not available, /dev/random is depleted.\n");
|
||||||
|
fprintf(stderr, "That's horrible for you but a nightmare for me. I die. Bye.\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u_int32_t arc4random() {
|
||||||
|
uint32_t x;
|
||||||
|
FILE *R = __getranddev();
|
||||||
|
fread(&x, sizeof(uint32_t), 1, R);
|
||||||
|
fclose(R);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void arc4random_buf(void *buf, size_t nbytes) {
|
||||||
|
FILE *R = __getranddev();
|
||||||
|
fread(buf, nbytes, 1, R);
|
||||||
|
fclose(R);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// +++ from libpcp/randomart.h: +++
|
// +++ from libpcp/randomart.h: +++
|
||||||
@@ -462,18 +522,6 @@ vault_item_header_t * ih2native(vault_item_header_t *h);
|
|||||||
int pcp_version();
|
int pcp_version();
|
||||||
|
|
||||||
|
|
||||||
// +++ from libpcp/warn.h: +++
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_ERR_H
|
|
||||||
#else
|
|
||||||
#define NEED_WARN_PROGNAME
|
|
||||||
const char * warn_progname;
|
|
||||||
void warn(const char *, ...);
|
|
||||||
void warnx(const char *, ...);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// +++ from libpcp/z85.h: +++
|
// +++ from libpcp/z85.h: +++
|
||||||
|
|
||||||
// from https://github.com/tlinden/curve-keygen/
|
// from https://github.com/tlinden/curve-keygen/
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ AM_CFLAGS = -I../libpcp -Wall -g
|
|||||||
|
|
||||||
lib_LTLIBRARIES = libpcp1.la
|
lib_LTLIBRARIES = libpcp1.la
|
||||||
|
|
||||||
libpcp1_la_SOURCES = mac.c mem.c pad.c version.c warn.c \
|
libpcp1_la_SOURCES = mac.c mem.c pad.c version.c \
|
||||||
z85.c zmq_z85.c key.c randomart.c \
|
z85.c zmq_z85.c key.c randomart.c \
|
||||||
vault.c fatal.c jenhash.c digital_crc32.c \
|
vault.c fatal.c jenhash.c digital_crc32.c \
|
||||||
crypto.c
|
crypto.c
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ am__uninstall_files_from_dir = { \
|
|||||||
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
|
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
|
||||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||||
libpcp1_la_LIBADD =
|
libpcp1_la_LIBADD =
|
||||||
am_libpcp1_la_OBJECTS = mac.lo mem.lo pad.lo version.lo warn.lo z85.lo \
|
am_libpcp1_la_OBJECTS = mac.lo mem.lo pad.lo version.lo z85.lo \
|
||||||
zmq_z85.lo key.lo randomart.lo vault.lo fatal.lo jenhash.lo \
|
zmq_z85.lo key.lo randomart.lo vault.lo fatal.lo jenhash.lo \
|
||||||
digital_crc32.lo crypto.lo
|
digital_crc32.lo crypto.lo
|
||||||
libpcp1_la_OBJECTS = $(am_libpcp1_la_OBJECTS)
|
libpcp1_la_OBJECTS = $(am_libpcp1_la_OBJECTS)
|
||||||
@@ -240,7 +240,7 @@ top_builddir = @top_builddir@
|
|||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
AM_CFLAGS = -I../libpcp -Wall -g
|
AM_CFLAGS = -I../libpcp -Wall -g
|
||||||
lib_LTLIBRARIES = libpcp1.la
|
lib_LTLIBRARIES = libpcp1.la
|
||||||
libpcp1_la_SOURCES = mac.c mem.c pad.c version.c warn.c \
|
libpcp1_la_SOURCES = mac.c mem.c pad.c version.c \
|
||||||
z85.c zmq_z85.c key.c randomart.c \
|
z85.c zmq_z85.c key.c randomart.c \
|
||||||
vault.c fatal.c jenhash.c digital_crc32.c \
|
vault.c fatal.c jenhash.c digital_crc32.c \
|
||||||
crypto.c
|
crypto.c
|
||||||
@@ -350,7 +350,6 @@ distclean-compile:
|
|||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randomart.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randomart.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vault.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vault.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/warn.Plo@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/z85.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/z85.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zmq_z85.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zmq_z85.Plo@am__quote@
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,18 @@
|
|||||||
/* Define to 1 if you have the `arc4random_buf' function. */
|
/* Define to 1 if you have the `arc4random_buf' function. */
|
||||||
#undef HAVE_ARC4RANDOM_BUF
|
#undef HAVE_ARC4RANDOM_BUF
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `be32toh' function. */
|
||||||
|
#undef HAVE_BE32TOH
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `bzero' function. */
|
||||||
|
#undef HAVE_BZERO
|
||||||
|
|
||||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
#undef HAVE_DLFCN_H
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <endian.h> header file. */
|
||||||
|
#undef HAVE_ENDIAN_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <errno.h> header file. */
|
/* Define to 1 if you have the <errno.h> header file. */
|
||||||
#undef HAVE_ERRNO_H
|
#undef HAVE_ERRNO_H
|
||||||
|
|
||||||
@@ -36,6 +45,9 @@
|
|||||||
/* Define to 1 if you have the <getopt.h> header file. */
|
/* Define to 1 if you have the <getopt.h> header file. */
|
||||||
#undef HAVE_GETOPT_H
|
#undef HAVE_GETOPT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `htobe32' function. */
|
||||||
|
#undef HAVE_HTOBE32
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
@@ -93,6 +105,9 @@
|
|||||||
/* Define to 1 if you have the `strtol' function. */
|
/* Define to 1 if you have the `strtol' function. */
|
||||||
#undef HAVE_STRTOL
|
#undef HAVE_STRTOL
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||||
|
#undef HAVE_SYS_ENDIAN_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
#undef HAVE_SYS_STAT_H
|
#undef HAVE_SYS_STAT_H
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/endian.h> // FIXME: put portable thing from scrypt here
|
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "platform.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
#include "randomart.h"
|
#include "randomart.h"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
// simple malloc() wrapper
|
// simple malloc() wrapper
|
||||||
// behaves like calloc(), which
|
// behaves like calloc(), which
|
||||||
|
|||||||
@@ -9,5 +9,71 @@
|
|||||||
#error Need either CONFIG_H_FILE or HAVE_CONFIG_H defined.
|
#error Need either CONFIG_H_FILE or HAVE_CONFIG_H defined.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ENDIAN_H
|
||||||
|
#include <endian.h>
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_SYS_ENDIAN_H
|
||||||
|
#include <sys/endian.h>
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_BETOH32
|
||||||
|
// openbsd, use aliases
|
||||||
|
#define be32toh betoh32
|
||||||
|
#define htobe32 hto32be
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
// Copyright (c) 1999 Joseph Samuel Myers. bsd-games
|
||||||
|
#define be32toh(x) ((void)0)
|
||||||
|
#define htobe32(x) ((void)0)
|
||||||
|
#else
|
||||||
|
#define be32toh(x) ((u_int32_t)ntohl((u_int32_t)(x)))
|
||||||
|
#define htobe32(x) ((u_int32_t)htonl((u_int32_t)(x)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // HAVE_BETOH32
|
||||||
|
#endif // HAVE_SYS_ENDIAN_H
|
||||||
|
#endif // HAVE_ENDIAN_H
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HAVE_ARC4RANDOM_BUF
|
||||||
|
// shitty OS. we've got to use other stuff
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
static inline FILE *__getranddev() {
|
||||||
|
FILE *R;
|
||||||
|
if((R = fopen("/dev/urandom", "rb")) == NULL) {
|
||||||
|
// not even this is here! what a shame
|
||||||
|
if((R = fopen("/dev/random", "rb")) == NULL) {
|
||||||
|
// not available or depleted. that's too bad
|
||||||
|
fprintf(stderr, "ERROR: /dev/urandom not available, /dev/random is depleted.\n");
|
||||||
|
fprintf(stderr, "That's horrible for you but a nightmare for me. I die. Bye.\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u_int32_t arc4random() {
|
||||||
|
uint32_t x;
|
||||||
|
FILE *R = __getranddev();
|
||||||
|
fread(&x, sizeof(uint32_t), 1, R);
|
||||||
|
fclose(R);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void arc4random_buf(void *buf, size_t nbytes) {
|
||||||
|
FILE *R = __getranddev();
|
||||||
|
fread(buf, nbytes, 1, R);
|
||||||
|
fclose(R);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* !_HAVE_PCP_PLATFORM_H */
|
#endif /* !_HAVE_PCP_PLATFORM_H */
|
||||||
|
|
||||||
|
|||||||
@@ -1,140 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright 2007-2009 Colin Percival
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (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 file was originally written by Colin Percival as part of the Tarsnap
|
|
||||||
* online backup system.
|
|
||||||
*/
|
|
||||||
#ifndef _SYSENDIAN_H_
|
|
||||||
#define _SYSENDIAN_H_
|
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
/* If we don't have be64enc, the <sys/endian.h> we have isn't usable. */
|
|
||||||
#if !HAVE_DECL_BE64ENC
|
|
||||||
#undef HAVE_SYS_ENDIAN_H
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_ENDIAN_H
|
|
||||||
|
|
||||||
#include <sys/endian.h>
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
static inline uint32_t
|
|
||||||
be32dec(const void *pp)
|
|
||||||
{
|
|
||||||
const uint8_t *p = (uint8_t const *)pp;
|
|
||||||
|
|
||||||
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
|
|
||||||
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
be32enc(void *pp, uint32_t x)
|
|
||||||
{
|
|
||||||
uint8_t * p = (uint8_t *)pp;
|
|
||||||
|
|
||||||
p[3] = x & 0xff;
|
|
||||||
p[2] = (x >> 8) & 0xff;
|
|
||||||
p[1] = (x >> 16) & 0xff;
|
|
||||||
p[0] = (x >> 24) & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t
|
|
||||||
be64dec(const void *pp)
|
|
||||||
{
|
|
||||||
const uint8_t *p = (uint8_t const *)pp;
|
|
||||||
|
|
||||||
return ((uint64_t)(p[7]) + ((uint64_t)(p[6]) << 8) +
|
|
||||||
((uint64_t)(p[5]) << 16) + ((uint64_t)(p[4]) << 24) +
|
|
||||||
((uint64_t)(p[3]) << 32) + ((uint64_t)(p[2]) << 40) +
|
|
||||||
((uint64_t)(p[1]) << 48) + ((uint64_t)(p[0]) << 56));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
be64enc(void *pp, uint64_t x)
|
|
||||||
{
|
|
||||||
uint8_t * p = (uint8_t *)pp;
|
|
||||||
|
|
||||||
p[7] = x & 0xff;
|
|
||||||
p[6] = (x >> 8) & 0xff;
|
|
||||||
p[5] = (x >> 16) & 0xff;
|
|
||||||
p[4] = (x >> 24) & 0xff;
|
|
||||||
p[3] = (x >> 32) & 0xff;
|
|
||||||
p[2] = (x >> 40) & 0xff;
|
|
||||||
p[1] = (x >> 48) & 0xff;
|
|
||||||
p[0] = (x >> 56) & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t
|
|
||||||
le32dec(const void *pp)
|
|
||||||
{
|
|
||||||
const uint8_t *p = (uint8_t const *)pp;
|
|
||||||
|
|
||||||
return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
|
|
||||||
((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
le32enc(void *pp, uint32_t x)
|
|
||||||
{
|
|
||||||
uint8_t * p = (uint8_t *)pp;
|
|
||||||
|
|
||||||
p[0] = x & 0xff;
|
|
||||||
p[1] = (x >> 8) & 0xff;
|
|
||||||
p[2] = (x >> 16) & 0xff;
|
|
||||||
p[3] = (x >> 24) & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t
|
|
||||||
le64dec(const void *pp)
|
|
||||||
{
|
|
||||||
const uint8_t *p = (uint8_t const *)pp;
|
|
||||||
|
|
||||||
return ((uint64_t)(p[0]) + ((uint64_t)(p[1]) << 8) +
|
|
||||||
((uint64_t)(p[2]) << 16) + ((uint64_t)(p[3]) << 24) +
|
|
||||||
((uint64_t)(p[4]) << 32) + ((uint64_t)(p[5]) << 40) +
|
|
||||||
((uint64_t)(p[6]) << 48) + ((uint64_t)(p[7]) << 56));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
le64enc(void *pp, uint64_t x)
|
|
||||||
{
|
|
||||||
uint8_t * p = (uint8_t *)pp;
|
|
||||||
|
|
||||||
p[0] = x & 0xff;
|
|
||||||
p[1] = (x >> 8) & 0xff;
|
|
||||||
p[2] = (x >> 16) & 0xff;
|
|
||||||
p[3] = (x >> 24) & 0xff;
|
|
||||||
p[4] = (x >> 32) & 0xff;
|
|
||||||
p[5] = (x >> 40) & 0xff;
|
|
||||||
p[6] = (x >> 48) & 0xff;
|
|
||||||
p[7] = (x >> 56) & 0xff;
|
|
||||||
}
|
|
||||||
#endif /* !HAVE_SYS_ENDIAN_H */
|
|
||||||
|
|
||||||
#endif /* !_SYSENDIAN_H_ */
|
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "platform.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "uthash.h"
|
#include "uthash.h"
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright 2009 Colin Percival
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (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 file was originally written by Colin Percival as part of the Tarsnap
|
|
||||||
* online backup system.
|
|
||||||
*/
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_ERR_H
|
|
||||||
/*
|
|
||||||
* Everything is provided through err.h and the associated library, so we
|
|
||||||
* don't need to do anything here.
|
|
||||||
*/
|
|
||||||
#else
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "warn.h"
|
|
||||||
|
|
||||||
const char * warn_progname = "(null)";
|
|
||||||
|
|
||||||
void
|
|
||||||
warn(const char * fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
fprintf(stderr, "%s", warn_progname);
|
|
||||||
if (fmt != NULL) {
|
|
||||||
fprintf(stderr, ": ");
|
|
||||||
vfprintf(stderr, fmt, ap);
|
|
||||||
}
|
|
||||||
fprintf(stderr, ": %s\n", strerror(errno));
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
warnx(const char * fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
fprintf(stderr, "%s", warn_progname);
|
|
||||||
if (fmt != NULL) {
|
|
||||||
fprintf(stderr, ": ");
|
|
||||||
vfprintf(stderr, fmt, ap);
|
|
||||||
}
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#ifndef _HAVE_PCP_WARN_H
|
|
||||||
#define _HAVE_PCP_WARN_H
|
|
||||||
|
|
||||||
#ifdef HAVE_ERR_H
|
|
||||||
#include <err.h>
|
|
||||||
#else
|
|
||||||
#define NEED_WARN_PROGNAME
|
|
||||||
const char * warn_progname;
|
|
||||||
void warn(const char *, ...);
|
|
||||||
void warnx(const char *, ...);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !_HAVE_WARN_H */
|
|
||||||
2
libtool
2
libtool
@@ -161,7 +161,7 @@ lock_old_archive_extraction=no
|
|||||||
LTCC="gcc"
|
LTCC="gcc"
|
||||||
|
|
||||||
# LTCC compiler flags.
|
# LTCC compiler flags.
|
||||||
LTCFLAGS="-g -O2 -I/usr/local/include"
|
LTCFLAGS="-I/usr/local/include -I/usr/local/include"
|
||||||
|
|
||||||
# Take the output of nm and produce a listing of raw symbols and C names.
|
# Take the output of nm and produce a listing of raw symbols and C names.
|
||||||
global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p' | sed '/ __gnu_lto/d'"
|
global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p' | sed '/ __gnu_lto/d'"
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
.\"
|
.\"
|
||||||
.IX Title "PCP1 1"
|
.IX Title "PCP1 1"
|
||||||
.TH PCP1 1 "2013-10-28" "PCP 0.0.1" "USER CONTRIBUTED DOCUMENTATION"
|
.TH PCP1 1 "2013-10-29" "PCP 0.0.1" "USER CONTRIBUTED DOCUMENTATION"
|
||||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||||
.\" way too many mistakes in technical documents.
|
.\" way too many mistakes in technical documents.
|
||||||
.if n .ad l
|
.if n .ad l
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ void pcppubkey_printshortinfo(pcp_pubkey_t *key) {
|
|||||||
int i;
|
int i;
|
||||||
printf(" Key-ID: 0x%s\n", key->id);
|
printf(" Key-ID: 0x%s\n", key->id);
|
||||||
printf(" Owner: %s\n", key->owner);
|
printf(" Owner: %s\n", key->owner);
|
||||||
char *r = pcpkey_get_art(key);
|
char *r = pcppubkey_get_art(key);
|
||||||
printf(" Random Art ID: ");
|
printf(" Random Art ID: ");
|
||||||
for (i=0; i<strlen(r); ++i) {
|
for (i=0; i<strlen(r); ++i) {
|
||||||
if(r[i] == '\n') {
|
if(r[i] == '\n') {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ void usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void version() {
|
void version() {
|
||||||
fprintf(stderr, "pcp version %d.%d.%d\n",
|
fprintf(stderr, "pcp version %d.%d.%d, use --help to learn how to use.\n",
|
||||||
PCP_VERSION_MAJOR, PCP_VERSION_MINOR, PCP_VERSION_PATCH);
|
PCP_VERSION_MAJOR, PCP_VERSION_MINOR, PCP_VERSION_PATCH);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -168,6 +168,11 @@ int main (int argc, char **argv) {
|
|||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
|
|
||||||
|
if(mode == 0) {
|
||||||
|
version();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if(usevault == 1) {
|
if(usevault == 1) {
|
||||||
pcp_inithashes();
|
pcp_inithashes();
|
||||||
vault = pcpvault_init(vaultfile);
|
vault = pcpvault_init(vaultfile);
|
||||||
@@ -327,7 +332,7 @@ int main (int argc, char **argv) {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// mode params mixed
|
// mode params mixed
|
||||||
fatal("Sorry, invalid combinatin of commandline parameters!\n");
|
fatal("Sorry, invalid combination of commandline parameters!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#ifndef _HAVE_PCP_H
|
#ifndef _HAVE_PCP_H
|
||||||
#define _HAVE_PCP_H
|
#define _HAVE_PCP_H
|
||||||
|
|
||||||
|
#ifndef _BSD_SOURCE
|
||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#ifndef _HAVE_PCP_Z85
|
#ifndef _HAVE_PCP_Z85
|
||||||
#define _HAVE_PCP_Z85
|
#define _HAVE_PCP_Z85
|
||||||
|
|
||||||
|
#ifndef _BSD_SOURCE
|
||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ md5msg = 66b8c4ca9e5d2a7e3c0559c3cdea3d50
|
|||||||
# negative tests, check for error handling
|
# negative tests, check for error handling
|
||||||
<test check-if-catch-conflicting-params>
|
<test check-if-catch-conflicting-params>
|
||||||
cmd = $pcp -S -P
|
cmd = $pcp -S -P
|
||||||
expect = /invalid combinatin of commandline parameters/
|
expect = /invalid combination of commandline parameters/
|
||||||
</test>
|
</test>
|
||||||
|
|
||||||
<test check-infile-error>
|
<test check-infile-error>
|
||||||
|
|||||||
Reference in New Issue
Block a user