Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 79e7de8

Browse files
committed
Merge remote-tracking branch 'upstream/master' into from-tfs
Conflicts: src/System.Private.DataContractSerialization/src/project.lock.json
2 parents 0d59118 + eb32fdd commit 79e7de8

File tree

283 files changed

+42782
-27349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+42782
-27349
lines changed

dir.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<!-- Build Tools Versions -->
1212
<PropertyGroup>
13-
<BuildToolsVersion>1.0.25-prerelease-00051</BuildToolsVersion>
13+
<BuildToolsVersion>1.0.25-prerelease-00053</BuildToolsVersion>
1414
<DnxVersion Condition="'$(OsEnvironment)'!='Unix'">1.0.0-beta5-11682</DnxVersion>
1515
<DnxVersion Condition="'$(OsEnvironment)'=='Unix'">1.0.0-beta5-11760</DnxVersion>
1616
<DnxPackageName Condition="'$(DnxPackageName)' == '' and '$(OsEnvironment)'!='Unix'">dnx-coreclr-win-x86.$(DnxVersion)</DnxPackageName>

src/.nuget/packages.Unix.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.DotNet.BuildTools" version="1.0.25-prerelease-00051" />
3+
<package id="Microsoft.DotNet.BuildTools" version="1.0.25-prerelease-00053" />
44
<package id="Microsoft.DotNet.BuildTools.ApiTools" version="1.0.0-prerelease" />
55
<package id="dnx-mono" version="1.0.0-beta5-11760" />
66
<package id="Microsoft.Net.ToolsetCompilers" version="1.0.0-rc3-20150510-01" />

