70 references to CryptoUtil
Microsoft.AspNetCore.Cryptography.Internal (12)
Cng\BCRYPT_KEY_LENGTHS_STRUCT.cs (1)
27
CryptoUtil
.Assert(keyLengthInBits % 8 == 0, "keyLengthInBits % 8 == 0");
SafeHandles\BCryptAlgorithmHandle.cs (9)
34
CryptoUtil
.AssertSafeHandleIsValid(retVal);
57
CryptoUtil
.AssertSafeHandleIsValid(retVal);
72
CryptoUtil
.Assert(byteLengthOfNameWithTerminatingNull % sizeof(char) == 0 && byteLengthOfNameWithTerminatingNull > sizeof(char) && byteLengthOfNameWithTerminatingNull <= StackAllocCharSize * sizeof(char), "byteLengthOfNameWithTerminatingNull % sizeof(char) == 0 && byteLengthOfNameWithTerminatingNull > sizeof(char) && byteLengthOfNameWithTerminatingNull <= StackAllocCharSize * sizeof(char)");
82
CryptoUtil
.Assert(numBytesCopied == byteLengthOfNameWithTerminatingNull, "numBytesCopied == byteLengthOfNameWithTerminatingNull");
93
CryptoUtil
.Assert(numBytesCopied == sizeof(uint), "numBytesCopied == sizeof(uint)");
104
CryptoUtil
.Assert(numBytesCopied == sizeof(uint), "numBytesCopied == sizeof(uint)");
115
CryptoUtil
.Assert(numBytesCopied == sizeof(BCRYPT_KEY_LENGTHS_STRUCT), "numBytesCopied == sizeof(BCRYPT_KEY_LENGTHS_STRUCT)");
126
CryptoUtil
.Assert(numBytesCopied == sizeof(uint), "numBytesCopied == sizeof(uint)");
148
CryptoUtil
.AssertSafeHandleIsValid(algHandle);
SafeHandles\BCryptHashHandle.cs (1)
23
CryptoUtil
.AssertSafeHandleIsValid(duplicateHandle);
SafeHandles\NCryptDescriptorHandle.cs (1)
28
CryptoUtil
.AssertSafeHandleIsValid(ruleStringHandle);
Microsoft.AspNetCore.Cryptography.Internal.Tests (4)
CryptoUtilTests.cs (4)
19
Assert.True(
CryptoUtil
.TimeConstantBuffersAreEqual(a.AsSpan(1, 3), b.AsSpan(2, 3)));
29
Assert.False(
CryptoUtil
.TimeConstantBuffersAreEqual(a.AsSpan(1, 3), b.AsSpan(2, 3)));
40
Assert.True(
CryptoUtil
.TimeConstantBuffersAreEqual((byte*)&a, (byte*)&b, sizeof(uint)));
51
Assert.False(
CryptoUtil
.TimeConstantBuffersAreEqual((byte*)&a, (byte*)&b, sizeof(uint)));
Microsoft.AspNetCore.Cryptography.KeyDerivation (6)
PBKDF2\ManagedPbkdf2Provider.cs (1)
83
throw
CryptoUtil
.Fail("Unrecognized PRF.");
PBKDF2\Win7Pbkdf2Provider.cs (1)
95
throw
CryptoUtil
.Fail("Unrecognized PRF.");
PBKDF2\Win8Pbkdf2Provider.cs (4)
125
throw
CryptoUtil
.Fail("Unrecognized PRF.");
136
CryptoUtil
.Assert(cbPasswordDigest > 0, "cbPasswordDigest > 0");
192
CryptoUtil
.Assert(numBytesDerived == cbDerivedBytes, "numBytesDerived == cbDerivedBytes");
207
throw
CryptoUtil
.Fail("Unrecognized PRF.");
Microsoft.AspNetCore.DataProtection (48)
ActivatorExtensions.cs (1)
28
??
CryptoUtil
.Fail<T>("CreateInstance returned null.");
AuthenticatedEncryption\AuthenticatedEncryptorExtensions.cs (1)
51
CryptoUtil
.Assert(roundTrippedData != null && roundTrippedData.Length == plaintextAsBytes.Length && plaintextAsGuid == new Guid(roundTrippedData),
AuthenticatedEncryption\CngGcmAuthenticatedEncryptorFactory.cs (1)
97
CryptoUtil
.Assert(algorithmHandle.GetCipherBlockLength() == 128 / 8, "GCM requires a block cipher algorithm with a 128-bit block size.");
Cng\CbcAuthenticatedEncryptor.cs (5)
243
CryptoUtil
.Assert(dwEncryptedBytes == cbOutput, "dwEncryptedBytes == cbOutput");
347
CryptoUtil
.Assert(dwActualCiphertextSize == dwCiphertextSize, "dwActualCiphertextSize == dwCiphertextSize");
400
CryptoUtil
.Assert(resultSpan.Length == outputSize, "writtenSpan length should equal calculated outputSize");
493
return
CryptoUtil
.TimeConstantBuffersAreEqual(pbExpectedDigest, pbActualDigest, _hmacAlgorithmDigestLengthInBytes);
573
CryptoUtil
.Assert(ptr - pbRetVal == retVal.Length, "ptr - pbRetVal == retVal.Length");
Cng\CngGcmAuthenticatedEncryptor.cs (5)
49
CryptoUtil
.Assert(symmetricAlgorithmHandle.GetCipherBlockLength() == 128 / 8, "GCM requires a block cipher algorithm with a 128-bit block size.");
127
CryptoUtil
.Assert(cbDecryptedBytesWritten == plaintextLength, "cbDecryptedBytesWritten == plaintextLength");
214
CryptoUtil
.Assert(cbResult == cbPlaintextData, "cbResult == cbPlaintextData");
319
CryptoUtil
.Assert(resultSpan.Length == outputSize, "writtenSpan length should equal calculated outputSize");
406
CryptoUtil
.Assert(ptr - pbRetVal == retVal.Length, "ptr - pbRetVal == retVal.Length");
Cng\DpapiSecretSerializerHelper.cs (3)
162
CryptoUtil
.AssertSafeHandleIsValid(protectedData);
289
CryptoUtil
.AssertSafeHandleIsValid(unencryptedPayloadHandle);
350
CryptoUtil
.AssertSafeHandleIsValid(descriptorHandle);
DataProtectionBuilderExtensions.cs (2)
331
CryptoUtil
.AssertPlatformIsWindows();
385
CryptoUtil
.AssertPlatformIsWindows8OrLater();
KeyManagement\KeyRingBasedDataProtector.cs (3)
107
CryptoUtil
.Assert(defaultEncryptorInstance != null, "defaultEncryptorInstance != null");
124
CryptoUtil
.Assert(retVal != null && retVal.Length >= sizeof(uint) + sizeof(Guid), "retVal != null && retVal.Length >= sizeof(uint) + sizeof(Guid)");
293
??
CryptoUtil
.Fail<byte[]>("IAuthenticatedEncryptor.Decrypt returned null.");
KeyManagement\KeyRingBasedSpanDataProtector.cs (1)
36
CryptoUtil
.Assert(defaultEncryptor != null, "DefaultAuthenticatedEncryptor != null");
KeyManagement\KeyRingProvider.cs (1)
126
CryptoUtil
.Assert(defaultKey != null, "Expected to see a default key.");
KeyManagement\XmlKeyManager.cs (2)
518
??
CryptoUtil
.Fail<IAuthenticatedEncryptorDescriptor>("CreateNewDescriptor returned null.");
585
return descriptorInstance ??
CryptoUtil
.Fail<IAuthenticatedEncryptorDescriptor>("ImportFromXml returned null.");
Managed\AesGcmAuthenticatedEncryptor.cs (2)
62
throw
CryptoUtil
.Fail("Unexpected AES key size in bytes only support 16, 24, 32."); // should never happen
203
CryptoUtil
.Assert(refPooledBuffer.WrittenSpan.Length == outputSize, "writtenSpan length should equal calculated outputSize");
Managed\HashAlgorithmExtensions.cs (1)
14
CryptoUtil
.Assert(hashSizeInBits >= 0 && hashSizeInBits % 8 == 0, "hashSizeInBits >= 0 && hashSizeInBits % 8 == 0");
Managed\ManagedAuthenticatedEncryptor.cs (7)
300
CryptoUtil
.Assert(refPooledBuffer.WrittenSpan.Length == outputSize, "bytesWritten == size");
424
return
CryptoUtil
.TimeConstantBuffersAreEqual(correctHash, providedMac);
642
CryptoUtil
.Assert(ciphertext != null && ciphertext.Length == _symmetricAlgorithmBlockSizeInBytes, "ciphertext != null && ciphertext.Length == _symmetricAlgorithmBlockSizeInBytes");
653
CryptoUtil
.Assert(digest != null && digest.Length == _validationAlgorithmDigestLengthInBytes, "digest != null && digest.Length == _validationAlgorithmDigestLengthInBytes");
658
CryptoUtil
.Assert(idx == retVal.Length, "idx == retVal.Length");
667
CryptoUtil
.Assert(retVal != null, "retVal != null");
678
CryptoUtil
.Assert(retVal != null, "retVal != null");
Managed\SymmetricAlgorithmExtensions.cs (1)
14
CryptoUtil
.Assert(blockSizeInBits >= 0 && blockSizeInBits % 8 == 0, "blockSizeInBits >= 0 && blockSizeInBits % 8 == 0");
RegistryPolicyResolver.cs (1)
96
throw
CryptoUtil
.Fail("Unrecognized EncryptionType: " + encryptionType);
Secret.cs (1)
147
CryptoUtil
.Assert(numTotalBytesToAllocate % CRYPTPROTECTMEMORY_BLOCK_SIZE == 0, "numTotalBytesToAllocate % CRYPTPROTECTMEMORY_BLOCK_SIZE == 0");
SP800_108\ManagedSP800_108_CTR_HMACSHA512.cs (1)
111
CryptoUtil
.Assert(prfOutputSizeInBytes == prfOutput.Length, "prfOutputSizeInBytes == prfOutput.Length");
SP800_108\Win8SP800_108_CTR_HMACSHA512Provider.cs (1)
65
CryptoUtil
.Assert(numBytesDerived == cbDerivedKey, "numBytesDerived == cbDerivedKey");
XmlEncryption\CertificateXmlEncryptor.cs (1)
126
??
CryptoUtil
.Fail<X509Certificate2>("Cert factory returned null.");
XmlEncryption\DpapiNGXmlDecryptor.cs (1)
37
CryptoUtil
.AssertPlatformIsWindows8OrLater();
XmlEncryption\DpapiNGXmlEncryptor.cs (3)
39
CryptoUtil
.AssertPlatformIsWindows8OrLater();
43
CryptoUtil
.AssertSafeHandleIsValid(_protectionDescriptorHandle);
100
CryptoUtil
.AssertPlatformIsWindows8OrLater();
XmlEncryption\DpapiXmlDecryptor.cs (1)
34
CryptoUtil
.AssertPlatformIsWindows();
XmlEncryption\DpapiXmlEncryptor.cs (1)
35
CryptoUtil
.AssertPlatformIsWindows();
XmlEncryption\XmlEncryptionExtensions.cs (1)
133
CryptoUtil
.Assert(encryptedXmlInfo != null, "IXmlEncryptor.Encrypt returned null.");