1 /* 2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the OpenSSL license (the "License"). You may not use 5 * this file except in compliance with the License. You can obtain a copy 6 * in the file LICENSE in the source distribution or at 7 * https://www.openssl.org/source/license.html 8 */ 9 10 #ifndef OPENSSL_HEADER_BIO_H 11 #define OPENSSL_HEADER_BIO_H 12 13 #include <openssl/base.h> 14 15 #include <stdio.h> // For FILE 16 17 #include <openssl/buffer.h> 18 #include <openssl/err.h> // for ERR_print_errors_fp 19 #include <openssl/ex_data.h> 20 #include <openssl/stack.h> 21 #include <openssl/thread.h> 22 23 #if defined(__cplusplus) 24 extern "C" { 25 #endif 26 27 28 // BIO abstracts over a file-descriptor like interface. 29 30 31 // Allocation and freeing. 32 33 DEFINE_STACK_OF(BIO) 34 35 // BIO_new creates a new BIO with the given method and a reference count of one. 36 // It returns the fresh |BIO|, or NULL on error. 37 OPENSSL_EXPORT BIO *BIO_new(const BIO_METHOD *method); 38 39 // BIO_free decrements the reference count of |bio|. If the reference count 40 // drops to zero, it calls the destroy callback, if present, on the method and 41 // frees |bio| itself. It then repeats that for the next BIO in the chain, if 42 // any. 43 // 44 // It returns one on success or zero otherwise. 45 OPENSSL_EXPORT int BIO_free(BIO *bio); 46 47 // BIO_vfree performs the same actions as |BIO_free|, but has a void return 48 // value. This is provided for API-compat. 49 // 50 // TODO(fork): remove. 51 OPENSSL_EXPORT void BIO_vfree(BIO *bio); 52 53 // BIO_up_ref increments the reference count of |bio| and returns one. 54 OPENSSL_EXPORT int BIO_up_ref(BIO *bio); 55 56 57 // Basic I/O. 58 59 // BIO_read attempts to read |len| bytes into |data|. It returns the number of 60 // bytes read, zero on EOF, or a negative number on error. 61 OPENSSL_EXPORT int BIO_read(BIO *bio, void *data, int len); 62 63 // BIO_gets reads a line from |bio| and writes at most |size| bytes into |buf|. 64 // It returns the number of bytes read or a negative number on error. This 65 // function's output always includes a trailing NUL byte, so it will read at 66 // most |size - 1| bytes. 67 // 68 // If the function read a complete line, the output will include the newline 69 // character, '\n'. If no newline was found before |size - 1| bytes or EOF, it 70 // outputs the bytes which were available. 71 OPENSSL_EXPORT int BIO_gets(BIO *bio, char *buf, int size); 72 73 // BIO_write writes |len| bytes from |data| to |bio|. It returns the number of 74 // bytes written or a negative number on error. 75 OPENSSL_EXPORT int BIO_write(BIO *bio, const void *data, int len); 76 77 // BIO_write_all writes |len| bytes from |data| to |bio|, looping as necessary. 78 // It returns one if all bytes were successfully written and zero on error. 79 OPENSSL_EXPORT int BIO_write_all(BIO *bio, const void *data, size_t len); 80 81 // BIO_puts writes a NUL terminated string from |buf| to |bio|. It returns the 82 // number of bytes written or a negative number on error. 83 OPENSSL_EXPORT int BIO_puts(BIO *bio, const char *buf); 84 85 // BIO_flush flushes any buffered output. It returns one on success and zero 86 // otherwise. 87 OPENSSL_EXPORT int BIO_flush(BIO *bio); 88 89 90 // Low-level control functions. 91 // 92 // These are generic functions for sending control requests to a BIO. In 93 // general one should use the wrapper functions like |BIO_get_close|. 94 95 // BIO_ctrl sends the control request |cmd| to |bio|. The |cmd| argument should 96 // be one of the |BIO_C_*| values. 97 OPENSSL_EXPORT long BIO_ctrl(BIO *bio, int cmd, long larg, void *parg); 98 99 // BIO_ptr_ctrl acts like |BIO_ctrl| but passes the address of a |void*| 100 // pointer as |parg| and returns the value that is written to it, or NULL if 101 // the control request returns <= 0. 102 OPENSSL_EXPORT char *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); 103 104 // BIO_int_ctrl acts like |BIO_ctrl| but passes the address of a copy of |iarg| 105 // as |parg|. 106 OPENSSL_EXPORT long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); 107 108 // BIO_reset resets |bio| to its initial state, the precise meaning of which 109 // depends on the concrete type of |bio|. It returns one on success and zero 110 // otherwise. 111 OPENSSL_EXPORT int BIO_reset(BIO *bio); 112 113 // BIO_eof returns non-zero when |bio| has reached end-of-file. The precise 114 // meaning of which depends on the concrete type of |bio|. Note that in the 115 // case of BIO_pair this always returns non-zero. 116 OPENSSL_EXPORT int BIO_eof(BIO *bio); 117 118 // BIO_set_flags ORs |flags| with |bio->flags|. 119 OPENSSL_EXPORT void BIO_set_flags(BIO *bio, int flags); 120 121 // BIO_test_flags returns |bio->flags| AND |flags|. 122 OPENSSL_EXPORT int BIO_test_flags(const BIO *bio, int flags); 123 124 // BIO_should_read returns non-zero if |bio| encountered a temporary error 125 // while reading (i.e. EAGAIN), indicating that the caller should retry the 126 // read. 127 OPENSSL_EXPORT int BIO_should_read(const BIO *bio); 128 129 // BIO_should_write returns non-zero if |bio| encountered a temporary error 130 // while writing (i.e. EAGAIN), indicating that the caller should retry the 131 // write. 132 OPENSSL_EXPORT int BIO_should_write(const BIO *bio); 133 134 // BIO_should_retry returns non-zero if the reason that caused a failed I/O 135 // operation is temporary and thus the operation should be retried. Otherwise, 136 // it was a permanent error and it returns zero. 137 OPENSSL_EXPORT int BIO_should_retry(const BIO *bio); 138 139 // BIO_should_io_special returns non-zero if |bio| encountered a temporary 140 // error while performing a special I/O operation, indicating that the caller 141 // should retry. The operation that caused the error is returned by 142 // |BIO_get_retry_reason|. 143 OPENSSL_EXPORT int BIO_should_io_special(const BIO *bio); 144 145 // BIO_RR_CONNECT indicates that a connect would have blocked 146 #define BIO_RR_CONNECT 0x02 147 148 // BIO_RR_ACCEPT indicates that an accept would have blocked 149 #define BIO_RR_ACCEPT 0x03 150 151 // BIO_get_retry_reason returns the special I/O operation that needs to be 152 // retried. The return value is one of the |BIO_RR_*| values. 153 OPENSSL_EXPORT int BIO_get_retry_reason(const BIO *bio); 154 155 // BIO_set_retry_reason sets the special I/O operation that needs to be retried 156 // to |reason|, which should be one of the |BIO_RR_*| values. 157 OPENSSL_EXPORT void BIO_set_retry_reason(BIO *bio, int reason); 158 159 // BIO_clear_flags ANDs |bio->flags| with the bitwise-complement of |flags|. 160 OPENSSL_EXPORT void BIO_clear_flags(BIO *bio, int flags); 161 162 // BIO_set_retry_read sets the |BIO_FLAGS_READ| and |BIO_FLAGS_SHOULD_RETRY| 163 // flags on |bio|. 164 OPENSSL_EXPORT void BIO_set_retry_read(BIO *bio); 165 166 // BIO_set_retry_write sets the |BIO_FLAGS_WRITE| and |BIO_FLAGS_SHOULD_RETRY| 167 // flags on |bio|. 168 OPENSSL_EXPORT void BIO_set_retry_write(BIO *bio); 169 170 // BIO_get_retry_flags gets the |BIO_FLAGS_READ|, |BIO_FLAGS_WRITE|, 171 // |BIO_FLAGS_IO_SPECIAL| and |BIO_FLAGS_SHOULD_RETRY| flags from |bio|. 172 OPENSSL_EXPORT int BIO_get_retry_flags(BIO *bio); 173 174 // BIO_clear_retry_flags clears the |BIO_FLAGS_READ|, |BIO_FLAGS_WRITE|, 175 // |BIO_FLAGS_IO_SPECIAL| and |BIO_FLAGS_SHOULD_RETRY| flags from |bio|. 176 OPENSSL_EXPORT void BIO_clear_retry_flags(BIO *bio); 177 178 // BIO_method_type returns the type of |bio|, which is one of the |BIO_TYPE_*| 179 // values. 180 OPENSSL_EXPORT int BIO_method_type(const BIO *bio); 181 182 // These are passed to the BIO callback 183 #define BIO_CB_FREE 0x01 184 #define BIO_CB_READ 0x02 185 #define BIO_CB_WRITE 0x03 186 #define BIO_CB_PUTS 0x04 187 #define BIO_CB_GETS 0x05 188 #define BIO_CB_CTRL 0x06 189 190 // The callback is called before and after the underling operation, 191 // The BIO_CB_RETURN flag indicates if it is after the call 192 #define BIO_CB_RETURN 0x80 193 194 // bio_info_cb is the type of a callback function that can be called for most 195 // BIO operations. The |event| argument is one of |BIO_CB_*| and can be ORed 196 // with |BIO_CB_RETURN| if the callback is being made after the operation in 197 // question. In that case, |return_value| will contain the return value from 198 // the operation. 199 typedef long (*bio_info_cb)(BIO *bio, int event, const char *parg, int cmd, 200 long larg, long return_value); 201 202 // BIO_callback_ctrl allows the callback function to be manipulated. The |cmd| 203 // arg will generally be |BIO_CTRL_SET_CALLBACK| but arbitrary command values 204 // can be interpreted by the |BIO|. 205 OPENSSL_EXPORT long BIO_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp); 206 207 // BIO_pending returns the number of bytes pending to be read. 208 OPENSSL_EXPORT size_t BIO_pending(const BIO *bio); 209 210 // BIO_ctrl_pending calls |BIO_pending| and exists only for compatibility with 211 // OpenSSL. 212 OPENSSL_EXPORT size_t BIO_ctrl_pending(const BIO *bio); 213 214 // BIO_wpending returns the number of bytes pending to be written. 215 OPENSSL_EXPORT size_t BIO_wpending(const BIO *bio); 216 217 // BIO_set_close sets the close flag for |bio|. The meaning of which depends on 218 // the type of |bio| but, for example, a memory BIO interprets the close flag 219 // as meaning that it owns its buffer. It returns one on success and zero 220 // otherwise. 221 OPENSSL_EXPORT int BIO_set_close(BIO *bio, int close_flag); 222 223 // BIO_number_read returns the number of bytes that have been read from 224 // |bio|. 225 OPENSSL_EXPORT uint64_t BIO_number_read(const BIO *bio); 226 227 // BIO_number_written returns the number of bytes that have been written to 228 // |bio|. 229 OPENSSL_EXPORT uint64_t BIO_number_written(const BIO *bio); 230 231 232 // Managing chains of BIOs. 233 // 234 // BIOs can be put into chains where the output of one is used as the input of 235 // the next etc. The most common case is a buffering BIO, which accepts and 236 // buffers writes until flushed into the next BIO in the chain. 237 238 // BIO_push adds |appended_bio| to the end of the chain with |bio| at the head. 239 // It returns |bio|. Note that |appended_bio| may be the head of a chain itself 240 // and thus this function can be used to join two chains. 241 // 242 // BIO_push takes ownership of the caller's reference to |appended_bio|. 243 OPENSSL_EXPORT BIO *BIO_push(BIO *bio, BIO *appended_bio); 244 245 // BIO_pop removes |bio| from the head of a chain and returns the next BIO in 246 // the chain, or NULL if there is no next BIO. 247 // 248 // The caller takes ownership of the chain's reference to |bio|. 249 OPENSSL_EXPORT BIO *BIO_pop(BIO *bio); 250 251 // BIO_next returns the next BIO in the chain after |bio|, or NULL if there is 252 // no such BIO. 253 OPENSSL_EXPORT BIO *BIO_next(BIO *bio); 254 255 // BIO_free_all calls |BIO_free|. 256 // 257 // TODO(fork): update callers and remove. 258 OPENSSL_EXPORT void BIO_free_all(BIO *bio); 259 260 // BIO_find_type walks a chain of BIOs and returns the first that matches 261 // |type|, which is one of the |BIO_TYPE_*| values. 262 OPENSSL_EXPORT BIO *BIO_find_type(BIO *bio, int type); 263 264 // BIO_copy_next_retry sets the retry flags and |retry_reason| of |bio| from 265 // the next BIO in the chain. 266 OPENSSL_EXPORT void BIO_copy_next_retry(BIO *bio); 267 268 269 // Printf functions. 270 271 // BIO_printf behaves like |printf| but outputs to |bio| rather than a |FILE|. 272 // It returns the number of bytes written or a negative number on error. 273 OPENSSL_EXPORT int BIO_printf(BIO *bio, const char *format, ...) 274 OPENSSL_PRINTF_FORMAT_FUNC(2, 3); 275 276 277 // Utility functions. 278 279 // BIO_indent prints min(|indent|, |max_indent|) spaces. It returns one on 280 // success and zero otherwise. 281 OPENSSL_EXPORT int BIO_indent(BIO *bio, unsigned indent, unsigned max_indent); 282 283 // BIO_hexdump writes a hex dump of |data| to |bio|. Each line will be indented 284 // by |indent| spaces. It returns one on success and zero otherwise. 285 OPENSSL_EXPORT int BIO_hexdump(BIO *bio, const uint8_t *data, size_t len, 286 unsigned indent); 287 288 // ERR_print_errors prints the current contents of the error stack to |bio| 289 // using human readable strings where possible. 290 OPENSSL_EXPORT void ERR_print_errors(BIO *bio); 291 292 // BIO_read_asn1 reads a single ASN.1 object from |bio|. If successful it sets 293 // |*out| to be an allocated buffer (that should be freed with |OPENSSL_free|), 294 // |*out_size| to the length, in bytes, of that buffer and returns one. 295 // Otherwise it returns zero. 296 // 297 // If the length of the object is greater than |max_len| or 2^32 then the 298 // function will fail. Long-form tags are not supported. If the length of the 299 // object is indefinite the full contents of |bio| are read, unless it would be 300 // greater than |max_len|, in which case the function fails. 301 // 302 // If the function fails then some unknown amount of data may have been read 303 // from |bio|. 304 OPENSSL_EXPORT int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, 305 size_t max_len); 306 307 308 // Memory BIOs. 309 // 310 // Memory BIOs can be used as a read-only source (with |BIO_new_mem_buf|) or a 311 // writable sink (with |BIO_new|, |BIO_s_mem| and |BIO_mem_contents|). Data 312 // written to a writable, memory BIO can be recalled by reading from it. 313 // 314 // Calling |BIO_reset| on a read-only BIO resets it to the original contents. 315 // On a writable BIO, it clears any data. 316 // 317 // If the close flag is set to |BIO_NOCLOSE| (not the default) then the 318 // underlying |BUF_MEM| will not be freed when the |BIO| is freed. 319 // 320 // Memory BIOs support |BIO_gets| and |BIO_puts|. 321 // 322 // |BIO_ctrl_pending| returns the number of bytes currently stored. 323 324 // BIO_NOCLOSE and |BIO_CLOSE| can be used as symbolic arguments when a "close 325 // flag" is passed to a BIO function. 326 #define BIO_NOCLOSE 0 327 #define BIO_CLOSE 1 328 329 // BIO_s_mem returns a |BIO_METHOD| that uses a in-memory buffer. 330 OPENSSL_EXPORT const BIO_METHOD *BIO_s_mem(void); 331 332 // BIO_new_mem_buf creates read-only BIO that reads from |len| bytes at |buf|. 333 // It returns the BIO or NULL on error. This function does not copy or take 334 // ownership of |buf|. The caller must ensure the memory pointed to by |buf| 335 // outlives the |BIO|. 336 // 337 // If |len| is negative, then |buf| is treated as a NUL-terminated string, but 338 // don't depend on this in new code. 339 OPENSSL_EXPORT BIO *BIO_new_mem_buf(const void *buf, ossl_ssize_t len); 340 341 // BIO_mem_contents sets |*out_contents| to point to the current contents of 342 // |bio| and |*out_len| to contain the length of that data. It returns one on 343 // success and zero otherwise. 344 OPENSSL_EXPORT int BIO_mem_contents(const BIO *bio, 345 const uint8_t **out_contents, 346 size_t *out_len); 347 348 // BIO_get_mem_data sets |*contents| to point to the current contents of |bio| 349 // and returns the length of the data. 350 // 351 // WARNING: don't use this, use |BIO_mem_contents|. A return value of zero from 352 // this function can mean either that it failed or that the memory buffer is 353 // empty. 354 OPENSSL_EXPORT long BIO_get_mem_data(BIO *bio, char **contents); 355 356 // BIO_get_mem_ptr sets |*out| to a BUF_MEM containing the current contents of 357 // |bio|. It returns one on success or zero on error. 358 OPENSSL_EXPORT int BIO_get_mem_ptr(BIO *bio, BUF_MEM **out); 359 360 // BIO_set_mem_buf sets |b| as the contents of |bio|. If |take_ownership| is 361 // non-zero, then |b| will be freed when |bio| is closed. Returns one on 362 // success or zero otherwise. 363 OPENSSL_EXPORT int BIO_set_mem_buf(BIO *bio, BUF_MEM *b, int take_ownership); 364 365 // BIO_set_mem_eof_return sets the value that will be returned from reading 366 // |bio| when empty. If |eof_value| is zero then an empty memory BIO will 367 // return EOF (that is it will return zero and |BIO_should_retry| will be 368 // false). If |eof_value| is non zero then it will return |eof_value| when it 369 // is empty and it will set the read retry flag (that is |BIO_read_retry| is 370 // true). To avoid ambiguity with a normal positive return value, |eof_value| 371 // should be set to a negative value, typically -1. 372 // 373 // For a read-only BIO, the default is zero (EOF). For a writable BIO, the 374 // default is -1 so that additional data can be written once exhausted. 375 OPENSSL_EXPORT int BIO_set_mem_eof_return(BIO *bio, int eof_value); 376 377 378 // File descriptor BIOs. 379 // 380 // File descriptor BIOs are wrappers around the system's |read| and |write| 381 // functions. If the close flag is set then then |close| is called on the 382 // underlying file descriptor when the BIO is freed. 383 // 384 // |BIO_reset| attempts to seek the file pointer to the start of file using 385 // |lseek|. 386 387 #if !defined(OPENSSL_NO_POSIX_IO) 388 // BIO_s_fd returns a |BIO_METHOD| for file descriptor fds. 389 OPENSSL_EXPORT const BIO_METHOD *BIO_s_fd(void); 390 391 // BIO_new_fd creates a new file descriptor BIO wrapping |fd|. If |close_flag| 392 // is non-zero, then |fd| will be closed when the BIO is. 393 OPENSSL_EXPORT BIO *BIO_new_fd(int fd, int close_flag); 394 #endif 395 396 // BIO_set_fd sets the file descriptor of |bio| to |fd|. If |close_flag| is 397 // non-zero then |fd| will be closed when |bio| is. It returns one on success 398 // or zero on error. 399 // 400 // This function may also be used with socket BIOs (see |BIO_s_socket| and 401 // |BIO_new_socket|). 402 OPENSSL_EXPORT int BIO_set_fd(BIO *bio, int fd, int close_flag); 403 404 // BIO_get_fd returns the file descriptor currently in use by |bio| or -1 if 405 // |bio| does not wrap a file descriptor. If there is a file descriptor and 406 // |out_fd| is not NULL, it also sets |*out_fd| to the file descriptor. 407 // 408 // This function may also be used with socket BIOs (see |BIO_s_socket| and 409 // |BIO_new_socket|). 410 OPENSSL_EXPORT int BIO_get_fd(BIO *bio, int *out_fd); 411 412 413 // File BIOs. 414 // 415 // File BIOs are wrappers around a C |FILE| object. 416 // 417 // |BIO_flush| on a file BIO calls |fflush| on the wrapped stream. 418 // 419 // |BIO_reset| attempts to seek the file pointer to the start of file using 420 // |fseek|. 421 // 422 // Setting the close flag causes |fclose| to be called on the stream when the 423 // BIO is freed. 424 425 // BIO_s_file returns a BIO_METHOD that wraps a |FILE|. 426 OPENSSL_EXPORT const BIO_METHOD *BIO_s_file(void); 427 428 // BIO_new_file creates a file BIO by opening |filename| with the given mode. 429 // See the |fopen| manual page for details of the mode argument. On Windows, 430 // files may be opened in either binary or text mode so, as in |fopen|, callers 431 // must specify the desired option in |mode|. 432 OPENSSL_EXPORT BIO *BIO_new_file(const char *filename, const char *mode); 433 434 // BIO_FP_TEXT indicates the |FILE| should be switched to text mode on Windows. 435 // It has no effect on non-Windows platforms. 436 #define BIO_FP_TEXT 0x10 437 438 // BIO_new_fp creates a new file BIO that wraps |file|. If |flags| contains 439 // |BIO_CLOSE|, then |fclose| will be called on |file| when the BIO is closed. 440 // 441 // On Windows, if |flags| contains |BIO_FP_TEXT|, this function will 442 // additionally switch |file| to text mode. This is not recommended, but may be 443 // required for OpenSSL compatibility. If |file| was not already in text mode, 444 // mode changes can cause unflushed data in |file| to be written in unexpected 445 // ways. See |_setmode| in Windows documentation for details. 446 // 447 // Unlike OpenSSL, if |flags| does not contain |BIO_FP_TEXT|, the translation 448 // mode of |file| is left as-is. In OpenSSL, |file| will be set to binary, with 449 // the same pitfalls as above. BoringSSL does not do this so that wrapping a 450 // |FILE| in a |BIO| will not inadvertently change its state. 451 // 452 // To avoid these pitfalls, callers should set the desired translation mode when 453 // opening the file. If targeting just BoringSSL, this is sufficient. If 454 // targeting both OpenSSL and BoringSSL, callers should set |BIO_FP_TEXT| to 455 // match the desired state of the file. 456 OPENSSL_EXPORT BIO *BIO_new_fp(FILE *file, int flags); 457 458 // BIO_get_fp sets |*out_file| to the current |FILE| for |bio|. It returns one 459 // on success and zero otherwise. 460 OPENSSL_EXPORT int BIO_get_fp(BIO *bio, FILE **out_file); 461 462 // BIO_set_fp sets the |FILE| for |bio|. If |flags| contains |BIO_CLOSE| then 463 // |fclose| will be called on |file| when |bio| is closed. It returns one on 464 // success and zero otherwise. 465 // 466 // On Windows, if |flags| contains |BIO_FP_TEXT|, this function will 467 // additionally switch |file| to text mode. This is not recommended, but may be 468 // required for OpenSSL compatibility. If |file| was not already in text mode, 469 // mode changes can cause unflushed data in |file| to be written in unexpected 470 // ways. See |_setmode| in Windows documentation for details. 471 // 472 // Unlike OpenSSL, if |flags| does not contain |BIO_FP_TEXT|, the translation 473 // mode of |file| is left as-is. In OpenSSL, |file| will be set to binary, with 474 // the same pitfalls as above. BoringSSL does not do this so that wrapping a 475 // |FILE| in a |BIO| will not inadvertently change its state. 476 // 477 // To avoid these pitfalls, callers should set the desired translation mode when 478 // opening the file. If targeting just BoringSSL, this is sufficient. If 479 // targeting both OpenSSL and BoringSSL, callers should set |BIO_FP_TEXT| to 480 // match the desired state of the file. 481 OPENSSL_EXPORT int BIO_set_fp(BIO *bio, FILE *file, int flags); 482 483 // BIO_read_filename opens |filename| for reading and sets the result as the 484 // |FILE| for |bio|. It returns one on success and zero otherwise. The |FILE| 485 // will be closed when |bio| is freed. On Windows, the file is opened in binary 486 // mode. 487 OPENSSL_EXPORT int BIO_read_filename(BIO *bio, const char *filename); 488 489 // BIO_write_filename opens |filename| for writing and sets the result as the 490 // |FILE| for |bio|. It returns one on success and zero otherwise. The |FILE| 491 // will be closed when |bio| is freed. On Windows, the file is opened in binary 492 // mode. 493 OPENSSL_EXPORT int BIO_write_filename(BIO *bio, const char *filename); 494 495 // BIO_append_filename opens |filename| for appending and sets the result as 496 // the |FILE| for |bio|. It returns one on success and zero otherwise. The 497 // |FILE| will be closed when |bio| is freed. On Windows, the file is opened in 498 // binary mode. 499 OPENSSL_EXPORT int BIO_append_filename(BIO *bio, const char *filename); 500 501 // BIO_rw_filename opens |filename| for reading and writing and sets the result 502 // as the |FILE| for |bio|. It returns one on success and zero otherwise. The 503 // |FILE| will be closed when |bio| is freed. On Windows, the file is opened in 504 // binary mode. 505 OPENSSL_EXPORT int BIO_rw_filename(BIO *bio, const char *filename); 506 507 // BIO_tell returns the file offset of |bio|, or a negative number on error or 508 // if |bio| does not support the operation. 509 // 510 // TODO(https://crbug.com/boringssl/465): On platforms where |long| is 32-bit, 511 // this function cannot report 64-bit offsets. 512 OPENSSL_EXPORT long BIO_tell(BIO *bio); 513 514 // BIO_seek sets the file offset of |bio| to |offset|. It returns a non-negative 515 // number on success and a negative number on error. If |bio| is a file 516 // descriptor |BIO|, it returns the resulting file offset on success. If |bio| 517 // is a file |BIO|, it returns zero on success. 518 // 519 // WARNING: This function's return value conventions differs from most functions 520 // in this library. 521 // 522 // TODO(https://crbug.com/boringssl/465): On platforms where |long| is 32-bit, 523 // this function cannot handle 64-bit offsets. 524 OPENSSL_EXPORT long BIO_seek(BIO *bio, long offset); 525 526 527 // Socket BIOs. 528 // 529 // Socket BIOs behave like file descriptor BIOs but, on Windows systems, wrap 530 // the system's |recv| and |send| functions instead of |read| and |write|. On 531 // Windows, file descriptors are provided by C runtime and are not 532 // interchangeable with sockets. 533 // 534 // Socket BIOs may be used with |BIO_set_fd| and |BIO_get_fd|. 535 // 536 // TODO(davidben): Add separate APIs and fix the internals to use |SOCKET|s 537 // around rather than rely on int casts. 538 539 #if !defined(OPENSSL_NO_SOCK) 540 OPENSSL_EXPORT const BIO_METHOD *BIO_s_socket(void); 541 542 // BIO_new_socket allocates and initialises a fresh BIO which will read and 543 // write to the socket |fd|. If |close_flag| is |BIO_CLOSE| then closing the 544 // BIO will close |fd|. It returns the fresh |BIO| or NULL on error. 545 OPENSSL_EXPORT BIO *BIO_new_socket(int fd, int close_flag); 546 #endif // !OPENSSL_NO_SOCK 547 548 549 // Connect BIOs. 550 // 551 // A connection BIO creates a network connection and transfers data over the 552 // resulting socket. 553 554 #if !defined(OPENSSL_NO_SOCK) 555 OPENSSL_EXPORT const BIO_METHOD *BIO_s_connect(void); 556 557 // BIO_new_connect returns a BIO that connects to the given hostname and port. 558 // The |host_and_optional_port| argument should be of the form 559 // "www.example.com" or "www.example.com:443". If the port is omitted, it must 560 // be provided with |BIO_set_conn_port|. 561 // 562 // It returns the new BIO on success, or NULL on error. 563 OPENSSL_EXPORT BIO *BIO_new_connect(const char *host_and_optional_port); 564 565 // BIO_set_conn_hostname sets |host_and_optional_port| as the hostname and 566 // optional port that |bio| will connect to. If the port is omitted, it must be 567 // provided with |BIO_set_conn_port|. 568 // 569 // It returns one on success and zero otherwise. 570 OPENSSL_EXPORT int BIO_set_conn_hostname(BIO *bio, 571 const char *host_and_optional_port); 572 573 // BIO_set_conn_port sets |port_str| as the port or service name that |bio| 574 // will connect to. It returns one on success and zero otherwise. 575 OPENSSL_EXPORT int BIO_set_conn_port(BIO *bio, const char *port_str); 576 577 // BIO_set_conn_int_port sets |*port| as the port that |bio| will connect to. 578 // It returns one on success and zero otherwise. 579 OPENSSL_EXPORT int BIO_set_conn_int_port(BIO *bio, const int *port); 580 581 // BIO_set_nbio sets whether |bio| will use non-blocking I/O operations. It 582 // returns one on success and zero otherwise. This only works for connect BIOs 583 // and must be called before |bio| is connected to take effect. 584 // 585 // For socket and fd BIOs, callers must configure blocking vs. non-blocking I/O 586 // using the underlying platform APIs. 587 OPENSSL_EXPORT int BIO_set_nbio(BIO *bio, int on); 588 589 // BIO_do_connect connects |bio| if it has not been connected yet. It returns 590 // one on success and <= 0 otherwise. 591 OPENSSL_EXPORT int BIO_do_connect(BIO *bio); 592 #endif // !OPENSSL_NO_SOCK 593 594 595 // Datagram BIOs. 596 // 597 // TODO(fork): not implemented. 598 599 #define BIO_CTRL_DGRAM_QUERY_MTU 40 // as kernel for current MTU 600 601 #define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for MTU. want to use 602 this if asking the kernel fails */ 603 604 #define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU was exceed in 605 the previous write operation. */ 606 607 // BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT is unsupported as it is unused by consumers 608 // and depends on |timeval|, which is not 2038-clean on all platforms. 609 610 #define BIO_CTRL_DGRAM_GET_PEER 46 611 612 #define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 613 614 615 // BIO Pairs. 616 // 617 // BIO pairs provide a "loopback" like system: a pair of BIOs where data 618 // written to one can be read from the other and vice versa. 619 620 // BIO_new_bio_pair sets |*out1| and |*out2| to two freshly created BIOs where 621 // data written to one can be read from the other and vice versa. The 622 // |writebuf1| argument gives the size of the buffer used in |*out1| and 623 // |writebuf2| for |*out2|. It returns one on success and zero on error. 624 OPENSSL_EXPORT int BIO_new_bio_pair(BIO **out1, size_t writebuf1, BIO **out2, 625 size_t writebuf2); 626 627 // BIO_ctrl_get_read_request returns the number of bytes that the other side of 628 // |bio| tried (unsuccessfully) to read. 629 OPENSSL_EXPORT size_t BIO_ctrl_get_read_request(BIO *bio); 630 631 // BIO_ctrl_get_write_guarantee returns the number of bytes that |bio| (which 632 // must have been returned by |BIO_new_bio_pair|) will accept on the next 633 // |BIO_write| call. 634 OPENSSL_EXPORT size_t BIO_ctrl_get_write_guarantee(BIO *bio); 635 636 // BIO_shutdown_wr marks |bio| as closed, from the point of view of the other 637 // side of the pair. Future |BIO_write| calls on |bio| will fail. It returns 638 // one on success and zero otherwise. 639 OPENSSL_EXPORT int BIO_shutdown_wr(BIO *bio); 640 641 642 // Custom BIOs. 643 // 644 // Consumers can create custom |BIO|s by filling in a |BIO_METHOD| and using 645 // low-level control functions to set state. 646 647 // BIO_get_new_index returns a new "type" value for a custom |BIO|. 648 OPENSSL_EXPORT int BIO_get_new_index(void); 649 650 // BIO_meth_new returns a newly-allocated |BIO_METHOD| or NULL on allocation 651 // error. The |type| specifies the type that will be returned by 652 // |BIO_method_type|. If this is unnecessary, this value may be zero. The |name| 653 // parameter is vestigial and may be NULL. 654 // 655 // Use the |BIO_meth_set_*| functions below to initialize the |BIO_METHOD|. The 656 // function implementations may use |BIO_set_data| and |BIO_get_data| to add 657 // method-specific state to associated |BIO|s. Additionally, |BIO_set_init| must 658 // be called after an associated |BIO| is fully initialized. State set via 659 // |BIO_set_data| may be released by configuring a destructor with 660 // |BIO_meth_set_destroy|. 661 OPENSSL_EXPORT BIO_METHOD *BIO_meth_new(int type, const char *name); 662 663 // BIO_meth_free releases memory associated with |method|. 664 OPENSSL_EXPORT void BIO_meth_free(BIO_METHOD *method); 665 666 // BIO_meth_set_create sets a function to be called on |BIO_new| for |method| 667 // and returns one. The function should return one on success and zero on 668 // error. 669 OPENSSL_EXPORT int BIO_meth_set_create(BIO_METHOD *method, 670 int (*create_func)(BIO *)); 671 672 // BIO_meth_set_destroy sets a function to release data associated with a |BIO| 673 // and returns one. The function's return value is ignored. 674 OPENSSL_EXPORT int BIO_meth_set_destroy(BIO_METHOD *method, 675 int (*destroy_func)(BIO *)); 676 677 // BIO_meth_set_write sets the implementation of |BIO_write| for |method| and 678 // returns one. |BIO_METHOD|s which implement |BIO_write| should also implement 679 // |BIO_CTRL_FLUSH|. (See |BIO_meth_set_ctrl|.) 680 OPENSSL_EXPORT int BIO_meth_set_write(BIO_METHOD *method, 681 int (*write_func)(BIO *, const char *, 682 int)); 683 684 // BIO_meth_set_read sets the implementation of |BIO_read| for |method| and 685 // returns one. 686 OPENSSL_EXPORT int BIO_meth_set_read(BIO_METHOD *method, 687 int (*read_func)(BIO *, char *, int)); 688 689 // BIO_meth_set_gets sets the implementation of |BIO_gets| for |method| and 690 // returns one. 691 OPENSSL_EXPORT int BIO_meth_set_gets(BIO_METHOD *method, 692 int (*gets_func)(BIO *, char *, int)); 693 694 // BIO_meth_set_ctrl sets the implementation of |BIO_ctrl| for |method| and 695 // returns one. 696 OPENSSL_EXPORT int BIO_meth_set_ctrl(BIO_METHOD *method, 697 long (*ctrl_func)(BIO *, int, long, 698 void *)); 699 700 // BIO_set_data sets custom data on |bio|. It may be retried with 701 // |BIO_get_data|. 702 // 703 // This function should only be called by the implementation of a custom |BIO|. 704 // In particular, the data pointer of a built-in |BIO| is private to the 705 // library. For other uses, see |BIO_set_ex_data| and |BIO_set_app_data|. 706 OPENSSL_EXPORT void BIO_set_data(BIO *bio, void *ptr); 707 708 // BIO_get_data returns custom data on |bio| set by |BIO_get_data|. 709 // 710 // This function should only be called by the implementation of a custom |BIO|. 711 // In particular, the data pointer of a built-in |BIO| is private to the 712 // library. For other uses, see |BIO_get_ex_data| and |BIO_get_app_data|. 713 OPENSSL_EXPORT void *BIO_get_data(BIO *bio); 714 715 // BIO_set_init sets whether |bio| has been fully initialized. Until fully 716 // initialized, |BIO_read| and |BIO_write| will fail. 717 OPENSSL_EXPORT void BIO_set_init(BIO *bio, int init); 718 719 // BIO_get_init returns whether |bio| has been fully initialized. 720 OPENSSL_EXPORT int BIO_get_init(BIO *bio); 721 722 // These are values of the |cmd| argument to |BIO_ctrl|. 723 724 // BIO_CTRL_RESET implements |BIO_reset|. The arguments are unused. 725 #define BIO_CTRL_RESET 1 726 727 // BIO_CTRL_EOF implements |BIO_eof|. The arguments are unused. 728 #define BIO_CTRL_EOF 2 729 730 // BIO_CTRL_INFO is a legacy command that returns information specific to the 731 // type of |BIO|. It is not safe to call generically and should not be 732 // implemented in new |BIO| types. 733 #define BIO_CTRL_INFO 3 734 735 // BIO_CTRL_GET_CLOSE returns the close flag set by |BIO_CTRL_SET_CLOSE|. The 736 // arguments are unused. 737 #define BIO_CTRL_GET_CLOSE 8 738 739 // BIO_CTRL_SET_CLOSE implements |BIO_set_close|. The |larg| argument is the 740 // close flag. 741 #define BIO_CTRL_SET_CLOSE 9 742 743 // BIO_CTRL_PENDING implements |BIO_pending|. The arguments are unused. 744 #define BIO_CTRL_PENDING 10 745 746 // BIO_CTRL_FLUSH implements |BIO_flush|. The arguments are unused. 747 #define BIO_CTRL_FLUSH 11 748 749 // BIO_CTRL_WPENDING implements |BIO_wpending|. The arguments are unused. 750 #define BIO_CTRL_WPENDING 13 751 752 // BIO_CTRL_SET_CALLBACK sets an informational callback of type 753 // int cb(BIO *bio, int state, int ret) 754 #define BIO_CTRL_SET_CALLBACK 14 755 756 // BIO_CTRL_GET_CALLBACK returns the callback set by |BIO_CTRL_SET_CALLBACK|. 757 #define BIO_CTRL_GET_CALLBACK 15 758 759 // The following are never used, but are defined to aid porting existing code. 760 #define BIO_CTRL_SET 4 761 #define BIO_CTRL_GET 5 762 #define BIO_CTRL_PUSH 6 763 #define BIO_CTRL_POP 7 764 #define BIO_CTRL_DUP 12 765 #define BIO_CTRL_SET_FILENAME 30 766 767 768 // ex_data functions. 769 // 770 // See |ex_data.h| for details. 771 772 OPENSSL_EXPORT int BIO_get_ex_new_index(long argl, void *argp, 773 CRYPTO_EX_unused *unused, 774 CRYPTO_EX_dup *dup_unused, 775 CRYPTO_EX_free *free_func); 776 OPENSSL_EXPORT int BIO_set_ex_data(BIO *bio, int idx, void *arg); 777 OPENSSL_EXPORT void *BIO_get_ex_data(const BIO *bio, int idx); 778 779 #define BIO_set_app_data(bio, arg) (BIO_set_ex_data(bio, 0, (char *)(arg))) 780 #define BIO_get_app_data(bio) (BIO_get_ex_data(bio, 0)) 781 782 783 // Deprecated functions. 784 785 // BIO_f_base64 returns a filter |BIO| that base64-encodes data written into 786 // it, and decodes data read from it. |BIO_gets| is not supported. Call 787 // |BIO_flush| when done writing, to signal that no more data are to be 788 // encoded. The flag |BIO_FLAGS_BASE64_NO_NL| may be set to encode all the data 789 // on one line. 790 // 791 // Use |EVP_EncodeBlock| and |EVP_DecodeBase64| instead. 792 OPENSSL_EXPORT const BIO_METHOD *BIO_f_base64(void); 793 794 OPENSSL_EXPORT void BIO_set_retry_special(BIO *bio); 795 796 // BIO_set_write_buffer_size returns zero. 797 OPENSSL_EXPORT int BIO_set_write_buffer_size(BIO *bio, int buffer_size); 798 799 // BIO_set_shutdown sets a method-specific "shutdown" bit on |bio|. 800 OPENSSL_EXPORT void BIO_set_shutdown(BIO *bio, int shutdown); 801 802 // BIO_get_shutdown returns the method-specific "shutdown" bit. 803 OPENSSL_EXPORT int BIO_get_shutdown(BIO *bio); 804 805 // BIO_meth_set_puts returns one. |BIO_puts| is implemented with |BIO_write| in 806 // BoringSSL. 807 OPENSSL_EXPORT int BIO_meth_set_puts(BIO_METHOD *method, 808 int (*puts)(BIO *, const char *)); 809 810 811 // Private functions 812 813 #define BIO_FLAGS_READ 0x01 814 #define BIO_FLAGS_WRITE 0x02 815 #define BIO_FLAGS_IO_SPECIAL 0x04 816 #define BIO_FLAGS_RWS (BIO_FLAGS_READ | BIO_FLAGS_WRITE | BIO_FLAGS_IO_SPECIAL) 817 #define BIO_FLAGS_SHOULD_RETRY 0x08 818 #define BIO_FLAGS_BASE64_NO_NL 0x100 819 // BIO_FLAGS_MEM_RDONLY is used with memory BIOs. It means we shouldn't free up 820 // or change the data in any way. 821 #define BIO_FLAGS_MEM_RDONLY 0x200 822 823 // BIO_TYPE_DESCRIPTOR denotes that the |BIO| responds to the |BIO_C_SET_FD| 824 // (|BIO_set_fd|) and |BIO_C_GET_FD| (|BIO_get_fd|) control hooks. 825 #define BIO_TYPE_DESCRIPTOR 0x0100 // socket, fd, connect or accept 826 #define BIO_TYPE_FILTER 0x0200 827 #define BIO_TYPE_SOURCE_SINK 0x0400 828 829 // These are the 'types' of BIOs 830 #define BIO_TYPE_NONE 0 831 #define BIO_TYPE_MEM (1 | BIO_TYPE_SOURCE_SINK) 832 #define BIO_TYPE_FILE (2 | BIO_TYPE_SOURCE_SINK) 833 #define BIO_TYPE_FD (4 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 834 #define BIO_TYPE_SOCKET (5 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 835 #define BIO_TYPE_NULL (6 | BIO_TYPE_SOURCE_SINK) 836 #define BIO_TYPE_SSL (7 | BIO_TYPE_FILTER) 837 #define BIO_TYPE_MD (8 | BIO_TYPE_FILTER) 838 #define BIO_TYPE_BUFFER (9 | BIO_TYPE_FILTER) 839 #define BIO_TYPE_CIPHER (10 | BIO_TYPE_FILTER) 840 #define BIO_TYPE_BASE64 (11 | BIO_TYPE_FILTER) 841 #define BIO_TYPE_CONNECT (12 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 842 #define BIO_TYPE_ACCEPT (13 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 843 #define BIO_TYPE_PROXY_CLIENT (14 | BIO_TYPE_FILTER) 844 #define BIO_TYPE_PROXY_SERVER (15 | BIO_TYPE_FILTER) 845 #define BIO_TYPE_NBIO_TEST (16 | BIO_TYPE_FILTER) 846 #define BIO_TYPE_NULL_FILTER (17 | BIO_TYPE_FILTER) 847 #define BIO_TYPE_BER (18 | BIO_TYPE_FILTER) // BER -> bin filter 848 #define BIO_TYPE_BIO (19 | BIO_TYPE_SOURCE_SINK) // (half a) BIO pair 849 #define BIO_TYPE_LINEBUFFER (20 | BIO_TYPE_FILTER) 850 #define BIO_TYPE_DGRAM (21 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 851 #define BIO_TYPE_ASN1 (22 | BIO_TYPE_FILTER) 852 #define BIO_TYPE_COMP (23 | BIO_TYPE_FILTER) 853 854 // BIO_TYPE_START is the first user-allocated |BIO| type. No pre-defined type, 855 // flag bits aside, may exceed this value. 856 #define BIO_TYPE_START 128 857 858 struct bio_method_st { 859 int type; 860 const char *name; 861 int (*bwrite)(BIO *, const char *, int); 862 int (*bread)(BIO *, char *, int); 863 // TODO(fork): remove bputs. 864 int (*bputs)(BIO *, const char *); 865 int (*bgets)(BIO *, char *, int); 866 long (*ctrl)(BIO *, int, long, void *); 867 int (*create)(BIO *); 868 int (*destroy)(BIO *); 869 long (*callback_ctrl)(BIO *, int, bio_info_cb); 870 }; 871 872 struct bio_st { 873 const BIO_METHOD *method; 874 CRYPTO_EX_DATA ex_data; 875 876 // init is non-zero if this |BIO| has been initialised. 877 int init; 878 // shutdown is often used by specific |BIO_METHOD|s to determine whether 879 // they own some underlying resource. This flag can often by controlled by 880 // |BIO_set_close|. For example, whether an fd BIO closes the underlying fd 881 // when it, itself, is closed. 882 int shutdown; 883 int flags; 884 int retry_reason; 885 // num is a BIO-specific value. For example, in fd BIOs it's used to store a 886 // file descriptor. 887 int num; 888 CRYPTO_refcount_t references; 889 void *ptr; 890 // next_bio points to the next |BIO| in a chain. This |BIO| owns a reference 891 // to |next_bio|. 892 BIO *next_bio; // used by filter BIOs 893 uint64_t num_read, num_write; 894 }; 895 896 #define BIO_C_SET_CONNECT 100 897 #define BIO_C_DO_STATE_MACHINE 101 898 #define BIO_C_SET_NBIO 102 899 #define BIO_C_SET_PROXY_PARAM 103 900 #define BIO_C_SET_FD 104 901 #define BIO_C_GET_FD 105 902 #define BIO_C_SET_FILE_PTR 106 903 #define BIO_C_GET_FILE_PTR 107 904 #define BIO_C_SET_FILENAME 108 905 #define BIO_C_SET_SSL 109 906 #define BIO_C_SET_MD 111 907 #define BIO_C_GET_MD 112 908 #define BIO_C_GET_CIPHER_STATUS 113 909 #define BIO_C_SET_BUF_MEM 114 910 #define BIO_C_GET_BUF_MEM_PTR 115 911 #define BIO_C_GET_BUFF_NUM_LINES 116 912 #define BIO_C_SET_BUFF_SIZE 117 913 #define BIO_C_SET_ACCEPT 118 914 #define BIO_C_SSL_MODE 119 915 #define BIO_C_GET_MD_CTX 120 916 #define BIO_C_GET_PROXY_PARAM 121 917 #define BIO_C_SET_BUFF_READ_DATA 122 // data to read first 918 #define BIO_C_GET_ACCEPT 124 919 #define BIO_C_FILE_SEEK 128 920 #define BIO_C_GET_CIPHER_CTX 129 921 #define BIO_C_SET_BUF_MEM_EOF_RETURN 130 // return end of input value 922 #define BIO_C_SET_BIND_MODE 131 923 #define BIO_C_GET_BIND_MODE 132 924 #define BIO_C_FILE_TELL 133 925 #define BIO_C_GET_SOCKS 134 926 #define BIO_C_SET_SOCKS 135 927 928 #define BIO_C_SET_WRITE_BUF_SIZE 136 // for BIO_s_bio 929 #define BIO_C_GET_WRITE_BUF_SIZE 137 930 #define BIO_C_GET_WRITE_GUARANTEE 140 931 #define BIO_C_GET_READ_REQUEST 141 932 #define BIO_C_SHUTDOWN_WR 142 933 #define BIO_C_NREAD0 143 934 #define BIO_C_NREAD 144 935 #define BIO_C_NWRITE0 145 936 #define BIO_C_NWRITE 146 937 #define BIO_C_RESET_READ_REQUEST 147 938 #define BIO_C_SET_MD_CTX 148 939 940 #define BIO_C_SET_PREFIX 149 941 #define BIO_C_GET_PREFIX 150 942 #define BIO_C_SET_SUFFIX 151 943 #define BIO_C_GET_SUFFIX 152 944 945 #define BIO_C_SET_EX_ARG 153 946 #define BIO_C_GET_EX_ARG 154 947 948 949 #if defined(__cplusplus) 950 } // extern C 951 952 extern "C++" { 953 954 BSSL_NAMESPACE_BEGIN 955 956 BORINGSSL_MAKE_DELETER(BIO, BIO_free) 957 BORINGSSL_MAKE_UP_REF(BIO, BIO_up_ref) 958 BORINGSSL_MAKE_DELETER(BIO_METHOD, BIO_meth_free) 959 960 BSSL_NAMESPACE_END 961 962 } // extern C++ 963 964 #endif 965 966 #define BIO_R_BAD_FOPEN_MODE 100 967 #define BIO_R_BROKEN_PIPE 101 968 #define BIO_R_CONNECT_ERROR 102 969 #define BIO_R_ERROR_SETTING_NBIO 103 970 #define BIO_R_INVALID_ARGUMENT 104 971 #define BIO_R_IN_USE 105 972 #define BIO_R_KEEPALIVE 106 973 #define BIO_R_NBIO_CONNECT_ERROR 107 974 #define BIO_R_NO_HOSTNAME_SPECIFIED 108 975 #define BIO_R_NO_PORT_SPECIFIED 109 976 #define BIO_R_NO_SUCH_FILE 110 977 #define BIO_R_NULL_PARAMETER 111 978 #define BIO_R_SYS_LIB 112 979 #define BIO_R_UNABLE_TO_CREATE_SOCKET 113 980 #define BIO_R_UNINITIALIZED 114 981 #define BIO_R_UNSUPPORTED_METHOD 115 982 #define BIO_R_WRITE_TO_READ_ONLY_BIO 116 983 984 #endif // OPENSSL_HEADER_BIO_H 985