Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pcsc-tools
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ludovic Rousseau
pcsc-tools
Commits
de52e744
Commit
de52e744
authored
Apr 08, 2017
by
Ludovic Rousseau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcsc_scan: add a stress() function
parent
a0bde8f5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
pcsc_scan.c
pcsc_scan.c
+77
-0
No files found.
pcsc_scan.c
View file @
de52e744
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include <time.h>
#include <time.h>
#include <unistd.h>
#include <unistd.h>
#include <string.h>
#include <string.h>
#include <sys/time.h>
#ifdef __APPLE__
#ifdef __APPLE__
#include <PCSC/wintypes.h>
#include <PCSC/wintypes.h>
...
@@ -97,6 +98,82 @@ static void spin_suspend(void)
...
@@ -97,6 +98,82 @@ static void spin_suspend(void)
fflush
(
stdout
);
fflush
(
stdout
);
}
}
static
LONG
stress
(
LONG
hContext
,
const
char
*
readerName
)
{
LONG
rv
;
SCARDHANDLE
hCard
;
DWORD
dwActiveProtocol
;
const
SCARD_IO_REQUEST
*
pioSendPci
;
printf
(
"Stress card
\n\n
"
);
rv
=
SCardConnect
(
hContext
,
readerName
,
SCARD_SHARE_SHARED
,
SCARD_PROTOCOL_T0
|
SCARD_PROTOCOL_T1
,
&
hCard
,
&
dwActiveProtocol
);
if
(
rv
!=
SCARD_S_SUCCESS
)
{
print_pcsc_error
(
"SCardConnect"
,
rv
);
return
rv
;
}
/* Select Master File */
BYTE
pbSendBuffer
[]
=
{
0
,
0xA4
,
0
,
0
,
2
,
0x3F
,
0
};
BYTE
pbRecvBuffer
[
256
+
2
];
DWORD
dwSendLength
,
dwRecvLength
;
struct
timeval
time_start
,
time_end
;
switch
(
dwActiveProtocol
)
{
case
SCARD_PROTOCOL_T0
:
pioSendPci
=
SCARD_PCI_T0
;
break
;
case
SCARD_PROTOCOL_T1
:
pioSendPci
=
SCARD_PCI_T1
;
break
;
case
SCARD_PROTOCOL_RAW
:
pioSendPci
=
SCARD_PCI_RAW
;
break
;
default:
printf
(
"Unknown protocol
\n
"
);
return
-
1
;
}
gettimeofday
(
&
time_start
,
NULL
);
#define COUNT 100
size_t
count
;
for
(
count
=
0
;
count
<
COUNT
;
count
++
)
{
printf
(
"
\033
[FAPDU n°: %ld
\n
"
,
count
);
dwSendLength
=
sizeof
(
pbSendBuffer
);
dwRecvLength
=
sizeof
(
pbRecvBuffer
);
rv
=
SCardTransmit
(
hCard
,
pioSendPci
,
pbSendBuffer
,
dwSendLength
,
NULL
,
pbRecvBuffer
,
&
dwRecvLength
);
if
(
rv
!=
SCARD_S_SUCCESS
)
{
print_pcsc_error
(
"SCardDisconnect"
,
rv
);
break
;
}
}
gettimeofday
(
&
time_end
,
NULL
);
struct
timeval
r
;
r
.
tv_sec
=
time_end
.
tv_sec
-
time_start
.
tv_sec
;
r
.
tv_usec
=
time_end
.
tv_usec
-
time_start
.
tv_usec
;
if
(
r
.
tv_usec
<
0
)
{
r
.
tv_sec
--
;
r
.
tv_usec
+=
1000000
;
}
long
delta
=
r
.
tv_sec
*
1000000
+
r
.
tv_usec
;
printf
(
"Total time: %ld µs
\n
"
,
delta
);
printf
(
"%f APDU/s
\n
"
,
1000000
.
/
(
delta
/
count
));
rv
=
SCardDisconnect
(
hCard
,
SCARD_LEAVE_CARD
);
if
(
rv
!=
SCARD_S_SUCCESS
)
print_pcsc_error
(
"SCardDisconnect"
,
rv
);
return
rv
;
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
current_reader
;
int
current_reader
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment