//
// PEM_def_callback from 0x821428 to 0x821550 (296 bytes)
//
// 6 xrefs:
// > PEM_do_header @ 0x821938
// > PEM_ASN1_write_bio @ 0x8223b4
// > PEM_read_bio_PrivateKey @ 0x823638
// > d2i_PKCS8PrivateKey_bio @ 0x8ba88c
// > sub_8BAB28 @ 0x8bacf0
// > ??> @ 0x652cc
//
// 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
//
int __fastcall PEM_def_callback(char *a1, signed int a2, int a3, const char *a4)
{
signed int v7; // r0
int result; // r0
const char *pw_prompt; // r7
if ( !a4 )
{
pw_prompt = (const char *)EVP_get_pw_prompt();
if ( !pw_prompt )
pw_prompt = "Enter PEM pass phrase:";
if ( a3 )
{
while ( !EVP_read_pw_string_min(a1, 4, a2, pw_prompt, a3) )
{
result = strlen(a1);
if ( result > 3 )
return result;
fprintf((FILE *)((char *)&_sF + 168), "phrase is too short, needs to be at least %d chars\n", 4);
}
}
else if ( !EVP_read_pw_string_min(a1, 0, a2, pw_prompt, 0) )
{
return strlen(a1);
}
ERR_put_error(9, 100, 109, (int)"crypto/pem/pem_lib.c", 64);
memset(a1, 0, a2);
return -1;
}
v7 = strlen(a4);
if ( v7 < a2 )
a2 = v7;
memcpy(a1, a4, a2);
return a2;
}