Eric Betts 8 kuukautta sitten
vanhempi
commit
a3d1b2880a

+ 7 - 0
application.fam

@@ -14,4 +14,11 @@ App(
     fap_author="bettse",
     fap_weburl="https://github.com/bettse/weebo",
     fap_icon_assets="images",  # Image assets to compile for this application
+    fap_libs=["mbedtls"],
+    fap_private_libs=[
+        Lib(
+            name="amiitool",
+        ),
+    ],
+
 )

+ 181 - 0
lib/amiitool/amiibo.c

@@ -0,0 +1,181 @@
+/*
+ * (c) 2015-2017 Marcos Del Sol Vives
+ * (c) 2016      javiMaD
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "amiibo.h"
+#include "util.h"
+#include "mbedtls/md.h"
+#include "mbedtls/aes.h"
+#include <errno.h>
+#include "portable_endian.h"
+
+#define htobe16(x) __builtin_bswap16(x)
+#define be16toh(x) __builtin_bswap16(x)
+
+#define HMAC_POS_DATA 0x008
+#define HMAC_POS_TAG 0x1B4
+
+void nfc3d_amiibo_calc_seed(const uint8_t * dump, uint8_t * key) {
+	memcpy(key + 0x00, dump + 0x029, 0x02);
+	memset(key + 0x02, 0x00, 0x0E);
+	memcpy(key + 0x10, dump + 0x1D4, 0x08);
+	memcpy(key + 0x18, dump + 0x1D4, 0x08);
+	memcpy(key + 0x20, dump + 0x1E8, 0x20);
+}
+
+void nfc3d_amiibo_keygen(const nfc3d_keygen_masterkeys * masterKeys, const uint8_t * dump, nfc3d_keygen_derivedkeys * derivedKeys) {
+	uint8_t seed[NFC3D_KEYGEN_SEED_SIZE];
+
+	nfc3d_amiibo_calc_seed(dump, seed);
+	nfc3d_keygen(masterKeys, seed, derivedKeys);
+}
+
+void nfc3d_amiibo_cipher(const nfc3d_keygen_derivedkeys * keys, const uint8_t * in, uint8_t * out) {
+	mbedtls_aes_context aes;
+	size_t nc_off = 0;
+	unsigned char nonce_counter[16];
+	unsigned char stream_block[16];
+
+	mbedtls_aes_setkey_enc( &aes, keys->aesKey, 128 );
+	memset(nonce_counter, 0, sizeof(nonce_counter));
+	memset(stream_block, 0, sizeof(stream_block));
+	memcpy(nonce_counter, keys->aesIV, sizeof(nonce_counter));
+	mbedtls_aes_crypt_ctr( &aes, 0x188, &nc_off, nonce_counter, stream_block, in + 0x02C, out + 0x02C );
+
+	memcpy(out + 0x000, in + 0x000, 0x008);
+	// Data signature NOT copied
+	memcpy(out + 0x028, in + 0x028, 0x004);
+	// Tag signature NOT copied
+	memcpy(out + 0x1D4, in + 0x1D4, 0x034);
+}
+
+void nfc3d_amiibo_tag_to_internal(const uint8_t * tag, uint8_t * intl) {
+	memcpy(intl + 0x000, tag + 0x008, 0x008);
+	memcpy(intl + 0x008, tag + 0x080, 0x020);
+	memcpy(intl + 0x028, tag + 0x010, 0x024);
+	memcpy(intl + 0x04C, tag + 0x0A0, 0x168);
+	memcpy(intl + 0x1B4, tag + 0x034, 0x020);
+	memcpy(intl + 0x1D4, tag + 0x000, 0x008);
+	memcpy(intl + 0x1DC, tag + 0x054, 0x02C);
+}
+
+void nfc3d_amiibo_internal_to_tag(const uint8_t * intl, uint8_t * tag) {
+	memcpy(tag + 0x008, intl + 0x000, 0x008);
+	memcpy(tag + 0x080, intl + 0x008, 0x020);
+	memcpy(tag + 0x010, intl + 0x028, 0x024);
+	memcpy(tag + 0x0A0, intl + 0x04C, 0x168);
+	memcpy(tag + 0x034, intl + 0x1B4, 0x020);
+	memcpy(tag + 0x000, intl + 0x1D4, 0x008);
+	memcpy(tag + 0x054, intl + 0x1DC, 0x02C);
+}
+
+bool nfc3d_amiibo_unpack(const nfc3d_amiibo_keys * amiiboKeys, const uint8_t * tag, uint8_t * plain) {
+	uint8_t internal[NFC3D_AMIIBO_SIZE];
+	nfc3d_keygen_derivedkeys dataKeys;
+	nfc3d_keygen_derivedkeys tagKeys;
+
+	// Convert format
+	nfc3d_amiibo_tag_to_internal(tag, internal);
+
+	// Generate keys
+	nfc3d_amiibo_keygen(&amiiboKeys->data, internal, &dataKeys);
+	nfc3d_amiibo_keygen(&amiiboKeys->tag, internal, &tagKeys);
+
+	// Decrypt
+	nfc3d_amiibo_cipher(&dataKeys, internal, plain);
+
+	// Regenerate tag HMAC. Note: order matters, data HMAC depends on tag HMAC!
+	mbedtls_md_hmac( mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), tagKeys.hmacKey, sizeof(tagKeys.hmacKey),	
+			 plain + 0x1D4, 0x34, plain + HMAC_POS_TAG );
+
+	// Regenerate data HMAC
+	mbedtls_md_hmac( mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), dataKeys.hmacKey, sizeof(dataKeys.hmacKey),	
+			 plain + 0x029, 0x1DF, plain + HMAC_POS_DATA );
+
+	return
+			memcmp(plain + HMAC_POS_DATA, internal + HMAC_POS_DATA, 32) == 0 &&
+			memcmp(plain + HMAC_POS_TAG, internal + HMAC_POS_TAG, 32) == 0;
+}
+
+void nfc3d_amiibo_pack(const nfc3d_amiibo_keys * amiiboKeys, const uint8_t * plain, uint8_t * tag) {
+	uint8_t cipher[NFC3D_AMIIBO_SIZE];
+	nfc3d_keygen_derivedkeys tagKeys;
+	nfc3d_keygen_derivedkeys dataKeys;
+
+	// Generate keys
+	nfc3d_amiibo_keygen(&amiiboKeys->tag, plain, &tagKeys);
+	nfc3d_amiibo_keygen(&amiiboKeys->data, plain, &dataKeys);
+
+	// Generate tag HMAC
+	mbedtls_md_hmac( mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), tagKeys.hmacKey, sizeof(tagKeys.hmacKey),	
+			 plain + 0x1D4, 0x34, cipher + HMAC_POS_TAG );
+
+	// Init mbedtls HMAC context
+	mbedtls_md_context_t ctx;
+	mbedtls_md_init( &ctx );
+	mbedtls_md_setup( &ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), 1 );
+
+	// Generate data HMAC
+	mbedtls_md_hmac_starts( &ctx, dataKeys.hmacKey, sizeof(dataKeys.hmacKey) );
+	mbedtls_md_hmac_update( &ctx, plain + 0x029, 0x18B ); // Data
+	mbedtls_md_hmac_update( &ctx, cipher + HMAC_POS_TAG, 0x20 ); // Tag HMAC
+	mbedtls_md_hmac_update( &ctx, plain + 0x1D4, 0x34 ); // Here be dragons
+
+	mbedtls_md_hmac_finish( &ctx, cipher + HMAC_POS_DATA );
+
+	// HMAC cleanup
+	mbedtls_md_free( &ctx );
+
+	// Encrypt
+	nfc3d_amiibo_cipher(&dataKeys, plain, cipher);
+
+	// Convert back to hardware
+	nfc3d_amiibo_internal_to_tag(cipher, tag);
+}
+
+bool nfc3d_amiibo_load_keys(nfc3d_amiibo_keys * amiiboKeys, const char * path) {
+	FILE * f = fopen(path, "rb");
+	if (!f) {
+		return false;
+	}
+
+	if (!fread(amiiboKeys, sizeof(*amiiboKeys), 1, f)) {
+		fclose(f);
+		return false;
+	}
+	fclose(f);
+
+	if (
+		(amiiboKeys->data.magicBytesSize > 16) ||
+		(amiiboKeys->tag.magicBytesSize > 16)
+	) {
+		errno = EILSEQ;
+		return false;
+	}
+
+	return true;
+}
+
+
+void nfc3d_amiibo_copy_app_data(const uint8_t * src, uint8_t * dst) {
+
+	uint16_t *ami_nb_wr = (uint16_t*)(dst + 0x29);
+	uint16_t *cfg_nb_wr = (uint16_t*)(dst + 0xB4);
+
+	/* increment write counters */
+	*ami_nb_wr = htobe16(be16toh(*ami_nb_wr) + 1);
+	*cfg_nb_wr = htobe16(be16toh(*cfg_nb_wr) + 1);
+
+	/* copy flags */
+	dst[0x2C] = src[0x2C];
+	/* copy programID */
+	memcpy(dst + 0xAC, src + 0xAC, 8);
+	/* copy AppID */
+	memcpy(dst + 0xB6, src + 0xB6, 4);
+	/* copy AppData */
+	memcpy(dst + 0xDC, src + 0xDC, 216);
+}
+

