/// <summary> /// Initializes this instance of an RSA signature algorithm. /// </summary> /// <param name="rsa">RSA cryptographic service provider to use.</param> /// <param name="hashAlgorithm">Hash algorithm used to compute data digests for signing.</param> private void InitializeAlgorithm(RSACryptoServiceProvider rsa, HashAlgorithm hashAlgorithm) { if (!(hashAlgorithm is SHA1) && !(hashAlgorithm is SHA256)) { throw new SecurityException("Unacceptable hash algorithm"); } if (!KEYSIZE_MAP.ContainsKey(rsa.KeySize)) { throw new SecurityException("Unacceptable RSA key size: " + rsa.KeySize); } this.rsa = rsa; int hashSize = KEYSIZE_MAP[rsa.KeySize]; if (hashSize != hashAlgorithm.HashSize) { throw new SecurityException("Unexpected hash size: " + hashAlgorithm.HashSize + " (expected " + hashSize + ")"); } this.hashAlgorithm = hashAlgorithm; //Compute the identity. RSAParameters parameters = rsa.ExportParameters(false); this.identity = new RSAIdentity(parameters); }
public RSASignature(byte[] data, RSAIdentity identity, byte[] signature) : base(data, identity) { this.signature = signature; }