summaryrefslogtreecommitdiffstats
path: root/src/blowfish.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-06-01 23:37:39 +0200
committerBram Moolenaar <Bram@vim.org>2010-06-01 23:37:39 +0200
commit04c9bafa7136564e3059d493dffa84a4c9b6dfb7 (patch)
tree6f000d5eca2d4494d97cb638308c7c95d471f3de /src/blowfish.c
parent8cd213c09a3598834888d81deb45ff17e6654a86 (diff)
Made crypt/decrypt faster.
Diffstat (limited to 'src/blowfish.c')
-rw-r--r--src/blowfish.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/blowfish.c b/src/blowfish.c
index e449da38fc..f88cbfdeac 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;
}
/*