RSA BSAFE Cert-C Micro Edition

The power of PKI for the smallest of devices

bio.h File Reference

This file provides the Basic Input/Output (BIO) functionality including functions, typedefs and structure declarations.

#include "r_com.h"
#include "r_vararg.h"
#include "bio_err.h"

Go to the source code of this file.

Data Structures

 BIO_METHOD
 This structure stores pointers to functions that implement the BIO methods. More...

 BIO
 This structure contains the data and BIO method structure. More...


Defines

#define BIO_TYPE_FILTER
 The base type indicating that a BIO of this type modifies the data written to, or read from a source/sink BIO. More...

#define BIO_TYPE_SOURCE_SINK
 The base type indicating that a BIO of this type takes data from a device, and/or sends data to a device (data exchange). More...

#define BIO_TYPE_DESCRIPTOR
 The base type that may be combined with the source/sink base type to indicate that the BIO uses a file descriptor. More...

#define BIO_TYPE_DGRAM
 The base type that may be combined with the source/sink base type to indicate that the BIO is a datagram socket.

#define BIO_TYPE_NONE
 Indicates that the BIO does not have a defined type.

#define BIO_TYPE_MEM
 Indicates that the BIO is a memory buffer source/sink BIO.

#define BIO_TYPE_FILE
 Indicates that the BIO is a file pointer source/sink BIO.

#define BIO_TYPE_FD
 Indicates that the BIO is a file descriptor source/sink BIO.

#define BIO_TYPE_NULL
 Indicates that the BIO is a NULL source/sink BIO. More...

#define BIO_TYPE_BUFFER
 Indicates that the BIO is a data buffer filter BIO. More...

#define BIO_TYPE_BASE64
 Indicates that the BIO is a data base 64 filter BIO.

#define BIO_TYPE_NULL_FILTER
 Indicates that the BIO is a NULL filter BIO. More...

#define BIO_CTRL_RESET
 Rewinds to the start of input or output and resets the state of the BIO. More...

#define BIO_CTRL_EOF
 Checks if the BIO has reached the End-of-File (EOF) marker.

#define BIO_CTRL_INFO
 Retrieves extra information from the BIO. More...

#define BIO_CTRL_SET
 Sets the BIO I/O type.

#define BIO_CTRL_GET
 Retrieves the BIO I/O type.

#define BIO_CTRL_PUSH
 An internal control used for BIO stack manipulation.

#define BIO_CTRL_POP
 An internal control used for BIO stack manipulation.

#define BIO_CTRL_GET_CLOSE
 Retrieves the state of the BIO shutdown flag used by BIO_free(). More...

#define BIO_CTRL_SET_CLOSE
 Sets the state of the BIO shutdown flag used by BIO_free(). More...

#define BIO_CTRL_PENDING
 Checks if there is more data buffered in the BIO be use.

#define BIO_CTRL_FLUSH
 Flushes any remaining data from the BIO data buffer.

#define BIO_CTRL_DUP
 Extra information to use for a duplicated BIO.

#define BIO_CTRL_WPENDING
 Retrieves the number of Bytes in the BIO data buffer pending to write.

#define BIO_CTRL_SET_CALLBACK
 Sets the BIO callback function.

#define BIO_CTRL_GET_CALLBACK
 Retrieves a pointer to a BIO callback function.

#define BIO_CTRL_SET_FILENAME
 Sets the file name to be used by the file BIO.

#define BIO_NOCLOSE
 Indicates not to close the I/O stream on BIO_free(). More...

#define BIO_CLOSE
 Indicates to close the I/O stream on BIO_free(). More...

#define BIO_FLAGS_READ
 Indicates that the BIO has data to read.

#define BIO_FLAGS_WRITE
 Indicates that the BIO has data to write.

#define BIO_FLAGS_IO_SPECIAL
 Indicates that the BIO performs custom socket I/O. More...

#define BIO_FLAGS_RWS
 Indicates a combination of BIO_FLAGS_READ, BIO_FLAGS_WRITE and BIO_FLAGS_IO_SPECIAL.

