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

◆ DeriveKeyMaterial() [1/2]

byte[] System.Security.Cryptography.ECDiffieHellmanCng.DeriveKeyMaterial ( CngKey otherPartyPublicKey)
inline

Definition at line 261 of file ECDiffieHellmanCng.cs.

262 {
263 if (otherPartyPublicKey == null)
264 {
265 throw new ArgumentNullException("otherPartyPublicKey");
266 }
267 if (otherPartyPublicKey.AlgorithmGroup != CngAlgorithmGroup.ECDiffieHellman)
268 {
269 throw new ArgumentException(System.SR.Cryptography_ArgECDHRequiresECDHKey, "otherPartyPublicKey");
270 }
271 if (otherPartyPublicKey.KeySize != KeySize)
272 {
273 throw new ArgumentException(System.SR.Cryptography_ArgECDHKeySizeMismatch, "otherPartyPublicKey");
274 }
275 global::Interop.NCrypt.SecretAgreementFlags flags = (UseSecretAgreementAsHmacKey ? global::Interop.NCrypt.SecretAgreementFlags.UseSecretAsHmacKey : global::Interop.NCrypt.SecretAgreementFlags.None);
276 using SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey);
277 switch (KeyDerivationFunction)
278 {
279 case ECDiffieHellmanKeyDerivationFunction.Hash:
280 return global::Interop.NCrypt.DeriveKeyMaterialHash(secretAgreement, HashAlgorithm.Algorithm, _secretPrepend, _secretAppend, flags);
281 case ECDiffieHellmanKeyDerivationFunction.Hmac:
282 return global::Interop.NCrypt.DeriveKeyMaterialHmac(secretAgreement, HashAlgorithm.Algorithm, _hmacKey, _secretPrepend, _secretAppend, flags);
283 default:
284 if (_label == null || _seed == null)
285 {
287 }
288 return global::Interop.NCrypt.DeriveKeyMaterialTls(secretAgreement, _label, _seed, flags);
289 }
290 }
static string Cryptography_TlsRequiresLabelAndSeed
Definition SR.cs:32
static string Cryptography_ArgECDHRequiresECDHKey
Definition SR.cs:42
static string Cryptography_ArgECDHKeySizeMismatch
Definition SR.cs:40
Definition SR.cs:7
SafeNCryptSecretHandle DeriveSecretAgreementHandle(ECDiffieHellmanPublicKey otherPartyPublicKey)
ECDiffieHellmanKeyDerivationFunction KeyDerivationFunction

References System.Security.Cryptography.ECDiffieHellmanCng._hmacKey, System.Security.Cryptography.ECDiffieHellmanCng._label, System.Security.Cryptography.ECDiffieHellmanCng._secretAppend, System.Security.Cryptography.ECDiffieHellmanCng._secretPrepend, System.Security.Cryptography.ECDiffieHellmanCng._seed, System.Security.Cryptography.CngKey.AlgorithmGroup, System.SR.Cryptography_ArgECDHKeySizeMismatch, System.SR.Cryptography_ArgECDHRequiresECDHKey, System.SR.Cryptography_TlsRequiresLabelAndSeed, System.Security.Cryptography.ECDiffieHellmanCng.DeriveSecretAgreementHandle(), System.Security.Cryptography.CngAlgorithmGroup.ECDiffieHellman, System.Security.Cryptography.ECDiffieHellmanCng.KeyDerivationFunction, System.Security.Cryptography.CngKey.KeySize, System.Security.Cryptography.ECDiffieHellmanCng.KeySize, and System.Security.Cryptography.ECDiffieHellmanCng.UseSecretAgreementAsHmacKey.