Exemplo n.º 1
0
    public override void Encrypt(ReadOnlySpan <byte> source, Span <byte> destination)
    {
        if (source.Length < BlockSize)
        {
            throw new ArgumentException(string.Empty, nameof(source));
        }

        if (destination.Length < BlockSize)
        {
            throw new ArgumentException(string.Empty, nameof(destination));
        }

        //Aes.IsSupported && Avx.IsSupported && Avx2.IsSupported
        SM4Utils.Encrypt8(Rk, source, destination);
    }
Exemplo n.º 2
0
        public override void Encrypt4(ReadOnlySpan <byte> source, Span <byte> destination)
        {
            if (Aes.IsSupported && Sse2.IsSupported && Ssse3.IsSupported)
            {
                if (source.Length < BlockSize << 2)
                {
                    throw new ArgumentException(string.Empty, nameof(source));
                }

                if (destination.Length < BlockSize << 2)
                {
                    throw new ArgumentException(string.Empty, nameof(destination));
                }

                SM4Utils.Encrypt4(_rk, source, destination);
                return;
            }

            base.Encrypt4(source, destination);
        }