RSACryptoServiceProvider.FromXmlString
public sealed class RSACryptoServiceProvider : RSA, ICspAsymmetricAlgorithm
// System.Security.Cryptography.RSA /// <summary>Initializes an <see cref="T:System.Security.Cryptography.RSA" /> object from the key information from an XML string.</summary> /// <param name="xmlString">The XML string containing <see cref="T:System.Security.Cryptography.RSA" /> key information.</param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="xmlString" /> parameter is <see langword="null" />.</exception> /// <exception cref="T:System.Security.Cryptography.CryptographicException">The format of the <paramref name="xmlString" /> parameter is not valid.</exception> /// <exception cref="T:System.PlatformNotSupportedException">.NET Core only: This member is not supported.</exception> // Token: 0x06002293 RID: 8851 RVA: 0x0007C3A4 File Offset: 0x0007A5A4 public override void FromXmlString(string xmlString) { if (xmlString == null) { throw new ArgumentNullException("xmlString"); } RSAParameters parameters = default(RSAParameters); Parser parser = new Parser(xmlString); SecurityElement topElement = parser.GetTopElement(); string text = topElement.SearchForTextOfLocalName("Modulus"); if (text == null) { throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString", new object[] { "RSA", "Modulus" })); } parameters.Modulus = Convert.FromBase64String(Utils.DiscardWhiteSpaces(text)); string text2 = topElement.SearchForTextOfLocalName("Exponent"); if (text2 == null) { throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidFromXmlString", new object[] { "RSA", "Exponent" })); } parameters.Exponent = Convert.FromBase64String(Utils.DiscardWhiteSpaces(text2)); string text3 = topElement.SearchForTextOfLocalName("P"); if (text3 != null) { parameters.P = Convert.FromBase64String(Utils.DiscardWhiteSpaces(text3)); } string text4 = topElement.SearchForTextOfLocalName("Q"); if (text4 != null) { parameters.Q = Convert.FromBase64String(Utils.DiscardWhiteSpaces(text4)); } string text5 = topElement.SearchForTextOfLocalName("DP"); if (text5 != null) { parameters.DP = Convert.FromBase64String(Utils.DiscardWhiteSpaces(text5)); } string text6 = topElement.SearchForTextOfLocalName("DQ"); if (text6 != null) { parameters.DQ = Convert.FromBase64String(Utils.DiscardWhiteSpaces(text6)); } string text7 = topElement.SearchForTextOfLocalName("InverseQ"); if (text7 != null) { parameters.InverseQ = Convert.FromBase64String(Utils.DiscardWhiteSpaces(text7)); } string text8 = topElement.SearchForTextOfLocalName("D"); if (text8 != null) { parameters.D = Convert.FromBase64String(Utils.DiscardWhiteSpaces(text8)); } this.ImportParameters(parameters); }
// System.Security.Cryptography.RSACryptoServiceProvider /// <summary>Imports the specified <see cref="T:System.Security.Cryptography.RSAParameters" />.</summary> /// <param name="parameters">The parameters for <see cref="T:System.Security.Cryptography.RSA" />.</param> /// <exception cref="T:System.Security.Cryptography.CryptographicException">The cryptographic service provider (CSP) cannot be acquired. /// -or- /// The <paramref name="parameters" /> parameter has missing fields.</exception> // Token: 0x060022B7 RID: 8887 RVA: 0x0007CB10 File Offset: 0x0007AD10 [SecuritySafeCritical] public override void ImportParameters(RSAParameters parameters) { if (this._safeKeyHandle != null && !this._safeKeyHandle.IsClosed) { this._safeKeyHandle.Dispose(); this._safeKeyHandle = null; } RSACspObject cspObject = RSACryptoServiceProvider.RSAStructToObject(parameters); this._safeKeyHandle = SafeKeyHandle.InvalidHandle; if (RSACryptoServiceProvider.IsPublic(parameters)) { Utils._ImportKey(Utils.StaticProvHandle, 41984, CspProviderFlags.NoFlags, cspObject, ref this._safeKeyHandle); return; } if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { KeyContainerPermission keyContainerPermission = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags); KeyContainerPermissionAccessEntry accessEntry = new KeyContainerPermissionAccessEntry(this._parameters, KeyContainerPermissionFlags.Import); keyContainerPermission.AccessEntries.Add(accessEntry); keyContainerPermission.Demand(); } if (this._safeProvHandle == null) { this._safeProvHandle = Utils.CreateProvHandle(this._parameters, this._randomKeyContainer); } Utils._ImportKey(this._safeProvHandle, 41984, this._parameters.Flags, cspObject, ref this._safeKeyHandle); }
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2014-11-19 炉石相关的开源