//
// PKCS7_signatureVerify from 0xa3d31c to 0xa3d660 (836 bytes)
//
// 2 xrefs:
// > PKCS7_dataVerify @ 0xa3d768
// > ??> @ 0x7f8ec
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:08:11 +0000
//
int __fastcall PKCS7_signatureVerify(_DWORD *a1, int a2, int a3, int a4)
{
int **v4; // r9
int *v9; // r6
char *v10; // r0
unsigned int v11; // r5
int v12; // r0
int v13; // r0
_DWORD *type; // r0
int v15; // r4
int v16; // r4
size_t *v18; // r4
int *v19; // r4
int v20; // r3
int v21; // r0
char *v22; // r0
int digestbyname; // r0
int *v24; // [sp+Ch] [bp-50h] BYREF
void *v25; // [sp+10h] [bp-4Ch] BYREF
int v26; // [sp+14h] [bp-48h] BYREF
_BYTE v27[68]; // [sp+18h] [bp-44h] BYREF
v9 = (int *)EVP_MD_CTX_new();
if ( !v9 )
{
ERR_put_error(33, 113, 65, (int)"crypto/pkcs7/pk7_doit.c", 946);
v16 = 0;
goto LABEL_16;
}
if ( OBJ_obj2nid(*(_DWORD *)(a2 + 16)) != (_BYTE *)&dword_14 + 2
&& OBJ_obj2nid(*(_DWORD *)(a2 + 16)) != (char *)&dword_18 )
{
ERR_put_error(33, 113, 114, (int)"crypto/pkcs7/pk7_doit.c", 951);
goto LABEL_15;
}
v10 = OBJ_obj2nid(**(_DWORD **)(a3 + 8));
if ( a1 )
v4 = &v24;
v11 = (unsigned int)v10;
if ( a1 )
{
while ( 1 )
{
type = BIO_find_type(a1, 520);
v15 = (int)type;
if ( !type )
goto LABEL_13;
BIO_ctrl(type, 120, 0, (int)v4);
if ( !v24 )
{
v16 = 0;
ERR_put_error(33, 113, 68, (int)"crypto/pkcs7/pk7_doit.c", 967);
goto LABEL_16;
}
v12 = EVP_MD_CTX_md((int)v24);
if ( EVP_MD_type(v12) == v11 )
break;
v13 = EVP_MD_CTX_md((int)v24);
if ( EVP_MD_pkey_type(v13) == v11 )
break;
a1 = (_DWORD *)BIO_next(v15);
if ( !a1 )
goto LABEL_13;
}
if ( !EVP_MD_CTX_copy_ex(v9, v24) )
goto LABEL_15;
v18 = *(size_t **)(a3 + 12);
if ( !v18 || !OPENSSL_sk_num(*(_DWORD *)(a3 + 12)) )
{
LABEL_20:
v19 = *(int **)(a3 + 20);
v20 = X509_get0_pubkey(a4);
if ( v20 )
{
if ( EVP_VerifyFinal((int **)v9, v19[2], *v19, v20) <= 0 )
{
ERR_put_error(33, 113, 105, (int)"crypto/pkcs7/pk7_doit.c", 1035);
v16 = -1;
}
else
{
v16 = 1;
}
}
else
{
v16 = -1;
}
goto LABEL_16;
}
v25 = nullptr;
if ( !EVP_DigestFinal_ex((int **)v9, (int)v27, &v26) )
goto LABEL_15;
v21 = PKCS7_digest_from_attributes((int)v18);
if ( !v21 )
{
v16 = 0;
ERR_put_error(33, 113, 108, (int)"crypto/pkcs7/pk7_doit.c", 1000);
goto LABEL_16;
}
if ( *(_DWORD *)v21 != v26 || memcmp(*(const void **)(v21 + 8), v27, *(_DWORD *)v21) )
{
ERR_put_error(33, 113, 101, (int)"crypto/pkcs7/pk7_doit.c", 1005);
v16 = -1;
goto LABEL_16;
}
v22 = OBJ_nid2sn(v11);
digestbyname = EVP_get_digestbyname((int)v22);
if ( EVP_DigestInit_ex(v9, digestbyname, nullptr) )
{
if ( ASN1_item_i2d(v18, (int *)&v25, PKCS7_ATTR_VERIFY_it) <= 0 )
{
ERR_put_error(33, 113, 13, (int)"crypto/pkcs7/pk7_doit.c", 1016);
v16 = -1;
goto LABEL_16;
}
if ( !EVP_DigestUpdate((int)v9) )
goto LABEL_15;
CRYPTO_free(v25, (int)"crypto/pkcs7/pk7_doit.c", 1023);
goto LABEL_20;
}
LABEL_15:
v16 = 0;
goto LABEL_16;
}
LABEL_13:
ERR_put_error(33, 113, 108, (int)"crypto/pkcs7/pk7_doit.c", 962);
v16 = 0;
LABEL_16:
EVP_MD_CTX_free(v9);
return v16;
}