Example #1
0
        private static byte[] GetSharedKey(Uri uri)
        {
            var curve = new NistP521();

            var coords = new Coordinates()
            {
                X = curve.PublicKey.X.ToString(),
                Y = curve.PublicKey.Y.ToString()
            };

            var json = Actions.WriteJson(coords);

            var response = Encoding.UTF8.GetString(Http.Post(uri, Encoding.UTF8.GetBytes(json)));

            var remoteCoords = Actions.ParseJson((response));
            var remotePoint  = new PointOnCurve(BigInteger.Parse(remoteCoords.X), BigInteger.Parse(remoteCoords.Y));

            return(curve.GetSharedKey(remotePoint, HashFunction.SHA256));
        }
 /// <summary>
 /// NIST P-521 Curve
 /// </summary>
 /// <param name="Curve">Curve instance</param>
 /// <param name="SymmetricCipher">Symmetric cipher to use by default.</param>
 public NistP521Endpoint(NistP521 Curve, IE2eSymmetricCipher SymmetricCipher)
     : base(Curve, SymmetricCipher)
 {
 }
 /// <summary>
 /// NIST P-521 Curve
 /// </summary>
 /// <param name="Curve">Curve instance</param>
 public NistP521Endpoint(NistP521 Curve)
     : this(Curve, new Aes256())
 {
 }
Example #4
0
 /// <summary>
 /// NIST P-521 Curve
 /// </summary>
 /// <param name="Curve">Curve instance</param>
 public NistP521Aes(NistP521 Curve)
     : base(Curve)
 {
 }