MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e/Microsoft/InfoCards/SelfIssuedAuthAsymmetricKey.cs
2022-08-18 06:28:56 -05:00

108 lines
4.4 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.SelfIssuedAuthAsymmetricKey
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e.exe
using Microsoft.InfoCards.Diagnostics;
using System;
using System.IdentityModel.Tokens;
using System.Security.Cryptography;
namespace Microsoft.InfoCards
{
internal class SelfIssuedAuthAsymmetricKey : AsymmetricSecurityKey, IDisposable
{
private SelfIssuedAuthRSACryptoProvider m_selfIssuedAuthRsaCryptoProvider;
public SelfIssuedAuthAsymmetricKey(RSACryptoServiceProvider rsa) => this.m_selfIssuedAuthRsaCryptoProvider = new SelfIssuedAuthRSACryptoProvider(rsa);
public override int KeySize => this.m_selfIssuedAuthRsaCryptoProvider.KeySize;
public override bool HasPrivateKey()
{
InfoCardTrace.ThrowInvalidArgumentConditional(this.m_selfIssuedAuthRsaCryptoProvider.IsPublicOnly(), "selfIssuedRsaCrypoProvider");
return true;
}
public override AsymmetricAlgorithm GetAsymmetricAlgorithm(
string algorithmUri,
bool privateKey)
{
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 (AsymmetricAlgorithm) this.m_selfIssuedAuthRsaCryptoProvider;
default:
throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException(SR.GetString("ClientUnsupportedCryptoAlgorithm", (object) algorithmUri)));
}
}
public override HashAlgorithm GetHashAlgorithmForSignature(string algorithmUri)
{
switch (algorithmUri)
{
case "http://www.w3.org/2000/09/xmldsig#rsa-sha1":
return (HashAlgorithm) new SHA1Managed();
default:
throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException(SR.GetString("UnsupportedSignatureAlgorithm", (object) algorithmUri)));
}
}
public override AsymmetricSignatureDeformatter GetSignatureDeformatter(
string algorithmUri)
{
switch (algorithmUri)
{
case "http://www.w3.org/2000/09/xmldsig#rsa-sha1":
return (AsymmetricSignatureDeformatter) new SelfIssuedAuthRSAPKCS1SignatureDeformatter((AsymmetricAlgorithm) this.m_selfIssuedAuthRsaCryptoProvider);
default:
throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException(SR.GetString("UnsupportedSignatureAlgorithm", (object) algorithmUri)));
}
}
public override AsymmetricSignatureFormatter GetSignatureFormatter(
string algorithmUri)
{
switch (algorithmUri)
{
case "http://www.w3.org/2000/09/xmldsig#rsa-sha1":
return (AsymmetricSignatureFormatter) new SelfIssuedAuthRSAPKCS1SignatureFormatter((AsymmetricAlgorithm) this.m_selfIssuedAuthRsaCryptoProvider);
default:
throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException(SR.GetString("UnsupportedSignatureAlgorithm", (object) algorithmUri)));
}
}
public override byte[] DecryptKey(string algorithmUri, byte[] keyData) => throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException());
public override byte[] EncryptKey(string algorithmUri, byte[] keyData) => throw InfoCardTrace.ThrowHelperError((Exception) new NotSupportedException());
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 true;
default:
return false;
}
}
public override bool IsSymmetricAlgorithm(string algorithmUri) => InfoCardCryptoHelper.IsSymmetricAlgorithm(algorithmUri);
public override bool IsAsymmetricAlgorithm(string algorithmUri) => InfoCardCryptoHelper.IsAsymmetricAlgorithm(algorithmUri);
public void Dispose()
{
if (this.m_selfIssuedAuthRsaCryptoProvider == null)
return;
this.m_selfIssuedAuthRsaCryptoProvider.Dispose();
this.m_selfIssuedAuthRsaCryptoProvider = (SelfIssuedAuthRSACryptoProvider) null;
}
}
}