diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-05-23 23:34:36 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-05-23 23:34:36 +0200 |
commit | 55debbe38429b81c0ce6e8400aef36812eb151d7 (patch) | |
tree | 992320729b697015fb4b99e9f8645cffe2eeddd6 /src/sha256.c | |
parent | c39125d7c45d17566665c06358501073ea9c4141 (diff) | |
download | vim-git-55debbe38429b81c0ce6e8400aef36812eb151d7.tar.gz |
Included patch for persistent undo. Lots of changes and added test.
Diffstat (limited to 'src/sha256.c')
-rw-r--r-- | src/sha256.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/sha256.c b/src/sha256.c index 9372d5f00..048ce75fe 100644 --- a/src/sha256.c +++ b/src/sha256.c @@ -20,18 +20,9 @@ #include "vim.h" -#ifdef FEAT_CRYPT +#if defined(FEAT_CRYPT) || defined(FEAT_PERSISTENT_UNDO) -typedef struct { - UINT32_T total[2]; - UINT32_T state[8]; - char_u buffer[64]; -} context_sha256_T; - -static void sha256_starts __ARGS((context_sha256_T *ctx)); static void sha256_process __ARGS((context_sha256_T *ctx, char_u data[64])); -static void sha256_update __ARGS((context_sha256_T *ctx, char_u *input, UINT32_T length)); -static void sha256_finish __ARGS((context_sha256_T *ctx, char_u digest[32])); static char_u *sha256_bytes __ARGS((char_u *buf, int buflen)); static unsigned int get_some_time __ARGS((void)); @@ -52,8 +43,8 @@ static unsigned int get_some_time __ARGS((void)); (b)[(i) + 3] = (char_u)((n) ); \ } - static void -sha256_starts(ctx) + void +sha256_start(ctx) context_sha256_T *ctx; { ctx->total[0] = 0; @@ -203,7 +194,7 @@ sha256_process(ctx, data) ctx->state[7] += H; } - static void + void sha256_update(ctx, input, length) context_sha256_T *ctx; char_u *input; @@ -250,7 +241,7 @@ static char_u sha256_padding[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - static void + void sha256_finish(ctx, digest) context_sha256_T *ctx; char_u digest[32]; @@ -296,7 +287,7 @@ sha256_bytes(buf, buflen) sha256_self_test(); - sha256_starts(&ctx); + sha256_start(&ctx); sha256_update(&ctx, buf, buflen); sha256_finish(&ctx, sha256sum); for (j = 0; j < 32; j++) @@ -368,7 +359,7 @@ sha256_self_test() } else { - sha256_starts(&ctx); + sha256_start(&ctx); memset(buf, 'a', 1000); for (j = 0; j < 1000; j++) sha256_update(&ctx, (char_u *)buf, 1000); @@ -416,7 +407,7 @@ sha2_seed(header, header_len) for (i = 0; i < (int)sizeof(random_data) - 1; i++) random_data[i] = (char_u)((get_some_time() ^ rand()) & 0xff); - sha256_starts(&ctx); + sha256_start(&ctx); sha256_update(&ctx, (char_u *)random_data, sizeof(random_data)); sha256_finish(&ctx, sha256sum); @@ -424,4 +415,4 @@ sha2_seed(header, header_len) header[i] = sha256sum[i % sizeof(sha256sum)]; } -#endif /* FEAT_CRYPT */ +#endif /* FEAT_CRYPT || FEAT_PERSISTENT_UNDO */ |