If a project is statically compiled with OpenSSL, can it take only affected parts of…
- User
If a project is statically compiled with OpenSSL, can it take only affected parts of libssl and librcypto and include only minimum of OpenSSL library? Shortly
- Assistant
No, if a project is statically linked with OpenSSL, it typically includes the entire OpenSSL library (libssl and libcrypto) code within the binary. Static linking involves incorporating all the necessary library code into the final executable at compile time, so the final binary can run independently without the need for separate library files.
However, it's not common to pick and choose "affected parts" of OpenSSL to statically compile into your project. OpenSSL doesn't straightforwardly support such partial inclusion because its components are interdependent, and the library relies on internal functions and structures that may be difficult to extricate.
- User
Why libssl and libcrypto are separate libraries? Aren't they parts of OpenDSL? breadline
- Assistant
OpenSSL is an open-source cryptographic library that primarily consists of two key libraries:
libsslandlibcrypto. These two libraries are separated due to their distinct functionalities: - User
Can you give a complete example of tcp client using TLS with OpenSSL' memory BIO only focusing on principal that OpenSSL shouldn't send to and receive data from network. Give an example of Epoll client with manual handshake implementation and send, recv system calls. Comment everything affected my question. Please give very good and comprehensive example.
- Assistant
- User
Is iy correct that there is BIO_write and not SSL_read? briefly
- Assistant
In the context of using OpenSSL with memory BIOs,
BIO_write()is used to write data into the memory BIO that OpenSSL will use for the SSL protocol. The data could be anything that is supposed be processed by OpenSSL, often received from a network socket and then fed into the SSL engine.Here's the distinction:
-
BIO_write(bio, buf, len)is used whenever you have raw data (such as data read from a TCP socket) that you want to pass to OpenSSL. This data is typically encrypted SSL/TLS data that OpenSSL needs to process. -
SSL_read(ssl, buf, num)is used to read decrypted application data from the SSL/TLS layer. It will only return application data that has been successfully decrypted and is ready for use by the application.
Both are essential when manually handling the I/O for an OpenSSL connection:
-
When data is received from the peer over the network, you use
recv()to read the data from the socket, and thenBIO_write()to write the received data into the SSL's read BIO for processing by OpenSSL.
-
- User
Can you give an example of reviving data from recv and decrypting it to plaintext?
- Assistant
Certainly! Below is an example that demonstrates how to receive data with
recv(), decrypt it with OpenSSL using memory BIOs, and obtain the plaintext. This example assumes you've already set up the SSL context, SSL object, and both read and write memory BIOs. It is also assumed that you've already completed the SSL handshake. The code comments will help to explain each step. - User
What's minimum data for SSL_ERROR_WANT_READ not to occur? If SSL_read retutns such an error will data written with BIO_write(SSL_get_rbio(ssl) to OpenSSL buffer be flushed or it will remain there until SSL_read is complete? How much data can the BIO buffer teke? Can I get and set the limit? Can I get a data there without flushing the BIO buffer?
- Assistant
- User
What's tls1.3 maximum record size? Briefly
- Assistant
In TLS 1.3, the maximum record size remains the same as in previous versions during the handshake and immediately after: 16384 bytes (16 KB) for the actual encrypted data, not including the record header and additional overhead from encryption (which may include explicit IVs and authentication tags). However, TLS 1.3 has a feature called "record size limit" that allows peers to negotiate smaller maximum record sizes if they wish.
Here's the general breakdown:
- Max encrypted record payload: 16384 bytes
- Record header: 5 bytes (for the record type, major version, minor version, and 2 bytes for the length)
- Encryption overhead: Variable depending on the cipher suite (for instance, the AEAD encryption tag)
The specific overhead from encryption (Authenticated Encryption with Associated Data, or AEAD) is algorithm-dependent but will generally include a tag that can be up to 16 bytes (128 bits) in length. This brings the total potential maximum size of a packed TLS 1.3 record to slightly over 16 KB.
- User
Can you give an example of writing data to "send" and encrypt it from plaintext first?
- Assistant
- User
If SSL_ERROR_WANT_WRITE error occurs on SSL_write, does it mean that data written to BIO remains in the BIO buffer unti it will be enough to flush it with BIO_read ?
- Assistant
If
SSL_write()returns anSSL_ERROR_WANT_WRITEerror, it typically indicates that the SSL object needs to write more data to the underlying BIO before it can complete the operation thatSSL_write()was trying to perform. This scenario is most common in non-blocking I/O settings where the underlying BIO is a socket BIO, and the socket is not ready to accept more data (e.g., the send buffer is full).In the case of a memory-based BIO (), which is used to buffer data in memory, would not typically occur because a memory BIO can grow to accommodate the data as long as the system has enough memory.