// // cms_EncryptedContent_init_bio from 0xe7b0c0 to 0xe7b570 (1200 bytes) // // 3 xrefs: // > cms_EnvelopedData_init_bio @ 0xe1e6d8 // > cms_EncryptedData_init_bio @ 0xe7b73c // > @ 0xbe3f8 // // 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 // _QWORD *__fastcall cms_EncryptedContent_init_bio(__int64 a1) { _BOOL4 v2; // w25 __int64 *v3; // x26 void *v4; // x0 __int64 v5; // x0 _QWORD *v6; // x20 unsigned int *v7; // x1 unsigned int *v8; // x0 unsigned int v9; // w0 int v10; // w0 _BYTE *v11; // x24 unsigned __int64 cipherbyname; // x22 _BYTE *v13; // x23 __int64 v14; // x1 unsigned int v16; // w0 char *v17; // x0 __int64 v18; // x0 _DWORD *v19; // x0 unsigned int *v20; // [xsp+68h] [xbp+68h] BYREF _BYTE v21[16]; // [xsp+70h] [xbp+70h] BYREF v2 = *(_QWORD *)(a1 + 24) != 0; v3 = *(__int64 **)(a1 + 8); v4 = BIO_f_cipher(); v5 = BIO_new((__int64)v4); v6 = (_QWORD *)v5; if ( !v5 ) { ERR_put_error(46, 120, 65, (__int64)"crypto/cms/cms_enc.c", 41); return nullptr; } BIO_ctrl(v5, 0x81u, 0, (__int64)&v20); if ( !v2 ) { v16 = OBJ_obj2nid(*v3); v17 = OBJ_nid2sn(v16); cipherbyname = EVP_get_cipherbyname((__int64)v17); if ( !cipherbyname ) { v13 = nullptr; ERR_put_error(46, 120, 148, (__int64)"crypto/cms/cms_enc.c", 58); goto LABEL_34; } if ( (int)EVP_CipherInit_ex((__int64)v20, (unsigned int *)cipherbyname, 0, 0, nullptr, 0) > 0 ) { if ( (int)EVP_CIPHER_asn1_to_param((__int64)v20, v3[1]) <= 0 ) { cipherbyname = 0; ERR_put_error(46, 120, 102, (__int64)"crypto/cms/cms_enc.c", 81); v13 = nullptr; goto LABEL_34; } v11 = nullptr; cipherbyname = (int)EVP_CIPHER_CTX_key_length((__int64)v20); goto LABEL_19; } LABEL_37: cipherbyname = 0; ERR_put_error(46, 120, 101, (__int64)"crypto/cms/cms_enc.c", 65); v13 = nullptr; goto LABEL_34; } v7 = *(unsigned int **)(a1 + 24); if ( *(_QWORD *)(a1 + 32) ) *(_QWORD *)(a1 + 24) = 0; if ( (int)EVP_CipherInit_ex((__int64)v20, v7, 0, 0, nullptr, v2) <= 0 ) goto LABEL_37; v8 = (unsigned int *)EVP_CIPHER_CTX_cipher((__int64)v20); v9 = EVP_CIPHER_type(v8); *v3 = (__int64)OBJ_nid2obj(v9); v10 = EVP_CIPHER_CTX_iv_length((__int64)v20); if ( v10 <= 0 ) { v11 = nullptr; } else { v11 = v21; if ( (int)RAND_bytes((__int64)v21, (unsigned int)v10) <= 0 ) { cipherbyname = 0; v13 = nullptr; goto LABEL_34; } } cipherbyname = (int)EVP_CIPHER_CTX_key_length((__int64)v20); if ( *(_QWORD *)(a1 + 32) ) { v13 = nullptr; goto LABEL_10; } LABEL_19: v13 = CRYPTO_malloc((void *)cipherbyname, (__int64)"crypto/cms/cms_enc.c", 87); if ( !v13 ) { ERR_put_error(46, 120, 65, (__int64)"crypto/cms/cms_enc.c", 89); goto LABEL_34; } if ( (int)EVP_CIPHER_CTX_rand_key(v20, (__int64)v13) <= 0 ) goto LABEL_34; if ( !*(_QWORD *)(a1 + 32) ) { *(_QWORD *)(a1 + 32) = v13; *(_QWORD *)(a1 + 40) = cipherbyname; if ( v2 ) { if ( (int)EVP_CipherInit_ex((__int64)v20, nullptr, 0, (__int64)v13, v11, v2) > 0 ) { v2 = 0; v13 = nullptr; goto LABEL_25; } v13 = nullptr; goto LABEL_39; } v13 = nullptr; ERR_clear_error(); } LABEL_10: v14 = *(_QWORD *)(a1 + 40); if ( v14 != cipherbyname && (int)EVP_CIPHER_CTX_set_key_length(v20, v14) <= 0 ) { if ( !v2 && !*(_DWORD *)(a1 + 48) ) { CRYPTO_clear_free(*(_BYTE **)(a1 + 32), *(_QWORD *)(a1 + 40), (__int64)"crypto/cms/cms_enc.c", 0x78u); *(_QWORD *)(a1 + 32) = v13; *(_QWORD *)(a1 + 40) = cipherbyname; v13 = nullptr; ERR_clear_error(); if ( (int)EVP_CipherInit_ex((__int64)v20, nullptr, 0, *(_QWORD *)(a1 + 32), v11, 0) > 0 ) goto LABEL_14; goto LABEL_39; } ERR_put_error(46, 120, 118, (__int64)"crypto/cms/cms_enc.c", 116); LABEL_34: CRYPTO_clear_free(*(_BYTE **)(a1 + 32), *(_QWORD *)(a1 + 40), (__int64)"crypto/cms/cms_enc.c", 0x9Bu); *(_QWORD *)(a1 + 32) = 0; CRYPTO_clear_free(v13, cipherbyname, (__int64)"crypto/cms/cms_enc.c", 0x9Eu); BIO_free(v6); return nullptr; } if ( (int)EVP_CipherInit_ex((__int64)v20, nullptr, 0, *(_QWORD *)(a1 + 32), v11, v2) <= 0 ) { LABEL_39: ERR_put_error(46, 120, 101, (__int64)"crypto/cms/cms_enc.c", 131); goto LABEL_34; } if ( !v2 ) { LABEL_14: CRYPTO_clear_free(*(_BYTE **)(a1 + 32), *(_QWORD *)(a1 + 40), (__int64)"crypto/cms/cms_enc.c", 0x9Bu); *(_QWORD *)(a1 + 32) = 0; CRYPTO_clear_free(v13, cipherbyname, (__int64)"crypto/cms/cms_enc.c", 0x9Eu); return v6; } LABEL_25: v18 = ASN1_TYPE_new(); v3[1] = v18; if ( !v18 ) { ERR_put_error(46, 120, 65, (__int64)"crypto/cms/cms_enc.c", 137); goto LABEL_34; } if ( (int)EVP_CIPHER_param_to_asn1((__int64)v20, v18) <= 0 ) { ERR_put_error(46, 120, 102, (__int64)"crypto/cms/cms_enc.c", 142); goto LABEL_34; } v19 = (_DWORD *)v3[1]; if ( *v19 == -1 ) { ASN1_TYPE_free((__int64)v19); v3[1] = 0; } if ( v2 ) goto LABEL_14; CRYPTO_clear_free(v13, cipherbyname, (__int64)"crypto/cms/cms_enc.c", 0x9Eu); return v6; }
GD Web Decomp Icon

GD Web Decomp

Raw Source