45 {
46
48
52
54
56
57 struct timeval before, after;
58 double this;
60
65
67
68
70 if (
yrc != YH_SUCCESS) {
71 fprintf(stderr, "Unable to initialize\n");
72 fprintf(stderr, "(Typically this happens if you don't have permissions to "
73 "open the device\n");
74 fprintf(stderr, "try re-running as root/Administrator)\n");
76 }
77
79 fprintf(stderr, "No suitable device found. Skipping this test\n");
81 }
82
84
86
87
92 fprintf(stderr,
"now doing plain with len %d\n",
len);
94 response_len = sizeof(response);
95
96 gettimeofday(&before, NULL);
98 &response_len);
99 gettimeofday(&after, NULL);
100
101 this = (after.tv_sec - before.tv_sec) * 1000;
102 this += ((double) (after.tv_usec - before.tv_usec)) / 1000;
103 if (i == 0) {
106 } else {
107 if (
this > rs[
rep].max) {
109 }
110 if (
this < rs[
rep].min) {
112 }
113 }
114
116
117 if (rs[
rep].
len != response_len ||
118 memcmp(data, response, rs[
rep].
len) != 0) {
119 fprintf(stderr, "Data mismatch\n");
120 return EXIT_FAILURE;
121 }
122 }
123 }
124
125
129
131 if (
yrc != YH_SUCCESS) {
133 return EXIT_FAILURE;
134 }
135
137 16, yh_context, &
ses);
138 if (
yrc != YH_SUCCESS) {
139 fprintf(stderr,
"Failed to create session: %s\n",
yh_strerror(
yrc));
140 return EXIT_FAILURE;
141 }
142
144 if (
yrc != YH_SUCCESS) {
145 fprintf(stderr,
"Failed to create session: %d, %s\n",
yrc,
147 return EXIT_FAILURE;
148 }
149
154 fprintf(stderr,
"now doing auth with len %d\n",
len);
156 response_len = sizeof(response);
157
158 gettimeofday(&before, NULL);
160 &response_len);
161 gettimeofday(&after, NULL);
162 if (
yrc != YH_SUCCESS) {
163 fprintf(stderr,
"Failed to send message: %d, %s\n",
yrc,
165 return EXIT_FAILURE;
166 }
167
168 this = (after.tv_sec - before.tv_sec) * 1000;
169 this += ((double) (after.tv_usec - before.tv_usec)) / 1000;
170 if (i == 0) {
173 } else {
174 if (
this > rs2[
rep].max) {
176 }
177 if (
this < rs2[
rep].min) {
179 }
180 }
181
183
184 if (rs2[
rep].
len != response_len ||
185 memcmp(data, response, rs2[
rep].
len) != 0) {
186 fprintf(stderr, "Data mismatch\n");
187 return EXIT_FAILURE;
188 }
189 }
190 }
191
193
195 fprintf(stdout, "| Len | min [ms] | max [ms] | avg [ms] | type |\n");
196 fprintf(stdout, "---------------------------------------------------\n");
198 fprintf(stdout,
"| %6d | %8.02f | %8.02f | %8.02f | plain |\n", rs[i].
len,
200 }
202 fprintf(stdout,
"| %6d | %8.02f | %8.02f | %8.02f | auth |\n", rs2[i].
len,
204 }
205
206 return EXIT_SUCCESS;
207}
const char * yh_strerror(yh_rc err)
yh_rc yh_create_session(yh_connector *connector, uint16_t authkey_id, const uint8_t *key_enc, size_t key_enc_len, const uint8_t *key_mac, size_t key_mac_len, bool recreate, yh_session **session)
yh_rc yh_set_verbosity(yh_connector *connector, uint8_t verbosity)
yh_rc yh_send_secure_msg(yh_session *session, yh_cmd cmd, const uint8_t *data, size_t data_len, yh_cmd *response_cmd, uint8_t *response, size_t *response_len)
yh_rc yh_authenticate_session(yh_session *session)
yh_rc yh_send_plain_msg(yh_connector *connector, yh_cmd cmd, const uint8_t *data, size_t data_len, yh_cmd *response_cmd, uint8_t *response, size_t *response_len)
#define YH_HOST_CHAL_LEN
Length of host challenge for authentication.
#define YH_MSG_BUF_SIZE
Maximum length of message buffer.
#define YH_KEY_LEN
Length of authentication keys.
#define YH_CONTEXT_LEN
Length of context array for authentication.
memset(pInfo->slotDescription, ' ', 64)
memcpy((char *) pInfo->slotDescription, s, l)