~ubuntu-branches/ubuntu/utopic/nettle/utopic

« back to all changes in this revision

Viewing changes to serpent-encrypt.c

  • Committer: Package Import Robot
  • Author(s): Magnus Holmgren
  • Date: 2013-05-07 22:57:14 UTC
  • mfrom: (8.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130507225714-s331yr8ov53dtt17
Tags: 2.7-2
Tag some (ECC related) symbols that only exist on some architectures.

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.
386
386
/* In-place linear transformation.  */
387
387
#define LINEAR_TRANSFORMATION(x0,x1,x2,x3)               \
388
388
  do {                                                   \
389
 
    x0 = ROL32 (x0, 13);                    \
390
 
    x2 = ROL32 (x2, 3);                     \
 
389
    x0 = ROTL32 (13, x0);                    \
 
390
    x2 = ROTL32 (3, x2);                     \
391
391
    x1 = x1 ^ x0 ^ x2;        \
392
392
    x3 = x3 ^ x2 ^ (x0 << 3); \
393
 
    x1 = ROL32 (x1, 1);                     \
394
 
    x3 = ROL32 (x3, 7);                     \
 
393
    x1 = ROTL32 (1, x1);                     \
 
394
    x3 = ROTL32 (7, x3);                     \
395
395
    x0 = x0 ^ x1 ^ x3;        \
396
396
    x2 = x2 ^ x3 ^ (x1 << 7); \
397
 
    x0 = ROL32 (x0, 5);                     \
398
 
    x2 = ROL32 (x2, 22);                    \
 
397
    x0 = ROTL32 (5, x0);                     \
 
398
    x2 = ROTL32 (22, x2);                    \
399
399
  } while (0)
400
400
 
401
401
/* Round inputs are x0,x1,x2,x3 (destroyed), and round outputs are
411
411
 
412
412
#define LINEAR_TRANSFORMATION64(x0,x1,x2,x3)             \
413
413
  do {                                                   \
414
 
    x0 = ROL64 (x0, 13);                    \
415
 
    x2 = ROL64 (x2, 3);                     \
 
414
    x0 = DROTL32 (13, x0);                    \
 
415
    x2 = DROTL32 (3, x2);                     \
416
416
    x1 = x1 ^ x0 ^ x2;        \
417
 
    x3 = x3 ^ x2 ^ RSHIFT64(x0, 3);         \
418
 
    x1 = ROL64 (x1, 1);                     \
419
 
    x3 = ROL64 (x3, 7);                     \
 
417
    x3 = x3 ^ x2 ^ DRSHIFT32(3, x0);        \
 
418
    x1 = DROTL32 (1, x1);                     \
 
419
    x3 = DROTL32 (7, x3);                     \
420
420
    x0 = x0 ^ x1 ^ x3;        \
421
 
    x2 = x2 ^ x3 ^ RSHIFT64(x1, 7);         \
422
 
    x0 = ROL64 (x0, 5);                     \
423
 
    x2 = ROL64 (x2, 22);                    \
 
421
    x2 = x2 ^ x3 ^ DRSHIFT32(7, x1);        \
 
422
    x0 = DROTL32 (5, x0);                     \
 
423
    x2 = DROTL32 (22, x2);                    \
424
424
  } while (0)
425
425
 
426
426
#define ROUND64(which, subkey, x0,x1,x2,x3, y0,y1,y2,y3) \