From: Ben Laurie Date: Sun, 8 Jul 2001 17:27:32 +0000 (+0000) Subject: Use & instead of % - worth about 4% for 8 byte blocks. X-Git-Tag: OpenSSL_0_9_6c~182^2~42 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f31b12503e6de9252d552b35df3e6e0f1f217b68;p=oweals%2Fopenssl.git Use & instead of % - worth about 4% for 8 byte blocks. --- diff --git a/CHANGES b/CHANGES index 94acfc5268..78a894d443 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,24 @@ *) applies to 0.9.6a (/0.9.6b) and 0.9.7 +) applies to 0.9.7 only + +) Speed up EVP routines. + Before: +encrypt +type 8 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes +des-cbc 4408.85k 5560.51k 5778.46k 5862.20k 5825.16k +des-cbc 4389.55k 5571.17k 5792.23k 5846.91k 5832.11k +des-cbc 4394.32k 5575.92k 5807.44k 5848.37k 5841.30k +decrypt +des-cbc 3482.66k 5069.49k 5496.39k 5614.16k 5639.28k +des-cbc 3480.74k 5068.76k 5510.34k 5609.87k 5635.52k +des-cbc 3483.72k 5067.62k 5504.60k 5708.01k 5724.80k + After: +encrypt +des-cbc 4581.64k 5666.39k 5811.23k 5871.60k 5833.23k +decrypt +des-cbc 3615.18k 5102.53k 5501.58k 5631.13k 5635.52k + [Ben Laurie] + *) Fix crypto/bn/asm/mips3.s. [Andy Polyakov] diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 14c8506e80..ae1a22ebb8 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -62,6 +62,8 @@ #include #include "evp_locl.h" +#include + 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) {