Skip to content

[Linux/ARM32] System.Security.Cryptography.Algorithms.Tests fail #18880

@hseok-oh

Description

@hseok-oh

Environemnt: Linux / ARM32bit
CoreCLR: Release build
CoreFX: Release build, enable outerloop test

Starting:    System.Security.Cryptography.Algorithms.Tests
   System.Security.Cryptography.Encryption.Aes.Tests.AesContractTests.InvalidIVSizes(invalidIvSize: 536870928) [FAIL]
      Assert.Throws() Failure
      Expected: typeof(System.ArgumentException)
      Actual:   typeof(System.OutOfMemoryException): Exception of type 'System.OutOfMemoryException' was thrown.
      Stack Trace:
            at System.Object.MemberwiseClone()
            at Internal.Cryptography.Helpers.CloneByteArray(Byte[] src)
            at Internal.Cryptography.AesImplementation.CreateDecryptor(Byte[] rgbKey, Byte[] rgbIV)
            at System.Security.Cryptography.Encryption.Aes.Tests.AesContractTests.<>c__DisplayClass4_1.<InvalidIVSizes>b__1()
Finished:    System.Security.Cryptography.Algorithms.Tests

Related code

        [Theory]
        [InlineData(64)]        // smaller than default BlockSize
        [InlineData(129)]       // larger than default BlockSize
        [InlineData(536870928)] // number of bits overflows and wraps around to default BlockSize
        public static void InvalidIVSizes(int invalidIvSize)
        {  
            using (Aes aes = AesFactory.Create())
            {  
                aes.GenerateKey();
                byte[] key = aes.Key;
                byte[] iv;
                try
                {  
                    iv = new byte[invalidIvSize];
                }
                catch (OutOfMemoryException) // in case there isn't enough memory at test-time to allocate the large array
                {  
                    return;
                }
                Assert.Throws<ArgumentException>("rgbIV", () => aes.CreateEncryptor(key, iv));
                Assert.Throws<ArgumentException>("rgbIV", () => aes.CreateDecryptor(key, iv));
            }
        }

        public sealed override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
        {  
            return CreateTransform(rgbKey, rgbIV.CloneByteArray(), encrypting: false);
        }

        public static byte[] CloneByteArray(this byte[] src)
        {  
            if (src == null)
            {  
                return null;
            }
            return (byte[])(src.Clone());
        }
  • It throws argument exception (not out of memory exception) when I modify test code to not use Assert.Throws for CreateDecryptor.
  • Test passed when I modify test code to not call CreateEncryptor and test CreateDecryptor only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-arm32area-System.Securityin-prThere is an active PR which will close this issue when it is mergedos-linuxLinux OS (any supported distro)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions