about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-04-16 17:28:03 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-04-16 17:28:03 +0200
commit2ccd9da8e877e0a689ae1e946fb5c4592d339055 (patch)
treec1ce3a9a129ee7c20668873d85d4fd108730f889 /src
parent18b5d6f1eddb3c93f077c92de30299282f5e2fd6 (diff)
downloadbox64-2ccd9da8e877e0a689ae1e946fb5c4592d339055.tar.gz
box64-2ccd9da8e877e0a689ae1e946fb5c4592d339055.zip
Added some wrapped function to libnss3 and friends
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt2
-rw-r--r--src/wrapped/generated/wrappedsmime3types.h2
-rwxr-xr-xsrc/wrapped/wrappednss3_private.h28
-rwxr-xr-xsrc/wrapped/wrappedsmime3.c28
-rwxr-xr-xsrc/wrapped/wrappedsmime3_private.h2
5 files changed, 47 insertions, 15 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index a7466c1c..19176594 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -4343,6 +4343,8 @@ wrappedsmime3:
   - SEC_PKCS12DecoderValidateBags
 - iFppp:
   - SEC_PKCS12Encode
+- iFpipp:
+  - CERT_DecodeCertPackage
 - pFpppp:
   - SEC_PKCS12CreateExportContext
 - pFpppppppp:
diff --git a/src/wrapped/generated/wrappedsmime3types.h b/src/wrapped/generated/wrappedsmime3types.h
index 245e1137..bd52a266 100644
--- a/src/wrapped/generated/wrappedsmime3types.h
+++ b/src/wrapped/generated/wrappedsmime3types.h
@@ -13,6 +13,7 @@
 
 typedef int32_t (*iFpp_t)(void*, void*);
 typedef int32_t (*iFppp_t)(void*, void*, void*);
+typedef int32_t (*iFpipp_t)(void*, int32_t, void*, void*);
 typedef void* (*pFpppp_t)(void*, void*, void*, void*);
 typedef void* (*pFpppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*);
 typedef void* (*pFppppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*);
@@ -20,6 +21,7 @@ typedef void* (*pFppppppppppp_t)(void*, void*, void*, void*, void*, void*, void*
 #define SUPER() ADDED_FUNCTIONS() \
 	GO(SEC_PKCS12DecoderValidateBags, iFpp_t) \
 	GO(SEC_PKCS12Encode, iFppp_t) \
+	GO(CERT_DecodeCertPackage, iFpipp_t) \
 	GO(SEC_PKCS12CreateExportContext, pFpppp_t) \
 	GO(SEC_PKCS12DecoderStart, pFpppppppp_t) \
 	GO(NSS_CMSEncoder_Start, pFppppppppppp_t)
diff --git a/src/wrapped/wrappednss3_private.h b/src/wrapped/wrappednss3_private.h
index 6e7b62d3..9cc602b9 100755
--- a/src/wrapped/wrappednss3_private.h
+++ b/src/wrapped/wrappednss3_private.h
@@ -38,7 +38,7 @@ GO(CERT_CheckCertValidTimes, iFpIi)
 //GO(__CERT_ClosePermCertDB, 
 //GO(CERT_CompareAVA, 
 GO(CERT_CompareCerts, iFpp)
-//GO(CERT_CompareName, 
+GO(CERT_CompareName, iFpp)
 //GO(CERT_CompareValidityTimes, 
 //GO(CERT_CompleteCRLDecodeEntries, 
 //GO(CERT_CopyName, 
@@ -85,7 +85,7 @@ GO(CERT_DestroyCertificatePoliciesExtension, vFp)
 GO(CERT_DestroyCertificateRequest, vFp)
 GO(CERT_DestroyCertList, vFp)
 //GO(CERT_DestroyCERTRevocationFlags, 
-//GO(CERT_DestroyName, 
+GO(CERT_DestroyName, vFp)
 //GO(CERT_DestroyOCSPCertID, 
 //GO(CERT_DestroyOCSPRequest, 
 //GO(CERT_DestroyOCSPResponse, 
@@ -248,11 +248,11 @@ GO(CERT_VerifyCertificateNow, iFppiipp)
 //GO(CERT_VerifyCertNow, 
 //GO(CERT_VerifyOCSPResponseSignature, 
 //GO(CERT_VerifySignedData, 
-//GO(CERT_VerifySignedDataWithPublicKey, 
+GO(CERT_VerifySignedDataWithPublicKey, iFppp)
 //GO(CERT_VerifySignedDataWithPublicKeyInfo, 
 //GO(DER_AsciiToTime, 
 GO(DER_DecodeTimeChoice, iFpp)
-//GO(DER_Encode, 
+GO(DER_Encode, iFpppp)
 //GO(DER_EncodeTimeChoice, 
 //GO(DER_GeneralizedDayToAscii, 
 //GO(DER_GeneralizedTimeToTime, 
@@ -269,11 +269,11 @@ GO(DER_DecodeTimeChoice, iFpp)
 //GO(DSAU_DecodeDerSigToLen, 
 //GO(DSAU_EncodeDerSig, 
 //GO(DSAU_EncodeDerSigWithLen, 
-//GO(HASH_Begin, 
+GO(HASH_Begin, vFp)
 //GO(HASH_Clone, 
-//GO(HASH_Create, 
-//GO(HASH_Destroy, 
-//GO(HASH_End, 
+GO(HASH_Create, pFi)
+GO(HASH_Destroy, vFp)
+GO(HASH_End, vFpppu)
 //GO(HASH_GetHashObject, 
 //GO(HASH_GetHashObjectByOidTag, 
 //GO(HASH_GetHashOidTagByHashType, 
@@ -282,8 +282,8 @@ GO(DER_DecodeTimeChoice, iFpp)
 GO(HASH_HashBuf, iFippu)
 //GO(HASH_ResultLen, 
 //GO(HASH_ResultLenByOidTag, 
-//GO(HASH_ResultLenContext, 
-//GO(HASH_Update, 
+GO(HASH_ResultLenContext, uFp)
+GO(HASH_Update, vFppu)
 //GO(NSSBase64_DecodeBuffer, 
 //GO(NSSBase64Decoder_Create, 
 //GO(NSSBase64Decoder_Destroy, 
@@ -647,7 +647,7 @@ GO(PORT_ArenaAlloc, pFpL)
 //GO(PORT_ArenaRelease, 
 //GO(PORT_ArenaStrdup, 
 //GO(PORT_ArenaUnmark, 
-//GO(PORT_ArenaZAlloc, 
+GO(PORT_ArenaZAlloc, pFpL)
 GO(PORT_Free, vFp)
 GO(PORT_FreeArena, vFpi)
 GO(PORT_GetError, iFv)
@@ -730,7 +730,7 @@ GO(SECITEM_ZfreeItem, vFpi)
 //GO(SECKEY_CreateDHPrivateKey, 
 //GO(SECKEY_CreateECPrivateKey, 
 //GO(SECKEY_CreateRSAPrivateKey, 
-//GO(SECKEY_CreateSubjectPublicKeyInfo, 
+GO(SECKEY_CreateSubjectPublicKeyInfo, pFp)
 //GO(SECKEY_DecodeDERSubjectPublicKeyInfo, 
 //GO(SECKEY_DestroyEncryptedPrivateKeyInfo, 
 GO(SECKEY_DestroyPrivateKey, vFp)
@@ -738,14 +738,14 @@ GO(SECKEY_DestroyPrivateKey, vFp)
 //GO(SECKEY_DestroyPrivateKeyList, 
 GO(SECKEY_DestroyPublicKey, vFp)
 //GO(SECKEY_DestroyPublicKeyList, 
-//GO(SECKEY_DestroySubjectPublicKeyInfo, 
+GO(SECKEY_DestroySubjectPublicKeyInfo, vFp)
 //DATA(SECKEY_DSAPublicKeyTemplate,     //R type
 //GO(SECKEY_ECParamsToBasePointOrderLen, 
 //GO(SECKEY_ECParamsToKeySize, 
 //GO(SECKEY_EncodeDERSubjectPublicKeyInfo, 
 DATA(SECKEY_EncryptedPrivateKeyInfoTemplate, 128)
 GO(SECKEY_ExtractPublicKey, pFp)
-//GO(SECKEY_GetPrivateKeyType, 
+GO(SECKEY_GetPrivateKeyType, iFp)
 //GO(SECKEY_GetPublicKeyType, 
 //GO(SECKEY_HashPassword, 
 //GO(SECKEY_ImportDERPublicKey, 
diff --git a/src/wrapped/wrappedsmime3.c b/src/wrapped/wrappedsmime3.c
index a9eea343..136e5510 100755
--- a/src/wrapped/wrappedsmime3.c
+++ b/src/wrapped/wrappedsmime3.c
@@ -241,6 +241,29 @@ static void* find_NSSCMSGetDecryptKeyCallback_Fct(void* fct)
     return NULL;
 }
 
