Ejemplo n.º 1
0
        /// <summary>
        /// Calculates an ECDH agreement.
        /// </summary>
        /// <param name="publicKey">The Curve25519 (typically remote party's) public key.</param>
        /// <param name="privateKey">The Curve25519 (typically yours) private key.</param>
        /// <returns>A 32-byte shared secret.</returns>
        public byte[] calculateAgreement(byte[] publicKey, byte[] privateKey)
        {
            if (publicKey == null || privateKey == null)
            {
                throw new ArgumentException("Keys must not be null!");
            }

            if (publicKey.Length != 32 || privateKey.Length != 32)
            {
                throw new ArgumentException("Keys must be 32 bytes!");
            }

            return(provider.calculateAgreement(privateKey, publicKey));
        }
Ejemplo n.º 2
0
 /**
  * Calculates an ECDH agreement.
  *
  * @param publicKey The Curve25519 (typically remote party's) public key.
  * @param privateKey The Curve25519 (typically yours) private key.
  * @return A 32-byte shared secret.
  */
 public byte[] calculateAgreement(byte[] privateKey, byte[] publicKey)
 {
     return(provider.calculateAgreement(privateKey, publicKey));
 }