private string GenerateSerialFromModel(SerialNumberGenerator serialNumberGenerator)
        {
            var rsaPrivateKeyIdentity = new RsaKeySetIdentity(RSAKeys.PrivateKeys.GetKeyString(), RSAKeys.PublicKeys.GetKeyString());
            var licenseKey            = serialNumberGenerator.GenerateLicenseData(rsaPrivateKeyIdentity);

            return(licenseKey);
        }
Example #2
0
        private static RsaKeySetIdentity GetLocalKeySetIdentity()
        {
            RsaKeySetIdentity rsaKeySetIdentity = new RsaKeySetIdentity(LicenseGeneratorStaticData.PrivateKeys.GeneralToolkitLib,
                                                                        LicenseGeneratorStaticData.PublicKeys.GeneralToolkitLib);

            return(rsaKeySetIdentity);
        }
        public void GenerateKeyPair()
        {
            RsaAsymetricEncryption rsaAsymetricEncryption = new RsaAsymetricEncryption();
            RsaKeySetIdentity      keySetIdentity         = rsaAsymetricEncryption.GenerateRsaKeyPair(RsaAsymetricEncryption.RsaKeySize.B4096);

            string privateKey = keySetIdentity.RsaPrivateKey;
            string publicKey  = keySetIdentity.RsaPublicKey;
        }
        public string GenerateLicenseData(RsaKeySetIdentity rsaPrivateKeySetIdentity)
        {
            RsaAsymetricEncryption rsaAsymetricEncryption  = new RsaAsymetricEncryption();
            RSAParameters          privateRSAKeyParameters = rsaAsymetricEncryption.ParseRsaKeyInfo(rsaPrivateKeySetIdentity);

            byte[] licenseDataBytes = ObjectSerializer.SerializeDataContract(this.LicenseData.RegistrationData);
            byte[] signedData       = HashAndSignBytes(licenseDataBytes, privateRSAKeyParameters);

            this._licenseData.ValidationHash  = signedData;
            this._licenseData.RegistrationKey = this.CreateRegistrationKey(licenseDataBytes);

            return(this._licenseData.RegistrationKey);
        }
Example #5
0
        public frmMain()
        {
            InitializeComponent();
            RsaAsymetricEncryption rsaAsymetricEncryption = new RsaAsymetricEncryption();

            rsaPrivateKeyIdentity = new RsaKeySetIdentity(RSAKeys.PrivateKeys.GetBase64Key(), RSAKeys.PublicKeys.GetBase64Key());
            RSAParameters rsaPrivateKeyParameters = rsaAsymetricEncryption.ParseRsaKeyInfo(rsaPrivateKeyIdentity);

            serialNumberGenerator = new SerialNumberGenerator(rsaPrivateKeyParameters, SerialNumbersSettings.ProtectedApp.SecureMemo);
            int nextMonth = DateTime.Today.AddMonths(1).Month;
            int year      = DateTime.Today.AddMonths(1).AddYears(DEFAULT_VALID_YEARS).Year;

            dateTimePicker.Value = new DateTime(year, nextMonth, 1);
            destinationFolder    = GetOutputPath(Assembly.GetExecutingAssembly().Location);
            this.CreateFolder(destinationFolder);
        }
        private SerialNumberGenerator CreateSerialNumberGenerator()
        {
            var rsaPublicKeyIdentity = new RsaKeySetIdentity(null, RSAKeys.PublicKeys.GetKeyString());
            RsaAsymetricEncryption rsaAsymmetricEncryption = new RsaAsymetricEncryption();
            RSAParameters          pubKeyParams            = rsaAsymmetricEncryption.ParseRsaPublicKeyOnlyInfo(rsaPublicKeyIdentity);

            SerialNumberGenerator serialNumberGenerator = new SerialNumberGenerator(pubKeyParams, SerialNumbersSettings.ProtectedApp.SecureMemo);

            RegistrationDataModel registrationData = new RegistrationDataModel
            {
                Company     = "Doe",
                Salt        = GeneralConverters.GetRandomHexValue(256),
                ValidTo     = DateTime.Now.AddYears(1),
                VersionName = LicenseGeneratorStaticData.SecureMemo.Versions.First()
            };

            serialNumberGenerator.LicenseData.RegistrationData = registrationData;

            return(serialNumberGenerator);
        }