Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e7722b3
util.c: create table for detect_model()
throwaway96 Nov 24, 2023
326b478
util.c: various improvements
throwaway96 Nov 24, 2023
0e2b5e2
clean up various stuff
throwaway96 Dec 31, 2023
b6ed607
epk3.c: fix format specifiers
throwaway96 Dec 31, 2023
96cf96a
epk.c: check for unhandled switch cases
throwaway96 Dec 31, 2023
156394d
epk.c: remove extraneous loop
throwaway96 Dec 31, 2023
cff273d
minor cleanup in mfile.[ch]
throwaway96 Dec 31, 2023
9fcd344
make -n affect all filesystems
throwaway96 Dec 31, 2023
9b53917
check multiple paths for AES key file
throwaway96 Dec 31, 2023
0b46580
change CompareFunc signature
throwaway96 Mar 22, 2026
94e5c08
change some types
throwaway96 Jan 4, 2024
cb9a745
epk.c: remove redundant comparisons
throwaway96 Jan 10, 2024
8a3de8c
epk.c: skip obvious non-files in RSA key search
throwaway96 Jan 10, 2024
09a409e
EPKv3 minor changes to PAK extraction
throwaway96 Jul 21, 2024
fee8734
epk.c: have SWU_CryptoInit_PEM() return the key
throwaway96 Jan 11, 2024
ea06bda
epk.c: fix bug in signature verification
throwaway96 Jan 11, 2024
fefba47
epk.c: streamline API_SWU_VerifyImage()
throwaway96 Jan 11, 2024
1728669
epk.c: dont mix EVP_Digest and EVP_Verify
throwaway96 Jan 11, 2024
e18f937
epk.c: show errors in API_SWU_VerifyImage()
throwaway96 Jan 12, 2024
49e0ee5
epk.c: use EVP_DigestVerify() for second hash
throwaway96 Jan 12, 2024
c24a710
epk3.c: add default cases to placate clang
throwaway96 Jan 12, 2024
d03fc96
epk1.c: fix memory leak
throwaway96 Jan 12, 2024
7a1a8bc
mediatek: simplify is_mtk_pkg() logic
throwaway96 Mar 3, 2024
d7f8f3a
make some of the EPKv1 code a bit less scary
throwaway96 May 25, 2024
c4eaa8a
fix crashes on empty input
throwaway96 Jul 21, 2024
2148ebb
lzo-lg.c: avoid warning
throwaway96 Dec 1, 2024
e5f5cff
epk.c: fix bugs and refactor
throwaway96 Mar 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef struct {
char *config_dir;
char *dest_dir;
int enableSignatureChecking;
bool noAutoUnsquashfs;
bool noAutoExtractFs;
bool signatureOnly;
} config_opts_t;

Expand Down
5 changes: 3 additions & 2 deletions include/epk.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef enum {
} BUILD_TYPE_T;

typedef enum {
INVALID = -1,
EPK,
EPK_V2,
EPK_V3,
Expand All @@ -39,7 +40,7 @@ typedef enum {
#define EPKV1_VERSION_FORMAT "%02" PRIx8 ".%02" PRIx8 ".%02" PRIx8

bool isEpkVersionString(const char *str);
int wrap_verifyimage(void *signature, void *data, size_t signSize, char *config_dir, SIG_TYPE_T sigType);
int wrap_decryptimage(void *src, size_t datalen, void *dest, char *config_dir, FILE_TYPE_T type, FILE_TYPE_T *outType);
bool wrap_verifyimage(const void *signature, const void *data, size_t signSize, const char *config_dir, SIG_TYPE_T sigType);
bool wrap_decryptimage(const void *src, size_t datalen, void *dest, const char *config_dir, FILE_TYPE_T type);
void extractEPKfile(const char *epk_file, config_opts_t *config_opts);
#endif
4 changes: 2 additions & 2 deletions include/epk2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#define EPK2_MAGIC "EPK2"
#define PAK_MAGIC "MPAK"

int compare_pak2_header(uint8_t *header, size_t headerSize);
int compare_epk2_header(uint8_t *header, size_t headerSize);
bool compare_pak2_header(const uint8_t *header, size_t headerSize);
bool compare_epk2_header(const uint8_t *header, size_t headerSize);
MFILE *isFileEPK2(const char *epk_file);
void extractEPK2(MFILE *epk, config_opts_t *config_opts);

Expand Down
4 changes: 2 additions & 2 deletions include/epk3.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#define EPK3_MAGIC "EPK3"

int compare_epk3_header(uint8_t *header, size_t headerSize);
int compare_epk3_new_header(uint8_t *header, size_t headerSize);
bool compare_epk3_header(const uint8_t *header, size_t headerSize);
bool compare_epk3_new_header(const uint8_t *header, size_t headerSize);
MFILE *isFileEPK3(const char *epk_file);
void extractEPK3(MFILE *epk, FILE_TYPE_T epkType, config_opts_t *config_opts);

Expand Down
2 changes: 1 addition & 1 deletion include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
#ifndef __MAIN_H
#define __MAIN_H
#include "config.h"
int handle_file(const char *file, config_opts_t *config_opts);
int handle_file(const char *file, const config_opts_t *config_opts);
Comment thread
throwaway96 marked this conversation as resolved.
Resolved
#endif //__MAIN_H
2 changes: 1 addition & 1 deletion include/mfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef struct {
void *pMem;
} MFILE;

MFILE *mfile_new();
MFILE *mfile_new(void);

void *mfile_map(MFILE *file, size_t size);
void *mfile_map_private(MFILE *file, size_t size);
Expand Down
2 changes: 1 addition & 1 deletion include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void unnfsb(const char *filename, const char *extractedFile);
MFILE *is_gzip(const char *filename);
int is_jffs2(const char *filename);
int isSTRfile(const char *filename);
int isdatetime(const char *datetime);
bool is_datetime(const char *datetime);
int isPartPakfile(const char *filename);
int is_kernel(const char *image_file);
void extract_kernel(const char *image_file, const char *destination_file);
Expand Down
16 changes: 7 additions & 9 deletions include/util_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
#ifndef __UTIL_CRYPTO_H
#define __UTIL_CRYPTO_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <openssl/aes.h>

Expand All @@ -15,14 +17,10 @@
#define KEY_ECB (1 << 0)
#define KEY_CBC (1 << 1)

typedef int (*CompareFunc)(uint8_t *data, size_t size);
typedef bool (*CompareFunc)(const uint8_t *data, size_t size);

void setKeyFile(const char *keyFile);
void setKeyFile_LG();
void setKeyFile_MTK();

uint8_t *getLastKey();
uint8_t *getLastIV();
void setKeyFile_LG(void);
void setKeyFile_MTK(void);

#define MAX_KEY_SIZE (AES_BLOCK_SIZE * 2) // AES-256

Expand All @@ -33,8 +31,8 @@ typedef struct {
} KeyPair;

KeyPair *find_AES_key(
uint8_t *in_data, size_t in_data_size, CompareFunc fCompare,
int key_type, void **dataOut, int verbose
const uint8_t *in_data, size_t in_data_size, CompareFunc fCompare,
int key_type, void **dataOut, bool verbose
);

#endif
5 changes: 5 additions & 0 deletions src/cramfs/uncramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ int is_cramfs_image(char const *imagefile, char *endian) {
perror(imagefile);
exit(1);
}

if (st.st_size < sizeof(struct cramfs_super)) {
return 0;
}

// Map the cramfs image
fd = open(imagefile, O_RDONLY);
fslen_ub = st.st_size;
Expand Down
Loading
Loading