/// <inheritdoc />
        public override void SetKey(AsymmetricAlgorithm privateKey)
        {
            if (privateKey == null)
            {
                throw ExceptionUtility.ArgumentNull(nameof(privateKey));
            }

            if (!(privateKey is GostAsymmetricAlgorithm gostPrivateKey))
            {
                throw ExceptionUtility.ArgumentOutOfRange(nameof(privateKey), Resources.ShouldSupportGost3410);
            }

            _privateKey = gostPrivateKey;
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public override void SetKey(AsymmetricAlgorithm publicKey)
        {
            if (publicKey == null)
            {
                throw ExceptionUtility.ArgumentNull(nameof(publicKey));
            }

            if (!(publicKey is GostAsymmetricAlgorithm gostPublicKey))
            {
                if (publicKey.SignatureAlgorithm.IndexOf("gost", StringComparison.OrdinalIgnoreCase) < 0)
                {
                    throw ExceptionUtility.ArgumentOutOfRange(nameof(publicKey), Resources.ShouldSupportGost3410);
                }

                gostPublicKey = new GostExternalAsymmetricAlgorithm(publicKey);
            }

            _publicKey = gostPublicKey;
        }