Пример #1
0
        public static unsafe int RealEncrypt(ReadOnlySpan <byte> data, Span <byte> tag, Span <byte> outData, ICryptor cryptor)
        {
            fixed(byte *dataPtr = &data.GetPinnableReference(), tagPtr = &tag.GetPinnableReference(), outDataPtr = &outData.GetPinnableReference())
            {
                // Reserve for iv
                var outLen = cryptor.EncryptAuth((ulong)dataPtr, (uint)data.Length, (ulong)tagPtr, (uint)tag.Length, (ulong)outDataPtr, (uint)outData.Length);

                if (outLen < 0)
                {
                    throw new AeadOperationException(outLen);
                }
                return(outLen);
            }
        }