//
// OCSP_REQ_CTX_nbio from 0x8b929c to 0x8b98b0 (1556 bytes)
//
// 2 xrefs:
// > OCSP_REQ_CTX_nbio_d2i @ 0x8b98fc
// > ??> @ 0x6b22c
//
// 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 OCSP_REQ_CTX_nbio(int *a1)
{
int v1; // r3
int v3; // r5
int v4; // r0
int v5; // r0
int v6; // r0
int v7; // r3
int v8; // r6
const char *v9; // r3
int v10; // t1
int v11; // r0
unsigned int v12; // r2
const char *v13; // r3
int v14; // t1
int v15; // lr
signed int v17; // r5
int v18; // r0
_BYTE *v19; // r2
int v20; // r3
bool v21; // zf
int v22; // r0
_BYTE *v23; // r3
int v24; // r2
const char *v25; // r5
int v26; // t1
int v27; // r2
int v28; // t1
int v29; // r2
int v30; // r0
char *v31; // r3
char *v32; // r12
unsigned int v33; // r2
unsigned int v34; // r2
size_t v35; // r0
char *v36; // lr
const char *v37; // [sp+8h] [bp-24h]
const char *v38; // [sp+10h] [bp-1Ch]
const char *v39; // [sp+10h] [bp-1Ch]
unsigned int v40; // [sp+14h] [bp-18h]
void *v41; // [sp+20h] [bp-Ch] BYREF
char *i; // [sp+24h] [bp-8h] BYREF
v1 = *a1;
LABEL_2:
v3 = v1 & 0x1000;
if ( (v1 & 0x1000) == 0 )
goto LABEL_15;
while ( 1 )
{
do
{
if ( v1 == 4101 )
goto LABEL_11;
if ( v1 > 4101 )
{
if ( v1 == 4103 )
goto LABEL_58;
if ( v1 >= 4103 )
{
if ( v1 == 4104 )
return 1;
if ( v1 != 4105 )
return 0;
if ( BIO_write(a1[4], (int)&word_9B1DDC, 2) != 2 )
goto LABEL_30;
*a1 = 4101;
LABEL_11:
v4 = BIO_ctrl((_DWORD *)a1[4], 3, 0, 0);
*a1 = 4102;
a1[5] = v4;
}
v5 = BIO_ctrl((_DWORD *)a1[4], 3, 0, (int)&v41);
v6 = BIO_write(a1[3], (int)v41 + v5 - a1[5], a1[5]);
if ( v6 <= 0 )
goto LABEL_88;
v7 = a1[5];
a1[5] = v7 - v6;
if ( v7 == v6 )
{
*a1 = 4103;
BIO_ctrl((_DWORD *)a1[4], 1, v7 - v6, v7 - v6);
LABEL_58:
if ( BIO_ctrl((_DWORD *)a1[3], 11, 0, 0) <= 0 )
{
LABEL_88:
if ( BIO_test_flags(a1[3], 8) )
return -1;
LABEL_30:
*a1 = 4096;
return 0;
}
v1 = 1;
*a1 = 1;
goto LABEL_2;
}
goto LABEL_14;
}
if ( v1 == 3 )
{
LABEL_48:
v22 = BIO_ctrl((_DWORD *)a1[4], 3, 0, (int)&v41);
if ( v22 <= 1 )
goto LABEL_14;
v23 = v41;
v41 = (char *)v41 + 1;
if ( *v23 != 48 )
goto LABEL_30;
v24 = (unsigned __int8)v23[1];
if ( (v24 & 0x80) != 0 )
{
if ( v22 <= 5 )
goto LABEL_14;
v30 = v24 & 0x7F;
if ( (unsigned int)(v30 - 1) > 3 )
goto LABEL_30;
v31 = v23 + 2;
v32 = &v31[v30];
v33 = 0;
do
{
++v31;
v34 = v33 << 8;
a1[5] = v34;
v41 = v31;
v33 = (unsigned __int8)*(v31 - 1) | v34;
a1[5] = v33;
}
while ( v31 != v32 );
if ( a1[6] < v33 )
goto LABEL_30;
a1[5] = v30 + 2 + v33;
}
else
{
a1[5] = v24 + 2;
}
*a1 = 4;
}
else
{
if ( v1 <= 3 )
{
if ( v1 >= 1 )
{
while ( 1 )
{
LABEL_36:
v17 = BIO_ctrl((_DWORD *)a1[4], 3, 0, (int)&v41);
if ( v17 <= 0 || !memchr(v41, 10, v17) )
{
if ( a1[2] > v17 )
goto LABEL_14;
goto LABEL_30;
}
v18 = BIO_gets((_DWORD *)a1[4], a1[1], a1[2]);
if ( v18 <= 0 )
break;
if ( a1[2] == v18 )
goto LABEL_30;
if ( *a1 == 1 )
{
v25 = (const char *)a1[1];
if ( *v25 )
{
if ( (*(_BYTE *)(ctype_ + *(unsigned __int8 *)v25 + 1) & 8) != 0 )
goto LABEL_66;
while ( 1 )
{
v28 = *(unsigned __int8 *)++v25;
v29 = ctype_ + v28;
if ( !v28 )
break;
if ( (*(_BYTE *)(v29 + 1) & 8) != 0 )
{
do
{
LABEL_66:
v26 = *(unsigned __int8 *)++v25;
v27 = ctype_ + v26;
if ( !v26 )
{
ERR_put_error(39, 118, 115, (int)"crypto/ocsp/ocsp_ht.c", 224);
*a1 = 4096;
return 0;
}
}
while ( (*(_BYTE *)(v27 + 1) & 8) != 0 );
v9 = v25;
do
{
v10 = *(unsigned __int8 *)++v9;
v11 = ctype_ + v10;
if ( !v10 )
{
ERR_put_error(39, 118, 115, (int)"crypto/ocsp/ocsp_ht.c", 233);
*a1 = 4096;
return 0;
}
}
while ( (*(_BYTE *)(v11 + 1) & 8) == 0 );
*v9 = 0;
v38 = v9;
v12 = strtoul(v25, &i, 10);
if ( *i )
goto LABEL_30;
v13 = v38 + 1;
if ( v38[1] )
{
if ( (*(_BYTE *)(ctype_ + *((unsigned __int8 *)v38 + 1) + 1) & 8) != 0 )
{
while ( 1 )
{
v14 = *(unsigned __int8 *)++v13;
v15 = ctype_ + v14;
if ( !v14 )
break;
if ( (*(_BYTE *)(v15 + 1) & 8) == 0 )
goto LABEL_84;
}
}
else
{
LABEL_84:
v40 = v12;
v39 = v13;
v35 = strlen(v13);
v13 = v39;
v12 = v40;
v36 = (char *)&v39[v35 - 1];
for ( i = v36; (*(_BYTE *)(ctype_ + (unsigned __int8)*v36 + 1) & 8) != 0; i = v36 )
{
*v36 = 0;
v36 = i - 1;
}
}
}
if ( v12 == 200 )
{
*a1 = 2;
goto LABEL_36;
}
v37 = v13;
ERR_put_error(39, 118, 114, (int)"crypto/ocsp/ocsp_ht.c", 260);
if ( *v37 )
ERR_add_error_data(4, "Code=", v25, ",Reason=", v37);
else
ERR_add_error_data(2, "Code=", v25);
goto LABEL_30;
}
}
}
ERR_put_error(39, 118, 115, (int)"crypto/ocsp/ocsp_ht.c", 215);
*a1 = 4096;
return 0;
}
v19 = (_BYTE *)a1[1];
v41 = v19;
v20 = (unsigned __int8)*v19;
if ( !*v19 )
{
LABEL_47:
*a1 = 3;
goto LABEL_48;
}
while ( 1 )
{
v21 = v20 == 10;
if ( v20 != 10 )
v21 = v20 == 13;
if ( !v21 )
break;
v41 = ++v19;
v20 = (unsigned __int8)*v19;
if ( !*v19 )
goto LABEL_47;
}
}
if ( BIO_test_flags(a1[4], 8) )
goto LABEL_14;
goto LABEL_30;
}
return 0;
}
if ( v1 != 4 )
return 0;
}
if ( BIO_ctrl((_DWORD *)a1[4], 3, 0, 0) >= a1[5] )
{
*a1 = 4104;
return 1;
}
LABEL_14:
v1 = *a1;
v3 = *a1 & 0x1000;
}
while ( v3 );
LABEL_15:
v8 = BIO_read(a1[3], a1[1], a1[2]);
if ( v8 <= 0 )
break;
if ( BIO_write(a1[4], a1[1], v8) != v8 )
return v3;
v1 = *a1;
}
v3 = BIO_test_flags(a1[3], 8);
if ( v3 )
return -1;
return v3;
}