Skip to content

Allow to use different sizes for both BIO buffers. - #210

Closed
normanmaurer wants to merge 1 commit into
1.1.33from
max_size_bio_2
Closed

normanmaurer wants to merge 1 commit into
1.1.33from
max_size_bio_2

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

e691680 introduced a new method that allowed to set the BIO buffer size but this size is used for both buffers while sometimes different sizes can make sense.

Modifications:

Add new method that take two different buffer sizes.

Result:

More flexible way of creating network BIOs.

@normanmaurer

Copy link
Copy Markdown
Member Author

@nmittler @Scottmitch

@nmittler nmittler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@normanmaurer is this an API-breaking change?

@normanmaurer

Copy link
Copy Markdown
Member Author

@nmittler nope as the old java methods are still there. Only the native method changed and new java methods were added.

Comment thread openssl-dynamic/src/main/c/ssl.c Outdated
}

TCN_IMPLEMENT_CALL(jlong, SSL, makeNetworkBIO)(TCN_STDARGS, jlong ssl) {
TCN_IMPLEMENT_CALL(jlong, SSL, makeNetworkBIO)(TCN_STDARGS, jlong ssl, jint max_bio_size1, jint max_bio_size2) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_bio_size1 -> maxInternalBIOSize
max_bio_size2 -> maxNetworkBIOSize

* the provided SSL instance, you must call freeBIO on the returned network BIO.
*
* @param ssl the SSL instance (SSL *)
* @param maxInternalBIOSize The maximum size of the BIO. Pass 0 to use the default max size.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clarify that this BIO is on the application side. also do the same for the network BIO. Add a link to https://www.openssl.org/docs/man1.0.1/crypto/BIO_s_bio.html (see the example section)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


if (max_bio_size < 0) {
tcn_ThrowException(e, "max_bio_size < 0");
if (maxInternalBIOSize < 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: most of the time this will not be violated ... I wonder if we can just reduce the amount of conditionals and combine the precondition check into a single conditional:

if (maxInternalBIOSize < 0 || maxNetworkBIOSize < 0) {
  tcn_ThrowException(e, "maxInternalBIOSize and maxNetworkBIOSize both must be >= 0");
  return 0;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Scottmitch let us just keep it as it is as this one will be called only very infrequently anyway.

Motivation:

e691680 introduced a new method that allowed to set the BIO buffer size but this size is used for both buffers while sometimes different sizes can make sense.

Modifications:

Add new method that take two different buffer sizes.

Result:

More flexible way of creating network BIOs.
@normanmaurer

Copy link
Copy Markdown
Member Author

@Scottmitch PTAL again

@normanmaurer

Copy link
Copy Markdown
Member Author

Cherry-picked into 1.1.33 (c542258) and master (1fedfa6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants