threefish 0.2.3 → 0.2.4
raw patch · 2 files changed
+45/−2 lines, 2 files
Files
- cbits/threefish.h +43/−0
- threefish.cabal +2/−2
+ cbits/threefish.h view
@@ -0,0 +1,43 @@+#ifndef _THREEFISH_H+#define _THREEFISH_H++typedef unsigned long long W64;+extern W64 key_const;++typedef struct {+ W64 key[4];+ W64 tweak[2];+ int outlen;+} skein_t;++#define rl(x, b) (((x) << ((b) & 63)) | ((x) >> ((64-(b)) & 63)))+#define rr(x, b) (((x) >> ((b) & 63)) | ((x) << ((64-(b)) & 63)))++typedef enum {+ T_KEY = 0,+ T_CONFIG = 4,+ T_PERSONALIZATION = 8,+ T_PUBKEY = 12,+ T_KEYIDENTIFIER = 16,+ T_NONCE = 20,+ T_MSG = 48,+ T_OUT = 63+} UBIType;++void encrypt256(W64* key, W64 t0, W64 t1, W64* in, W64* out);+void decrypt256(W64* key, W64 t0, W64 t1, W64* in, W64* out);++/* note that here outlen is in *bits* */+void skein256_init(skein_t* ctx, W64* key, W64 outlen);+/* firstlast & 1 if we're starting a new type, firstlast & 2 if it's the last update */+void skein256_update(skein_t* ctx, int firstlast, UBIType type, W64 len, W64* data);+void skein256_output(skein_t* ctx, int from, int to, W64* out);++inline void init_tweak(UBIType type, W64* t);+inline void mk_config_tweak(W64* t);+inline void set_type(UBIType type, W64* t);+inline void set_first(unsigned char first, W64* t);+inline void set_last(unsigned char last, W64* t);+inline void add_bytes(W64 bytes, W64* t);++#endif
threefish.cabal view
@@ -1,5 +1,5 @@ name: threefish-version: 0.2.3+version: 0.2.4 synopsis: The Threefish block cipher and the Skein hash function for Haskell. description: Implements 256 and 512 bit variants of Threefish and Skein. Skein is usable as a "normal" hash function as well as in Skein-MAC, as a cryptographically secure PRNG, as a stream cipher and as a key derivation function, all implemented according to the specifications of the Skein 1.3 paper. homepage: http://github.com/valderman/threefish@@ -49,7 +49,7 @@ default-language: Haskell2010 ghc-options: -Wall -O2 include-dirs: cbits- includes:+ install-includes: threefish.h c-sources: cbits/threefish256.c,