+// CERTImportCertificateFunc ...
+#define GO(A)   \
+static uintptr_t my_CERTImportCertificateFunc_fct_##A = 0;                                  \
+static int my_CERTImportCertificateFunc_##A(void* a, void* b, int c)                        \
+{                                                                                           \
+    return (int)RunFunction(my_context, my_CERTImportCertificateFunc_fct_##A, 2, a, b, c);  \
+}
+SUPER()
+#undef GO
+static void* find_CERTImportCertificateFunc_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_CERTImportCertificateFunc_fct_##A == (uintptr_t)fct) return my_CERTImportCertificateFunc_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_CERTImportCertificateFunc_fct_##A == 0) {my_CERTImportCertificateFunc_fct_##A = (uintptr_t)fct; return my_CERTImportCertificateFunc_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for smime3 CERTImportCertificateFunc callback\n");
+    return NULL;
+}
+
 #undef SUPER
 
 EXPORT void my_SEC_PKCS12CreateExportContext(x64emu_t* emu, void* f, void* pwfnarg, void* slot, void* wincx)
@@ -274,6 +297,11 @@ EXPORT void* my_NSS_CMSEncoder_Start(x64emu_t* emu, void* cmsg, void* outputf, v
                     find_NSSCMSGetDecryptKeyCallback_Fct(decryptcb), decryptarg, detached, items);
 }
 
+EXPORT int my_CERT_DecodeCertPackage(x64emu_t* emu, void* cert, int len, void* f, void* data)
+{
+    return my->CERT_DecodeCertPackage(cert, len, find_CERTImportCertificateFunc_Fct(f), data);
+}
+
 #define CUSTOM_INIT \
     getMy(lib);
 
diff --git a/src/wrapped/wrappedsmime3_private.h b/src/wrapped/wrappedsmime3_private.h
index 1bf39ae3..f4e3bd8b 100755
--- a/src/wrapped/wrappedsmime3_private.h
+++ b/src/wrapped/wrappedsmime3_private.h
@@ -4,7 +4,7 @@
 
 //GO(CERT_ConvertAndDecodeCertificate, 
 //GO(CERT_DecodeCertFromPackage, 
-//GO(CERT_DecodeCertPackage, 
+GOM(CERT_DecodeCertPackage, iFEpipp)
 //GO(NSS_CMSContentInfo_GetBulkKey, 
 //GO(NSS_CMSContentInfo_GetBulkKeySize, 
 //GO(NSS_CMSContentInfo_GetContent,