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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to