예제 #1
0
        // Token: 0x06000189 RID: 393 RVA: 0x00005230 File Offset: 0x00003430
        public void Decrypt(ReadOnlySpan <byte> source, Span <byte> target, ReadOnlySpan <byte> nonce)
        {
            if (nonce.Length != Interop.SodiumNonceSize)
            {
                throw new ArgumentException(string.Format("Invalid nonce size. Nonce needs to have a length of {0} bytes.", Interop.SodiumNonceSize), "nonce");
            }
            if (target.Length != source.Length - Interop.SodiumMacSize)
            {
                throw new ArgumentException(string.Format("Invalid target buffer size. Target buffer needs to have a length that is input buffer decreased by Sodium MAC size ({0} bytes).", Interop.SodiumMacSize), "target");
            }
            int num;

            if ((num = Interop.Decrypt(source, target, this.Key.Span, nonce)) != 0)
            {
                throw new CryptographicException(string.Format("Could not decrypt the buffer. Sodium returned code {0}.", num));
            }
        }
예제 #2
0
        public void Decrypt(ReadOnlySpan <byte> source, Span <byte> target, ReadOnlySpan <byte> nonce)
        {
            if (nonce.Length != Interop.SodiumNonceSize)
            {
                throw new ArgumentException($"Invalid nonce size. Nonce needs to have a length of {Interop.SodiumNonceSize} bytes.", nameof(nonce));
            }

            if (target.Length != source.Length - Interop.SodiumMacSize)
            {
                throw new ArgumentException($"Invalid target buffer size. Target buffer needs to have a length that is input buffer decreased by Sodium MAC size ({Interop.SodiumMacSize} bytes).", nameof(target));
            }

            int result;

            if ((result = Interop.Decrypt(source, target, this.Key.Span, nonce)) != 0)
            {
                throw new CryptographicException($"Could not decrypt the buffer. Sodium returned code {result}.");
            }
        }