|
| 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