Example #1
0
        public string GetEcPublicKeyContent(IAsymmetricKey publicKey)
        {
            var ecKey = (IEcKey)publicKey;

            if (ecKey.IsCurve25519)
            {
                throw new InvalidOperationException("Curve25519 must be formatted in Edwards form when converted to Ssh key.");
            }

            var keyParameters = (ECPublicKeyParameters)PublicKeyFactory.CreateKey(publicKey.Content);

            string curve = sshSupportedCurves.Single(c => c.Contains(ecKey.Curve)).First();

            byte[] identifier = encoding.GetBytes(sshCurveHeaders[curve]);
            byte[] header     = encoding.GetBytes(sshCurveIdentifiers[curve]);
            byte[] q          = keyParameters.Q.GetEncoded(false);

            using (var stream = new MemoryStream())
            {
                stream.Write(LengthAsBytes(identifier.Length), 0, 4);
                stream.Write(identifier, 0, identifier.Length);
                stream.Write(LengthAsBytes(header.Length), 0, 4);
                stream.Write(header, 0, header.Length);
                stream.Write(LengthAsBytes(q.Length), 0, 4);
                stream.Write(q, 0, q.Length);
                return(base64.ToBase64String(stream.ToArray()));
            }
        }
Example #2
0
        public void Execute(T command)
        {
            var base64Formatted = base64.ToBase64String(command.Out.Content);

            command.FileContent = encoding.GetBytes(base64Formatted);
            decoratedCommandHandler.Execute(command);
        }
 public void Execute(T command)
 {
     command.ContentToStdOut = base64.ToBase64String(command.Out.Content);
     decoratedCommandHandler.Execute(command);
 }
        public void ShouldSetBase64FormattedSignatureAsFileContent()
        {
            var base64Result = base64.ToBase64String(signature.Content);

            Assert.AreEqual(base64Result, command.FileContent);
        }