Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DeriveSecretAgreementHandle()

SafeNCryptSecretHandle System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanCng.DeriveSecretAgreementHandle ( ECDiffieHellmanPublicKey otherPartyPublicKey)
inlineprivate

Definition at line 115 of file ECDiffieHellmanImplementation.cs.

116 {
117 if (otherPartyPublicKey == null)
118 {
119 throw new ArgumentNullException("otherPartyPublicKey");
120 }
121 ECParameters parameters = otherPartyPublicKey.ExportParameters();
122 using ECDiffieHellmanCng eCDiffieHellmanCng = (ECDiffieHellmanCng)ECDiffieHellman.Create(parameters);
123 using SafeNCryptKeyHandle safeNCryptKeyHandle = eCDiffieHellmanCng.GetDuplicatedKeyHandle();
124 string propertyAsString = CngKeyLite.GetPropertyAsString(safeNCryptKeyHandle, "Algorithm Group", CngPropertyOptions.None);
125 if (propertyAsString != "ECDH")
126 {
127 throw new ArgumentException(System.SR.Cryptography_ArgECDHRequiresECDHKey, "otherPartyPublicKey");
128 }
129 if (CngKeyLite.GetKeyLength(safeNCryptKeyHandle) != KeySize)
130 {
131 throw new ArgumentException(System.SR.Cryptography_ArgECDHKeySizeMismatch, "otherPartyPublicKey");
132 }
133 using SafeNCryptKeyHandle privateKey = GetDuplicatedKeyHandle();
134 return global::Interop.NCrypt.DeriveSecretAgreement(privateKey, safeNCryptKeyHandle);
135 }
static string Cryptography_ArgECDHRequiresECDHKey
Definition SR.cs:42
static string Cryptography_ArgECDHKeySizeMismatch
Definition SR.cs:40
Definition SR.cs:7

References System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanCng.ECDiffieHellmanCng(), System.Security.Cryptography.ECDiffieHellman.Create(), System.SR.Cryptography_ArgECDHKeySizeMismatch, System.SR.Cryptography_ArgECDHRequiresECDHKey, System.Security.Cryptography.ECDiffieHellmanPublicKey.ExportParameters(), System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanCng.GetDuplicatedKeyHandle(), System.Security.Cryptography.CngKeyLite.GetKeyLength(), System.Security.Cryptography.CngKeyLite.GetPropertyAsString(), and System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanCng.KeySize.

Referenced by System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanCng.DeriveKeyFromHash(), System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanCng.DeriveKeyFromHmac(), and System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanCng.DeriveKeyTls().