#define BIO_FLAGS_SHOULD_RETRY
 Indicates whether a retry on write or read should be attempted for the BIO. More...

#define BIO_FLAGS_FLUSH_ON_WRITE
 Indicates that the BIO should flush the data buffer on the write operation.

#define BIO_FLAGS_EOM
 Indicates that there is no more data in the message.

#define BIO_RR_CONNECT
 Returned from the connect BIO when a connect would have been blocked.

#define BIO_RR_ACCEPT
 Returned from the accept BIO. More...

#define BIO_CB_FREE
 Indicates that the BIO callback function was called during an execution of BIO_free().

#define BIO_CB_READ
 Indicates that the BIO callback function was called during an execution of BIO_read().

#define BIO_CB_WRITE
 Indicates that the BIO callback function was called during an execution of BIO_write().

#define BIO_CB_PUTS
 Indicates that the BIO callback function was called during an execution of BIO_puts().

#define BIO_CB_GETS
 Indicates that the BIO callback function was called during an execution of BIO_gets().

#define BIO_CB_CTRL
 Indicates that the BIO callback function was called during an execution of BIO_ctrl().

#define BIO_CB_FUNC_MASK
 Used to mask the function number of the command.

#define BIO_CB_RETURN
 Indicates that the BIO callback function was called after the execution of the underlying operation, rather than before. More...

#define BIO_CB_TYPE_FUNC
 This is the standard callback function. More...

#define BIO_CB_TYPE_INFO
 This is the information callback for connections. More...

#define BIO_CB_TYPE_STATE
 This is the state callback. More...

#define BIO_C_NEXT_MSG
 Perform processing to prepare for the next message.

#define BIO_C_SET_STORE
 Set the store context against the BIO filter.

#define BIO_C_SET_VFY_CTX
 Set the verification context against the BIO filter.

#define BIO_C_SET_EITEMS
 Set the R_EITEMS against the BIO filter.

#define BIO_C_SET_CTX
 Set the context for further operations against the BIO filter.

#define BIO_C_SET_CODE
 Set the OP program code against the BIO filter.

#define BIO_C_SET_STATE_CB
 Set the state callback and argument against the BIO filter.

#define BIO_C_GET_STATE_CB
 Retrieve the state callback and argument from the BIO filter.

#define BIO_C_END_OF_MSG
 Indicate that all the data has been written and any post-processing should start and/or trailing data should now be put out.

#define BIO_C_STATE_STRING
 Obtain the string corresponding to the state value passed.

#define BIO_C_SET_PADDING_MODE
 Set the padding method for a cipher BIO.

#define BIO_C_SET_ASYM_KEY
 Set the private asymmetric key for a cryptographic message BIO. More...

#define BIO_C_SET_CERT
 Set the certificate of a recipient for a cryptographic message BIO. More...

#define BIO_C_SET_ALG_ID
 Set the ID of the encryption algorithm used in encrypting the content data of an enveloped message.

#define BIO_C_GET_PARAMS
 Get the parameters of the cryptographic algorithm.

#define BIO_C_SET_KEY_SIZE
 Set the size (length) of the key.

#define BIO_C_SET_EFF_BITS
 Set the effective key bits.

#define BIO_C_SET_NO_ROUNDS
 Set the number of rounds.

#define BIO_C_SET_WRAPPED
 Set whether the cryptographic message is wrapped.

#define BIO_C_SET_CONTENT_TYPE
 Set the content type of the cryptographic message.

#define BIO_C_INIT
 Initialize the BIO with the data passed in.

#define BIO_DUMP_FORMAT_HEX
 Format the output of each Byte as two hexadecimal characters.

#define BIO_DUMP_FORMAT_HEX_PREFIX
 Format the output of each Byte as '0x' (zero-small-x), followed by two hexadecimal characters.

#define BIO_PRINT_HEX_REVERSE
 The BIO_print_hex() flag required for printing little-endian numbers. More...


Typedefs

typedef struct bio_st BIO
 The BIO object type identifier.

