I'm trying to integrate a key generator inside my application but it appears as though I keep getting EP_ERROR_KEYBUFFEREMPTY error code.
I have included Enigma_KeyGen_IDEA64.cs inside my application, and copied keygen64.dll to my build directory and included in my project build. The code I have for TKeyGenParams is
Code: Select all
var regName = "Test User";
var buffer = new string('\0', 2048);
var key = new Enigma_KeyGen_IDE64.TKeyGenParams()
{
// Encryption data
PrivateKey = "", // removed
PublicKey = "", // removed
EncryptedConstant = 0, // removed
EncryptedSections = new bool[] { false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false },
// Expiration
UseKeyExpiration = true,
ExpirationDay = 28,
ExpirationMonth = 11,
ExpirationYear = 2018,
// Hardware ID
HardwareID = "", // removed
// Locking methods
UseHardwareLocking = true,
UseRegisterAfter = false,
UseRegisterBefore = false,
UseExecutionsLimit = false,
UseDaysLimit = false,
UseRunTimeLimit = false,
UseGlobalTimeLimit = false,
UseCountyLimit = false,
// Key
Key = buffer,
KeyLen = buffer.Length,
KeyBase = Enigma_KeyGen_IDE64.RB_64,
KeyMode = Enigma_KeyGen_IDE64.RM_4096,
KeyWithHyphens = false,
// Registration Info
RegInfo = regName,
RegInfoLen = regName.Length
};
Code: Select all
var encryptionResult = Enigma_KeyGen_IDE64.KG_GenerateRegistrationKey(ref key);
I'm using C# 7.3 and also tried KG_GenerateRegistrationKeyA and KG_GenerateRegistrationKeyW (exits my application).
DLL Decl:
Code: Select all
// Enigma keygen API
[DllImport("Keygen/keygen64.dll")]
public static extern uint KG_GenerateRegistrationKey(ref TKeyGenParams kg);
Code: Select all
var keybuffer = new char[2048];
keybuffer.Initialize();
test.Key = keybuffer.ToString();
test.KeyLen = keybuffer.Length;
And swapped out the Marshall types:
Code: Select all
UnmanagedType.LPWStr
UnmanagedType.LPStr
UnmanagedType.BStr