100 lines
3.8 KiB
C#
100 lines
3.8 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Mono.Security.Cryptography;
|
|
|
|
namespace System.Security.Cryptography
|
|
{
|
|
/// <summary>Decrypts the PKCS #1 key exchange data.</summary>
|
|
// Token: 0x0200051F RID: 1311
|
|
[ComVisible(true)]
|
|
public class RSAPKCS1KeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter" /> class.</summary>
|
|
// Token: 0x06003040 RID: 12352 RVA: 0x0009DE10 File Offset: 0x0009C010
|
|
public RSAPKCS1KeyExchangeDeformatter()
|
|
{
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter" /> class with the specified key.</summary>
|
|
/// <param name="key">The instance of the <see cref="T:System.Security.Cryptography.RSA" /> algorithm that holds the private key. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="key" /> is null.</exception>
|
|
// Token: 0x06003041 RID: 12353 RVA: 0x0009DE18 File Offset: 0x0009C018
|
|
public RSAPKCS1KeyExchangeDeformatter(AsymmetricAlgorithm key)
|
|
{
|
|
this.SetKey(key);
|
|
}
|
|
|
|
/// <summary>Gets the parameters for the PKCS #1 key exchange.</summary>
|
|
/// <returns>An XML string containing the parameters of the PKCS #1 key exchange operation.</returns>
|
|
// Token: 0x17000980 RID: 2432
|
|
// (get) Token: 0x06003042 RID: 12354 RVA: 0x0009DE28 File Offset: 0x0009C028
|
|
// (set) Token: 0x06003043 RID: 12355 RVA: 0x0009DE2C File Offset: 0x0009C02C
|
|
public override string Parameters
|
|
{
|
|
get
|
|
{
|
|
return null;
|
|
}
|
|
set
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the random number generator algorithm to use in the creation of the key exchange.</summary>
|
|
/// <returns>The instance of a random number generator algorithm to use.</returns>
|
|
// Token: 0x17000981 RID: 2433
|
|
// (get) Token: 0x06003044 RID: 12356 RVA: 0x0009DE30 File Offset: 0x0009C030
|
|
// (set) Token: 0x06003045 RID: 12357 RVA: 0x0009DE38 File Offset: 0x0009C038
|
|
public RandomNumberGenerator RNG
|
|
{
|
|
get
|
|
{
|
|
return this.random;
|
|
}
|
|
set
|
|
{
|
|
this.random = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Extracts secret information from the encrypted key exchange data.</summary>
|
|
/// <returns>The secret information derived from the key exchange data.</returns>
|
|
/// <param name="rgbIn">The key exchange data within which the secret information is hidden. </param>
|
|
/// <exception cref="T:System.Security.Cryptography.CryptographicUnexpectedOperationException">The key is missing.</exception>
|
|
/// <PermissionSet>
|
|
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
|
/// </PermissionSet>
|
|
// Token: 0x06003046 RID: 12358 RVA: 0x0009DE44 File Offset: 0x0009C044
|
|
public override byte[] DecryptKeyExchange(byte[] rgbIn)
|
|
{
|
|
if (this.rsa == null)
|
|
{
|
|
throw new CryptographicUnexpectedOperationException(Locale.GetText("No key pair available."));
|
|
}
|
|
byte[] array = PKCS1.Decrypt_v15(this.rsa, rgbIn);
|
|
if (array != null)
|
|
{
|
|
return array;
|
|
}
|
|
throw new CryptographicException(Locale.GetText("PKCS1 decoding error."));
|
|
}
|
|
|
|
/// <summary>Sets the private key to use for decrypting the secret information.</summary>
|
|
/// <param name="key">The instance of the <see cref="T:System.Security.Cryptography.RSA" /> algorithm that holds the private key. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="key" /> is null.</exception>
|
|
// Token: 0x06003047 RID: 12359 RVA: 0x0009DE90 File Offset: 0x0009C090
|
|
public override void SetKey(AsymmetricAlgorithm key)
|
|
{
|
|
this.rsa = (RSA)key;
|
|
}
|
|
|
|
// Token: 0x0400139F RID: 5023
|
|
private RSA rsa;
|
|
|
|
// Token: 0x040013A0 RID: 5024
|
|
private RandomNumberGenerator random;
|
|
}
|
|
}
|