diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-06-01 23:37:39 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-06-01 23:37:39 +0200 |
commit | 04c9bafa7136564e3059d493dffa84a4c9b6dfb7 (patch) | |
tree | 6f000d5eca2d4494d97cb638308c7c95d471f3de /src/blowfish.c | |
parent | 8cd213c09a3598834888d81deb45ff17e6654a86 (diff) | |
download | vim-git-04c9bafa7136564e3059d493dffa84a4c9b6dfb7.tar.gz |
Made crypt/decrypt faster.
Diffstat (limited to 'src/blowfish.c')
-rw-r--r-- | src/blowfish.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/blowfish.c b/src/blowfish.c index e449da38f..f88cbfdea 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -18,6 +18,7 @@ #define ARRAY_LENGTH(A) (sizeof(A)/sizeof(A[0])) #define BF_BLOCK 8 +#define BF_BLOCK_MASK 7 #define BF_OFB_LEN (8*(BF_BLOCK)) typedef union { @@ -563,14 +564,14 @@ bf_ofb_update(c) int bf_ranbyte() { - int current_byte = randbyte_offset++; - int current_block = (current_byte / BF_BLOCK) * BF_BLOCK; + int b; - if (randbyte_offset == BF_OFB_LEN) + if ((randbyte_offset & BF_BLOCK_MASK) == 0) + bf_e_cblock(&ofb_buffer[randbyte_offset]); + b = ofb_buffer[randbyte_offset]; + if (++randbyte_offset == BF_OFB_LEN) randbyte_offset = 0; - if ((current_byte % BF_BLOCK) == 0) - bf_e_cblock(&ofb_buffer[current_block]); - return ofb_buffer[current_byte]; + return b; } /* |