Encodes a APDU as an octet string
@param ctx sc_context_t object (used for logging)
@param apdu APDU to be encoded as an octet string
@param proto protocol version to be used
@param out output buffer of size outlen.
@param outlen size of hte output buffer
@return SC_SUCCESS on success and an error code otherwise
Appends a sc_path_t object to another sc_path_t object (note:
this function is a wrapper for sc_concatenate_path)
@param dest destination sc_path_t object
@param src sc_path_t object to append
@return SC_SUCCESS on success and an error code otherwise
Appends a record to the current (i.e. selected) file.
@param card struct sc_card object on which to issue the command
@param buf buffer with to the data for the new record
@param count length of the data
@param flags flags (may contain a short file id of a file to select)
@retval number of bytes written or an error value
Transforms an APDU from binary to its @c sc_apdu_t representation
@param ctx sc_context_t object (used for logging)
@param buf APDU to be encoded as an @c sc_apdu_t object
@param len length of @a buf
@param apdu @c sc_apdu_t object to initialize
@return SC_SUCCESS on success and an error code otherwise
@note On successful initialization apdu->data will point to @a buf with an
appropriate offset. Only free() @a buf, when apdu->data is not needed any
longer.
@note On successful initialization @a apdu->resp and apdu->resplen will be
0. You should modify both if you are expecting data in the response APDU.
Cancel all pending PC/SC calls
NOTE: only PC/SC backend implements this function.
@param ctx pointer to application context
@retval SC_SUCCESS on success
Find a given tag in a compact TLV structure
@param[in] buf input buffer holding the compact TLV structure
@param[in] len length of the input buffer @buf in bytes
@param[in] tag compact tag to search for - high nibble: plain tag, low nibble: length.
If length is 0, only the plain tag is used for searching,
in any other case, the length must also match.
@param[out] outlen pointer where the size of the buffer returned is to be stored
@return pointer to the tag value found within @buf, or NULL if not found/on error
Compares two sc_object_id objects
@param oid1 the first sc_object_id object
@param oid2 the second sc_object_id object
@return 1 if the oids are equal and a zero value otherwise
Compares two sc_path_t objects
@param patha sc_path_t object of the first path
@param pathb sc_path_t object of the second path
@return 1 if both paths are equal and 0 otherwise
Checks whether one path is a prefix of another path
@param prefix sc_path_t object with the prefix
@param path sc_path_t object with the path which should start
with the given prefix
@return 1 if the parameter prefix is a prefix of path and 0 otherwise
Concatenate two sc_path_t values and store the result in
d (note: d can be the same as p1 or p2).
@param d destination sc_path_t object
@param p1 first sc_path_t object
@param p2 second sc_path_t object
@return SC_SUCCESS on success and an error code otherwise
Connects to a card in a reader and auto-detects the card driver.
The ATR (Answer to Reset) string of the card is also retrieved.
@param reader Reader structure
@param card The allocated card object will go here
Creates a new sc_context_t object.
@param ctx pointer to a sc_context_t pointer for the newly
created sc_context_t object.
@param parm parameters for the sc_context_t creation (see
sc_context_param_t for a description of the supported
options)..
@return SC_SUCCESS on success and an error code otherwise.
Repairs an already existing sc_context_t object. This may occur if
multithreaded issues mean that another context in the same heap is deleted.
@param ctx pointer to a sc_context_t pointer containing the (partial)
context.
@return SC_SUCCESS or an error value if an error occurred.
Returns a pointer to the specified sc_reader_t object
@param ctx OpenSC context
@param i number of the reader structure to return (starting with 0)
@return the requested sc_reader object or NULL if the index is
not available
Returns a pointer to the specified sc_reader_t object
@param ctx OpenSC context
@param id id of the reader (starting from 0)
@return the requested sc_reader object or NULL if the reader is
not available
Returns a pointer to the specified sc_reader_t object
@param ctx OpenSC context
@param name name of the reader to look for
@return the requested sc_reader object or NULL if the reader is
not available
Redirects OpenSC debug log to the specified file
@param ctx existing OpenSC context
@param filename path to the file or “stderr” or “stdout”
@return SC_SUCCESS on success and an error code otherwise
In windows: get configuration option from environment or from registers.
@param env name of environment variable
@param reg name of register value
@param key path of register key
@return SC_SUCCESS on success and an error code otherwise.
Checks if a card is present in a reader
@param reader Reader structure
@retval If an error occurred, the return value is a (negative)
OpenSC error code. If no card is present, 0 is returned.
Otherwise, a positive value is returned, which is a
combination of flags. The flag SC_READER_CARD_PRESENT is
always set. In addition, if the card was exchanged,
the SC_READER_CARD_CHANGED flag is set.
Disconnects from a card, and frees the card structure. Any locks
made by the application must be released before calling this function.
NOTE: The card is not reset nor powered down after the operation.
@param card The card to disconnect
@return SC_SUCCESS on success and an error code otherwise
Sets (part of) the content fo an EF to its logical erased state
@param card struct sc_card object on which to issue the command
@param idx index within the file for the data to be erased
@param count number of bytes to erase
@param flags flags for the ERASE BINARY command (currently not used)
@return number of bytes written or an error code
Establishes an OpenSC context. Note: this function is deprecated,
please use sc_context_create() instead.
@param ctx A pointer to a pointer that will receive the allocated context
@param app_name A string that identifies the application, used primarily
in finding application-specific configuration data. Can be NULL.
Converts a given OID in ascii form to a internal sc_object_id object
@param oid OUT sc_object_id object for the result
@param in ascii string with the oid (“1.2.3.4.5…”)
@return SC_SUCCESS or an error value if an error occurred.
Gets challenge from the card (normally random data).
@param card struct sc_card object on which to issue the command
@param rndout buffer for the returned random challenge
@param len length of the challenge
@return SC_SUCCESS on success and an error code otherwise
List file ids within a DF
@param card struct sc_card object on which to issue the command
@param buf buffer for the read file ids (the filed ids are
stored in the buffer as a sequence of 2 byte values)
@param buflen length of the supplied buffer
@return number of files ids read or an error code
Resets the security status of the card (i.e. withdraw all granted
access rights). Note: not all card operating systems support a logout
command and in this case SC_ERROR_NOT_SUPPORTED is returned.
@param card struct sc_card object
@return SC_SUCCESS on success, SC_ERROR_NOT_SUPPORTED if the card
doesn’t support a logout command and an error code otherwise
Clears a memory buffer (note: when OpenSSL is used this is
currently a wrapper for OPENSSL_cleanse() ).
@param ptr pointer to the memory buffer
@param len length of the memory buffer
Prints the sc_path_t object to a character buffer
@param buf pointer to the buffer
@param buflen size of the buffer
@param path sc_path_t object to be printed
@return SC_SUCCESS on success and an error code otherwise
Sets the content of a sc_path_t object.
@param path sc_path_t object to set
@param type type of path
@param id value of the path
@param id_len length of the path value
@param index index within the file
@param count number of bytes
@return SC_SUCCESS on success and an error code otherwise
Return string representation of the given sc_path_t object
Warning: as static memory is used for the return value
this function is not thread-safe !!!
@param path sc_path_t object of the path to be printed
@return pointer to a const buffer with the string representation
of the path
Read data from a binary EF
@param card struct sc_card object on which to issue the command
@param idx index within the file with the data to read
@param buf buffer to the read data
@param count number of bytes to read
@param flags flags for the READ BINARY command (currently not used)
@return number of bytes read or an error code
Reads a record from the current (i.e. selected) file.
@param card struct sc_card object on which to issue the command
@param rec_nr SC_READ_RECORD_CURRENT or a record number starting from 1
@param buf Pointer to a buffer for storing the data
@param count Number of bytes to read
@param flags flags (may contain a short file id of a file to select)
@retval number of bytes read or an error value
Resets the card.
NOTE: only PC/SC backend implements this function at this moment.
@param card The card to reset.
@param do_cold_reset 0 for a warm reset, 1 for a cold reset (unpower)
@retval SC_SUCCESS on success
Does the equivalent of ISO 7816-4 command SELECT FILE.
@param card struct sc_card object on which to issue the command
@param path The path, file id or name of the desired file
@param file If not NULL, will receive a pointer to a new structure
@return SC_SUCCESS on success and an error code otherwise
Sends a APDU to the card
@param card struct sc_card object to which the APDU should be send
@param apdu sc_apdu_t object of the APDU to be send
@return SC_SUCCESS on success and an error code otherwise
Updates the content of a binary EF
@param card struct sc_card object on which to issue the command
@param idx index within the file for the data to be updated
@param buf buffer with the new data
@param count number of bytes to update
@param flags flags for the UPDATE BINARY command (currently not used)
@return number of bytes written or an error code
Updates the data of a record from the current (i.e. selected) file.
@param card struct sc_card object on which to issue the command
@param rec_nr SC_READ_RECORD_CURRENT or a record number starting from 1
@param buf buffer with to the new data to be written
@param count number of bytes to update
@param flags flags (may contain a short file id of a file to select)
@retval number of bytes written or an error value
Waits for an event on readers. Note: only the event is detected,
there is no update of any card or other info.
NOTE: Only PC/SC backend implements this.
@param ctx pointer to a Context structure
@param event_mask The types of events to wait for; this should
be ORed from one of the following
SC_EVENT_CARD_REMOVED
SC_EVENT_CARD_INSERTED
SC_EVENT_READER_ATTACHED
@param event_reader (OUT) the reader on which the event was detected, or NULL if new reader
@param event (OUT) the events that occurred. This is also ORed
from the SC_EVENT_CARD_* constants listed above.
@param timeout Amount of millisecs to wait; -1 means forever
@retval < 0 if an error occurred
@retval = 0 if a an event happened
@retval = 1 if the timeout occurred
Write data to a binary EF
@param card struct sc_card object on which to issue the command
@param idx index within the file for the data to be written
@param buf buffer with the data
@param count number of bytes to write
@param flags flags for the WRITE BINARY command (currently not used)
@return number of bytes written or an error code
Writes data to a record from the current (i.e. selected) file.
@param card struct sc_card object on which to issue the command
@param rec_nr SC_READ_RECORD_CURRENT or a record number starting from 1
@param buf buffer with to the data to be written
@param count number of bytes to write
@param flags flags (may contain a short file id of a file to select)
@retval number of bytes written or an error value