mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
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
This commit is contained in:
parent
ee36a396cd
commit
d66c16749a
4 changed files with 353 additions and 0 deletions
78
utils/samsungtools/samsung.h
Normal file
78
utils/samsungtools/samsung.h
Normal file
|
|
@ -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__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue