Commit e2617599 authored by Mati's avatar Mati

Merge tag 'upstream/0.10.5'

Upstream version 0.10.5
parents 0ed35691 386a9e85
2011-05-18 09:18 rconty@il4p.fr
2013-01-20 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: mfoc: improve tests made before running and show tag
info using print_nfc_iso14443a_info()
* ChangeLog: Update outdated email addresses
2011-04-08 15:19 rconty@il4p.fr
2013-01-20 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: mfoc: try to disconnect() the device on error.
* src/crapto1.c, src/crapto1.h, src/crypto1.c, src/mfoc.c,
src/mfoc.h: Format source code with "make style"
2011-04-08 10:05 rconty@il4p.fr
2013-01-20 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: mfoc: show errors then exit on mf_configure()
* Makefile.am: Add "make style" directive to format source code
2011-04-08 09:32 rconty@il4p.fr
2013-01-20 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: mfoc: apply a patch suggested by Valentijn Sessink.
See Issue 56.
* configure.ac, src/mfoc.c: Updates source to use libnfc 1.7.0
2011-04-08 09:17 rconty@il4p.fr
2013-01-20 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: mfoc: minors fixes and indent.
* src/mifare.c, src/mifare.h, src/nfc-utils.c, src/nfc-utils.h:
Update mifare.* and nfc-utils.* from libnfc utils directory
2011-04-08 08:54 rconty@il4p.fr
2013-01-20 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: mfoc: show error (using nfc_perror) then exit if some
nfc_* functions failed on init.
* .gitignore: Ignore generated files in source repository
2011-04-08 08:35 rconty@il4p.fr
2012-10-14 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: mfoc: minor debug improvements.
* src/mfoc.c: Fix tolerance (-T) option (Fixes issue 102) Thanks to
fnargwibble
2011-04-04 12:28 rconty@il4p.fr
2012-06-03 Romuald Conty <romuald@libnfc.org>
* configure.ac, src/mfoc.c: mfoc: minor fixes/enhancements and
version bumping
* src/mifare.c: do not display an error when authentication failed
2011-04-04 10:38 rconty@il4p.fr
2012-06-03 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c, src/mifare.c: mfoc: hide authentication errors
* src/mfoc.c, src/mfoc.h: use authuid instead uid name when handling
the authentication uid bytes (different from UID with 7bytes MIFARE
Classic
2011-04-04 10:01 rconty@il4p.fr
2012-06-03 Romuald Conty <romuald@libnfc.org>
* src/mifare.c, src/mifare.h, src/nfc-utils.c, src/nfc-utils.h:
mfoc: sync nfc-utils.h/c and mifare.c/h with libnfc's ones.
* src/crapto1.h, src/mfoc.c, src/mfoc.h, src/mifare.c,
src/mifare.h, src/nfc-utils.c, src/nfc-utils.h: some code clean up:
find . -name '*.[ch]' | xargs perl -pi -e 's/\t+$//; s/ +$//'
2011-02-21 16:26 rtartiere@il4p.fr
2012-06-02 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c, src/mifare.h: Allow to find default keys using 7bytes
UID MIFARE Classic tags
2012-06-02 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: Remove not requiered anticol and configuration, its
speed up default keys search
2012-06-02 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: Enhance default keys search result: '/', '\' and 'x'
means respectively A, B and both key(s) found.
2012-06-01 Romuald Conty <romuald@libnfc.org>
* INSTALL, configure.ac, debian/control, src/Makefile.am,
src/crapto1.c, src/mfoc.c, src/mfoc.h, src/mifare.c: foc> source
code maintenance: - upgrade to last libnfc devel API - removes various warnings - update debian package
2012-05-28 Ludovic Rousseau <ludovic.rousseau@gmail.com>
* debian/watch: Update upstream URL Closes Issue #92
2012-05-22 Ludovic Rousseau <ludovic.rousseau@gmail.com>
* debian/control: Upgrade libnfc-dev version in Build-Depends: Closes Issue #91
2012-05-14 Romain Tartiere <romain.tartiere@gmail.com>
* src/crapto1.h: Export lfsr_rollback_word().
2012-05-14 Romain Tartiere <romain.tartiere@gmail.com>
* src/mfoc.c, src/mfoc.h: Drop unused argument.
2012-05-14 Romain Tartiere <romain.tartiere@gmail.com>
* src/mfoc.c, src/mfoc.h: Fix a bunch of signed/unsigned
comparisons.
2012-05-14 Romain Tartiere <romain.tartiere@gmail.com>
* configure.ac: Complete configure.ac.
2012-05-14 Romain Tartiere <romain.tartiere@gmail.com>
* src/Makefile.am: Rely on variables set by the autotools.
2012-01-26 Audrey Diacre <adiacre@il4p.fr>
* src/mfoc.c, src/mfoc.h, src/mifare.c, src/mifare.h,
src/nfc-utils.c, src/nfc-utils.h: update to use libnfc's trunk
2011-10-17 Romuald Conty <romuald@libnfc.org>
* configure.ac, src/Makefile.am: compilation improvements (Thanks to
Thomas Hood)
2011-09-28 Romuald Conty <romuald@libnfc.org>
* configure.ac, src/mfoc.c, src/mifare.c: Sync w/ libnfc-1.5.1
(Fixes Issue 79)
2011-07-11 Romuald Conty <romuald@libnfc.org>
* src/nfc-utils.c: sync nfc-utils.c with libnfc trunk.
2011-05-20 Romuald Conty <romuald@libnfc.org>
* debian/control, debian/watch: debian: update pam_nfc, mfoc and
libfreefare packages to use dh7.
2011-05-20 Romuald Conty <romuald@libnfc.org>
* INSTALL, debian/control: debian: silent lintian warning
2011-05-20 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: usage output is now more standard (Thanks to Thomas
Hood)
2011-05-20 Romuald Conty <romuald@libnfc.org>
* debian/changelog, debian/control, debian/rules: debian package now
use dh_autoreconf to build against svn.
2011-05-19 Romuald Conty <romuald@libnfc.org>
* debian/rules: in some cases ./configure file needs to be chmoded
(dpkg-source -b mfoc).
2011-05-19 Romuald Conty <romuald@libnfc.org>
* AUTHORS, debian/changelog, debian/compat, debian/control,
debian/copyright, debian/docs, debian/manpages, debian/rules,
debian/source/format, debian/watch: import debian files (Thanks to
Thomas Hood)
2011-05-18 Romuald Conty <romuald@libnfc.org>
* src/Makefile.am, src/mfoc.1: add manpage (Thanks to Thomas Hood)
2011-05-18 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: read multiple keys from command line (Thanks to Frank
Morgner) (Fixes Issue 63)
2011-05-18 Romuald Conty <romuald@libnfc.org>
* ChangeLog, configure.ac: prepare 0.10.2 release
2011-05-18 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: improve tests made before running and show tag info
using print_nfc_iso14443a_info()
2011-04-08 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: try to disconnect() the device on error.
2011-04-08 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: show errors then exit on mf_configure()
2011-04-08 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: apply a patch suggested by Valentijn Sessink. See
Issue 56.
2011-04-08 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: minors fixes and indent.
2011-04-08 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: show error (using nfc_perror) then exit if some nfc_*
functions failed on init.
2011-04-08 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: minor debug improvements.
2011-04-04 Romuald Conty <romuald@libnfc.org>
* configure.ac, src/mfoc.c: minor fixes/enhancements and version
bumping
2011-04-04 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c, src/mifare.c: hide authentication errors
2011-04-04 Romuald Conty <romuald@libnfc.org>
* src/mifare.c, src/mifare.h, src/nfc-utils.c, src/nfc-utils.h: sync
nfc-utils.h/c and mifare.c/h with libnfc's ones.
2011-02-21 Romain Tartiere <romain.tartiere@gmail.com>
* src/Makefile.am: mfox: Unbreak autotools on FreeBSD.
2011-02-02 10:46 rconty@il4p.fr
2011-02-02 Romuald Conty <romuald@libnfc.org>
* src/mfoc.c: mfoc: use strtoll() function in order to retrieve
64bits wide value. (Fixes Issue 55)
* src/mfoc.c: use strtoll() function in order to retrieve 64bits
wide value. (Fixes Issue 55)
2010-11-18 11:20 rconty@il4p.fr
2010-11-18 Romuald Conty <romuald@libnfc.org>
* configure.ac: mfoc: bump package version
* configure.ac: bump package version
2010-11-18 11:18 rconty@il4p.fr
2010-11-18 Romuald Conty <romuald@libnfc.org>
* src/nfc-utils.c, src/nfc-utils.h: mfoc: sync nfc-utils.* from
libnfc
* src/nfc-utils.c, src/nfc-utils.h: sync nfc-utils.* from libnfc
2010-11-02 09:36 rconty@il4p.fr
2010-11-02 Romuald Conty <romuald@libnfc.org>
* configure.ac, src/mfoc.c, src/mfoc.h, src/nfc-utils.c,
src/nfc-utils.h: mfoc: upgrade code to work with develoment
version of libnfc (upcomming 1.4.0)
Update code to match with the new API;
Sync nfc-utils.[ch] from libnfc's repo;
Update ./configure to detect libnfc 1.4.0;
2010-09-14 09:38 rconty@il4p.fr
* ., AUTHORS, Makefile.in, aclocal.m4, autogen.sh, config.h,
config.h.in, configure, configure.ac, depcomp, install-sh,
missing, src, src/Makefile.am, src/mfoc.c, src/mifare.c,
src/mifare.h, src/nfc-utils.c, src/nfc-utils.h: mfoc: update code
in order to use libnfc 1.3.9, minor clean up, and minor
enhancements.
2010-09-14 09:34 rconty@il4p.fr
* ., AUTHORS, COPYING, ChangeLog, INSTALL, Makefile.am,
Makefile.in, NEWS, README, TODO, aclocal.m4, autogen.sh,
config.h, config.h.in, configure, configure.ac, depcomp,
install-sh, missing, src, src/Makefile.am, src/crapto1.c,
src/crapto1.h, src/crypto1.c, src/mfoc.c, src/mfoc.h: Import MFOC
0.08 from http://www.nethemba.com/mfoc.tar.bz2 on 13th Sept 2010
src/nfc-utils.h: upgrade code to work with develoment version of
libnfc (upcomming 1.4.0) Update code to match with the new API; Sync
nfc-utils.[ch] from libnfc's repo; Update ./configure to detect
libnfc 1.4.0;
2010-09-14 Romuald Conty <romuald@libnfc.org>
* AUTHORS, Makefile.in, aclocal.m4, autogen.sh, config.h,
config.h.in, configure, configure.ac, depcomp, install-sh, missing,
src/Makefile.am, src/mfoc.c, src/mifare.c, src/mifare.h,
src/nfc-utils.c, src/nfc-utils.h: update code in order to use libnfc
1.3.9, minor clean up, and minor enhancements.
2010-09-14 Romuald Conty <romuald@libnfc.org>
* Import MFOC 0.08 from http://www.nethemba.com/mfoc.tar.bz2 on 13th
Sept 2010
SUBDIRS = src
#pkgconfigdir = $(libdir)/pkgconfig
#pkgconfig_DATA = libnfc.pc
style:
find . -name "*.[ch]" -exec perl -pi -e 's/[ \t]+$$//' {} \;
find . -name "*.[ch]" -exec astyle --formatted --mode=c --suffix=none \
--indent=spaces=2 --indent-switches --indent-preprocessor \
--keep-one-line-blocks --max-instatement-indent=60 \
--brackets=linux --pad-oper --unpad-paren --pad-header \
--align-pointer=name {} \;
# Makefile.in generated by automake 1.11.6 from Makefile.am.
# Makefile.in generated by automake 1.11.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
......@@ -15,23 +15,6 @@
@SET_MAKE@
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
......@@ -78,11 +61,6 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
......@@ -448,10 +426,13 @@ distdir: $(DISTFILES)
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
......@@ -537,7 +518,7 @@ distcheck: dist
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod u+w $(distdir)
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
......@@ -725,8 +706,13 @@ uninstall-am:
uninstall uninstall-am
#pkgconfigdir = $(libdir)/pkgconfig
#pkgconfig_DATA = libnfc.pc
style:
find . -name "*.[ch]" -exec perl -pi -e 's/[ \t]+$$//' {} \;
find . -name "*.[ch]" -exec astyle --formatted --mode=c --suffix=none \
--indent=spaces=2 --indent-switches --indent-preprocessor \
--keep-one-line-blocks --max-instatement-indent=60 \
--brackets=linux --pad-oper --unpad-paren --pad-header \
--align-pointer=name {} \;
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
......
# generated automatically by aclocal 1.11.6 -*- Autoconf -*-
# generated automatically by aclocal 1.11.3 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
......@@ -14,8 +14,8 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
[m4_warning([this file was generated for autoconf 2.69.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
[m4_warning([this file was generated for autoconf 2.68.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
......@@ -198,7 +198,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.11'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.11.6], [],
m4_if([$1], [1.11.3], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
......@@ -214,7 +214,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.11.6])dnl
[AM_AUTOMAKE_VERSION([1.11.3])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
......
This diff is collapsed.
AC_INIT([mfoc],[0.10.3],[mifare@nethemba.com])
AC_INIT([mfoc],[0.10.5],[mifare@nethemba.com])
AC_CONFIG_MACRO_DIR([m4])
......@@ -13,7 +13,7 @@ AM_INIT_AUTOMAKE
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# Checks for pkg-config modules.
LIBNFC_REQUIRED_VERSION=1.6.0
LIBNFC_REQUIRED_VERSION=1.7.0
PKG_CHECK_MODULES([libnfc], [libnfc >= $LIBNFC_REQUIRED_VERSION], [], [AC_MSG_ERROR([libnfc >= $LIBNFC_REQUIRED_VERSION is mandatory.])])
PKG_CONFIG_REQUIRES="libnfc"
......
This diff is collapsed.
# Makefile.in generated by automake 1.11.6 from Makefile.am.
# Makefile.in generated by automake 1.11.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
......@@ -17,23 +17,6 @@
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
......@@ -90,11 +73,6 @@ am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(mfoc_SOURCES)
DIST_SOURCES = $(mfoc_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
......@@ -263,11 +241,8 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p; \
......@@ -332,18 +307,11 @@ distclean-compile:
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
install-man1: $(dist_man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(dist_man_MANS)'; \
test -n "$(man1dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.1[a-z]*$$/p'; \
fi; \
test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
@list=''; test -n "$(man1dir)" || exit 0; \
{ for i in $$list; do echo "$$i"; done; \
l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.1[a-z]*$$/p'; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
......
This diff is collapsed.
......@@ -24,65 +24,65 @@
extern "C" {
#endif
struct Crypto1State {uint32_t odd, even;};
struct Crypto1State* crypto1_create(uint64_t);
void crypto1_destroy(struct Crypto1State*);
void crypto1_get_lfsr(struct Crypto1State*, uint64_t*);
uint8_t crypto1_bit(struct Crypto1State*, uint8_t, int);
uint8_t crypto1_byte(struct Crypto1State*, uint8_t, int);
uint32_t crypto1_word(struct Crypto1State*, uint32_t, int);
uint32_t prng_successor(uint32_t x, uint32_t n);
struct Crypto1State {uint32_t odd, even;};
struct Crypto1State *crypto1_create(uint64_t);
void crypto1_destroy(struct Crypto1State *);
void crypto1_get_lfsr(struct Crypto1State *, uint64_t *);
uint8_t crypto1_bit(struct Crypto1State *, uint8_t, int);
uint8_t crypto1_byte(struct Crypto1State *, uint8_t, int);
uint32_t crypto1_word(struct Crypto1State *, uint32_t, int);
uint32_t prng_successor(uint32_t x, uint32_t n);
struct Crypto1State* lfsr_recovery32(uint32_t ks2, uint32_t in);
struct Crypto1State* lfsr_recovery64(uint32_t ks2, uint32_t ks3);
struct Crypto1State *lfsr_recovery32(uint32_t ks2, uint32_t in);
struct Crypto1State *lfsr_recovery64(uint32_t ks2, uint32_t ks3);
void lfsr_rollback(struct Crypto1State* s, uint32_t in, int fb);
uint32_t lfsr_rollback_word(struct Crypto1State *s, uint32_t in, int fb);
int nonce_distance(uint32_t from, uint32_t to);
void lfsr_rollback(struct Crypto1State *s, uint32_t in, int fb);
uint32_t lfsr_rollback_word(struct Crypto1State *s, uint32_t in, int fb);
int nonce_distance(uint32_t from, uint32_t to);
#define FOREACH_VALID_NONCE(N, FILTER, FSIZE)\
uint32_t __n = 0,__M = 0, N = 0;\
int __i;\
for(; __n < 1 << 16; N = prng_successor(__M = ++__n, 16))\
for(__i = FSIZE - 1; __i >= 0; __i--)\
if(BIT(FILTER, __i) ^ parity(__M & 0xFF01))\
break;\
else if(__i)\
__M = prng_successor(__M, (__i == 7) ? 48 : 8);\
else
uint32_t __n = 0,__M = 0, N = 0;\
int __i;\
for(; __n < 1 << 16; N = prng_successor(__M = ++__n, 16))\
for(__i = FSIZE - 1; __i >= 0; __i--)\
if(BIT(FILTER, __i) ^ parity(__M & 0xFF01))\
break;\
else if(__i)\
__M = prng_successor(__M, (__i == 7) ? 48 : 8);\
else
#define LF_POLY_ODD (0x29CE5C)
#define LF_POLY_EVEN (0x870804)
#define BIT(x, n) ((x) >> (n) & 1)
#define BEBIT(x, n) BIT(x, (n) ^ 24)
static inline int parity(uint32_t x)
{
static inline int parity(uint32_t x)
{
#if !defined __i386__ || !defined __GNUC__
x ^= x >> 16;
x ^= x >> 8;
x ^= x >> 4;
return BIT(0x6996, x & 0xf);
x ^= x >> 16;
x ^= x >> 8;
x ^= x >> 4;
return BIT(0x6996, x & 0xf);
#else
asm( "movl %1, %%eax\n"
"mov %%ax, %%cx\n"
"shrl $0x10, %%eax\n"
"xor %%ax, %%cx\n"
"xor %%ch, %%cl\n"
"setpo %%al\n"
"movzx %%al, %0\n": "=r"(x) : "r"(x): "eax","ecx");
return x;
__asm__("movl %1, %%eax\n"
"mov %%ax, %%cx\n"
"shrl $0x10, %%eax\n"
"xor %%ax, %%cx\n"
"xor %%ch, %%cl\n"
"setpo %%al\n"
"movzx %%al, %0\n": "=r"(x) : "r"(x): "eax", "ecx");
return x;
#endif
}
static inline int filter(uint32_t const x)
{
uint32_t f;
}
static inline int filter(uint32_t const x)
{
uint32_t f;
f = 0xf22c0 >> (x & 0xf) & 16;
f |= 0x6c9c0 >> (x >> 4 & 0xf) & 8;
f |= 0x3c8b0 >> (x >> 8 & 0xf) & 4;
f |= 0x1e458 >> (x >> 12 & 0xf) & 2;
f |= 0x0d938 >> (x >> 16 & 0xf) & 1;
return BIT(0xEC57E80A, f);
}
f = 0xf22c0 >> (x & 0xf) & 16;
f |= 0x6c9c0 >> (x >> 4 & 0xf) & 8;
f |= 0x3c8b0 >> (x >> 8 & 0xf) & 4;
f |= 0x1e458 >> (x >> 12 & 0xf) & 2;
f |= 0x0d938 >> (x >> 16 & 0xf) & 1;
return BIT(0xEC57E80A, f);
}
#ifdef __cplusplus
}
#endif
......
......@@ -21,63 +21,62 @@
#include <stdlib.h>
#define SWAPENDIAN(x)\
(x = (x >> 8 & 0xff00ff) | (x & 0xff00ff) << 8, x = x >> 16 | x << 16)
(x = (x >> 8 & 0xff00ff) | (x & 0xff00ff) << 8, x = x >> 16 | x << 16)
struct Crypto1State * crypto1_create(uint64_t key)
{
struct Crypto1State *s = malloc(sizeof(*s));
int i;
for(i = 47;s && i > 0; i -= 2) {
s->odd = s->odd << 1 | BIT(key, (i - 1) ^ 7);
s->even = s->even << 1 | BIT(key, i ^ 7);
}
return s;
struct Crypto1State *crypto1_create(uint64_t key) {
struct Crypto1State *s = malloc(sizeof(*s));
int i;
for (i = 47; s && i > 0; i -= 2) {
s->odd = s->odd << 1 | BIT(key, (i - 1) ^ 7);
s->even = s->even << 1 | BIT(key, i ^ 7);
}
return s;
}
void crypto1_destroy(struct Crypto1State *state)
{
free(state);
free(state);
}
void crypto1_get_lfsr(struct Crypto1State *state, uint64_t *lfsr)
{
int i;
for(*lfsr = 0, i = 23; i >= 0; --i) {
*lfsr = *lfsr << 1 | BIT(state->odd, i ^ 3);
*lfsr = *lfsr << 1 | BIT(state->even, i ^ 3);
}
int i;
for (*lfsr = 0, i = 23; i >= 0; --i) {
*lfsr = *lfsr << 1 | BIT(state->odd, i ^ 3);
*lfsr = *lfsr << 1 | BIT(state->even, i ^ 3);
}
}
uint8_t crypto1_bit(struct Crypto1State *s, uint8_t in, int is_encrypted)
{
uint32_t feedin;
uint8_t ret = filter(s->odd);
uint32_t feedin;
uint8_t ret = filter(s->odd);
feedin = ret & !!is_encrypted;
feedin ^= !!in;
feedin ^= LF_POLY_ODD & s->odd;
feedin ^= LF_POLY_EVEN & s->even;
s->even = s->even << 1 | parity(feedin);
feedin = ret & !!is_encrypted;
feedin ^= !!in;
feedin ^= LF_POLY_ODD & s->odd;
feedin ^= LF_POLY_EVEN & s->even;
s->even = s->even << 1 | parity(feedin);
s->odd ^= (s->odd ^= s->even, s->even ^= s->odd);
s->odd ^= (s->odd ^= s->even, s->even ^= s->odd);
return ret;
return ret;
}
uint8_t crypto1_byte(struct Crypto1State *s, uint8_t in, int is_encrypted)
{
uint8_t i, ret = 0;
uint8_t i, ret = 0;
for (i = 0; i < 8; ++i)
ret |= crypto1_bit(s, BIT(in, i), is_encrypted) << i;
for (i = 0; i < 8; ++i)
ret |= crypto1_bit(s, BIT(in, i), is_encrypted) << i;
return ret;
return ret;
}
uint32_t crypto1_word(struct Crypto1State *s, uint32_t in, int is_encrypted)
{
uint32_t i, ret = 0;
uint32_t i, ret = 0;
for (i = 0; i < 32; ++i)
ret |= crypto1_bit(s, BEBIT(in, i), is_encrypted) << (i ^ 24);
for (i = 0; i < 32; ++i)
ret |= crypto1_bit(s, BEBIT(in, i), is_encrypted) << (i ^ 24);
return ret;
return ret;
}
/* prng_successor
......@@ -85,9 +84,9 @@ uint32_t crypto1_word(struct Crypto1State *s, uint32_t in, int is_encrypted)
*/
uint32_t prng_successor(uint32_t x, uint32_t n)
{
SWAPENDIAN(x);
while(n--)
x = x >> 1 | (x >> 16 ^ x >> 18 ^ x >> 19 ^ x >> 21) << 31;
SWAPENDIAN(x);
while (n--)
x = x >> 1 | (x >> 16 ^ x >> 18 ^ x >> 19 ^ x >> 21) << 31;
return SWAPENDIAN(x);