protected RSAPKCS1Algorithm(string hashAlgorithm, CryptographicKey publicKey = null, CryptographicKey privateKey = null) : this(hashAlgorithm) { this.disposePublicKey = true; this.disposePrivateKey = true; if (publicKey != null) { this.publicKey = GetAlgorithmFromCryptographicKey(publicKey); if (this.publicKey.KeySize < 2048) { this.Dispose(); throw new ArgumentException("Key size must be at 2048bits"); } } if (privateKey != null) { this.privateKey = GetAlgorithmFromCryptographicKey(privateKey); if (this.privateKey.KeySize < 2048) { this.Dispose(); throw new ArgumentException("Key size must be at 2048bits"); } } }
public override void SetKey(CryptographicKey key) { throw new NotImplementedException(); }
public RS512Algorithm(CryptographicKey publicKey = null, CryptographicKey privateKey = null) : base("SHA512", publicKey, privateKey) { }
public override void SetKey(CryptographicKey key) { base.SetKey(key); }
public RS256Algorithm(CryptographicKey publicKey = null, CryptographicKey privateKey = null) : base("SHA256", publicKey, privateKey) { }
public HS384Algorithm(CryptographicKey key) : this(GetKey(key)) { }
/// <summary> /// Create a public AsymmetricAlgorithm from CryptographicKey /// </summary> /// <param name="key"></param> public virtual void SetKey(CryptographicKey key) { this.disposePublicKey = true; if (key.X509CertificateChain.Count() > 0) { // check x509 thumbprint } else if (key.X509Url != null) { // check x509 thumbprint } else { this.publicKey = GetAlgorithmFromCryptographicKey(key); } }
private static AsymmetricAlgorithm GetAlgorithmFromCryptographicKey(CryptographicKey key) { RSAParameters rsaParameters = default(RSAParameters); key.TryGetValue("e", out rsaParameters.Modulus); key.TryGetValue("n", out rsaParameters.Exponent); key.TryGetValue("d", out rsaParameters.D); key.TryGetValue("p", out rsaParameters.P); key.TryGetValue("q", out rsaParameters.Q); key.TryGetValue("dp", out rsaParameters.DP); key.TryGetValue("dq", out rsaParameters.DQ); var provider = new RSACryptoServiceProvider(); provider.ImportParameters(rsaParameters); return provider; }
public RS384Algorithm(CryptographicKey publicKey = null, CryptographicKey privateKey = null) : base("SHA384", publicKey, privateKey) { }