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

◆ GetPrimeCurveBlob() [2/2]

static unsafe byte[] System.Security.Cryptography.ECCng.GetPrimeCurveBlob ( ref ECParameters parameters,
bool ecdh )
inlinestaticpackage

Definition at line 119 of file ECCng.cs.

120 {
121 bool flag = parameters.D != null;
122 ECCurve curve = parameters.Curve;
123 int num = sizeof(global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB) + curve.Prime.Length + curve.A.Length + curve.B.Length + curve.G.X.Length + curve.G.Y.Length + curve.Order.Length + curve.Cofactor.Length + ((curve.Seed != null) ? curve.Seed.Length : 0) + parameters.Q.X.Length + parameters.Q.Y.Length;
124 if (flag)
125 {
126 num += parameters.D.Length;
127 }
128 byte[] array = new byte[num];
129 fixed (byte* ptr = &array[0])
130 {
131 global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB* ptr2 = (global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB*)ptr;
132 ptr2->Version = 1;
133 ptr2->Magic = ((!flag) ? (ecdh ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_GENERIC_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC) : (ecdh ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_GENERIC_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC));
134 ptr2->cbCofactor = curve.Cofactor.Length;
135 ptr2->cbFieldLength = parameters.Q.X.Length;
136 ptr2->cbSeed = ((curve.Seed != null) ? curve.Seed.Length : 0);
137 ptr2->cbSubgroupOrder = curve.Order.Length;
138 ptr2->CurveGenerationAlgId = GetHashAlgorithmId(curve.Hash);
139 ptr2->CurveType = ConvertToCurveTypeEnum(curve.CurveType);
140 int offset = sizeof(global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB);
141 global::Interop.BCrypt.Emit(array, ref offset, curve.Prime);
142 global::Interop.BCrypt.Emit(array, ref offset, curve.A);
143 global::Interop.BCrypt.Emit(array, ref offset, curve.B);
144 global::Interop.BCrypt.Emit(array, ref offset, curve.G.X);
145 global::Interop.BCrypt.Emit(array, ref offset, curve.G.Y);
146 global::Interop.BCrypt.Emit(array, ref offset, curve.Order);
147 global::Interop.BCrypt.Emit(array, ref offset, curve.Cofactor);
148 if (curve.Seed != null)
149 {
150 global::Interop.BCrypt.Emit(array, ref offset, curve.Seed);
151 }
152 global::Interop.BCrypt.Emit(array, ref offset, parameters.Q.X);
153 global::Interop.BCrypt.Emit(array, ref offset, parameters.Q.Y);
154 if (flag)
155 {
156 global::Interop.BCrypt.Emit(array, ref offset, parameters.D);
157 }
158 }
159 return array;
160 }
static global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM GetHashAlgorithmId(HashAlgorithmName? name)
Definition ECCng.cs:9
static global::Interop.BCrypt.ECC_CURVE_TYPE_ENUM ConvertToCurveTypeEnum(ECCurve.ECCurveType value)
Definition ECCng.cs:297

References System.Security.Cryptography.ECCurve.A, System.array, System.Security.Cryptography.ECCurve.B, System.Security.Cryptography.ECCurve.Cofactor, System.Security.Cryptography.ECCng.ConvertToCurveTypeEnum(), System.Security.Cryptography.ECCurve.CurveType, System.Security.Cryptography.ECCurve.G, System.Security.Cryptography.ECCng.GetHashAlgorithmId(), System.Security.Cryptography.ECCurve.Hash, System.offset, System.Security.Cryptography.ECCurve.Order, System.Security.Cryptography.ECCurve.Prime, System.Security.Cryptography.ECCurve.Seed, System.Security.Cryptography.ECPoint.X, and System.Security.Cryptography.ECPoint.Y.