+ 29 - 0
lib/amiitool/amiibo.h

@@ -0,0 +1,29 @@
+/*
+ * (c) 2015-2017 Marcos Del Sol Vives
+ * (c) 2016      javiMaD
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HAVE_NFC3D_AMIIBO_H
+#define HAVE_NFC3D_AMIIBO_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "keygen.h"
+
+#define NFC3D_AMIIBO_SIZE 520
+
+#pragma pack(1)
+typedef struct {
+	nfc3d_keygen_masterkeys data;
+	nfc3d_keygen_masterkeys tag;
+} nfc3d_amiibo_keys;
+#pragma pack()
+
+bool nfc3d_amiibo_unpack(const nfc3d_amiibo_keys * amiiboKeys, const uint8_t * tag, uint8_t * plain);
+void nfc3d_amiibo_pack(const nfc3d_amiibo_keys * amiiboKeys, const uint8_t * plain, uint8_t * tag);
+bool nfc3d_amiibo_load_keys(nfc3d_amiibo_keys * amiiboKeys, const char * path);
+void nfc3d_amiibo_copy_app_data(const uint8_t * src, uint8_t * dst);
+
+#endif

+ 78 - 0
lib/amiitool/drbg.c

@@ -0,0 +1,78 @@
+/*
+ * (c) 2015-2017 Marcos Del Sol Vives
+ * (c) 2016      javiMaD
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "drbg.h"
+#include <assert.h>
+#include <string.h>
+#include <mbedtls/md.h>
+
+void nfc3d_drbg_init(nfc3d_drbg_ctx * ctx, const uint8_t * hmacKey, size_t hmacKeySize, const uint8_t * seed, size_t seedSize) {
+	assert(ctx != NULL);
+	assert(hmacKey != NULL);
+	assert(seed != NULL);
+	assert(seedSize <= NFC3D_DRBG_MAX_SEED_SIZE);
+
+	// Initialize primitives
+	ctx->used = false;
+	ctx->iteration = 0;
+	ctx->bufferSize = sizeof(ctx->iteration) + seedSize;
+
+	// The 16-bit counter is prepended to the seed when hashing, so we'll leave 2 bytes at the start
+	memcpy(ctx->buffer + sizeof(uint16_t), seed, seedSize);
+
+	// Initialize underlying HMAC context
+	mbedtls_md_init(&ctx->hmacCtx);
+	mbedtls_md_setup(&ctx->hmacCtx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), 1);
+	mbedtls_md_hmac_starts(&ctx->hmacCtx, hmacKey, hmacKeySize);
+}
+
+void nfc3d_drbg_step(nfc3d_drbg_ctx * ctx, uint8_t * output) {
+	assert(ctx != NULL);
+	assert(output != NULL);
+
+	if (ctx->used) {
+		// If used at least once, reinitialize the HMAC
+		mbedtls_md_hmac_reset(&ctx->hmacCtx);
+	} else {
+		ctx->used = true;
+	}
+
+	// Store counter in big endian, and increment it
+	ctx->buffer[0] = ctx->iteration >> 8;
+	ctx->buffer[1] = ctx->iteration >> 0;
+	ctx->iteration++;
+
+	// Do HMAC magic
+	mbedtls_md_hmac_update(&ctx->hmacCtx, ctx->buffer, ctx->bufferSize);
+	mbedtls_md_hmac_finish(&ctx->hmacCtx, output);
+}
+
+void nfc3d_drbg_cleanup(nfc3d_drbg_ctx * ctx) {
+	assert(ctx != NULL);
+	mbedtls_md_free(&ctx->hmacCtx);
+}
+
+void nfc3d_drbg_generate_bytes(const uint8_t * hmacKey, size_t hmacKeySize, const uint8_t * seed, size_t seedSize, uint8_t * output, size_t outputSize) {
+	uint8_t temp[NFC3D_DRBG_OUTPUT_SIZE];
+
+	nfc3d_drbg_ctx rngCtx;
+	nfc3d_drbg_init(&rngCtx, hmacKey, hmacKeySize, seed, seedSize);
+
+	while (outputSize > 0) {
+		if (outputSize < NFC3D_DRBG_OUTPUT_SIZE) {
+			nfc3d_drbg_step(&rngCtx, temp);
+			memcpy(output, temp, outputSize);
+			break;
+		}
+
+		nfc3d_drbg_step(&rngCtx, output);
+		output += NFC3D_DRBG_OUTPUT_SIZE;
+		outputSize -= NFC3D_DRBG_OUTPUT_SIZE;
+	}
+
+	nfc3d_drbg_cleanup(&rngCtx);
+}

+ 33 - 0
lib/amiitool/drbg.h

@@ -0,0 +1,33 @@
+/*
+ * (c) 2015-2017 Marcos Del Sol Vives
+ * (c) 2016      javiMaD
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HAVE_NFC3D_DRBG_H
+#define HAVE_NFC3D_DRBG_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "mbedtls/md.h"
+
+#define NFC3D_DRBG_MAX_SEED_SIZE	480	/* Hardcoded max size in 3DS NFC module */
+#define NFC3D_DRBG_OUTPUT_SIZE		32	/* Every iteration generates 32 bytes */
+
+typedef struct {
+	mbedtls_md_context_t hmacCtx;
+	bool used;
+	uint16_t iteration;
+
+	uint8_t buffer[sizeof(uint16_t) + NFC3D_DRBG_MAX_SEED_SIZE];
+	size_t bufferSize;
+} nfc3d_drbg_ctx;
+
+void nfc3d_drbg_init(nfc3d_drbg_ctx * ctx, const uint8_t * hmacKey, size_t hmacKeySize, const uint8_t * seed, size_t seedSize);
+void nfc3d_drbg_step(nfc3d_drbg_ctx * ctx, uint8_t * output);
+void nfc3d_drbg_cleanup(nfc3d_drbg_ctx * ctx);
+void nfc3d_drbg_generate_bytes(const uint8_t * hmacKey, size_t hmacKeySize, const uint8_t * seed, size_t seedSize, uint8_t * output, size_t outputSize);
+
+#endif
+

