mirror of
https://gitea.tendokyu.moe/Dniel97/segatools.git
synced 2024-11-27 22:40:48 +01:00
iccard/aime.c: Add (incomplete) AiMe card formatter
This commit is contained in:
parent
87af39a269
commit
225a889b34
47
iccard/aime.c
Normal file
47
iccard/aime.c
Normal file
@ -0,0 +1,47 @@
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "iccard/aime.h"
|
||||
#include "iccard/mifare.h"
|
||||
|
||||
#include "util/dprintf.h"
|
||||
|
||||
HRESULT aime_card_populate(
|
||||
struct mifare *mifare,
|
||||
const uint8_t *luid,
|
||||
size_t nbytes)
|
||||
{
|
||||
uint8_t b;
|
||||
size_t i;
|
||||
|
||||
assert(mifare != NULL);
|
||||
assert(luid != NULL);
|
||||
|
||||
memset(mifare, 0, sizeof(*mifare));
|
||||
|
||||
if (nbytes != 10) {
|
||||
dprintf("AiMe IC: LUID must be 10 bytes\n");
|
||||
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < 10 ; i++) {
|
||||
b = luid[i];
|
||||
|
||||
if ((b & 0xF0) > 0x90 || (b & 0x0F) > 0x09) {
|
||||
dprintf("AiMe IC: LUID must be binary-coded decimal\n");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
mifare->sectors[0].blocks[2].bytes[6 + i] = b;
|
||||
}
|
||||
|
||||
/* TODO An authentic Aime pass has a checksum of the LUID in the last few
|
||||
bytes of block 1. The output of this function fails authenticity check
|
||||
in its current form. */
|
||||
|
||||
dprintf("AiMe IC: WARNING: Authenticity hash not yet implemented!\n");
|
||||
|
||||
return S_OK;
|
||||
}
|
13
iccard/aime.h
Normal file
13
iccard/aime.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "iccard/mifare.h"
|
||||
|
||||
HRESULT aime_card_populate(
|
||||
struct mifare *mifare,
|
||||
const uint8_t *luid,
|
||||
size_t nbytes);
|
@ -7,6 +7,8 @@ iccard_lib = static_library(
|
||||
capnhook.get_variable('hook_dep'),
|
||||
],
|
||||
sources : [
|
||||
'aime.c',
|
||||
'aime.h',
|
||||
'felica.c',
|
||||
'felica.h',
|
||||
'mifare.h',
|
||||
|
Loading…
Reference in New Issue
Block a user