//
// PKCS5_v2_scrypt_keyivgen from 0xe731c8 to 0xe733d0 (520 bytes)
//
// 2 xrefs:
// > ??> @ 0x62790
// > ??> @ 0x1227820
//
// 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 PKCS5_v2_scrypt_keyivgen(__int64 a1, __int64 a2, int a3, __int64 a4, __int64 a5, __int64 a6, int a7)
{
int **v11; // x19
unsigned __int64 v12; // x20
int *v13; // x1
unsigned int v14; // w21
__int64 v16; // x1
unsigned __int64 v18; // [xsp+78h] [xbp+68h] BYREF
unsigned __int64 v19; // [xsp+80h] [xbp+70h] BYREF
unsigned __int64 v20; // [xsp+88h] [xbp+78h] BYREF
unsigned __int64 v21[8]; // [xsp+90h] [xbp+80h] BYREF
if ( !EVP_CIPHER_CTX_cipher(a1) )
{
ERR_put_error(6, 180, 131, (__int64)"crypto/asn1/p5_scrypt.c", 237);
LABEL_18:
v11 = nullptr;
v14 = 0;
goto LABEL_9;
}
v11 = (int **)ASN1_TYPE_unpack_sequence((__int64)byte_11333F0, a4);
if ( !v11 )
{
ERR_put_error(6, 180, 114, (__int64)"crypto/asn1/p5_scrypt.c", 246);
goto LABEL_18;
}
v12 = (int)EVP_CIPHER_CTX_key_length(a1);
v13 = v11[4];
if ( !v13 || (unsigned int)ASN1_INTEGER_get_uint64(v21, v13) && v21[0] == v12 )
{
if ( (unsigned int)ASN1_INTEGER_get_uint64(&v20, v11[1])
&& (unsigned int)ASN1_INTEGER_get_uint64(&v19, v11[2])
&& (unsigned int)ASN1_INTEGER_get_uint64(&v18, v11[3])
&& (unsigned int)EVP_PBE_scrypt(0, 0, 0, 0, v20, v19, v18, 0, 0, 0) )
{
v16 = a3;
v14 = 0;
if ( (unsigned int)EVP_PBE_scrypt(a2, v16, *((_QWORD *)*v11 + 1), **v11, v20, v19, v18, 0, v21, v12) )
v14 = EVP_CipherInit_ex(a1, nullptr, 0, (__int64)v21, nullptr, a7);
}
else
{
v14 = 0;
ERR_put_error(6, 180, 171, (__int64)"crypto/asn1/p5_scrypt.c", 269);
}
}
else
{
v14 = 0;
ERR_put_error(6, 180, 123, (__int64)"crypto/asn1/p5_scrypt.c", 259);
}
if ( v12 )
OPENSSL_cleanse(v21, v12);
LABEL_9:
SCRYPT_PARAMS_free((__int64)v11);
return v14;
}