+ 54 - 0
lib/amiitool/keygen.c

@@ -0,0 +1,54 @@
+/*
+ * (c) 2015-2017 Marcos Del Sol Vives
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "drbg.h"
+#include "keygen.h"
+#include "util.h"
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+void nfc3d_keygen_prepare_seed(const nfc3d_keygen_masterkeys * baseKeys, const uint8_t * baseSeed, uint8_t * output, size_t * outputSize) {
+	assert(baseKeys != NULL);
+	assert(baseSeed != NULL);
+	assert(output != NULL);
+	assert(outputSize != NULL);
+
+	uint8_t * start = output;
+
+	// 1: Copy whole type string
+	output = memccpy(output, baseKeys->typeString, '\0', sizeof(baseKeys->typeString));
+
+	// 2: Append (16 - magicBytesSize) from the input seed
+	size_t leadingSeedBytes = 16 - baseKeys->magicBytesSize;
+	memcpy(output, baseSeed, leadingSeedBytes);
+	output += leadingSeedBytes;
+
+	// 3: Append all bytes from magicBytes
+	memcpy(output, baseKeys->magicBytes, baseKeys->magicBytesSize);
+	output += baseKeys->magicBytesSize;
+
+	// 4: Append bytes 0x10-0x1F from input seed
+	memcpy(output, baseSeed + 0x10, 16);
+	output += 16;
+
+	// 5: Xor last bytes 0x20-0x3F of input seed with AES XOR pad and append them
+	unsigned int i;
+	for (i = 0; i < 32; i++) {
+		output[i] = baseSeed[i + 32] ^ baseKeys->xorPad[i];
+	}
+	output += 32;
+
+	*outputSize = output - start;
+}
+
+void nfc3d_keygen(const nfc3d_keygen_masterkeys * baseKeys, const uint8_t * baseSeed, nfc3d_keygen_derivedkeys * derivedKeys) {
+	uint8_t preparedSeed[NFC3D_DRBG_MAX_SEED_SIZE];
+	size_t preparedSeedSize;
+
+	nfc3d_keygen_prepare_seed(baseKeys, baseSeed, preparedSeed, &preparedSeedSize);
+	nfc3d_drbg_generate_bytes(baseKeys->hmacKey, sizeof(baseKeys->hmacKey), preparedSeed, preparedSeedSize, (uint8_t *) derivedKeys, sizeof(*derivedKeys));
+}

+ 34 - 0
lib/amiitool/keygen.h

@@ -0,0 +1,34 @@
+/*
+ * (c) 2015-2017 Marcos Del Sol Vives
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HAVE_NFC3D_KEYGEN_H
+#define HAVE_NFC3D_KEYGEN_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#define NFC3D_KEYGEN_SEED_SIZE 64
+
+#pragma pack(1)
+typedef struct {
+	uint8_t hmacKey[16];
+	char typeString[14];
+	uint8_t rfu;
+	uint8_t magicBytesSize;
+	uint8_t magicBytes[16];
+	uint8_t xorPad[32];
+} nfc3d_keygen_masterkeys;
+
+typedef struct {
+	const uint8_t aesKey[16];
+	const uint8_t aesIV[16];
+	const uint8_t hmacKey[16];
+} nfc3d_keygen_derivedkeys;
+#pragma pack()
+
+void nfc3d_keygen(const nfc3d_keygen_masterkeys * baseKeys, const uint8_t * baseSeed, nfc3d_keygen_derivedkeys * derivedKeys);
+
+#endif

+ 121 - 0
lib/amiitool/portable_endian.h

@@ -0,0 +1,121 @@
+// "License": Public Domain
+// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
+// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
+// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
+// an example on how to get the endian conversion functions on different platforms.
+
+#ifndef PORTABLE_ENDIAN_H__
+#define PORTABLE_ENDIAN_H__
+
+#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
+
+#       define __WINDOWS__
+
+#endif
+
+#if defined(__linux__) || defined(__CYGWIN__)
+
+#       include <endian.h>
+
+#elif defined(__APPLE__)
+
+#       include <libkern/OSByteOrder.h>
+
+#       define htobe16(x) OSSwapHostToBigInt16(x)
+#       define htole16(x) OSSwapHostToLittleInt16(x)
+#       define be16toh(x) OSSwapBigToHostInt16(x)
+#       define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#       define htobe32(x) OSSwapHostToBigInt32(x)
+#       define htole32(x) OSSwapHostToLittleInt32(x)
+#       define be32toh(x) OSSwapBigToHostInt32(x)
+#       define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#       define htobe64(x) OSSwapHostToBigInt64(x)
+#       define htole64(x) OSSwapHostToLittleInt64(x)
+#       define be64toh(x) OSSwapBigToHostInt64(x)
+#       define le64toh(x) OSSwapLittleToHostInt64(x)
+
+#       define __BYTE_ORDER    BYTE_ORDER
+#       define __BIG_ENDIAN    BIG_ENDIAN
+#       define __LITTLE_ENDIAN LITTLE_ENDIAN
+#       define __PDP_ENDIAN    PDP_ENDIAN
+
+#elif defined(__OpenBSD__)
+
+#       include <sys/endian.h>
+
+#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+
+#       include <sys/endian.h>
+
+#       define be16toh(x) betoh16(x)
+#       define le16toh(x) letoh16(x)
+
+#       define be32toh(x) betoh32(x)
+#       define le32toh(x) letoh32(x)
+
+#       define be64toh(x) betoh64(x)
+#       define le64toh(x) letoh64(x)
+
+#elif defined(__WINDOWS__)
+
+#       include <windows.h>
+
+#       if BYTE_ORDER == LITTLE_ENDIAN
+
+#               if defined(_MSC_VER)
+#                       include <stdlib.h>
+#                       define htobe16(x) _byteswap_ushort(x)
+#                       define htole16(x) (x)
+#                       define be16toh(x) _byteswap_ushort(x)
+#                       define le16toh(x) (x)
+
+#                       define htobe32(x) _byteswap_ulong(x)
+#                       define htole32(x) (x)
+#                       define be32toh(x) _byteswap_ulong(x)
+#                       define le32toh(x) (x)
+
+#                       define htobe64(x) _byteswap_uint64(x)
+#                       define htole64(x) (x)
+#                       define be64toh(x) _byteswap_uint64(x)
+#                       define le64toh(x) (x)
+
+#               elif defined(__GNUC__) || defined(__clang__)
+
+#                       define htobe16(x) __builtin_bswap16(x)
+#                       define htole16(x) (x)
+#                       define be16toh(x) __builtin_bswap16(x)
+#                       define le16toh(x) (x)
+
+#                       define htobe32(x) __builtin_bswap32(x)
+#                       define htole32(x) (x)
+#                       define be32toh(x) __builtin_bswap32(x)
+#                       define le32toh(x) (x)
+
+#                       define htobe64(x) __builtin_bswap64(x)
+#                       define htole64(x) (x)
+#                       define be64toh(x) __builtin_bswap64(x)
+#                       define le64toh(x) (x)
+#               else
+#                       //error platform not supported
+#               endif
+
+#       else
+
+#               //error byte order not supported
+
+#       endif
+
+#       define __BYTE_ORDER    BYTE_ORDER
+#       define __BIG_ENDIAN    BIG_ENDIAN
+#       define __LITTLE_ENDIAN LITTLE_ENDIAN
+#       define __PDP_ENDIAN    PDP_ENDIAN
+
+#else
+
+#       //error platform not supported
+
+#endif
+
+#endif

+ 27 - 0
lib/amiitool/util.c

@@ -0,0 +1,27 @@
+/*
+ * (c) 2015-2017 Marcos Del Sol Vives
+ * (c) 2016      javiMaD
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "util.h"
+#include <stdint.h>
+
+void printhex(void * data, size_t size) {
+	size_t i;
+	uint8_t * bytes = (uint8_t *) data;
+	for (i = 0; i < size; i++) {
+		if ((i % 16) > 0) {
+			printf(" ");
+		}
+		printf("%02X", bytes[i]);
+		if ((i % 16) == 15) {
+			printf("\n");
+		}
+	}
+	if ((i % 16) != 15) {
+		printf("\n");
+	}
+}
+

+ 17 - 0
lib/amiitool/util.h

@@ -0,0 +1,17 @@
+/*
+ * (c) 2015-2017 Marcos Del Sol Vives
+ * (c) 2016      javiMaD
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HAVE_UTIL_H
+#define HAVE_UTIL_H
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+void printhex(void * data, size_t size);
+
+#endif

+ 21 - 0
lib/amiitool/version.c

@@ -0,0 +1,21 @@
+/*
+ * (c) 2017      Marcos Del Sol Vives
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <version.h>
+#include <stdio.h>
+
+const char * nfc3d_version_fork() {
+	// TODO: maybe this should go in another file?
+	return "socram";
+}
+
+uint32_t nfc3d_version_commit() {
+	return 0;
+}
+
+uint32_t nfc3d_version_build() {
+	return 0;
+}

+ 16 - 0
lib/amiitool/version.h

@@ -0,0 +1,16 @@
+/*
+ * (c) 2017      Marcos Del Sol Vives
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HAVE_NFC3D_VERSION_H
+#define HAVE_NFC3D_VERSION_H
+
+#include <stdint.h>
+
+const char * nfc3d_version_fork();
+uint32_t nfc3d_version_build();
+uint32_t nfc3d_version_commit();
+
+#endif