aboutsummaryrefslogtreecommitdiff
path: root/crypto/evp/evp_enc.c
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2001-07-08 17:27:32 +0000
committerBen Laurie <ben@openssl.org>2001-07-08 17:27:32 +0000
commitf31b12503e6de9252d552b35df3e6e0f1f217b68 (patch)
treeea9713f8935609ee04624501d14baffaa415f1cc /crypto/evp/evp_enc.c
parentf82197ad75cb012836bc58adaaa77aa59a1deeb2 (diff)
downloadopenssl-f31b12503e6de9252d552b35df3e6e0f1f217b68.zip
openssl-f31b12503e6de9252d552b35df3e6e0f1f217b68.tar.gz
openssl-f31b12503e6de9252d552b35df3e6e0f1f217b68.tar.bz2
Use & instead of % - worth about 4% for 8 byte blocks.
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r--crypto/evp/evp_enc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 14c8506..ae1a22e 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -62,6 +62,8 @@
#include <openssl/err.h>
#include "evp_locl.h"
+#include <assert.h>
+
const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT;
void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
@@ -88,6 +90,12 @@ int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET);
return 0;
}
+
+ /* we assume block size is a power of 2 in *cryptUpdate */
+ assert(ctx->cipher->block_size == 1
+ || ctx->cipher->block_size == 8
+ || ctx->cipher->block_size == 16);
+
if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
switch(EVP_CIPHER_CTX_mode(ctx)) {
@@ -147,7 +155,6 @@ int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
return EVP_CipherInit(ctx, cipher, key, iv, 0);
}
-
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
unsigned char *in, int inl)
{
@@ -176,7 +183,8 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
*outl+=bl;
}
}
- i=inl%bl; /* how much is left */
+ // i=inl%bl; /* how much is left */
+ i=inl&(bl-1);
inl-=i;
if (inl > 0)
{