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

◆ GenerateKey()

override void System.Security.Cryptography.ECDsaCng.GenerateKey ( ECCurve curve)
inlinevirtual

Reimplemented from System.Security.Cryptography.ECDsa.

Definition at line 190 of file ECDsaCng.cs.

191 {
192 curve.Validate();
194 if (curve.IsNamed)
195 {
196 if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
197 {
198 throw new PlatformNotSupportedException(System.SR.Format(System.SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
199 }
200 CngAlgorithm cngAlgorithm = CngKey.EcdsaCurveNameToAlgorithm(curve.Oid.FriendlyName);
201 if (CngKey.IsECNamedCurve(cngAlgorithm.Algorithm))
202 {
203 CngKey orGenerateKey = _core.GetOrGenerateKey(curve);
204 ForceSetKeySize(orGenerateKey.KeySize);
205 return;
206 }
207 int num = 0;
208 if (cngAlgorithm == CngAlgorithm.ECDsaP256)
209 {
210 num = 256;
211 }
212 else if (cngAlgorithm == CngAlgorithm.ECDsaP384)
213 {
214 num = 384;
215 }
216 else
217 {
218 if (!(cngAlgorithm == CngAlgorithm.ECDsaP521))
219 {
221 }
222 num = 521;
223 }
224 _core.GetOrGenerateKey(num, cngAlgorithm);
225 ForceSetKeySize(num);
226 }
227 else
228 {
229 if (!curve.IsExplicit)
230 {
231 throw new PlatformNotSupportedException(System.SR.Format(System.SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
232 }
233 CngKey orGenerateKey2 = _core.GetOrGenerateKey(curve);
234 ForceSetKeySize(orGenerateKey2.KeySize);
235 }
236 }
static string Cryptography_CurveNotSupported
Definition SR.cs:64
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Cryptography_InvalidCurveOid
Definition SR.cs:66
static string Cryptography_InvalidKeySize
Definition SR.cs:92
Definition SR.cs:7
void ForceSetKeySize(int newKeySize)
Definition ECDsaCng.cs:441
CngKey GetOrGenerateKey(int keySize, CngAlgorithm algorithm)

References System.Security.Cryptography.ECDsaCng._core, System.Security.Cryptography.CngAlgorithm.Algorithm, System.SR.Cryptography_CurveNotSupported, System.SR.Cryptography_InvalidCurveOid, System.SR.Cryptography_InvalidKeySize, System.Security.Cryptography.ECCurve.CurveType, Internal.Cryptography.CngAlgorithmCore.DisposeKey(), System.Security.Cryptography.CngKey.EcdsaCurveNameToAlgorithm(), System.Security.Cryptography.CngAlgorithm.ECDsaP256, System.Security.Cryptography.CngAlgorithm.ECDsaP384, System.Security.Cryptography.CngAlgorithm.ECDsaP521, System.Security.Cryptography.ECDsaCng.ForceSetKeySize(), System.SR.Format(), System.Security.Cryptography.Oid.FriendlyName, Internal.Cryptography.CngAlgorithmCore.GetOrGenerateKey(), System.Security.Cryptography.CngKey.IsECNamedCurve(), System.Security.Cryptography.ECCurve.IsExplicit, System.Security.Cryptography.ECCurve.IsNamed, System.Security.Cryptography.CngKey.KeySize, System.Security.Cryptography.ECCurve.Oid, System.Security.Cryptography.ECCurve.Validate(), and System.Security.Cryptography.Oid.Value.

Referenced by System.Security.Cryptography.ECDsaCng.ECDsaCng().