typedef long BIO_CB_FUNC_T (BIO *bio, int cmd, char *argp, int argi, long argl, long ret)
 Used for creating user-defined debugging routines or surrender functions. More...

typedef long R_BIO_CB_FUNC_T (BIO *bio, int cmd, char *argp, int argi, long argl, long ret)
 Deprecated name for the BIO callback type.

typedef int BIO_STATE_CB_FUNC_T (BIO *bio, int type, int state, int ret, int flag, char *cb_arg)
 The type of callback function that reports on the BIO state. More...

typedef struct bio_state_cb_st BIO_STATE_CB
 The type used to hold the state callback and its user-defined argument for transportation.

typedef struct bio_init_st BIO_INIT
 This structure stores the data that is required to perform initialization on a new BIO that was created from the resource list.

typedef struct bio_method_st BIO_METHOD
 This structure stores pointers to functions that implement the BIO methods. More...


Functions

long BIO_set_fp (BIO *bio, char *fp, long flags)
 Sets the file pointer fp to be used with the BIO bio. More...

long BIO_get_fp (BIO *bio, char *fp)
 Returns the file pointer associated with the BIO bio. More...

int BIO_seek (BIO *bio, long offset)
 Moves the current position in the BIO bio. More...

int BIO_tell (BIO *bio)
 Retrieves the current position in the BIO bio. More...

long BIO_read_filename (BIO *bio, char *name)
 Opens the file name name for reading on the BIO bio. More...

long BIO_write_filename (BIO *bio, char *name)
 Opens the file name name for writing on the BIO bio. More...

long BIO_append_filename (BIO *bio, char *name)
 Opens the file name name for writing on the BIO bio after End-of-File (EOF). More...

long BIO_rw_filename (BIO *bio, char *name)
 Opens the file name name on the BIO bio for both reading and writing. More...

int BIO_reset (BIO *bio)
 Resets the BIO bio to its initial state. More...

int BIO_set_close (BIO *bio, long mode)
 Sets the close mode for the BIO bio. More...

int BIO_get_close (BIO *bio)
 Returns the close flag for the BIO bio. More...

int BIO_flush (BIO *bio)
 Flushes any data stored in any output buffers of the BIO stack bio. More...

int BIO_end_of_msg (BIO *bio)
 Tells the BIO that no more data is to be written in this message. More...

long BIO_set_verification (BIO *bio, R_VERIFY_CTX *ctx)
 Sets the verification context against a BIO. More...

long BIO_set_store (BIO *bio, R_CERT_STORE_CTX *store)
 Sets the certificate store context against a BIO. More...

long BIO_set_cert (BIO *bio, R_CERT *cert)
 Sets the certificate against a BIO. More...

long BIO_set_asym_key (BIO *bio, R_PKEY *pkey)
 Sets the asymmetric key against a BIO. More...

long BIO_set_alg (BIO *bio, R_CR_ALG_ID alg_id)
 Sets the symmetric cipher algorithm against a BIO. More...

BIO_METHODBIO_s_file (void)
 Returns a reference to the static BIO_METHOD used by a file source sink BIO. More...

BIOBIO_new_file (char *filename, char *mode)
 Creates a file BIO descriptor filename with a file opening mode of mode. More...

BIOBIO_new_fp (FILE *stream, int close_flag)
 Creates a new file BIO descriptor file pointer. More...

BIOBIO_new (BIO_METHOD *method)
 Creates a new BIO and associates the method type against the structure. More...

int BIO_free (BIO *bio)
 Frees the BIO bio. More...

void BIO_free_all (BIO *bio)
 Frees all BIOs in the BIO stack bio. More...

int BIO_read (BIO *bio, char *out, int outl)
 Reads data through the BIO bio. More...

int BIO_gets (BIO *bio, char *in, int inl)
 Reads a string from the BIO bio into the specified buffer in. More...

int BIO_write (BIO *bio, char *in, int inl)
 Writes data through the BIO bio. More...

int BIO_puts (BIO *bio, char *in)
 Writes the NULL terminated string contained in in to the BIO bio. More...

