MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-69bb73081eac86b8cf86f45e33515d0095855636967076e2b593d7a30cd80a07/Microsoft/InfoCards/RemoteX509AsymmetricSecurityKey.cs
2022-08-18 06:28:56 -05:00

81 lines
2.8 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.RemoteX509AsymmetricSecurityKey
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 516D8B44-4448-4D2C-8B8E-FFBB3FFE472B
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-69bb73081eac86b8cf86f45e33515d0095855636967076e2b593d7a30cd80a07.exe
using Microsoft.InfoCards.Diagnostics;
using System;
using System.IdentityModel.Tokens;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace Microsoft.InfoCards
{
internal class RemoteX509AsymmetricSecurityKey : X509AsymmetricSecurityKey, IDisposable
{
private X509Certificate2 m_cert;
private object m_sync;
private bool m_disposed;
public RemoteX509AsymmetricSecurityKey(X509Certificate2 cert)
: base(cert)
{
this.m_cert = cert;
if (!(this.m_cert.PrivateKey is RemoteCryptoRsaServiceProvider))
throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException());
this.m_sync = new object();
}
public override AsymmetricAlgorithm GetAsymmetricAlgorithm(
string algorithmUri,
bool privateKey)
{
return this.IsSupportedAlgorithm(algorithmUri) ? base.GetAsymmetricAlgorithm(algorithmUri, privateKey) : throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException());
}
public override AsymmetricSignatureDeformatter GetSignatureDeformatter(
string algorithmUri)
{
return this.IsSupportedAlgorithm(algorithmUri) ? base.GetSignatureDeformatter(algorithmUri) : throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException());
}
public override AsymmetricSignatureFormatter GetSignatureFormatter(
string algorithmUri)
{
if (!this.IsSupportedAlgorithm(algorithmUri))
throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException());
RemoteAsymmetricSignatureFormatter signatureFormatter = new RemoteAsymmetricSignatureFormatter();
signatureFormatter.SetKey(this.m_cert.PrivateKey);
return (AsymmetricSignatureFormatter) signatureFormatter;
}
public override bool IsSupportedAlgorithm(string algorithmUri)
{
switch (algorithmUri)
{
case "http://www.w3.org/2000/09/xmldsig#rsa-sha1":
case "http://www.w3.org/2001/04/xmlenc#rsa-1_5":
case "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p":
return base.IsSupportedAlgorithm(algorithmUri);
default:
return false;
}
}
void IDisposable.Dispose()
{
if (this.m_disposed)
return;
lock (this.m_sync)
{
if (this.m_disposed)
return;
this.m_disposed = true;
this.m_cert.PrivateKey?.Dispose();
this.m_cert.PublicKey.Key?.Dispose();
}
}
}
}