/// <summary>XmlToProvider</summary> /// <param name="param">RSAParameters</param> /// <returns>RSA(公開鍵)</returns> public RSA XmlToProvider(RSAParameters param) { RSA rsa = AsymmetricAlgorithmCmnFunc.RsaFactory(); rsa.ImportParameters(param); return(rsa); }
// 実用鍵からの変換 #region RSAProvider(RSAParameters) ⇔ Xml or Jwk 公開鍵 #region Xml /// <summary> /// RSAParametersからXml公開鍵へ変換 /// </summary> /// <param name="param">RSAParameters</param> /// <returns>Xml公開鍵</returns> public string ParamToXml(RSAParameters param) { RSA rsa = AsymmetricAlgorithmCmnFunc.RsaFactory(); rsa.ImportParameters(param); return(rsa.ToXmlString(false)); // Public }
/// <summary>JwkToProvider</summary> /// <param name="jwkObject">JObject</param> /// <returns>RSA(公開鍵)</returns> public RSA JwkToProvider(JObject jwkObject) { RSAParameters rsaParameters = this.JwkToParam(jwkObject); RSA rsa = AsymmetricAlgorithmCmnFunc.RsaFactory(); rsa.ImportParameters(rsaParameters); return(rsa); }
/// <summary>JwkToProvider</summary> /// <param name="jwkString">string</param> /// <returns>RSA(公開鍵)</returns> public static RSA JwkToProvider(string jwkString) { RSAParameters rsaParameters = RsaPublicKeyConverter.JwkToParam(jwkString); RSA rsa = AsymmetricAlgorithmCmnFunc.RsaFactory(); rsa.ImportParameters(rsaParameters); return(rsa); }
/// <summary>constructor</summary> protected RsaBob() { RSA rsa = AsymmetricAlgorithmCmnFunc.RsaFactory(); this._asa = rsa; if (rsa is RSACryptoServiceProvider) { this._exchangeKey = ((RSACryptoServiceProvider)rsa).ExportCspBlob(false); // 交換鍵 } // RSACng、RSAOpenSslはこっち(しかない) this._exchangeKey2 = rsa.ExportParameters(false); // 交換鍵(JWK対応 }
/// <summary>constructor</summary> /// <param name="exchangeKeyOfBob">Bobの交換鍵</param> protected RsaAlice(RSAParameters exchangeKeyOfBob) { // RSACng、RSAOpenSslはこっち(しかない) RSA rsa = AsymmetricAlgorithmCmnFunc.RsaFactory(); this._asa = rsa; // Bobの交換鍵を(RSAの公開鍵)インポート rsa.ImportParameters(exchangeKeyOfBob); // 秘密鍵と交換鍵を生成 this.CreateKeys(); }
/// <summary>constructor</summary> /// <param name="exchangeKeyOfBob">Bobの交換鍵</param> protected RsaAlice(byte[] exchangeKeyOfBob) { RSA rsa = AsymmetricAlgorithmCmnFunc.RsaFactory(); this._asa = rsa; // Bobの交換鍵を(RSAの公開鍵)インポート if (rsa is RSACryptoServiceProvider) { ((RSACryptoServiceProvider)rsa).ImportCspBlob(exchangeKeyOfBob); } // 秘密鍵と交換鍵を生成 this.CreateKeys(); }