long BIO_ctrl (BIO *bio, int cmd, long larg, char *parg)
 Provides the replaceable point for all implementation-specific behavior for the I/O. More...

BIOBIO_push (BIO *bio, BIO *stack)
 Pushes the BIO bio onto the existing BIO stack and returns a pointer to the new stack. More...

BIOBIO_pop (BIO *bio)
 Pops the uppermost BIO bio from the BIO stack and returns the remaining BIO stack. More...

BIOBIO_find_type (BIO *bio, int type)
 Returns a BIO from the stack bio with a specified type. More...

BIOBIO_get_retry_BIO (BIO *bio, int *reason)
 Walks the BIO stack bio and returns the first BIO found that has a retry error set and the reason why the operation should be retried. More...

BIOBIO_dup_chain (BIO *in)
 Iterates down the BIO stack bio and creates a new copy of each BIO. More...

long MS_CALLBACK BIO_debug_cb (BIO *bio, int cmd, char *argp, int argi, long argl, long ret)
 Sets a prepared callback for the BIO structure bio to output debug information via BIO_set_cb(). More...

BIO_METHODBIO_s_mem (void)
 Returns a reference to the static BIO_METHOD used by a memory source sink BIO.

BIO_METHODBIO_s_null (void)
 Returns a reference to the static BIO_METHOD used by a NULL source sink BIO. More...

BIO_METHODBIO_f_null (void)
 This section lists the Filter BIOs that may be used in a BIO stack. More...

BIO_METHODBIO_f_buffer (void)
 Returns a reference to the static BIO_METHOD used by a buffer filter BIO. More...

int BIO_dump (BIO *bio, unsigned char *bytes, int len)
 Dumps the contents of binary data buffer bytes to the BIO structure bio in hexadecimal and ASCII form, removing any trailing spaces or NULL characters. More...

int BIO_dump_format (BIO *bio, unsigned char *data, int len, int format, int separator, int indent, int wrap)
 Specifies the format for dumping the contents of the BIO structure bio. More...

BIOBIO_new_mem (void)
 Creates a memory BIO where all read and write operations refer to an internal memory buffer. More...

void BIO_copy_next_retry (BIO *bio)
 Copies the retry flags and reason from the next BIO in the BIO stack to this BIO bio in order to propagate the retry values up one element in the BIO stack. More...

void BIO_reference_inc (BIO *bio)
 Increments the reference count for the BIO bio. More...

void BIO_set_flags (BIO *bio, int f)
 Sets the flags indicating the current state of the BIO bio. More...

int BIO_get_flags (BIO *bio)
 Returns the flags indicating the current state of the BIO bio. More...

void BIO_clear_flags (BIO *bio, int f)
 Clears the flags used internally by the BIO bio. More...

void BIO_clear_retry_flags (BIO *bio)
 Clears the flags field for BIO_FLAGS_RWS and BIO_FLAGS_SHOULD_RETRY for the BIO bio. More...

int BIO_get_retry_flags (BIO *bio)
 Retrieves the settings from the retry flags field for the BIO bio. More...

int BIO_should_read (BIO *bio)
 Indicates whether the last read operation should be retried for the BIO bio. More...

int BIO_should_write (BIO *bio)
 Indicates whether the last write operation should be retried for the BIO bio. More...

int BIO_should_io_special (BIO *bio)
 Indicates a BIO-specific retry reason caused the transitory error for the BIO bio. More...

int BIO_should_retry (BIO *bio)
 Indicates whether the last I/O operation (read or write) should be retried for the BIO bio. More...

int BIO_get_retry_reason (BIO *bio)
 Returns the settings from the retry reason field for the BIO bio. More...

char* BIO_method_name (BIO *bio)
 Returns the name field for the method structure for the BIO bio. More...

int BIO_method_type (BIO *bio)
 Returns the numeric type of the method structure for the BIO bio. More...

void BIO_set_cb (BIO *bio, BIO_CB_FUNC_T *cb)
 Sets a user-defined callback for the BIO bio. More...

