kernel: Reformat code using clang-format (#347)
* The coding format is too messy, reformat to improve readability and get closer to Linux kernel coding style. * While at it, update .clang-format file to linux-mainline state.
This commit is contained in:
@@ -29,10 +29,10 @@ static struct apk_sign_key {
|
||||
unsigned size;
|
||||
const char *sha256;
|
||||
} apk_sign_keys[] = {
|
||||
{EXPECTED_SIZE_SHIRKNEKO, EXPECTED_HASH_SHIRKNEKO}, // SukiSU
|
||||
{EXPECTED_SIZE_OTHER, EXPECTED_HASH_OTHER}, // Dynamic Sign
|
||||
{ EXPECTED_SIZE_SHIRKNEKO, EXPECTED_HASH_SHIRKNEKO }, // SukiSU
|
||||
{ EXPECTED_SIZE_OTHER, EXPECTED_HASH_OTHER }, // Dynamic Sign
|
||||
#ifdef EXPECTED_SIZE
|
||||
{EXPECTED_SIZE, EXPECTED_HASH}, // Custom
|
||||
{ EXPECTED_SIZE, EXPECTED_HASH }, // Custom
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -82,7 +82,8 @@ static int ksu_sha256(const unsigned char *data, unsigned int datalen,
|
||||
crypto_free_shash(alg);
|
||||
return ret;
|
||||
}
|
||||
static bool check_block(struct file *fp, u32 *size4, loff_t *pos, u32 *offset, int *matched_index)
|
||||
static bool check_block(struct file *fp, u32 *size4, loff_t *pos, u32 *offset,
|
||||
int *matched_index)
|
||||
{
|
||||
int i;
|
||||
struct apk_sign_key sign_key;
|
||||
@@ -127,7 +128,7 @@ static bool check_block(struct file *fp, u32 *size4, loff_t *pos, u32 *offset, i
|
||||
}
|
||||
ksu_kernel_read_compat(fp, cert, *size4, pos);
|
||||
unsigned char digest[SHA256_DIGEST_SIZE];
|
||||
if (ksu_sha256(cert, *size4, digest) < 0 ) {
|
||||
if (ksu_sha256(cert, *size4, digest) < 0) {
|
||||
pr_info("sha256 error\n");
|
||||
return false;
|
||||
}
|
||||
@@ -136,8 +137,9 @@ static bool check_block(struct file *fp, u32 *size4, loff_t *pos, u32 *offset, i
|
||||
hash_str[SHA256_DIGEST_SIZE * 2] = '\0';
|
||||
|
||||
bin2hex(hash_str, digest, SHA256_DIGEST_SIZE);
|
||||
pr_info("sha256: %s, expected: %s, index: %d\n", hash_str, sign_key.sha256, i);
|
||||
|
||||
pr_info("sha256: %s, expected: %s, index: %d\n", hash_str,
|
||||
sign_key.sha256, i);
|
||||
|
||||
if (strcmp(sign_key.sha256, hash_str) == 0) {
|
||||
signature_valid = true;
|
||||
if (matched_index) {
|
||||
@@ -202,7 +204,8 @@ static bool has_v1_signature_file(struct file *fp)
|
||||
return false;
|
||||
}
|
||||
|
||||
static __always_inline bool check_v2_signature(char *path, bool check_multi_manager, int *signature_index)
|
||||
static __always_inline bool
|
||||
check_v2_signature(char *path, bool check_multi_manager, int *signature_index)
|
||||
{
|
||||
unsigned char buffer[0x11] = { 0 };
|
||||
u32 size4;
|
||||
@@ -279,7 +282,8 @@ static __always_inline bool check_v2_signature(char *path, bool check_multi_mana
|
||||
offset = 4;
|
||||
if (id == 0x7109871au) {
|
||||
v2_signing_blocks++;
|
||||
bool result = check_block(fp, &size4, &pos, &offset, &matched_index);
|
||||
bool result = check_block(fp, &size4, &pos, &offset,
|
||||
&matched_index);
|
||||
if (result) {
|
||||
v2_signing_valid = true;
|
||||
}
|
||||
@@ -327,11 +331,12 @@ clean:
|
||||
if (signature_index) {
|
||||
*signature_index = matched_index;
|
||||
}
|
||||
|
||||
|
||||
if (check_multi_manager) {
|
||||
// 0: ShirkNeko/SukiSU, 1: Dynamic Sign
|
||||
if (matched_index == 0 || matched_index == 1) {
|
||||
pr_info("Multi-manager APK detected (dynamic_sign enabled): signature_index=%d\n", matched_index);
|
||||
pr_info("Multi-manager APK detected (dynamic_sign enabled): signature_index=%d\n",
|
||||
matched_index);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -369,10 +374,10 @@ module_param_cb(ksu_debug_manager_uid, &expected_size_ops,
|
||||
|
||||
bool is_manager_apk(char *path)
|
||||
{
|
||||
return check_v2_signature(path, false, NULL);
|
||||
return check_v2_signature(path, false, NULL);
|
||||
}
|
||||
|
||||
bool ksu_is_multi_manager_apk(char *path, int *signature_index)
|
||||
{
|
||||
return check_v2_signature(path, true, signature_index);
|
||||
return check_v2_signature(path, true, signature_index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user