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

◆ ExportPrimeCurveParameters() [2/2]

static unsafe void System.Security.Cryptography.ECCng.ExportPrimeCurveParameters ( ref ECParameters ecParams,
byte[] ecBlob,
bool includePrivateParameters )
inlinestaticpackage

Definition at line 186 of file ECCng.cs.

187 {
188 global::Interop.BCrypt.KeyBlobMagicNumber magic = (global::Interop.BCrypt.KeyBlobMagicNumber)BitConverter.ToInt32(ecBlob, 0);
189 CheckMagicValueOfKey(magic, includePrivateParameters);
190 if (ecBlob.Length < sizeof(global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB))
191 {
192 throw global::Interop.NCrypt.ErrorCode.E_FAIL.ToCryptographicException();
193 }
194 fixed (byte* ptr = &ecBlob[0])
195 {
196 global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB* ptr2 = (global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB*)ptr;
197 ECCurve curve = default(ECCurve);
198 curve.CurveType = ConvertToCurveTypeEnum(ptr2->CurveType);
199 curve.Hash = GetHashAlgorithmName(ptr2->CurveGenerationAlgId);
200 int offset = sizeof(global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB);
201 curve.Prime = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength);
202 curve.A = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength);
203 curve.B = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength);
204 curve.G = new ECPoint
205 {
206 X = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength),
207 Y = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength)
208 };
209 curve.Order = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbSubgroupOrder);
210 curve.Cofactor = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbCofactor);
211 curve.Seed = ((ptr2->cbSeed == 0) ? null : global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbSeed));
212 ecParams.Q = new ECPoint
213 {
214 X = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength),
215 Y = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength)
216 };
217 if (includePrivateParameters)
218 {
219 ecParams.D = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbSubgroupOrder);
220 }
221 ecParams.Curve = curve;
222 }
223 }
static ? HashAlgorithmName GetHashAlgorithmName(global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM hashId)
Definition ECCng.cs:23
static void CheckMagicValueOfKey(global::Interop.BCrypt.KeyBlobMagicNumber magic, bool includePrivateParameters)
Definition ECCng.cs:224
static global::Interop.BCrypt.ECC_CURVE_TYPE_ENUM ConvertToCurveTypeEnum(ECCurve.ECCurveType value)
Definition ECCng.cs:297

References System.Security.Cryptography.ECCng.CheckMagicValueOfKey(), System.Security.Cryptography.ECCng.ConvertToCurveTypeEnum(), System.Security.Cryptography.ECCng.GetHashAlgorithmName(), System.offset, System.BitConverter.ToInt32(), System.X, and System.Y.