void BIO_set_cb_arg (BIO *bio, char *arg)
 Sets an extra user-defined argument against the BIO bio that developers may use in the callback. More...

void BIO_set_bio_cb (BIO *bio, BIO_CB_FUNC_T *cb, char *arg)
 Sets the BIO callback and an argument against the BIO bio. More...

char* BIO_get_cb_arg (BIO *bio)
 Returns a pointer to the user-defined data for the user-defined callback that exists within the BIO bio. More...

BIO_CB_FUNC_TBIO_get_cb (BIO *bio)
 Returns the user-defined callback function for the BIO bio if a callback function is defined. More...

void BIO_set_state_cb (BIO *bio, BIO_STATE_CB_FUNC_T *cb, char *arg)
 Sets the BIO state callback and an argument against the BIO bio. More...

int BIO_state_to_string (BIO *bio, int state, size_t len, char *str)
 Converts the state value of the internal state machine of the BIO into a string. More...

char* BIO_get_state_cb_arg (BIO *bio)
 Returns a pointer to the user-defined data for the user-defined state callback that exists within the BIO bio. More...

BIO_STATE_CB_FUNC_TBIO_get_state_cb (BIO *bio)
 Returns the user-defined state callback function for the BIO bio if a state callback function is defined. More...

int BIO_set_cb_recursive (BIO *bio, int type, void *cb, char *arg)
 Sets the BIO state callback and an argument against all the BIO objects in the stack. More...

int BIO_flags_to_string (int flags, char sep, size_t len, char *str)
 Converts the flags of a BIO into a string. More...

int BIO_cb_cmd_to_string (int cmd, size_t len, char *str)
 Converts the information callback cmd for a BIO into a string. More...

int BIO_open_file (BIO *bio, char *name, char *mode)
 Opens the file name with a file opening mode of mode. More...

int BIO_print_hex (BIO *bio, unsigned char *bytes, int len, int flags)
 Prints an array of Bytes in hexadecimal format to the BIO bio. More...

int BIO_printf (BIO *bio,...)
 Provides the equivalent of the standard C runtime printf function where the output is directed to the BIO structure bio with a format string. More...


Define Documentation

#define BIO_C_SET_ASYM_KEY
 

Set the private asymmetric key for a cryptographic message BIO. This asymmetric key is used to decrypt the symmetric key which encrypts the enveloped data content.

#define BIO_C_SET_CERT
 

Set the certificate of a recipient for a cryptographic message BIO. The certificate is used to determine the recipient index in the header of a PKCS#7 enveloped message.


Typedef Documentation

typedef struct bio_method_st BIO_METHOD
 

This structure stores pointers to functions that implement the BIO methods. Each BIO has seven methods. A NULL pointer indicates that the method is not implemented.
The methods define the behavior of an individual BIO type, and are called directly by the BIO access functions. The methods modify the general BIO behavior by replacing it with the specific behavior for the BIO sub-class.


Function Documentation

BIO_METHOD* BIO_f_buffer void    ;
 

Returns a reference to the static BIO_METHOD used by a buffer filter BIO. The buffer filter BIO is used to store data where the next BIO in the BIO stack is non-blocking, and may not be able to read or write all requested data within a single call.

BIO_METHOD* BIO_f_null void    ;
 

This section lists the Filter BIOs that may be used in a BIO stack. These provide data filtering prior to writing to, or after reading from, a source/sink BIO.

BIO_METHOD* BIO_s_file void    ;
 

Returns a reference to the static BIO_METHOD used by a file source sink BIO. The file source sink BIO is only available on platforms supporting file operations.

BIO_METHOD* BIO_s_null   ;
 

Returns a reference to the static BIO_METHOD used by a NULL source sink BIO. The NULL source sink BIO is used to discard data rather than output it. A read operation from a NULL source sink BIO does not modify the output buffer supplied.

Returns:
A BIO_METHOD reference.
See also:
BIO_new().


Copyright (c) 1999-2002 RSA Security Inc. All rights reserved. 061-001005-150-001-000-3768 - 1.5