Ejemplo n.º 1
0
// FIXME	[DataProtectionPermission (SecurityAction.Demand, UnprotectData = true)]
        public static byte[] Unprotect(byte[] encryptedData, byte[] optionalEntropy, DataProtectionScope scope)
        {
            if (encryptedData == null)
            {
                throw new ArgumentNullException("encryptedData");
            }

            // on Windows this is supported only under 2000 and later OS
            Check(scope);

            switch (impl)
            {
            case DataProtectionImplementation.ManagedProtection:
                try {
                    return(ManagedProtection.Unprotect(encryptedData, optionalEntropy, scope));
                }
                catch (Exception e) {
                    string msg = Locale.GetText("Data unprotection failed.");
                    throw new CryptographicException(msg, e);
                }

            case DataProtectionImplementation.Win32CryptoProtect:
                try {
                    return(NativeDapiProtection.Unprotect(encryptedData, optionalEntropy, scope));
                }
                catch (Exception e) {
                    string msg = Locale.GetText("Data unprotection failed.");
                    throw new CryptographicException(msg, e);
                }

            default:
                throw new PlatformNotSupportedException();
            }
        }
Ejemplo n.º 2
0
// FIXME	[DataProtectionPermission (SecurityAction.Demand, UnprotectData = true)]
        public static byte[] Unprotect(byte[] encryptedData, byte[] optionalEntropy, DataProtectionScope scope)
        {
            if (encryptedData == null)
            {
                throw new ArgumentNullException("encryptedData");
            }

            // on Windows this is supported by CoreFX implementation
            Check(scope);

            switch (impl)
            {
#if !MOBILE
            case DataProtectionImplementation.ManagedProtection:
                try {
                    return(ManagedProtection.Unprotect(encryptedData, optionalEntropy, scope));
                }
                catch (Exception e) {
                    string msg = Locale.GetText("Data unprotection failed.");
                    throw new CryptographicException(msg, e);
                }
#endif
            default:
                throw new PlatformNotSupportedException();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Unprotects data using local user account
 /// </summary>
 /// <param name="data">Data to unprotect</param>
 /// <returns>Unprotected data</returns>
 public static byte[] Unprotect(byte[] data, byte[] optionalEntropy = null, DataProtectionScope scope = DataProtectionScope.CurrentUser)
 {
     if (CryptoUtility.IsWindows)
     {
         return(CryptOperationWindows(false, data, optionalEntropy, scope));
     }
     else
     {
         return(ManagedProtection.Unprotect(data, optionalEntropy, scope));
     }
 }
Ejemplo n.º 4
0
 private byte[] Unprotect(byte[] protectedData)
 {
     //  ProtectedData throws UnsupportedPlatform exception, utilizing ManagedProtection directly from Mono
     return(ManagedProtection.Unprotect(protectedData, this._additionalEntropy, DataProtectionScope.CurrentUser));
 }
Ejemplo n.º 5
0
 protected override byte [] Unprotect(byte [] data)
 => ManagedProtection.Unprotect(
     data,
     null,
     DataProtectionScope.CurrentUser);