summaryrefslogtreecommitdiffstats
path: root/utils/samsungtools/samsung.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-11-29 17:29:13 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2012-11-29 17:30:54 +0100
commitd66c16749a5c07aadcd0eb97b9340d7fa5ea26b0 (patch)
tree4c1b30ca5073cf2f6f7a227715fca557fbf39999 /utils/samsungtools/samsung.h
parentee36a396cd1619585a83803630db2d79b6cbefbd (diff)
downloadrockbox-d66c16749a5c07aadcd0eb97b9340d7fa5ea26b0.tar.gz
rockbox-d66c16749a5c07aadcd0eb97b9340d7fa5ea26b0.tar.bz2
rockbox-d66c16749a5c07aadcd0eb97b9340d7fa5ea26b0.zip
Introduce samsungtools to decrypt samsung firmware
Samsung provides many firmware upgrade in the format of a .dat file, at least for nearly all YP's (checked for Q2, R0, T10, Z5). This is a simple cyclic xor which a fixed key, a md5 sum and a header specifying the model/version/region. Change-Id: Ib0461a74196383189fd2d8162da444a85a229c60
Diffstat (limited to 'utils/samsungtools/samsung.h')
-rw-r--r--utils/samsungtools/samsung.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/utils/samsungtools/samsung.h b/utils/samsungtools/samsung.h
new file mode 100644
index 0000000000..4336e02651
--- /dev/null
+++ b/utils/samsungtools/samsung.h
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2012 Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __SAMSUNG_H__
+#define __SAMSUNG_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/**
+ * Low-Level
+ */
+
+struct yp_header_t
+{
+ char signature[12];
+ uint32_t pad;
+ char version[8];
+ char region[4];
+ char extra[4];
+ char model[20];
+ uint32_t datasize;
+} __attribute__((packed));
+
+struct yp_md5_t
+{
+ uint8_t md5[16];
+} __attribute__((packed));
+
+#define YP_SIGNATURE "SAMSUNG YEPP"
+
+/**
+ * API
+ */
+
+struct samsung_firmware_t
+{
+ char version[8];
+ char region[4];
+ char extra[4];
+ char model[20];
+ void *data;
+ int data_size;
+};
+
+enum samsung_error_t
+{
+ SAMSUNG_SUCCESS = 0,
+ SAMSUNG_READ_ERROR = -1,
+ SAMSUNG_FORMAT_ERROR = -2,
+ SAMSUNG_MD5_ERROR = -3,
+};
+
+typedef int (*samsung_read_t)(void *user, int offset, void *buffer, int size);
+typedef void (*samsung_printf_t)(void *user, bool error, const char *fmt, ...);
+
+struct samsung_firmware_t *samsung_read(samsung_read_t read,
+ samsung_printf_t printf, void *user, enum samsung_error_t *err);
+void samsung_free(struct samsung_firmware_t *fw);
+
+#endif /* __SAMSUNG_H__ */