I sent the dll to virus total to see if anything hit on it and it came back clean. https://www.virustotal.com/gui/file/3a6 ... d3/details
*Code not completed or fully tested
Code: Select all
XIncludeFile("bigint.pbi")
XIncludeFile("cc2rsa.pbi")
ProcedureCDLL AttachProcess(Instance)
Global.Cc2RSA::RSAKeyPair KP
Global.i AESKey
AESKey = AllocateMemory(32)
EndProcedure
ProcedureCDLL RSAGenerateKey(bits.i=2048)
Cc2RSA::GenerateKeyPair(KP, bits)
EndProcedure
ProcedureCDLL RSAClearKey()
BigInt::SetValue(KP\PublicExponent, $0)
BigInt::SetValue(KP\SecretExponent, $0)
BigInt::SetValue(KP\Modulus, $0)
EndProcedure
ProcedureCDLL RSALoadKey(PublicExponent.i, SecretExponent.i,Modulus.i)
BigInt::SetHexValue(KP\PublicExponent, PeekS(PublicExponent, -1, #PB_Ascii ))
BigInt::SetHexValue(KP\SecretExponent, PeekS(SecretExponent, -1, #PB_Ascii ))
BigInt::SetHexValue(KP\Modulus, PeekS(Modulus, -1, #PB_Ascii ))
EndProcedure
ProcedureCDLL RSAGetKey(PublicExponent.i, SecretExponent.i,Modulus.i)
PokeS(PublicExponent, BigInt::GetHex(KP\PublicExponent), 8191, #PB_Ascii )
PokeS(SecretExponent, BigInt::GetHex(KP\SecretExponent), 8191, #PB_Ascii )
PokeS(Modulus, BigInt::GetHex(KP\Modulus), 8191, #PB_Ascii )
EndProcedure
ProcedureCDLL RSAProcess(textdata.s, Mode.i, result.i)
Protected.BigInt::BigInt data1, data2
BigInt::SetHexValue(data2, textdata)
Cc2RSA::RSAProcessRaw(data1, data2, KP, Mode)
PokeS(result, BigInt::GetHex(data1), 8191, #PB_Ascii )
EndProcedure
ProcedureCDLL AESGenerateKey()
OpenCryptRandom()
CryptRandomData(AESKey, 32)
CloseCryptRandom()
EndProcedure
ProcedureCDLL AESClearKey()
FillMemory(AESKey, 32, $00, #PB_Byte )
EndProcedure
ProcedureCDLL AESGetKey(AESKeyOut.i)
KeyHex.s = ""
For x = 0 To 31
KeyHex + RSet(Hex(PeekB(AESKey+x), #PB_Byte), 2, "0")
Next
PokeS(AESKeyOut, KeyHex, 64, #PB_Ascii )
EndProcedure
ProcedureCDLL AESLoadKey(AESKeyIn.i)
For x = 0 To 31
PokeB(AESKey+x, Val("$" + PeekS(AESKeyIn + ( x * 2 ), 2, #PB_Ascii )))
Next
EndProcedure
ProcedureCDLL AESEncrypt(DataIn.i, Dataout.i, iv.i)
OpenCryptRandom()
CryptRandomData(iv, 16)
CloseCryptRandom()
AESEncoder(DataIn, Dataout, StringByteLength(PeekS(DataIn, -1, #PB_Ascii), #PB_Ascii), AESKey, 256, #PB_Cipher_CBC)
PokeS(Dataout, Str( StringByteLength(PeekS(DataIn, -1, #PB_Ascii), #PB_Ascii) ), -1, #PB_Ascii)
EndProcedure