~ubuntu-branches/ubuntu/wily/nettle/wily-proposed

« back to all changes in this revision

Viewing changes to serpent-internal.h

  • Committer: Package Import Robot
  • Author(s): Magnus Holmgren
  • Date: 2013-05-04 19:50:28 UTC
  • mfrom: (1.4.6) (3.1.11 experimental)
  • Revision ID: package-import@ubuntu.com-20130504195028-fp6c9fw1tsm5scwa
Tags: 2.7-1
* New upstream release (Closes: #706081).
* Include watch file improvements from Bart Martens <bartm@debian.org>
  via the QA system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 * 
25
25
 * You should have received a copy of the GNU Lesser General Public License
26
26
 * along with the nettle library; see the file COPYING.LIB.  If not, write to
27
 
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28
 
 * MA 02111-1307, USA.
 
27
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
28
 * MA 02111-1301, USA.
29
29
 */
30
30
 
31
31
/* This file is derived from cipher/serpent.c in Libgcrypt v1.4.6.
41
41
#ifndef NETTLE_SERPENT_INTERNAL_H_INCLUDED
42
42
#define NETTLE_SERPENT_INTERNAL_H_INCLUDED
43
43
 
44
 
/* FIXME: Unify ROL macros used here, in camellia.c and cast128.c. */
45
 
#define ROL32(x,n) ((((x))<<(n)) | (((x))>>(32-(n))))
46
 
 
47
44
#define KEYXOR(x0,x1,x2,x3, subkey)                    \
48
45
  do {                                                 \
49
46
    (x0) ^= (subkey)[0];                               \
54
51
 
55
52
#if HAVE_NATIVE_64_BIT
56
53
/* Operate independently on both halves of a 64-bit word. */
57
 
#define ROL64(x,n) \
58
 
  (((x) << (n) & ~(((1L << (n))-1) << 32)) \
59
 
   |(((x) >> (32-(n))) & ~(((1L << (32-(n)))-1) << (n))))
 
54
#define DROTL32(n,x) \
 
55
  (((x) << (n) & ~((((uint64_t) 1 << (n))-1) << 32)) \
 
56
   |(((x) >> (32-(n))) & ~((((uint64_t) 1 << (32-(n)))-1) << (n))))
60
57
 
61
58
#define KEYXOR64(x0,x1,x2,x3, subkey)                  \
62
59
  do {                                                 \
67
64
    _sk = (subkey)[3]; _sk |= _sk << 32; (x3) ^= _sk;    \
68
65
  } while (0)
69
66
 
70
 
#define RSHIFT64(x,n) \
71
 
  ( ((x) << (n)) & ~(((1L << n) - 1) << 32))
 
67
#define DRSHIFT32(n,x) \
 
68
  ( ((x) << (n)) & ~((((uint64_t) 1 << (n)) - 1) << 32))
72
69
#endif /* HAVE_NATIVE_64_BIT */
73
70
 
74
71
#endif /* NETTLE_SERPENT_INTERNAL_H_INCLUDED */