ReadOnlyCollection <SecurityKey> BuildCryptoList() { List <SecurityKey> cryptoList = new List <SecurityKey>(); for (int i = 0; i < this.statements.Count; ++i) { SamlSubjectStatement statement = this.statements[i] as SamlSubjectStatement; if (statement != null) { bool skipCrypto = false; SecurityKey crypto = null; if (statement.SamlSubject != null) { crypto = statement.SamlSubject.Crypto; } InMemorySymmetricSecurityKey inMemorySymmetricSecurityKey = crypto as InMemorySymmetricSecurityKey; if (inMemorySymmetricSecurityKey != null) { // Verify that you have not already added this to crypto list. for (int j = 0; j < cryptoList.Count; ++j) { if ((cryptoList[j] is InMemorySymmetricSecurityKey) && (cryptoList[j].KeySize == inMemorySymmetricSecurityKey.KeySize)) { byte[] key1 = ((InMemorySymmetricSecurityKey)cryptoList[j]).GetSymmetricKey(); byte[] key2 = inMemorySymmetricSecurityKey.GetSymmetricKey(); int k = 0; for (k = 0; k < key1.Length; ++k) { if (key1[k] != key2[k]) { break; } } skipCrypto = (k == key1.Length); } if (skipCrypto) { break; } } } if (!skipCrypto && (crypto != null)) { cryptoList.Add(crypto); } } } return(cryptoList.AsReadOnly()); }
private ReadOnlyCollection <SecurityKey> BuildCryptoList() { List <SecurityKey> list = new List <SecurityKey>(); for (int i = 0; i < this.statements.Count; i++) { SamlSubjectStatement statement = this.statements[i] as SamlSubjectStatement; if (statement != null) { bool flag = false; SecurityKey item = null; if (statement.SamlSubject != null) { item = statement.SamlSubject.Crypto; } InMemorySymmetricSecurityKey key2 = item as InMemorySymmetricSecurityKey; if (key2 != null) { for (int j = 0; j < list.Count; j++) { if ((list[j] is InMemorySymmetricSecurityKey) && (list[j].KeySize == key2.KeySize)) { byte[] symmetricKey = ((InMemorySymmetricSecurityKey)list[j]).GetSymmetricKey(); byte[] buffer2 = key2.GetSymmetricKey(); int index = 0; index = 0; while (index < symmetricKey.Length) { if (symmetricKey[index] != buffer2[index]) { break; } index++; } flag = index == symmetricKey.Length; } if (flag) { break; } } } if (!flag && (item != null)) { list.Add(item); } } } return(list.AsReadOnly()); }