コード例 #1
0
ファイル: Ed25519.cs プロジェクト: niilante/paseto-dotnet
        public static bool Verify(byte[] signature, byte[] message, byte[] publicKey)
        {
            if (signature == null)
            {
                throw new ArgumentNullException(nameof(signature));
            }

            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (publicKey == null)
            {
                throw new ArgumentNullException(nameof(publicKey));
            }

            if (signature.Length != SignatureSizeInBytes)
            {
                throw new ArgumentException(string.Format("Signature size must be {0}", SignatureSizeInBytes), "signature.Length");
            }

            if (publicKey.Length != PublicKeySizeInBytes)
            {
                throw new ArgumentException(string.Format("Public key size must be {0}", PublicKeySizeInBytes), "publicKey.Length");
            }

            return(Ed25519Operations.crypto_sign_verify(signature, 0, message, 0, message.Length, publicKey, 0));
        }
コード例 #2
0
        /// <summary>
        /// Verify Ed25519 signature
        /// </summary>
        /// <param name="signature">Signature bytes</param>
        /// <param name="message">Message</param>
        /// <param name="publicKey">Public key</param>
        /// <returns>True if signature is valid, false if it's not</returns>
        public static bool Verify(byte[] signature, byte[] message, byte[] publicKey)
        {
            Contract.Requires <ArgumentNullException>(signature != null && message != null && publicKey != null);
            Contract.Requires <ArgumentException>(signature.Length == SignatureSize && publicKey.Length == PublicKeySize);

            return(Ed25519Operations.crypto_sign_verify(signature, 0, message, 0, message.Length, publicKey, 0));
        }
コード例 #3
0
ファイル: Ed25519.cs プロジェクト: trackforce/nats.net
        /// <summary>
        /// Verify Ed25519 signature
        /// </summary>
        /// <param name="signature">Signature bytes</param>
        /// <param name="message">Message</param>
        /// <param name="publicKey">Public key</param>
        /// <returns>True if signature is valid, false if it's not</returns>
        public static bool Verify(ArraySegment <byte> signature, ArraySegment <byte> message, ArraySegment <byte> publicKey)
        {
            // Contract.Requires<ArgumentException>(signature.Count == SignatureSize && publicKey.Count == PublicKeySize);
            if (signature.Count != SignatureSize || publicKey.Count != PublicKeySize)
            {
                throw new ArgumentException();
            }

            return(Ed25519Operations.crypto_sign_verify(signature.Array, signature.Offset, message.Array, message.Offset, message.Count, publicKey.Array, publicKey.Offset));
        }
コード例 #4
0
 public static bool Verify(ArraySegment <byte> signature, ArraySegment <byte> message, ArraySegment <byte> publicKey)
 {
     if (signature.Count != SignatureSizeInBytes)
     {
         throw new ArgumentException(string.Format("Signature size must be {0}", SignatureSizeInBytes), "signature.Count");
     }
     if (publicKey.Count != PublicKeySizeInBytes)
     {
         throw new ArgumentException(string.Format("Public key size must be {0}", PublicKeySizeInBytes), "publicKey.Count");
     }
     return(Ed25519Operations.crypto_sign_verify(signature.Array, signature.Offset, message.Array, message.Offset, message.Count, publicKey.Array, publicKey.Offset));
 }
コード例 #5
0
 public static bool Verify(ReadOnlySpan <byte> signature, ReadOnlySpan <byte> message, ReadOnlySpan <byte> publicKey)
 {
     if (signature.Length != SignatureSizeInBytes)
     {
         throw new ArgumentException($"Signature size must be {SignatureSizeInBytes}", nameof(signature));
     }
     if (publicKey.Length != PublicKeySizeInBytes)
     {
         throw new ArgumentException($"Public key size must be {PublicKeySizeInBytes}", nameof(signature));
     }
     return(Ed25519Operations.crypto_sign_verify(signature, message, publicKey));
 }
コード例 #6
0
ファイル: Ed25519.cs プロジェクト: trackforce/nats.net
        /// <summary>
        /// Verify Ed25519 signature
        /// </summary>
        /// <param name="signature">Signature bytes</param>
        /// <param name="message">Message</param>
        /// <param name="publicKey">Public key</param>
        /// <returns>True if signature is valid, false if it's not</returns>
        public static bool Verify(byte[] signature, byte[] message, byte[] publicKey)
        {
            // Contract.Requires<ArgumentNullException>(signature != null && message != null && publicKey != null);
            if (signature == null || message == null || publicKey == null)
            {
                throw new ArgumentException();
            }
            // Contract.Requires<ArgumentException>(signature.Length == SignatureSize && publicKey.Length == PublicKeySize);
            if (signature.Length != SignatureSize || publicKey.Length != PublicKeySize)
            {
                throw new ArgumentException();
            }

            return(Ed25519Operations.crypto_sign_verify(signature, 0, message, 0, message.Length, publicKey, 0));
        }
コード例 #7
0
 /// <summary>
 /// Verify Ed25519 signature
 /// </summary>
 /// <param name="signature">Signature bytes</param>
 /// <param name="message">Message</param>
 /// <param name="publicKey">Public key</param>
 /// <returns>True if signature is valid, false if it's not</returns>
 public static bool Verify(byte[] signature, byte[] message, byte[] publicKey)
 {
     return(Ed25519Operations.crypto_sign_verify(signature, 0, message, 0, message.Length, publicKey, 0));
 }
コード例 #8
0
 /// <summary>
 /// Verify Ed25519 signature
 /// </summary>
 /// <param name="signature">Signature bytes</param>
 /// <param name="message">Message</param>
 /// <param name="publicKey">Public key</param>
 /// <returns>True if signature is valid, false if it's not</returns>
 public static bool Verify(ArraySegment <byte> signature, ArraySegment <byte> message, ArraySegment <byte> publicKey)
 {
     return(Ed25519Operations.crypto_sign_verify(signature.Array, signature.Offset, message.Array, message.Offset, message.Count, publicKey.Array, publicKey.Offset));
 }