extract/v2: simply finding the signature type

cute-signatures
Aydin Mercan 2022-08-10 17:00:53 +03:00
parent 1c54a3fbb4
commit 0d59807471
Signed by: jaiden
SSH Key Fingerprint: SHA256:vy6hjzotbn/MWZAbjzURNk3NL62EPkjoHsJ5xr/s7nk
1 changed files with 11 additions and 13 deletions

View File

@ -107,20 +107,17 @@ static int check_signing_key_trust(struct apk_sign_ctx *sctx)
static int apk_sign_ctx_process_file(struct apk_sign_ctx *ctx, const struct apk_file_info *fi, struct apk_istream *is)
{
static struct {
char type[8];
uint8_t alg;
} signature_type[] = {
{"RSA256", APK_SIGNATURE_RSA256},
{"RSA512", APK_SIGNATURE_RSA512},
{"CUTE", APK_SIGNATURE_CUTE},
{"RSA", APK_SIGNATURE_RSA},
static const char *signature_type[4] = {
[APK_SIGNATURE_RSA] = "RSA",
[APK_SIGNATURE_RSA512] = "RSA512",
[APK_SIGNATURE_RSA256] = "RSA256",
[APK_SIGNATURE_CUTE] = "CUTE",
};
uint16_t signature_alg = APK_SIGNATURE_MAX;
struct apk_public_key *public_key;
const char *name = NULL;
int r, i;
int r;
if (ctx->data_started) {
return 1;
@ -166,10 +163,11 @@ static int apk_sign_ctx_process_file(struct apk_sign_ctx *ctx, const struct apk_
|| ctx->signature.public_key != NULL)
return 0;
for (i = 0; i < ARRAY_SIZE(signature_type); i++) {
size_t slen = strlen(signature_type[i].type);
if (strncmp(&fi->name[6], signature_type[i].type, slen) == 0 && fi->name[6 + slen] == '.') {
signature_alg = signature_type[i].alg;
for (uint16_t i = 0; i < ARRAY_SIZE(signature_type); i++) {
size_t slen = strlen(signature_type[i]);
if (strncmp(&fi->name[6], signature_type[i], slen) == 0 && fi->name[6 + slen] == '.') {
signature_alg = i;
name = &fi->name[6 + slen + 1];
break;
}