libopensc: new exported function to reverse memory buffer
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5516 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
4f9924eae8
commit
dce63c8bfc
|
@ -117,6 +117,7 @@ sc_lock
|
|||
sc_logout
|
||||
sc_make_cache_dir
|
||||
sc_mem_clear
|
||||
sc_mem_reverse
|
||||
sc_path_print
|
||||
sc_path_set
|
||||
sc_pin_cmd
|
||||
|
|
|
@ -1149,6 +1149,7 @@ int sc_base64_decode(const char *in, u8 *out, size_t outlen);
|
|||
*/
|
||||
void sc_mem_clear(void *ptr, size_t len);
|
||||
void *sc_mem_alloc_secure(size_t len);
|
||||
int sc_mem_reverse(unsigned char *buf, size_t len);
|
||||
|
||||
int sc_get_cache_dir(sc_context_t *ctx, char *buf, size_t bufsize);
|
||||
int sc_make_cache_dir(sc_context_t *ctx);
|
||||
|
|
|
@ -727,6 +727,23 @@ void sc_mem_clear(void *ptr, size_t len)
|
|||
#endif
|
||||
}
|
||||
|
||||
int sc_mem_reverse(unsigned char *buf, size_t len)
|
||||
{
|
||||
unsigned char ch;
|
||||
size_t ii;
|
||||
|
||||
if (!buf || !len)
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
|
||||
for (ii = 0; ii < len / 2; ii++) {
|
||||
ch = *(buf + ii);
|
||||
*(buf + ii) = *(buf + len - 1 - ii);
|
||||
*(buf + len - 1 - ii) = ch;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sc_remote_apdu_allocate(struct sc_remote_data *rdata,
|
||||
struct sc_remote_apdu **new_rapdu)
|
||||
|
|
Loading…
Reference in New Issue