diff options
Diffstat (limited to 'plugins/MirOTR/Libgcrypt/cipher/seed.c')
-rw-r--r-- | plugins/MirOTR/Libgcrypt/cipher/seed.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/plugins/MirOTR/Libgcrypt/cipher/seed.c b/plugins/MirOTR/Libgcrypt/cipher/seed.c index b0980d61ec..9f87c05589 100644 --- a/plugins/MirOTR/Libgcrypt/cipher/seed.c +++ b/plugins/MirOTR/Libgcrypt/cipher/seed.c @@ -29,15 +29,12 @@ #include "types.h" /* for byte and u32 typedefs */ #include "g10lib.h" #include "cipher.h" +#include "bufhelp.h" #define NUMKC 16 -#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \ - ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) -#define PUTU32(ct, st) { (ct)[0] = (byte)((st) >> 24); \ - (ct)[1] = (byte)((st) >> 16); \ - (ct)[2] = (byte)((st) >> 8); \ - (ct)[3] = (byte)(st); } +#define GETU32(pt) buf_get_be32(pt) +#define PUTU32(ct, st) buf_put_be32(ct, st) union wordbuf { @@ -59,7 +56,7 @@ union wordbuf static const char *selftest(void); -typedef struct +typedef struct { u32 keyschedule[32]; } SEED_context; @@ -258,7 +255,7 @@ static const u32 KC[NUMKC] = { /* Perform the key setup. - */ + */ static gcry_err_code_t do_setkey (SEED_context *ctx, const byte *key, const unsigned keylen) { @@ -371,13 +368,13 @@ do_encrypt (const SEED_context *ctx, byte *outbuf, const byte *inbuf) PUTU32 (outbuf+12, x2); } -static void +static unsigned int seed_encrypt (void *context, byte *outbuf, const byte *inbuf) { SEED_context *ctx = context; do_encrypt (ctx, outbuf, inbuf); - _gcry_burn_stack (4*6); + return /*burn_stack*/ (4*6); } @@ -417,13 +414,13 @@ do_decrypt (SEED_context *ctx, byte *outbuf, const byte *inbuf) PUTU32 (outbuf+12, x2); } -static void +static unsigned int seed_decrypt (void *context, byte *outbuf, const byte *inbuf) { SEED_context *ctx = context; do_decrypt (ctx, outbuf, inbuf); - _gcry_burn_stack (4*6); + return /*burn_stack*/ (4*6); } @@ -432,7 +429,7 @@ static const char* selftest (void) { SEED_context ctx; - byte scratch[16]; + byte scratch[16]; /* The test vector is taken from the appendix section B.3 of RFC4269. */ @@ -473,6 +470,7 @@ static gcry_cipher_oid_spec_t seed_oids[] = gcry_cipher_spec_t _gcry_cipher_spec_seed = { + GCRY_CIPHER_SEED, {0, 0}, "SEED", NULL, seed_oids, 16, 128, sizeof (SEED_context), seed_setkey, seed_encrypt, seed_decrypt, }; |