view libtomcrypt/src/ciphers/anubis.c @ 1880:4c1560627693

add pubkey_info field to authstate structure
author HansH111 <hans@atbas.org>
date Sun, 13 Mar 2022 17:37:44 +0000
parents 6dba84798cd5
children
line wrap: on
line source

/* LibTomCrypt, modular cryptographic library -- Tom St Denis
 *
 * LibTomCrypt is a library that provides various cryptographic
 * algorithms in a highly modular and flexible manner.
 *
 * The library is free for all purposes without any express
 * guarantee it works.
 */

/**
  @file anubis.c
  Anubis implementation derived from public domain source
  Authors: Paulo S.L.M. Barreto and Vincent Rijmen.
*/

#include "tomcrypt.h"

#ifdef LTC_ANUBIS

const struct ltc_cipher_descriptor anubis_desc = {
   "anubis",
   19,
   16, 40, 16, 12,
   &anubis_setup,
   &anubis_ecb_encrypt,
   &anubis_ecb_decrypt,
   &anubis_test,
   &anubis_done,
   &anubis_keysize,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};

#define MIN_N           4
#define MAX_N           10
#define MIN_ROUNDS      (8 + MIN_N)
#define MAX_ROUNDS      (8 + MAX_N)
#define MIN_KEYSIZEB    (4*MIN_N)
#define MAX_KEYSIZEB    (4*MAX_N)
#define BLOCKSIZE       128
#define BLOCKSIZEB      (BLOCKSIZE/8)


/*
 * Though Anubis is endianness-neutral, the encryption tables are listed
 * in BIG-ENDIAN format, which is adopted throughout this implementation
 * (but little-endian notation would be equally suitable if consistently
 * employed).
 */
#if defined(LTC_ANUBIS_TWEAK)

static const ulong32 T0[256] = {
    0xba69d2bbU, 0x54a84de5U, 0x2f5ebce2U, 0x74e8cd25U,
    0x53a651f7U, 0xd3bb6bd0U, 0xd2b96fd6U, 0x4d9a29b3U,
    0x50a05dfdU, 0xac458acfU, 0x8d070e09U, 0xbf63c6a5U,
    0x70e0dd3dU, 0x52a455f1U, 0x9a29527bU, 0x4c982db5U,
    0xeac98f46U, 0xd5b773c4U, 0x97336655U, 0xd1bf63dcU,
    0x3366ccaaU, 0x51a259fbU, 0x5bb671c7U, 0xa651a2f3U,
    0xdea15ffeU, 0x48903dadU, 0xa84d9ad7U, 0x992f5e71U,
    0xdbab4be0U, 0x3264c8acU, 0xb773e695U, 0xfce5d732U,
    0xe3dbab70U, 0x9e214263U, 0x913f7e41U, 0x9b2b567dU,
    0xe2d9af76U, 0xbb6bd6bdU, 0x4182199bU, 0x6edca579U,
    0xa557aef9U, 0xcb8b0b80U, 0x6bd6b167U, 0x95376e59U,
    0xa15fbee1U, 0xf3fbeb10U, 0xb17ffe81U, 0x0204080cU,
    0xcc851792U, 0xc49537a2U, 0x1d3a744eU, 0x14285078U,
    0xc39b2bb0U, 0x63c69157U, 0xdaa94fe6U, 0x5dba69d3U,
    0x5fbe61dfU, 0xdca557f2U, 0x7dfae913U, 0xcd871394U,
    0x7ffee11fU, 0x5ab475c1U, 0x6cd8ad75U, 0x5cb86dd5U,
    0xf7f3fb08U, 0x264c98d4U, 0xffe3db38U, 0xedc79354U,
    0xe8cd874aU, 0x9d274e69U, 0x6fdea17fU, 0x8e010203U,
    0x19326456U, 0xa05dbae7U, 0xf0fde71aU, 0x890f1e11U,
    0x0f1e3c22U, 0x070e1c12U, 0xaf4386c5U, 0xfbebcb20U,
    0x08102030U, 0x152a547eU, 0x0d1a342eU, 0x04081018U,
    0x01020406U, 0x64c88d45U, 0xdfa35bf8U, 0x76ecc529U,