wireshark/wsutil/sober128.h
Peter Wu 7893ffa478 wsutil/sober128: remove unused macros and functions
Removed unused macros/functions that are apparently imported from
LibTomCrypt, only LOAD32L and STORE32L are needed. Remove code that
tries to distinguish between little/big endian, since WORDS_BIGENDIAN
was never defined, this would never have worked on big endian anyway.

Remove the special ROR "optimization" for GCC on i386, modern compilers
are able to optimize it to exactly the same thing. The generic
LOAD32L/STORE32L macros are less optimized (as can be seen in the
generated code), but this was not noticable in the mean running time.

Tested with the packet capture from bug 3232, the result is the same:

    tshark -ocorosync_totemnet.private_keys:example.com -r corosync-totemsrp--key:example.com--2nodes.pcap -Vx

Bug: 13368
Change-Id: I59bf27d7dd990bbcd5ad34a1797f4a6c8a04512d
Reviewed-on: https://code.wireshark.org/review/19894
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2017-02-02 21:13:55 +00:00

48 lines
1.6 KiB
C

/* This file is derived from sober128 implementation in corosync
cluster engine. corosync cluster engine borrows the implementation
from LibTomCrypt.
The latest version of the original code can be found at
http://www.libtom.net/LibTomCrypt/ according to which this code is in the
Public Domain
*/
/* About LibTomCrypt:
* ---------------------------------------------------------------------
* 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.
*
* Tom St Denis, tomstdenis@iahu.ca, http://www.libtom.net/LibTomCrypt/
*/
#ifndef _SOBER127_H
#define _SOBER127_H
#include "ws_symbol_export.h"
typedef struct _sober128_prng {
unsigned long R[17], /* Working storage for the shift register */
initR[17], /* saved register contents */
konst, /* key dependent constant */
sbuf; /* partial word encryption buffer */
int nbuf, /* number of part-word stream bits buffered */
flag, /* first add_entropy call or not? */
set; /* did we call add_entropy to set key? */
} sober128_prng;
WS_DLL_PUBLIC
int sober128_start(sober128_prng *prng);
WS_DLL_PUBLIC
int sober128_add_entropy(const unsigned char *buf, unsigned long len, sober128_prng *prng);
WS_DLL_PUBLIC
unsigned long sober128_read(unsigned char *buf, unsigned long len, sober128_prng *prng);
#endif /* sober128.h */