...
 
Commits (180)
......@@ -20,8 +20,13 @@ configure
aclocal.m4
autom4te.cache
depcomp
compile
install-sh
libtool
ltmain.sh
missing
test-driver
.*-stamp
test-out.log
test-suite.log
*.egg-info
include: "https://git.autistici.org/ai3/build-deb/raw/master/ci-common.yml"
# Note: this should match what's in lib/nacl-20110221/do.
short_hostname := $(shell hostname | sed 's/\..*//' | tr -cd '[a-z][A-Z][0-9]')
NACL_ABI := $(shell $(top_srcdir)/lib/nacl-20110221/printabi.debian)
NACL_DIR = $(top_builddir)/lib/nacl-20110221/build/$(short_hostname)
NACL_LIB_DIR = $(NACL_DIR)/lib/$(NACL_ABI)
AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(NACL_DIR)/include/$(NACL_ABI)
-D_GNU_SOURCE -Wall -Werror \
-I$(top_srcdir)/src
AM_LDFLAGS = \
-L$(top_builddir)/src \
-L$(NACL_LIB_DIR)
NACL_LIBS = $(NACL_LIB_DIR)/libnacl.a $(NACL_LIB_DIR)/librandombytes.a
SSO_LIBS = $(top_builddir)/src/sso/libsso.la $(NACL_LIBS)
LDADD = $(SSO_LIBS)
-L$(top_builddir)/src
......@@ -33,7 +33,7 @@ The login service is fully stateless and can be easily replicated (for
large setups). Authentication is ultimately performed by pluggable
authentication modules (PAM and LDAP support are included in the
source distribution). You can write your own following the API in
``src/sso_server/sso_server/auth/base.py``.
``src/sso_server/sso_server/auth/__init__.py``.
Services
......@@ -110,7 +110,7 @@ Each service supporting SSO must provide support for two special URLs:
credentials. This handler should return an HTML page containing just
the text "OK".
The login server supports these two parameters:
The login server supports the following parameters:
*s* - Service name
Note that all service names should end with a slash. The
......@@ -140,7 +140,7 @@ An SSO ticket is just a signed string consisting of fields separated
by the pipe (``|``) character. It includes the ticket format version,
username, service name, domain name, and group memberships.
The current format version number is 2.
The current format version number is 3.
......@@ -159,8 +159,11 @@ first:
* Python development environment
* (the crypto library NaCl is currently included with the code, but
will soon become an external dependency).
On a Debian/Ubuntu system this can be accomplished with the following
command (including dependencies required to run tests)::
$ sudo apt-get install swig libpam0g-dev apache2-dev \
python-dev python-setuptools python-nose python-m2crypto
Then it should be just a matter of running::
......
AC_INIT([sso], [2.0], [info@autistici.org])
AC_CONFIG_SRCDIR([src/sso/ticket.cc])
AC_CONFIG_SRCDIR([src/sso/sso.c])
AC_LANG(C++)
AM_INIT_AUTOMAKE([dist-bzip2 foreign])
AC_CONFIG_HEADERS(src/sso/config.h)
AC_CONFIG_MACRO_DIR([m4])
AC_DISABLE_SHARED
dnl AC_DISABLE_SHARED
dnl Program checks.
AC_PROG_CC
......@@ -16,10 +16,11 @@ AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
CFLAGS="$CFLAGS -fPIC -std=c99 -pedantic"
CXXFLAGS="$CXXFLAGS -fPIC"
dnl Checks for libraries.
ACX_PTHREAD([have_pthread=yes], [heve_pthread=no])
ACX_PTHREAD([have_pthread=yes], [have_pthread=no])
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
......@@ -38,27 +39,12 @@ dnl Checks for apxs.
if test "$build_mod_sso" != "no" ; then
AX_WITH_APXS()
APACHE_CFLAGS="-I`${APXS} -q INCLUDEDIR`"
AC_ARG_WITH(apr_config,
AC_HELP_STRING([[--with-apr-config=FILE]],
[Path to apr-config program]),
[ apr_config="$withval" ],
[AC_PATH_PROGS(apr_config,
[apr-config apr-0-config apr-1-config],
[no],
[$PATH:/usr/sbin/:/usr/local/apache2/bin]
)]
)
if test "$apr_config" != "no" ; then
AC_MSG_CHECKING('APR includes')
APACHE_CFLAGS="$APACHE_CFLAGS -I`${apr_config} --includedir`"
AC_MSG_RESULT($APACHE_CFLAGS)
AC_MSG_CHECKING('APR libs')
APR_LIBS="`${apr_config} --link-libtool --libs`"
AC_MSG_RESULT($APR_LIBS)
fi
AC_SUBST(APACHE_CFLAGS)
APACHE_LIBEXEC_DIR="`${APXS} -q LIBEXECDIR`"
AC_SUBST(APACHE_LIBEXEC_DIR)
PKG_CHECK_MODULES(APR, [apr-1, apr-util-1])
AC_SUBST(APR_CFLAGS)
AC_SUBST(APR_LIBS)
fi
AM_CONDITIONAL(ENABLE_MOD_SSO, [ test "$build_mod_sso" != "no" ])
......@@ -73,7 +59,12 @@ AC_ARG_ENABLE(pam-sso,
dnl Probe for the functionality of the PAM libraries and their include file
dnl naming. Mac OS X puts them in pam/* instead of security/*.
if test "$build_pam_sso" != "no" ; then
AC_SEARCH_LIBS([pam_set_data], [pam])
dnl Do not add -lpam to LIBS, set PAM_LIBS instead.
save_LIBS="$LIBS"
AC_SEARCH_LIBS([pam_set_data], [pam], [], [
AC_MSG_ERROR([libpam not found])])
LIBS="$save_LIBS"
AC_SUBST(PAM_LIBS, [-lpam])
AC_CHECK_FUNCS([pam_getenv pam_getenvlist pam_modutil_getpwnam])
AC_REPLACE_FUNCS([pam_syslog pam_vsyslog])
AC_CHECK_HEADERS([security/pam_modutil.h], [],
......@@ -98,13 +89,11 @@ if test "$build_pam_sso" != "no" ; then
fi
AM_CONDITIONAL(ENABLE_PAM_SSO, [ test "$build_pam_sso" != "no" ])
dnl SWIG
dnl AC_PROG_SWIG(1.3.17)
AX_PKG_SWIG(1.3.17)
AX_SWIG_ENABLE_CXX
AX_SWIG_MULTI_MODULE_SUPPORT
AX_SWIG_PYTHON
AM_CONDITIONAL(SWIG, [ test -n "$SWIG" && $SWIG -version >/dev/null 2>&1 ])
dnl Python-dev (actually only used for $PYTHON)
AX_PYTHON_DEVEL
dnl nosetests
AC_PATH_PROG([NOSETESTS], [nosetests])
dnl GoogleTest (use the embedded version)
GTEST_LIBS="\$(top_builddir)/lib/gtest/libgtest.la"
......@@ -128,7 +117,6 @@ dnl Final stage
AC_OUTPUT(
Makefile
lib/Makefile
lib/nacl-20110221/Makefile
lib/gtest/Makefile
src/Makefile
src/sso/Makefile
......
tmp
ai-sso-python
ai-sso
libapache2-mod-sso
libpam-sso
*.substvars
*.debhelper.log
.debhelper
debhelper-build-stamp
files
debian/tmp/usr/lib/python*
......@@ -6,14 +6,17 @@
# Required-Stop: $local_fs $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop the A/I Single-Sign-On server
# Short-Description: A/I Single-Sign-On Server
# Description: Starts and stops the A/I Single-Sign-On server.
### END INIT INFO
DAEMON=/usr/sbin/sso_server
NAME=sso_server
GUNICORN=/usr/bin/gunicorn
GUNICORN_APP="sso_server.wsgi:app"
GUNICORN_OPTS=
RUNDIR=/var/run/sso
LOGDIR=/var/log/sso
PIDFILE=${RUNDIR}/sso_server.pid
PIDFILE=${RUNDIR}/${NAME}.pid
SSO_PORT=5002
USER=ai-sso
NO_START=1
......@@ -21,33 +24,53 @@ NO_START=1
check_dirs() {
test -d ${RUNDIR} || mkdir ${RUNDIR}
chown ${USER} ${RUNDIR}
test -d ${LOGDIR} || mkdir ${LOGDIR}
chown -R ${USER} ${LOGDIR}
}
test -e /etc/default/ai-sso-server && . /etc/default/ai-sso-server
test -x ${DAEMON} || exit 0
test -x ${GUNICORN} || exit 0
test ${NO_START} -eq 1 && exit 0
. /lib/lsb/init-functions
GUNICORN_OPTS="
--log-config=/etc/sso/logging.conf
--bind 0.0.0.0:${SSO_PORT}
--worker-class gevent
--daemon --pid ${PIDFILE}
--name ${NAME}
${GUNICORN_OPTS}
"
case "$1" in
start)
echo -n "Starting SSO Server... "
log_daemon_msg "Starting SSO server"
check_dirs
start-stop-daemon --start --pidfile ${PIDFILE} --make-pidfile \
--background --chuid ${USER} --exec ${DAEMON} -- --port=${SSO_PORT}
echo "ok"
start-stop-daemon --start --oknodo \
--pidfile ${PIDFILE} \
--chuid ${USER} \
--exec ${GUNICORN} -- ${GUNICORN_OPTS} ${GUNICORN_APP}
if [ $? -eq 0 ]; then
log_success_msg
else
log_failure_msg
exit 1
fi
;;
stop)
echo -n "Stopping SSO Server... "
start-stop-daemon --stop \
--pidfile ${PIDFILE} && rm -f ${PIDFILE}
echo "ok"
log_daemon_msg "Stopping SSO server"
start-stop-daemon --stop --oknodo --user ${USER} --pidfile ${PIDFILE}
if [ $? -eq 0 ]; then
log_success_msg
else
log_failure_msg
fi
rm -f ${PIDFILE} 2>/dev/null
;;
reload)
echo -n "Reloading SSO Server... "
log_daemon_msg "Reloading SSO server"
kill -HUP `cat ${PIDFILE}`
echo "ok"
log_success_msg
;;
restart)
$0 stop
......@@ -55,7 +78,8 @@ restart)
$0 start
;;
*)
echo -e "Only [start|stop|reload|restart] operation are allowed\n"
echo "Usage: /etc/init.d/ai-sso-server {start|stop|reload|restart}" 1>&2
exit 1
;;
esac
......
[Unit]
Description=AI SSO Server
After=network.target
[Service]
PIDFile=/var/run/sso/sso_server.pid
User=root
WorkingDirectory=/var/run/sso
Environment=SSO_PORT=5002
ExecStart=/usr/bin/gunicorn \
--log-config /etc/sso/logging.conf \
--bind 0.0.0.0:${SSO_PORT} \
--worker-class gevent \
--pid /var/run/sso/sso_server.pid \
--name ai-sso-server \
sso_server.wsgi:app
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
Restart=always
[Install]
WantedBy=multi-user.target
d /var/run/sso 0700 root
[loggers]
keys=root, gunicorn.error
[handlers]
keys=syslog
[formatters]
keys=generic
[logger_root]
level=INFO
handlers=syslog
[logger_gunicorn.error]
level=INFO
handlers=syslog
qualname=gunicorn.error
[handler_syslog]
class=logging.handlers.SysLogHandler
formatter=generic
args=('/dev/log',)
[formatter_generic]
format=sso_server[%(process)d] %(levelname)s: %(message)s
class=logging.Formatter
debian/tmp/usr/lib/libsso*
debian/tmp/etc/sso
ai-sso (2.3.0) unstable; urgency=medium
* Added support for nonces in login exchange.
* Dropped Python sso server (ai-sso-server), replaced by
git.autistici.org/id/go-sso.
* Slightly more modern Debian packaging.
-- Autistici/Inventati <debian@autistici.org> Sat, 22 Jun 2019 12:15:18 +0100
ai-sso (2.2.0) unstable; urgency=medium
* Add apache2.4 support
-- Autistici/Inventati <debian@autistici.org> Sat, 02 Jul 2016 09:55:29 +0100
ai-sso (2.1.0) unstable; urgency=low
* Reimplemented in C using tweetnacl.
-- Autistici/Inventati <debian@autistici.org> Mon, 07 Sep 2015 21:35:03 +0000
ai-sso (2.0.2) unstable; urgency=medium
* Logging fixes.
-- Autistici/Inventati <debian@autistici.org> Sun, 18 Jan 2015 19:05:08 +0000
ai-sso (2.0.1) unstable; urgency=low
* OTP support.
* Use 'gunicorn' for serving.
-- Autistici/Inventati <debian@autistici.org> Sun, 30 Mar 2014 11:35:20 +0100
ai-sso (2.0) unstable; urgency=low
* Source upgraded to version 2.0.
......
......@@ -2,9 +2,10 @@ Source: ai-sso
Section: net
Priority: extra
Maintainer: Autistici/Inventati <debian@autistici.org>
Build-Depends: debhelper (>= 5), apache2-prefork-dev | apache2-threaded-dev,
autoconf, automake, libtool, python-dev, python-support, swig,
libpam-dev, python-setuptools
Build-Depends: debhelper (>= 10), apache2-dev | apache2-prefork-dev | apache2-threaded-dev,
apache2, autoconf, automake, libtool, python-dev, dh-python, python-all,
libpam-dev, libssl-dev, python-setuptools, python-flup, pkg-config, libz-dev,
python-m2crypto, python-flask, python-nose, python-mox, python-beautifulsoup
Standards-Version: 3.7.2
Package: ai-sso
......@@ -19,15 +20,9 @@ Depends: ai-sso, ${python:Depends}
Description: A/I SSO Python modules.
Python bindings for the SSO library.
Package: ai-sso-server
Architecture: all
Depends: ai-sso, ai-sso-python, python-flask, ${python:Depends}
Description: A/I SSO Server.
The login server for the A/I SSO service.
Package: libapache2-mod-sso
Architecture: any
Depends: ai-sso, apache2.2-common
Depends: ai-sso, apache2-api-20120211
Description: A/I SSO module for Apache2.
Apache2 module to support A/I SSO.
......
debian/tmp/usr/lib/apache2/modules/
debian/tmp/etc/apache2/
debian/tmp/lib/security/pam_sso.so
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
PYVERS=$(shell pyversions -vs)
%:
dh $@
configure: configure-stamp
configure-stamp:
dh_testdir
override_dh_auto_configure:
sh autogen.sh
./configure --prefix=/usr --with-pam-dir=/lib/security --enable-pam-sso --enable-mod-sso --enable-shared
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
dh_testdir
$(MAKE)
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
# Add here commands to clean up after the build process.
-$(MAKE) clean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# ai-sso
install -d $(CURDIR)/debian/ai-sso/etc/sso
install -d $(CURDIR)/debian/ai-sso/usr/lib/apache2/modules
$(MAKE) install DESTDIR=$(CURDIR)/debian/ai-sso
# ai-sso-python
install -d $(CURDIR)/debian/ai-sso-python/usr/lib
mv -f $(CURDIR)/debian/ai-sso/usr/lib/python* $(CURDIR)/debian/ai-sso-python/usr/lib/
# ai-sso-server
install -d $(CURDIR)/debian/ai-sso-server/etc/sso
install -o root -g root -m 644 debian/ai-sso-server.config-dist \
$(CURDIR)/debian/ai-sso-server/etc/sso/config.dist
#for v in $(PYVERS); do \
#install -d $(CURDIR)/debian/ai-sso-server/usr/lib/python$$v/site-packages/libsso ; \
#(tar -c -f- --exclude=.svn -C libsso/python sso_server | \
#tar -x -f- -C $(CURDIR)/debian/ai-sso-server/usr/lib/python$$v/site-packages/libsso) ; \
#rm -rf $(CURDIR)/debian/ai-sso-server/usr/lib/python$$v/site-packages/libsso/sso_server/test ; \
#chown -R root:root $(CURDIR)/debian/ai-sso-server/usr/lib/python$$v/site-packages/libsso ; \
#done
install -d $(CURDIR)/debian/ai-sso-server/usr/sbin
/bin/echo -e "#!/usr/bin/python\nfrom sso_server.main import main\nmain()" > \
$(CURDIR)/debian/ai-sso-server/usr/sbin/sso_server
chmod 0755 $(CURDIR)/debian/ai-sso-server/usr/sbin/sso_server
# libapache2-mod-sso
install -d $(CURDIR)/debian/libapache2-mod-sso/usr/lib/apache2/modules
mv $(CURDIR)/debian/ai-sso/usr/lib/apache2/modules/mod_sso.so \
$(CURDIR)/debian/libapache2-mod-sso/usr/lib/apache2/modules/mod_sso.so
rm -fr $(CURDIR)/debian/ai-sso/usr/lib/apache2
install -d $(CURDIR)/debian/libapache2-mod-sso/etc/apache2/mods-available
override_dh_auto_install:
install -d $(CURDIR)/debian/tmp/etc/sso
install -d $(CURDIR)/debian/tmp/usr/lib/apache2/modules
install -d $(CURDIR)/debian/tmp/etc/apache2/mods-available
install -m 644 -o root -g root $(CURDIR)/debian/mod_sso.conf \
$(CURDIR)/debian/libapache2-mod-sso/etc/apache2/mods-available/sso.conf
$(CURDIR)/debian/tmp/etc/apache2/mods-available/sso.conf
install -m 644 -o root -g root $(CURDIR)/debian/mod_sso.load \
$(CURDIR)/debian/libapache2-mod-sso/etc/apache2/mods-available/sso.load
# libpam-sso
install -d $(CURDIR)/debian/libpam-sso/lib/security
cp -L $(CURDIR)/debian/ai-sso/lib/security/pam_sso.so \
$(CURDIR)/debian/libpam-sso/lib/security/pam_sso.so
-rm -fr $(CURDIR)/debian/libpam-sso/lib
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
$(CURDIR)/debian/tmp/etc/apache2/mods-available/sso.load
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installlogrotate
# dh_install
# dh_installmenu
# dh_installdebconf
# dh_installemacsen
# dh_installpam
# dh_installmime
dh_pysupport
dh_installinit
# dh_installcron
# dh_installinfo
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
#dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
dh_auto_install
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
mv $(CURDIR)/debian/tmp/lib/security/pam_sso.so.0.0.0 \
$(CURDIR)/debian/tmp/lib/security/pam_sso.so
SUBDIRS = nacl-20110221 gtest
SUBDIRS = gtest
crypto_verify
crypto_verify_BYTES
crypto_core
crypto_core_OUTPUTBYTES
crypto_core_INPUTBYTES
crypto_core_KEYBYTES
crypto_core_CONSTBYTES
crypto_hashblocks
crypto_hashblocks_STATEBYTES
crypto_hashblocks_BLOCKBYTES
crypto_hash
crypto_hash_BYTES
crypto_stream
crypto_stream_xor
crypto_stream_beforenm
crypto_stream_afternm
crypto_stream_xor_afternm
crypto_stream_KEYBYTES
crypto_stream_NONCEBYTES
crypto_stream_BEFORENMBYTES
crypto_onetimeauth
crypto_onetimeauth_verify
crypto_onetimeauth_BYTES
crypto_onetimeauth_KEYBYTES
crypto_auth
crypto_auth_verify
crypto_auth_BYTES
crypto_auth_KEYBYTES
crypto_secretbox
crypto_secretbox_open
crypto_secretbox_KEYBYTES
crypto_secretbox_NONCEBYTES
crypto_secretbox_ZEROBYTES
crypto_secretbox_BOXZEROBYTES
crypto_scalarmult
crypto_scalarmult_base
crypto_scalarmult_BYTES
crypto_scalarmult_SCALARBYTES
crypto_box
crypto_box_open
crypto_box_keypair
crypto_box_beforenm
crypto_box_afternm
crypto_box_open_afternm
crypto_box_PUBLICKEYBYTES
crypto_box_SECRETKEYBYTES
crypto_box_BEFORENMBYTES
crypto_box_NONCEBYTES
crypto_box_ZEROBYTES
crypto_box_BOXZEROBYTES
crypto_sign
crypto_sign_open
crypto_sign_keypair
crypto_sign_BYTES
crypto_sign_PUBLICKEYBYTES
crypto_sign_SECRETKEYBYTES
include $(top_srcdir)/Makefile.defs
all: .build-stamp .librandombytes-stamp
.build-stamp:
$(srcdir)/do
-touch $@
.librandombytes-stamp: .build-stamp
$(AR) cru $(NACL_LIB_DIR)/librandombytes.a \
$(NACL_LIB_DIR)/randombytes.o
$(RANLIB) $(NACL_LIB_DIR)/librandombytes.a
-touch $@
clean:
-rm -f .build-stamp
crypto_verify
crypto_core
crypto_hashblocks
crypto_hash
crypto_stream
crypto_onetimeauth
crypto_auth
crypto_secretbox
crypto_scalarmult
crypto_box
crypto_sign
extern int crypto_verify(const unsigned char *,const unsigned char *);
extern int crypto_core(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_hashblocks(unsigned char *,const unsigned char *,unsigned long long);
extern int crypto_hash(unsigned char *,const unsigned char *,unsigned long long);
extern int crypto_stream(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_beforenm(unsigned char *,const unsigned char *);
extern int crypto_stream_afternm(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_xor_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_onetimeauth(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_onetimeauth_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_auth(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_auth_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_secretbox(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_secretbox_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_scalarmult(unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_scalarmult_base(unsigned char *,const unsigned char *);
extern int crypto_box(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_keypair(unsigned char *,unsigned char *);
extern int crypto_box_beforenm(unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_box_open_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_sign(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_sign_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_sign_keypair(unsigned char *,unsigned char *);
extern std::string crypto_auth(const std::string &,const std::string &);
extern void crypto_auth_verify(const std::string &,const std::string &,const std::string &);
extern std::string crypto_box(const std::string &,const std::string &,const std::string &,const std::string &);
extern std::string crypto_box_open(const std::string &,const std::string &,const std::string &,const std::string &);
extern std::string crypto_box_keypair(std::string *);
extern std::string crypto_hash(const std::string &);
extern std::string crypto_onetimeauth(const std::string &,const std::string &);
extern void crypto_onetimeauth_verify(const std::string &,const std::string &,const std::string &);
extern std::string crypto_scalarmult(const std::string &,const std::string &);
extern std::string crypto_scalarmult_base(const std::string &);
extern std::string crypto_secretbox(const std::string &,const std::string &,const std::string &);
extern std::string crypto_secretbox_open(const std::string &,const std::string &,const std::string &);
extern std::string crypto_stream(size_t,const std::string &,const std::string &);
extern std::string crypto_stream_xor(const std::string &,const std::string &,const std::string &);
extern std::string crypto_sign(const std::string &,const std::string &);
extern std::string crypto_sign_open(const std::string &,const std::string &);
extern std::string crypto_sign_keypair(std::string *);
/*
commandline/nacl-sha256.c version 20080713
D. J. Bernstein
Public domain.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "crypto_hash_sha256.h"
unsigned char *input;
unsigned long long inputalloc;
unsigned long long inputlen;
unsigned char h[crypto_hash_sha256_BYTES];
void h_print(void)
{
int i;
for (i = 0;i < crypto_hash_sha256_BYTES;++i) printf("%02x",255 & (int) h[i]);
printf("\n");
}
int main()
{
struct stat st;
int ch;
if (fstat(0,&st) == 0) {
input = mmap(0,st.st_size,PROT_READ,MAP_SHARED,0,0);
if (input != MAP_FAILED) {
crypto_hash_sha256(h,input,st.st_size);
h_print();
return 0;
}
}
input = 0;
inputalloc = 0;
inputlen = 0;
while ((ch = getchar()) != EOF) {
if (inputlen >= inputalloc) {
void *newinput;
while (inputlen >= inputalloc)
inputalloc = inputalloc * 2 + 1;
if (posix_memalign(&newinput,16,inputalloc) != 0) return 111;
memcpy(newinput,input,inputlen);
free(input);
input = newinput;
}
input[inputlen++] = ch;
}
crypto_hash_sha256(h,input,inputlen);
h_print();
return 0;
}
/*
commandline/nacl-sha512.c version 20080713
D. J. Bernstein
Public domain.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "crypto_hash_sha512.h"
unsigned char *input;
unsigned long long inputalloc;
unsigned long long inputlen;
unsigned char h[crypto_hash_sha512_BYTES];
void h_print(void)
{
int i;
for (i = 0;i < crypto_hash_sha512_BYTES;++i) printf("%02x",255 & (int) h[i]);
printf("\n");
}
int main()
{
struct stat st;
int ch;
if (fstat(0,&st) == 0) {
input = mmap(0,st.st_size,PROT_READ,MAP_SHARED,0,0);
if (input != MAP_FAILED) {
crypto_hash_sha512(h,input,st.st_size);
h_print();
return 0;
}
}
input = 0;
inputalloc = 0;
inputlen = 0;
while ((ch = getchar()) != EOF) {
if (inputlen >= inputalloc) {
void *newinput;
while (inputlen >= inputalloc)
inputalloc = inputalloc * 2 + 1;
if (posix_memalign(&newinput,16,inputalloc) != 0) return 111;
memcpy(newinput,input,inputlen);
free(input);
input = newinput;
}
input[inputlen++] = ch;
}
crypto_hash_sha512(h,input,inputlen);
h_print();
return 0;
}
/*
cpucycles/alpha.c version 20060316
D. J. Bernstein
Public domain.
*/
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
static long long tod(void)
{
struct timeval t;
gettimeofday(&t,(struct timezone *) 0);
return t.tv_sec * (long long) 1000000 + t.tv_usec;
}