From 9b33e0a4893772bd3689c8403a7754593410469a Mon Sep 17 00:00:00 2001 From: djm <> Date: Wed, 6 Oct 2010 22:57:46 +0000 Subject: More OpenSSL fixes: - Update local engines for the EVP API change (len u_int => size_t) - Use hw_cryptodev.c instead of eng_cryptodev.c - Make x86_64-xlate.pl always write to the output file and not stdout, fixing "make -j" builds (spotted by naddy@) ok naddy@ --- src/lib/libcrypto/engine/eng_aesni.c | 8 ++++---- src/lib/libcrypto/engine/hw_cryptodev.c | 16 +++++++++------- src/lib/libcrypto/perlasm/x86_64-xlate.pl | 2 +- src/lib/libssl/crypto/Makefile | 4 ++-- src/lib/libssl/src/crypto/engine/eng_aesni.c | 8 ++++---- src/lib/libssl/src/crypto/engine/hw_cryptodev.c | 16 +++++++++------- src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl | 2 +- 7 files changed, 30 insertions(+), 26 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/engine/eng_aesni.c b/src/lib/libcrypto/engine/eng_aesni.c index eeded1eefa..5fdb33bfde 100644 --- a/src/lib/libcrypto/engine/eng_aesni.c +++ b/src/lib/libcrypto/engine/eng_aesni.c @@ -438,20 +438,20 @@ aesni_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *user_key, } static int aesni_cipher_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); aesni_ecb_encrypt(in, out, inl, key, ctx->encrypt); return 1; } static int aesni_cipher_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); aesni_cbc_encrypt(in, out, inl, key, ctx->iv, ctx->encrypt); return 1; } static int aesni_cipher_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); aesni_cfb128_encrypt(in, out, inl, key, ctx->iv, @@ -459,7 +459,7 @@ static int aesni_cipher_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out, return 1; } static int aesni_cipher_ofb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); aesni_ofb128_encrypt(in, out, inl, key, ctx->iv, &ctx->num); return 1; diff --git a/src/lib/libcrypto/engine/hw_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c index 03022f2fd3..6ac2f9be30 100644 --- a/src/lib/libcrypto/engine/hw_cryptodev.c +++ b/src/lib/libcrypto/engine/hw_cryptodev.c @@ -56,13 +56,13 @@ ENGINE_load_cryptodev(void) #include #include -#include -#include #include +#include #include -#include -#include +#include #include +#include +#include #if defined(__i386__) || defined(__amd64__) #include @@ -97,7 +97,7 @@ static int get_cryptodev_ciphers(const int **cnids); static int cryptodev_usable_ciphers(const int **nids); static int cryptodev_usable_digests(const int **nids); static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl); + const unsigned char *in, size_t inl); static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx); @@ -381,7 +381,7 @@ cryptodev_usable_digests(const int **nids) static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { struct crypt_op cryp; struct dev_crypto_state *state = ctx->cipher_data; @@ -644,7 +644,7 @@ viac3_xcrypt_cbc(int *cw, const void *src, void *dst, void *key, int rep, static int xcrypt_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { unsigned char *save_iv_store[EVP_MAX_IV_LENGTH + 15]; unsigned char *save_iv = DOALIGN(save_iv_store); @@ -659,6 +659,8 @@ xcrypt_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, return (1); if ((inl % ctx->cipher->block_size) != 0) return (0); + if (inl > UINT_MAX) + return (0); if (ISUNALIGNED(in) || ISUNALIGNED(out)) { spare = malloc(inl); diff --git a/src/lib/libcrypto/perlasm/x86_64-xlate.pl b/src/lib/libcrypto/perlasm/x86_64-xlate.pl index 8153a92a7b..d66ad24095 100755 --- a/src/lib/libcrypto/perlasm/x86_64-xlate.pl +++ b/src/lib/libcrypto/perlasm/x86_64-xlate.pl @@ -66,7 +66,7 @@ if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } my ($outdev,$outino,@junk)=stat($output); open STDOUT,">$output" || die "can't open $output: $!" - if ($stddev!=$outdev || $stdino!=$outino); + if (1 || $stddev!=$outdev || $stdino!=$outino); } my $gas=1; $gas=0 if ($output =~ /\.asm$/); diff --git a/src/lib/libssl/crypto/Makefile b/src/lib/libssl/crypto/Makefile index 93657a0bb8..dfcfffe193 100644 --- a/src/lib/libssl/crypto/Makefile +++ b/src/lib/libssl/crypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.56 2010/10/04 19:15:40 naddy Exp $ +# $OpenBSD: Makefile,v 1.57 2010/10/06 22:57:46 djm Exp $ LIB= crypto WANTLINT= @@ -150,7 +150,7 @@ SRCS+= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c SRCS+= eng_table.c eng_pkey.c eng_fat.c eng_all.c SRCS+= tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c SRCS+= tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c -SRCS+= eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c +SRCS+= eng_openssl.c eng_cnf.c eng_dyn.c hw_cryptodev.c SRCS+= eng_aesni.c # local addition # err/ diff --git a/src/lib/libssl/src/crypto/engine/eng_aesni.c b/src/lib/libssl/src/crypto/engine/eng_aesni.c index eeded1eefa..5fdb33bfde 100644 --- a/src/lib/libssl/src/crypto/engine/eng_aesni.c +++ b/src/lib/libssl/src/crypto/engine/eng_aesni.c @@ -438,20 +438,20 @@ aesni_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *user_key, } static int aesni_cipher_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); aesni_ecb_encrypt(in, out, inl, key, ctx->encrypt); return 1; } static int aesni_cipher_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); aesni_cbc_encrypt(in, out, inl, key, ctx->iv, ctx->encrypt); return 1; } static int aesni_cipher_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); aesni_cfb128_encrypt(in, out, inl, key, ctx->iv, @@ -459,7 +459,7 @@ static int aesni_cipher_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out, return 1; } static int aesni_cipher_ofb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); aesni_ofb128_encrypt(in, out, inl, key, ctx->iv, &ctx->num); return 1; diff --git a/src/lib/libssl/src/crypto/engine/hw_cryptodev.c b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c index 03022f2fd3..6ac2f9be30 100644 --- a/src/lib/libssl/src/crypto/engine/hw_cryptodev.c +++ b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c @@ -56,13 +56,13 @@ ENGINE_load_cryptodev(void) #include #include -#include -#include #include +#include #include -#include -#include +#include #include +#include +#include #if defined(__i386__) || defined(__amd64__) #include @@ -97,7 +97,7 @@ static int get_cryptodev_ciphers(const int **cnids); static int cryptodev_usable_ciphers(const int **nids); static int cryptodev_usable_digests(const int **nids); static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl); + const unsigned char *in, size_t inl); static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx); @@ -381,7 +381,7 @@ cryptodev_usable_digests(const int **nids) static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { struct crypt_op cryp; struct dev_crypto_state *state = ctx->cipher_data; @@ -644,7 +644,7 @@ viac3_xcrypt_cbc(int *cw, const void *src, void *dst, void *key, int rep, static int xcrypt_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, unsigned int inl) + const unsigned char *in, size_t inl) { unsigned char *save_iv_store[EVP_MAX_IV_LENGTH + 15]; unsigned char *save_iv = DOALIGN(save_iv_store); @@ -659,6 +659,8 @@ xcrypt_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, return (1); if ((inl % ctx->cipher->block_size) != 0) return (0); + if (inl > UINT_MAX) + return (0); if (ISUNALIGNED(in) || ISUNALIGNED(out)) { spare = malloc(inl); diff --git a/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl b/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl index 8153a92a7b..d66ad24095 100755 --- a/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl +++ b/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl @@ -66,7 +66,7 @@ if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } my ($outdev,$outino,@junk)=stat($output); open STDOUT,">$output" || die "can't open $output: $!" - if ($stddev!=$outdev || $stdino!=$outino); + if (1 || $stddev!=$outdev || $stdino!=$outino); } my $gas=1; $gas=0 if ($output =~ /\.asm$/); -- cgit v1.2.3-55-g6feb