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;
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 }
160 }
static global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM GetHashAlgorithmId(HashAlgorithmName? name)
static global::Interop.BCrypt.ECC_CURVE_TYPE_ENUM ConvertToCurveTypeEnum(ECCurve.ECCurveType value)