Home | History | Annotate | Download | only in ssl

Lines Matching refs:ssl

15 #include <openssl/ssl.h>
40 OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
47 OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
79 static int setup_read_buffer(SSL *ssl) {
80 SSL3_BUFFER *buf = &ssl->s3->read_buffer;
86 size_t header_len = ssl_record_prefix_len(ssl);
88 if (SSL_IS_DTLS(ssl)) {
97 uint8_t *ssl_read_buffer(SSL *ssl) {
98 return ssl->s3->read_buffer.buf + ssl->s3->read_buffer.offset;
101 size_t ssl_read_buffer_len(const SSL *ssl) {
102 return ssl->s3->read_buffer.len;
105 static int dtls_read_buffer_next_packet(SSL *ssl) {
106 SSL3_BUFFER *buf = &ssl->s3->read_buffer;
111 OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
115 /* Read a single packet from |ssl->rbio|. |buf->cap| must fit in an int. */
116 ssl->rwstate = SSL_READING;
117 int ret = BIO_read(ssl->rbio, buf->buf + buf->offset, (int)buf->cap);
121 ssl->rwstate = SSL_NOTHING;
127 static int tls_read_buffer_extend_to(SSL *ssl, size_t len) {
128 SSL3_BUFFER *buf = &ssl->s3->read_buffer;
131 OPENSSL_PUT_ERROR(SSL, SSL_R_BUFFER_TOO_SMALL);
139 ssl->rwstate = SSL_READING;
140 int ret = BIO_read(ssl->rbio, buf->buf + buf->offset + buf->len,
145 ssl->rwstate = SSL_NOTHING;
154 int ssl_read_buffer_extend_to(SSL *ssl, size_t len) {
156 ssl_read_buffer_discard(ssl);
158 if (!setup_read_buffer(ssl)) {
162 if (ssl->rbio == NULL) {
163 OPENSSL_PUT_ERROR(SSL, SSL_R_BIO_NOT_SET);
170 if (SSL_IS_DTLS(ssl)) {
172 ret = dtls_read_buffer_next_packet(ssl);
174 ret = tls_read_buffer_extend_to(ssl, len);
180 ssl_read_buffer_discard(ssl);
185 void ssl_read_buffer_consume(SSL *ssl, size_t len) {
186 SSL3_BUFFER *buf = &ssl->s3->read_buffer;
189 if (!SSL_IS_DTLS(ssl)) {
199 void ssl_read_buffer_discard(SSL *ssl) {
200 if (ssl->s3->read_buffer.len == 0) {
201 ssl_read_buffer_clear(ssl);
205 void ssl_read_buffer_clear(SSL *ssl) {
206 clear_buffer(&ssl->s3->read_buffer);
210 int ssl_write_buffer_is_pending(const SSL *ssl) {
211 return ssl->s3->write_buffer.len > 0;
224 int ssl_write_buffer_init(SSL *ssl, uint8_t **out_ptr, size_t max_len) {
225 SSL3_BUFFER *buf = &ssl->s3->write_buffer;
228 OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
232 size_t header_len = ssl_seal_prefix_len(ssl);
237 if (SSL_IS_DTLS(ssl)) {
241 if (ssl->mode & SSL_MODE_CBC_RECORD_SPLITTING) {
247 OPENSSL_PUT_ERROR(SSL, SSL_R_BUFFER_TOO_SMALL);
258 void ssl_write_buffer_set_len(SSL *ssl, size_t len) {
259 SSL3_BUFFER *buf = &ssl->s3->write_buffer;
267 static int tls_write_buffer_flush(SSL *ssl) {
268 SSL3_BUFFER *buf = &ssl->s3->write_buffer;
271 ssl->rwstate = SSL_WRITING;
272 int ret = BIO_write(ssl->wbio, buf->buf + buf->offset, buf->len);
276 ssl->rwstate = SSL_NOTHING;
279 ssl_write_buffer_clear(ssl);
283 static int dtls_write_buffer_flush(SSL *ssl) {
284 SSL3_BUFFER *buf = &ssl->s3->write_buffer;
289 ssl->rwstate = SSL_WRITING;
290 int ret = BIO_write(ssl->wbio, buf->buf + buf->offset, buf->len);
295 ssl_write_buffer_clear(ssl);
298 ssl->rwstate = SSL_NOTHING;
299 ssl_write_buffer_clear(ssl);
303 int ssl_write_buffer_flush(SSL *ssl) {
304 if (ssl->wbio == NULL) {
305 OPENSSL_PUT_ERROR(SSL, SSL_R_BIO_NOT_SET);
310 if (SSL_IS_DTLS(ssl)) {
311 return dtls_write_buffer_flush(ssl);
313 return tls_write_buffer_flush(ssl);
317 void ssl_write_buffer_clear(SSL *ssl) {
318 clear_buffer(&ssl->s3->write_buffer);