Exemplo n.º 1
0
        public static SysInfo GetComputerId()
        {
            string assemblyName = Assembly.GetExecutingAssembly().GetName().Name;

            SystemInfo.UseProcessorID               = true;
            SystemInfo.UseBaseBoardProduct          = true;
            SystemInfo.UseBaseBoardManufacturer     = true;
            SystemInfo.UseDiskDriveSignature        = true;
            SystemInfo.UseVideoControllerCaption    = true;
            SystemInfo.UsePhysicalMediaSerialNumber = true;
            SystemInfo.UseBiosVersion               = true;
            SystemInfo.UseBiosManufacturer          = true;
            SystemInfo.UseWindowsSerialNumber       = true;

            string sysInfoTmp = SystemInfo.GetSystemInfo(assemblyName);

            sysInfoTmp = SerialNumbersSettings.ProtectedApplications.SaltData.GeneralToolkit + sysInfoTmp + SerialNumbersSettings.ProtectedApplications.SaltData.GeneralToolkit;
            byte[] sysInfoBytes = Encoding.ASCII.GetBytes(sysInfoTmp);
            byte[] cumputerIdBytes;

            using (var hashAlg = SHA512.Create())
            {
                cumputerIdBytes = hashAlg.ComputeHash(sysInfoBytes);
            }

            byte[] rsaSignedHashBytes = SerialNumberManager.HashAndSignBytes(cumputerIdBytes, RSALocalCryptoKeyManager.GetAssemblyRsaParameters());

            return(new SysInfo(Converters.GeneralConverters.ByteArrayToBase64(cumputerIdBytes), Converters.GeneralConverters.ByteArrayToBase64(rsaSignedHashBytes)));
        }
Exemplo n.º 2
0
        public void Init(SerialNumbersSettings.ProtectedApp app)
        {
            string pubKey;

            switch (app)
            {
            case SerialNumbersSettings.ProtectedApp.SecureMemo:
                pubKey = SerialNumbersSettings.ProtectedApplications.PublicKeys.SecureMemo;
                break;

            case SerialNumbersSettings.ProtectedApp.SearchForDuplicates:
                pubKey = SerialNumbersSettings.ProtectedApplications.PublicKeys.SearchForDuplicates;
                break;

            default:
                throw new ArgumentOutOfRangeException("app");
            }


            RSA_AsymetricEncryption rsaAsymetricEncryption  = new RSA_AsymetricEncryption();
            RSAKeySetIdentity       rsaPublicKeySetIdentity = new RSAKeySetIdentity("", pubKey);
            RSAParameters           rsaPublicKey            = rsaAsymetricEncryption.ParseRSAPublicKeyOnlyInfo(rsaPublicKeySetIdentity);

            _serialNumberManager = new SerialNumberManager(rsaPublicKey, app);
        }