From dev-return-169804-archive-asf-public=cust-asf.ponee.io@commons.apache.org Mon Feb 11 18:59:14 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 353A9180669 for ; Mon, 11 Feb 2019 19:59:14 +0100 (CET) Received: (qmail 87139 invoked by uid 500); 11 Feb 2019 18:59:07 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 86488 invoked by uid 99); 11 Feb 2019 18:59:07 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2019 18:59:07 +0000 From: GitBox To: dev@commons.apache.org Subject: [GitHub] vanzin commented on a change in pull request #92: OpenSSL 1.1.0 updates with backward compatibility for OpenSSL 1.0.2 and 1.0.1 Message-ID: <154991154670.12220.9348729221101739077.gitbox@gitbox.apache.org> Date: Mon, 11 Feb 2019 18:59:06 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit vanzin commented on a change in pull request #92: OpenSSL 1.1.0 updates with backward compatibility for OpenSSL 1.0.2 and 1.0.1 URL: https://github.com/apache/commons-crypto/pull/92#discussion_r255646781 ########## File path: src/main/native/org/apache/commons/crypto/cipher/OpenSslNative.c ########## @@ -716,3 +677,52 @@ JNIEXPORT void JNICALL Java_org_apache_commons_crypto_cipher_OpenSslNative_clean EVP_CTX_Wrapper *wrapper = CTX_WRAPPER(ctx); free_context_wrapper(wrapper); } + +static int check_update_max_output_len(JNIEnv *env, EVP_CIPHER_CTX *context, jlong ctx, int input_len, int max_output_len) +{ + EVP_CTX_Wrapper *wrapper = CTX_WRAPPER(ctx); + if (dlsym_EVP_CIPHER_CTX_test_flags(context, EVP_CIPH_NO_PADDING) == EVP_CIPH_NO_PADDING) { + if (max_output_len >= input_len) { + return 1; + } + return 0; + } else { + int b = dlsym_EVP_CIPHER_CTX_block_size(context); + if (wrapper->encrypt) { + if (max_output_len >= input_len + b - 1) { + return 1; + } + } else { + if (max_output_len >= input_len + b) { + return 1; + } + } + return 0; + } +} + +static int check_doFinal_max_output_len(JNIEnv *env, EVP_CIPHER_CTX *context, int max_output_len) +{ + if (dlsym_EVP_CIPHER_CTX_test_flags(context, EVP_CIPH_NO_PADDING) == EVP_CIPH_NO_PADDING) { + return 1; + } else { + int b = dlsym_EVP_CIPHER_CTX_block_size(context); + if (max_output_len >= b) { + return 1; + } + return 0; Review comment: indentation ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org