예제 #1
0
 public static TheoryData <KeyWrapTheoryData> RsaUnwrapMismatchTheoryData()
 {
     return(new TheoryData <KeyWrapTheoryData>
     {
         new KeyWrapTheoryData
         {
             ExpectedException = ExpectedException.KeyWrapException("IDX10659:"),
             TestId = "AlgorithmMismatchRsaPKCS1RsaOAEP",
             UnwrapAlgorithm = SecurityAlgorithms.RsaOAEP,
             UnwrapKey = KeyingMaterial.RsaSecurityKey_2048,
             WrapAlgorithm = SecurityAlgorithms.RsaPKCS1,
             WrapKey = KeyingMaterial.RsaSecurityKey_2048_Public
         },
         new KeyWrapTheoryData
         {
             ExpectedException = ExpectedException.KeyWrapException("IDX10659:"),
             TestId = "KeyMismatchRsa4096Rsa2048",
             UnwrapAlgorithm = SecurityAlgorithms.RsaOAEP,
             UnwrapKey = KeyingMaterial.RsaSecurityKey_2048,
             WrapAlgorithm = SecurityAlgorithms.RsaOAEP,
             WrapKey = KeyingMaterial.RsaSecurityKey_4096_Public,
         },
         new KeyWrapTheoryData
         {
             ExpectedException = ExpectedException.KeyWrapException("IDX10659:"),
             TestId = "AlgorithmAndKeyMismatchRsaPKCS1Bits4096RsaOAEKey2048",
             UnwrapAlgorithm = SecurityAlgorithms.RsaOAEP,
             UnwrapKey = KeyingMaterial.RsaSecurityKey_2048,
             WrapAlgorithm = SecurityAlgorithms.RsaPKCS1,
             WrapKey = KeyingMaterial.RsaSecurityKey_4096_Public,
         }
     });
 }
예제 #2
0
        private static void AddUnwrapTamperedTheoryData(string testId, SecurityKey key, string algorithm, TheoryData <KeyWrapTestParams> theoryData)
        {
            var keyToWrap  = Guid.NewGuid().ToByteArray();
            var provider   = CryptoProviderFactory.Default.CreateKeyWrapProvider(key, algorithm);
            var wrappedKey = provider.WrapKey(keyToWrap);

            TestUtilities.XORBytes(wrappedKey);
            theoryData.Add(new KeyWrapTestParams
            {
                EncryptAlgorithm = algorithm,
                EncryptKey       = key,
                EE         = ExpectedException.KeyWrapException("IDX10659:"),
                Provider   = provider,
                WrappedKey = wrappedKey
            });
        }
예제 #3
0
        private static void AddUnwrapTamperedTheoryData(
            string testId,
            SecurityKey encrtyptKey,
            SecurityKey decryptKey,
            string algorithm,
            TheoryData <RsaKeyWrapTestParams> theoryData)
        {
            var keyToWrap  = Guid.NewGuid().ToByteArray();
            var provider   = new RsaKeyWrapProvider(encrtyptKey, algorithm, false);
            var wrappedKey = provider.WrapKey(keyToWrap);

            TestUtilities.XORBytes(wrappedKey);
            theoryData.Add(new RsaKeyWrapTestParams
            {
                DecryptAlgorithm = algorithm,
                DecryptKey       = decryptKey,
                EE         = ExpectedException.KeyWrapException("IDX10659:"),
                Provider   = provider,
                WrappedKey = wrappedKey
            });
        }
예제 #4
0
        public static TheoryData <RsaKeyWrapTestParams> RsaUnwrapMismatchTheoryData()
        {
            var theoryData = new TheoryData <RsaKeyWrapTestParams>();

            theoryData.Add(new RsaKeyWrapTestParams
            {
                EncryptAlgorithm = SecurityAlgorithms.RsaPKCS1,
                EncryptKey       = KeyingMaterial.RsaSecurityKey_2048_Public,
                DecryptAlgorithm = SecurityAlgorithms.RsaOAEP,
                DecryptKey       = KeyingMaterial.RsaSecurityKey_2048,
                EE     = ExpectedException.KeyWrapException("IDX10659:"),
                TestId = "RSAUnwrapAlgorithmMismatch_RsaPKCS1_RsaOAEP"
            });

            theoryData.Add(new RsaKeyWrapTestParams
            {
                EncryptAlgorithm = SecurityAlgorithms.RsaOAEP,
                EncryptKey       = KeyingMaterial.RsaSecurityKey_4096_Public,
                DecryptAlgorithm = SecurityAlgorithms.RsaOAEP,
                DecryptKey       = KeyingMaterial.RsaSecurityKey_2048,
                EE     = ExpectedException.KeyWrapException("IDX10659:"),
                TestId = "RSAUnwrapKeyMismatch_RsaSecurityKey_4096_RsaSecurityKey_2048"
            });

            theoryData.Add(new RsaKeyWrapTestParams
            {
                EncryptAlgorithm = SecurityAlgorithms.RsaPKCS1,
                EncryptKey       = KeyingMaterial.RsaSecurityKey_4096_Public,
                DecryptAlgorithm = SecurityAlgorithms.RsaOAEP,
                DecryptKey       = KeyingMaterial.RsaSecurityKey_2048,
                EE     = ExpectedException.KeyWrapException("IDX10659:"),
                TestId = "RSAUnwrapAlgorithmAndKeyMismatch_RsaPKCS1_RsaOAEP_RsaSecurityKey_4096_RsaSecurityKey_2048"
            });

            return(theoryData);
        }
예제 #5
0
        private static TheoryData <KeyWrapTestParams> UnwrapMismatchTheoryData()
        {
            var theoryData = new TheoryData <KeyWrapTestParams>();

            AddUnwrapMismatchTheoryData("Test1", Default.SymmetricEncryptionKey128, Default.SymmetricEncryptionKey128_2, SecurityAlgorithms.Aes128KW, SecurityAlgorithms.Aes128KW, ExpectedException.KeyWrapException("IDX10659:"), theoryData);
            AddUnwrapMismatchTheoryData("Test2", Default.SymmetricEncryptionKey256, Default.SymmetricEncryptionKey256_2, SecurityAlgorithms.Aes256KW, SecurityAlgorithms.Aes256KW, ExpectedException.KeyWrapException("IDX10659:"), theoryData);
            AddUnwrapMismatchTheoryData("Test3", Default.SymmetricEncryptionKey128, Default.SymmetricEncryptionKey256, SecurityAlgorithms.Aes128KW, SecurityAlgorithms.Aes256KW, ExpectedException.KeyWrapException("IDX10659:"), theoryData);

            return(theoryData);
        }