src/.nuget/packages.Windows_NT.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.DotNet.BuildTools" version="1.0.25-prerelease-00051" />
3+
<package id="Microsoft.DotNet.BuildTools" version="1.0.25-prerelease-00053" />
44
<package id="dnx-coreclr-win-x86" version="1.0.0-beta5-11682" />
55
<package id="Microsoft.DotNet.BuildTools.ApiTools" version="1.0.0-prerelease" />
66
</packages>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
internal static partial class Interop
5+
{
6+
internal static partial class libc
7+
{
8+
internal enum FcntlCommands
9+
{
10+
F_LINUX_SPECIFIC_BASE = 1024,
11+
F_SETPIPE_SZ = F_LINUX_SPECIFIC_BASE + 7,
12+
F_GETPIPE_SZ = F_LINUX_SPECIFIC_BASE + 8
13+
}
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Runtime.InteropServices;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class libc
10+
{
11+
// fcntl takes a variable number of arguments, which is difficult to represent in C#.
12+
// Instead, since we only have a small and fixed number of call sites, we declare
13+
// an overload for each of the specific argument sets we need.
14+
15+
[DllImport(Libraries.Libc)]
16+
internal static extern unsafe int fcntl(int fd, FcntlCommands cmd);
17+
18+
[DllImport(Libraries.Libc)]
19+
internal static extern unsafe int fcntl(int fd, FcntlCommands cmd, int arg1);
20+
}
21+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Runtime.InteropServices;
6+
7+
using Microsoft.Win32.SafeHandles;
8+
9+
internal static partial class Interop
10+
{
11+
internal static partial class libcrypto
12+
{
13+
[DllImport(Libraries.LibCrypto)]
14+
internal static extern void BN_clear_free(IntPtr a);
15+
16+
[DllImport(Libraries.LibCrypto)]
17+
private static extern IntPtr BN_bin2bn(byte[] s, int len, IntPtr zero);
18+
19+
[DllImport(Libraries.LibCrypto)]
20+
private static extern unsafe int BN_bn2bin(SafeBignumHandle a, byte* to);
21+
22+
[DllImport(Libraries.LibCrypto)]
23+
private static extern int BN_num_bits(SafeBignumHandle a);
24+
25+
/// <summary>
26+
/// Returns the number of bytes needed to export a BIGNUM.
27+
/// </summary>
28+
/// <remarks>This is a macro in bn.h, expanded here.</remarks>
29+
private static int BN_num_bytes(SafeBignumHandle a)
30+
{
31+
return (BN_num_bits(a) + 7) / 8;
32+
}
33+
34+
internal static IntPtr CreateBignumPtr(byte[] bigEndianValue)
35+
{
36+
if (bigEndianValue == null)
37+
{
38+
return IntPtr.Zero;
39+
}
40+
41+
IntPtr handle = BN_bin2bn(bigEndianValue, bigEndianValue.Length, IntPtr.Zero);
42+
return handle;
43+
}
44+
45+
internal static SafeBignumHandle CreateBignum(byte[] bigEndianValue)
46+
{
47+
IntPtr handle = CreateBignumPtr(bigEndianValue);
48+
return new SafeBignumHandle(handle, true);
49+
}
50+
51+
private static byte[] ExtractBignum(IntPtr bignum, int targetSize)
52+
{
53+
// Given that the only reference held to bignum is an IntPtr, create an unowned SafeHandle
54+
// to ensure that we don't destroy the key after extraction.
55+
using (SafeBignumHandle handle = new SafeBignumHandle(bignum, ownsHandle: false))
56+
{
57+
return ExtractBignum(handle, targetSize);
58+
}
59+
}
60+
61+
private static unsafe byte[] ExtractBignum(SafeBignumHandle bignum, int targetSize)
62+
{
63+
if (bignum == null || bignum.IsInvalid)
64+
{
65+
return null;
66+
}
67+
68+
int compactSize = BN_num_bytes(bignum);
69+
70+
if (targetSize < compactSize)
71+
{
72+
targetSize = compactSize;
73+
}
74+
75+
// OpenSSL BIGNUM values do not record leading zeroes.
76+
// Windows Crypt32 does.
77+
//
78+
// Since RSACryptoServiceProvider already checks that RSAParameters.DP.Length is
79+
// exactly half of RSAParameters.Modulus.Length, we need to left-pad (big-endian)
80+
// the array with zeroes.
81+
int offset = targetSize - compactSize;
82+
83+
byte[] buf = new byte[targetSize];
84+
85+
fixed (byte* to = buf)
86+
{
87+
byte* start = to + offset;
88+
BN_bn2bin(bignum, start);
89+
}
90+
91+
return buf;
92+
}
93+
}
94+
}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Runtime.InteropServices;
6+
7+
using Microsoft.Win32.SafeHandles;
8+
9+
internal static partial class Interop
10+
{
11+
internal static partial class libcrypto
12+
{
13+
// This was computed by sizeof(EVP_CIPHER_CTX) on a 64-bit Ubuntu
14+
// machine running OpenSSL 1.0.1f. If we end up making a native
15+
// interop boundary library for OpenSSL then a very good candidate
16+
// method would be EVP_CIPHER_CTX_new, so the size can be computed
17+
// to match the platform.
18+
internal const int EVP_CIPHER_CTX_SIZE = 168;
19+
20+
[DllImport(Libraries.LibCrypto)]
21+
internal static extern void EVP_CIPHER_CTX_init(SafeEvpCipherCtxHandle ctx);
22+
23+
[DllImport(Libraries.LibCrypto)]
24+
[return: MarshalAs(UnmanagedType.Bool)]
25+
internal static extern bool EVP_CipherInit_ex(
26+
SafeEvpCipherCtxHandle ctx,
27+
IntPtr cipher,
28+
IntPtr engineNull,
29+
byte[] key,
30+
byte[] iv,
31+
int enc);
32+
33+
[DllImport(Libraries.LibCrypto)]
34+
[return: MarshalAs(UnmanagedType.Bool)]
35+
internal static extern bool EVP_CIPHER_CTX_set_padding(SafeEvpCipherCtxHandle x, int padding);
36+
37+
[DllImport(Libraries.LibCrypto)]
38+
[return: MarshalAs(UnmanagedType.Bool)]
39+
internal static unsafe extern bool EVP_CipherUpdate(
40+
SafeEvpCipherCtxHandle ctx,
41+
byte* @out,
42+
out int outl,
43+
byte* @in,
44+
int inl);
45+
46+
[DllImport(Libraries.LibCrypto)]
47+
[return: MarshalAs(UnmanagedType.Bool)]
48+
internal static extern unsafe bool EVP_CipherFinal_ex(
49+
SafeEvpCipherCtxHandle ctx,
50+
byte* outm,
51+
out int outl);
52+
53+
[DllImport(Libraries.LibCrypto)]
54+
[return: MarshalAs(UnmanagedType.Bool)]
55+
internal static extern bool EVP_CIPHER_CTX_cleanup(IntPtr ctx);
56+
57+
[DllImport(Libraries.LibCrypto)]
58+
internal static extern IntPtr EVP_aes_128_ecb();
59+
60+
[DllImport(Libraries.LibCrypto)]
61+
internal static extern IntPtr EVP_aes_128_cbc();
62+
63+
//[DllImport(Libraries.LibCrypto)]
64+
//internal static extern IntPtr EVP_aes_128_cfb1();
65+
66+
//[DllImport(Libraries.LibCrypto)]
67+
//internal static extern IntPtr EVP_aes_128_cfb8();
68+
69+
//[DllImport(Libraries.LibCrypto)]
70+
//internal static extern IntPtr EVP_aes_128_cfb128();
71+
72+
//[DllImport(Libraries.LibCrypto)]
73+
//internal static extern IntPtr EVP_aes_128_ofb();
74+
75+
//[DllImport(Libraries.LibCrypto)]
76+
//internal static extern IntPtr EVP_aes_128_ctr();
77+
78+
//[DllImport(Libraries.LibCrypto)]
79+
//internal static extern IntPtr EVP_aes_128_ccm();
80+
81+
//[DllImport(Libraries.LibCrypto)]
82+
//internal static extern IntPtr EVP_aes_128_gcm();
83+
84+
//[DllImport(Libraries.LibCrypto)]
85+
//internal static extern IntPtr EVP_aes_128_xts();
86+
87+
//[DllImport(Libraries.LibCrypto)]
88+
//internal static extern IntPtr EVP_aes_128_wrap();
89+
90+
//[DllImport(Libraries.LibCrypto)]
91+
//internal static extern IntPtr EVP_aes_128_wrap_pad();
92+
93+
//[DllImport(Libraries.LibCrypto)]
94+
//internal static extern IntPtr EVP_aes_128_ocb();
95+
96+
[DllImport(Libraries.LibCrypto)]
97+
internal static extern IntPtr EVP_aes_192_ecb();
98+
99+
[DllImport(Libraries.LibCrypto)]
100+
internal static extern IntPtr EVP_aes_192_cbc();
101+
102+
//[DllImport(Libraries.LibCrypto)]
103+
//internal static extern IntPtr EVP_aes_192_cfb1();
104+
105+
//[DllImport(Libraries.LibCrypto)]
106+
//internal static extern IntPtr EVP_aes_192_cfb8();
107+
108+
//[DllImport(Libraries.LibCrypto)]
109+
//internal static extern IntPtr EVP_aes_192_cfb128();
110+
111+
//[DllImport(Libraries.LibCrypto)]
112+
//internal static extern IntPtr EVP_aes_192_ofb();
113+
114+
//[DllImport(Libraries.LibCrypto)]
115+
//internal static extern IntPtr EVP_aes_192_ctr();
116+
117+
//[DllImport(Libraries.LibCrypto)]
118+
//internal static extern IntPtr EVP_aes_192_ccm();
119+
120+
//[DllImport(Libraries.LibCrypto)]
121+
//internal static extern IntPtr EVP_aes_192_gcm();
122+
123+
//[DllImport(Libraries.LibCrypto)]
124+
//internal static extern IntPtr EVP_aes_192_wrap();
125+
126+
//[DllImport(Libraries.LibCrypto)]
127+
//internal static extern IntPtr EVP_aes_192_wrap_pad();
128+
129+
//[DllImport(Libraries.LibCrypto)]
130+
//internal static extern IntPtr EVP_aes_192_ocb();
131+
132+
[DllImport(Libraries.LibCrypto)]
133+
internal static extern IntPtr EVP_aes_256_ecb();
134+
135+
[DllImport(Libraries.LibCrypto)]
136+
internal static extern IntPtr EVP_aes_256_cbc();
137+
138+
//[DllImport(Libraries.LibCrypto)]
139+
//internal static extern IntPtr EVP_aes_256_cfb1();
140+
141+
//[DllImport(Libraries.LibCrypto)]
142+
//internal static extern IntPtr EVP_aes_256_cfb8();
143+
144+
//[DllImport(Libraries.LibCrypto)]
145+
//internal static extern IntPtr EVP_aes_256_cfb128();
146+
147+
//[DllImport(Libraries.LibCrypto)]
148+
//internal static extern IntPtr EVP_aes_256_ofb();
149+
150+
//[DllImport(Libraries.LibCrypto)]
151+
//internal static extern IntPtr EVP_aes_256_ctr();
152+
153+
//[DllImport(Libraries.LibCrypto)]
154+
//internal static extern IntPtr EVP_aes_256_ccm();
155+
156+
//[DllImport(Libraries.LibCrypto)]
157+
//internal static extern IntPtr EVP_aes_256_gcm();
158+
159+
//[DllImport(Libraries.LibCrypto)]
160+
//internal static extern IntPtr EVP_aes_256_xts();
161+
162+
//[DllImport(Libraries.LibCrypto)]
163+
//internal static extern IntPtr EVP_aes_256_wrap();
164+
165+
//[DllImport(Libraries.LibCrypto)]
166+
//internal static extern IntPtr EVP_aes_256_wrap_pad();
167+
168+
//[DllImport(Libraries.LibCrypto)]
169+
//internal static extern IntPtr EVP_aes_256_ocb();
170+
}
171+
}

0 commit comments

Comments
 (0)