예제 #1
0
        public LicenseBlob TryDeserialize(string license, string licenseSource, bool locallySourced)
        {
            LicenseBlob blob;

            try {
                blob = LicenseBlob.Deserialize(license);
            } catch (Exception ex) {
                AcceptIssue(new Issue("Failed to parse license (from " + licenseSource + "):",
                                      WebConfigLicenseReader.TryRedact(license) + "\n" + ex, IssueSeverity.Error));
                return(null);
            }
            if (!blob.VerifySignature(TrustedKeys, null))
            {
                sink.AcceptIssue(new Issue(
                                     "License " + blob.Fields.Id + " (from " + licenseSource +
                                     ") has been corrupted or has not been signed with a matching private key.", IssueSeverity.Error));
                return(null);
            }
            if (locallySourced && blob.Fields.MustBeFetched())
            {
                sink.AcceptIssue(new Issue(
                                     "This license cannot be installed directly; it must be fetched from a license server",
                                     WebConfigLicenseReader.TryRedact(license), IssueSeverity.Error));
                return(null);
            }
            return(blob);
        }
예제 #2
0
        static bool Validate(string license_str, BigInteger mod, BigInteger exp, StringBuilder log)
        {
            var blob = LicenseBlob.Deserialize(license_str);

            log?.AppendLine("---------------------------------------------");
            log?.AppendLine("Parsed info: " + blob.Fields().ToString());
            log?.AppendLine("Plaintext hash: " + BitConverter.ToString(new SHA512Managed().ComputeHash(blob.Data())).ToLower().Replace("-", ""));
            return(blob.VerifySignature(new[] { new RSADecryptPublic(mod, exp) }, log));
        }
예제 #3
0
        public static bool Revalidate(this ILicenseBlob b, IEnumerable <RSADecryptPublic> trustedKeys)
        {
            var ourCopy = LicenseBlob.Deserialize(b.Original);

            return(ourCopy.VerifySignature(trustedKeys, null) && ourCopy.Fields.DataMatches(b.Fields));
        }