public IAsymmetricKey GetPublicKey(byte[] keyContent)
        {
            SubjectPublicKeyInfo publicKeyInfo;

            try
            {
                publicKeyInfo = keyInfoWrapper.GetPublicKeyInfo(keyContent);
            }
            catch (ArgumentException)
            {
                throw new CryptographicException("Public key is not valid.");
            }

            return(GetKey(keyContent, publicKeyInfo.AlgorithmID.Algorithm.Id, AsymmetricKeyType.Public));
        }
Example #2
0
        private void SetupValidKeyInfo()
        {
            keyInfoWrapper.Setup(k => k.GetPublicKeyInfo(It.IsAny <byte[]>()))
            .Returns <byte[]>(content =>
            {
                var wrapper = new KeyInfoWrapper();
                return(wrapper.GetPublicKeyInfo(content));
            });

            keyInfoWrapper.Setup(k => k.GetPrivateKeyInfo(It.IsAny <byte[]>()))
            .Returns <byte[]>(content =>
            {
                var wrapper = new KeyInfoWrapper();
                return(wrapper.GetPrivateKeyInfo(content));
            });
        }