//
// PEM_get_EVP_CIPHER_INFO from 0xdc7384 to 0xdc76e0 (860 bytes)
//
// 4 xrefs:
// > PEM_bytes_read_bio @ 0xdc88d4
// > PEM_X509_INFO_read_bio @ 0xe6454c
// > PEM_X509_INFO_read_bio @ 0xe64680
// > ??> @ 0xa4370
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall PEM_get_EVP_CIPHER_INFO(const char *a1, __int64 *a2)
{
unsigned int v4; // w21
size_t v5; // x2
const char *v7; // x19
const char *v8; // x19
const char *v9; // x23
const char *v10; // x19
char *v11; // x26
char v12; // w23
__int64 cipherbyname; // x0
__int64 v14; // x25
size_t v15; // x19
char *v16; // x23
int v17; // w0
void *v18; // x20
int v19; // w0
int v20; // w22
int v21; // w22
__int64 v22; // x19
int v23; // w0
int v24; // w2
int v25; // w1
char v26; // w2
*a2 = 0;
if ( a1 && *a1 && *a1 != 10 )
{
v4 = strncmp(a1, "Proc-Type:", 0xAu);
if ( v4 )
{
v4 = 0;
ERR_put_error(9, 107, 107, (__int64)"crypto/pem/pem_lib.c", 479);
}
else
{
v5 = (size_t)&a1[strspn(a1 + 10, " \t") + 10];
if ( *(_BYTE *)v5 != 52 || *(_BYTE *)(v5 + 1) != 44 )
return v4;
v7 = (const char *)(v5 + 2 + strspn((const char *)(v5 + 2), " \t"));
if ( !strncmp(v7, "ENCRYPTED", 9u) && (v8 = v7 + 9, strspn(v8, " \t\r\n")) )
{
v9 = &v8[strspn(v8, " \t\r")];
if ( *v9 == 10 )
{
v4 = strncmp(v9 + 1, "DEK-Info:", 9u);
if ( v4 )
{
v4 = 0;
ERR_put_error(9, 107, 105, (__int64)"crypto/pem/pem_lib.c", 507);
}
else
{
v10 = &v9[strspn(v9 + 10, " \t") + 10];
v11 = (char *)&v10[strcspn(v10, " \t,")];
v12 = *v11;
*v11 = 0;
cipherbyname = EVP_get_cipherbyname((__int64)v10);
*a2 = cipherbyname;
*v11 = v12;
v14 = cipherbyname;
v15 = strspn(v11, " \t");
v16 = &v11[v15];
if ( !v14 )
{
ERR_put_error(9, 107, 114, (__int64)"crypto/pem/pem_lib.c", 526);
return v4;
}
v17 = EVP_CIPHER_iv_length(v14);
if ( v17 <= 0 )
{
if ( !v17 && v11[v15] == 44 )
{
ERR_put_error(9, 107, 130, (__int64)"crypto/pem/pem_lib.c", 534);
return v4;
}
}
else
{
++v16;
if ( v11[v15] != 44 )
{
ERR_put_error(9, 107, 129, (__int64)"crypto/pem/pem_lib.c", 531);
return v4;
}
}
v18 = a2 + 1;
v19 = EVP_CIPHER_iv_length(v14);
v20 = v19;
if ( v19 > 0 )
memset(v18, 0, (unsigned int)(v19 - 1) + 1LL);
v21 = 2 * v20;
v22 = 0;
if ( v21 <= 0 )
return 1;
while ( 1 )
{
v23 = OPENSSL_hexchar2int(v16[v22]);
v24 = v22 & 1;
v25 = (int)v22++ >> 1;
v26 = v24 ? 0 : 4;
if ( v23 < 0 )
break;
*((_BYTE *)v18 + v25) |= v23 << v26;
if ( v21 <= (int)v22 )
return 1;
}
ERR_put_error(9, 101, 103, (__int64)"crypto/pem/pem_lib.c", 556);
}
}
else
{
ERR_put_error(9, 107, 112, (__int64)"crypto/pem/pem_lib.c", 498);
}
}
else
{
ERR_put_error(9, 107, 106, (__int64)"crypto/pem/pem_lib.c", 492);
}
}
return v4;
}
return 1;
}