1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| #define TEST_XXX_IS_SAME \
unsigned char is_same = 1; \
\
for(pos = 0; (is_same && (pos < KEY_LENGTH)); ++pos) { \
if (app_master_key[pos] != key_XXX[pos]) { is_same = 0; } \
} \
\
if (!is_same) { \
is_same = 1; \
\
for(pos = 0; (is_same && (pos < KEY_LENGTH)); ++pos) { \
if (app_read_key[pos] != key_XXX[pos]) { is_same = 0; } \
} \
\
if (!is_same) { \
is_same = 1; \
\
for(pos = 0; (is_same && (pos < KEY_LENGTH)); ++pos) { \
if (app_write_key[pos] != key_XXX[pos]) { is_same = 0; } \
} \
\
if (!is_same) { \
ret = 1; \
} else { \
handler->error = GLB_ERR_HANDLER_XXX_APK2; \
\
ret = 0; \
} \
} else { \
handler->error = GLB_ERR_HANDLER_XXX_APK1; \
\
ret = 0; \
} \
} else { \
handler->error = GLB_ERR_HANDLER_XXX_MAK; \
\
ret = 0; \
}
#define WRITE_CARD_XXX_CONTENT \
/*XXX test: FILE_MAX_SIZE == (AID_LENGTH + FID_LENGTH + (3 * KEY_LENGTH));*/ \
unsigned char pos, key_pos; \
\
handler->last_task = TASK_PUT_FILE_CONTENT; handler->error = GLB_ERROR_NONE; \
\
is_finished = 0; \
nb_tries = 0; \
\
/*Write AID, FID, first APK1, second APK1*/ \
for(pos = 0; pos < AID_LENGTH; ++pos) { handler->little_buffer[AID_LENGTH - pos - 1] = app_ID[pos]; } \
\
handler->little_buffer[AID_LENGTH] = 01 /*file_index*/; \
\
key_pos = AID_LENGTH + 1; \
\
for(pos = 0; pos < KEY_LENGTH; ++pos) { handler->little_buffer[key_pos + pos] = first_app_read_key[pos]; } \
\
key_pos += KEY_LENGTH; \
\
for(pos = 0; pos < KEY_LENGTH; ++pos) { handler->little_buffer[key_pos + pos] = second_app_read_key[pos]; } \
\
/*pos += key_pos;*/ \
\
for(pos = 0; pos < KEY_LENGTH; ++pos) { handler->little_buffer[key_pos + pos] = 0x94; } \
\
key_pos += KEY_LENGTH; \
\
/*for(; pos < FILE_MAX_SIZE; ++pos) { handler->little_buffer[key_pos + pos] = 0x00; }*/ \
\
do { \
ret = device_put_file_content(&(handler->device), NULL, NULL, 0x01, 0, FILE_MAX_SIZE, handler->little_buffer); \
\
TEST_RETURN_TRY \
} while(!ret && !is_finished); |