libopensc: API for the 'erase-binary' card operation

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5005 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
vtarasov 2010-12-30 13:25:09 +00:00
parent ee907b7a69
commit 8b270205cc
3 changed files with 29 additions and 0 deletions

View File

@ -531,6 +531,23 @@ int sc_update_binary(sc_card_t *card, unsigned int idx,
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
}
int sc_erase_binary(struct sc_card *card, unsigned int offs, size_t count,
unsigned long flags)
{
int r;
assert(card != NULL && card->ops != NULL);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "called; erase %d bytes from offset %d", count, offs);
if (card->ops->erase_binary == NULL)
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_NOT_SUPPORTED);
r = card->ops->erase_binary(card, offs, count, flags);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
}
int sc_select_file(sc_card_t *card,
const sc_path_t *in_path,
sc_file_t **file)

View File

@ -237,6 +237,7 @@ sc_verify
sc_wait_for_event
sc_write_binary
sc_write_record
sc_erase_binary
sc_get_iso7816_driver
sc_pkcs15init_add_app
sc_pkcs15init_authenticate

View File

@ -861,6 +861,17 @@ int sc_write_binary(sc_card_t *card, unsigned int idx, const u8 * buf,
int sc_update_binary(sc_card_t *card, unsigned int idx, const u8 * buf,
size_t count, unsigned long flags);
/**
* Sets (part of) the content fo an EF to its logical erased state
* @param card sc_card_t 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 writen or an error code
*/
int sc_erase_binary(struct sc_card *card, unsigned int idx,
size_t count, unsigned long flags);
#define SC_RECORD_EF_ID_MASK 0x0001FUL
/** flags for record operations */
/** use first record */