Example #1
0
        public static bool VerifyLicenseKeyTextFallback(this string licenseKeyText, out LicenseKey key)
        {
            RSAParameters publicKeyParams;

            try
            {
                var publicRsaProvider = new RSACryptoServiceProvider();
                publicRsaProvider.FromXmlString(LicenseUtils.LicensePublicKey);
                publicKeyParams = publicRsaProvider.ExportParameters(false);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not import LicensePublicKey", ex);
            }

            try
            {
                key = licenseKeyText.ToLicenseKeyFallback();
            }
            catch (Exception ex)
            {
                throw new Exception("Could not deserialize LicenseKeyText Manually", ex);
            }

            byte[] originalData;
            byte[] signedData;

            try
            {
                originalData = key.GetHashKeyToSign().ToUtf8Bytes();
            }
            catch (Exception ex)
            {
                throw new Exception("Could not convert HashKey to UTF-8", ex);
            }

            try
            {
                signedData = Convert.FromBase64String(key.Hash);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not convert key.Hash from Base64", ex);
            }

            try
            {
                return(VerifySignedHash(originalData, signedData, publicKeyParams));
            }
            catch (Exception ex)
            {
                throw new Exception($"Could not Verify License Key ({originalData.Length}, {signedData.Length})", ex);
            }
        }
Example #2
0
        public static bool VerifyLicenseKeyText(this string licenseKeyText, out LicenseKey key)
        {
            var publicRsaProvider = new System.Security.Cryptography.RSACryptoServiceProvider();

            publicRsaProvider.FromXml(LicenseUtils.LicensePublicKey);
            var publicKeyParams = publicRsaProvider.ExportParameters(false);

            key = licenseKeyText.ToLicenseKey();
            var originalData = key.GetHashKeyToSign().ToUtf8Bytes();
            var signedData   = Convert.FromBase64String(key.Hash);

            return(VerifySignedHash(originalData, signedData, publicKeyParams));
        }
        public static bool VerifyLicenseKeyText(this string licenseKeyText, out LicenseKey key)
        {
            var publicRsaProvider = new RSACryptoServiceProvider();
            publicRsaProvider.FromXmlString(LicensePublicKey);
            var publicKeyParams = publicRsaProvider.ExportParameters(false);

            key = licenseKeyText.ToLicenseKey();
            var originalData = key.GetHashKeyToSign().ToUtf8Bytes();
            var signedData = Convert.FromBase64String(key.Hash);

            return VerifySignedHash(originalData, signedData, publicKeyParams);
        }