Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion ctypes_generation/definitions/defines/wintrust_crypt_def.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,38 @@
#define CRYPT_ARCHIVABLE 0x00004000
#define CRYPT_FORCE_KEY_PROTECTION_HIGH 0x00008000

#define CERT_RDN_ANY_TYPE 0
#define CERT_RDN_ENCODED_BLOB 1
#define CERT_RDN_OCTET_STRING 2
#define CERT_RDN_NUMERIC_STRING 3
#define CERT_RDN_PRINTABLE_STRING 4
#define CERT_RDN_TELETEX_STRING 5
#define CERT_RDN_T61_STRING 5
#define CERT_RDN_VIDEOTEX_STRING 6
#define CERT_RDN_IA5_STRING 7
#define CERT_RDN_GRAPHIC_STRING 8
#define CERT_RDN_VISIBLE_STRING 9
#define CERT_RDN_ISO646_STRING 9
#define CERT_RDN_GENERAL_STRING 10
#define CERT_RDN_UNIVERSAL_STRING 11
#define CERT_RDN_INT4_STRING 11
#define CERT_RDN_BMP_STRING 12
#define CERT_RDN_UNICODE_STRING 12
#define CERT_RDN_UTF8_STRING 13
#define CERT_RDN_TYPE_MASK 0xff
#define CERT_RDN_FLAGS_MASK 0xff000000
#define CERT_RDN_ENABLE_T61_UNICODE_FLAG 0x80000000
#define CERT_RDN_ENABLE_UTF8_UNICODE_FLAG 0x20000000
#define CERT_RDN_FORCE_UTF8_UNICODE_FLAG 0x10000000
#define CERT_RDN_DISABLE_CHECK_TYPE_FLAG 0x40000000
#define CERT_RDN_DISABLE_IE4_UTF8_FLAG 0x1000000

#define CRYPT_DECODE_NOCOPY_FLAG 0x1
#define CRYPT_DECODE_TO_BE_SIGNED_FLAG 0x2
#define CRYPT_DECODE_SHARE_OID_STRING_FLAG 0x4
#define CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG 0x8
#define CRYPT_DECODE_ALLOC_FLAG 0x8000
#define CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG CERT_RDN_DISABLE_IE4_UTF8_FLAG

#define CRYPT_ENCODE_DECODE_NONE 0
#define X509_CERT (1)
Expand Down Expand Up @@ -582,4 +614,23 @@
#define CMSG_CTRL_MAIL_LIST_DECRYPT 18
#define CMSG_CTRL_VERIFY_SIGNATURE_EX 19
#define CMSG_CTRL_ADD_CMS_SIGNER_INFO 20
#define CMSG_CTRL_ENABLE_STRONG_SIGNATURE 21
#define CMSG_CTRL_ENABLE_STRONG_SIGNATURE 21


//+-------------------------------------------------------------------------
// The following flag should be set in the above dwFlags to enable
// a CertSetCertificateContextProperty(CERT_KEY_CONTEXT_PROP_ID) after a
// CryptAcquireContext is done in the Sign or Decrypt Message functions.
//
// The following define must not collide with any of the
// CryptAcquireContext dwFlag defines.
//--------------------------------------------------------------------------
#define CERT_SET_KEY_PROV_HANDLE_PROP_ID 0x00000001
#define CERT_SET_KEY_CONTEXT_PROP_ID 0x00000001

// Special dwKeySpec indicating a CNG NCRYPT_KEY_HANDLE instead of a CAPI1
// HCRYPTPROV
#define CERT_NCRYPT_KEY_SPEC 0xFFFFFFFF


#define CERT_REQUEST_V1 0
24 changes: 24 additions & 0 deletions ctypes_generation/definitions/functions/crypto_wintrust.txt
Original file line number Diff line number Diff line change
Expand Up @@ -617,4 +617,28 @@ BOOL CryptGetOIDFunctionValue(
BOOL CertCloseStore(
HCERTSTORE hCertStore,
DWORD dwFlags
);

BOOL CryptSignAndEncodeCertificate(
[in] BCRYPT_KEY_HANDLE hBCryptKey,
[in] DWORD dwKeySpec,
[in] DWORD dwCertEncodingType,
[in] LPCSTR lpszStructType,
[in] PVOID pvStructInfo,
[in] PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
[in] PVOID pvHashAuxInfo,
[out] BYTE *pbEncoded,
[in, out] DWORD *pcbEncoded
);

BOOL CryptSignCertificate(
[in] BCRYPT_KEY_HANDLE hBCryptKey,
[in] DWORD dwKeySpec,
[in] DWORD dwCertEncodingType,
[in] BYTE *pbEncodedToBeSigned,
[in] DWORD cbEncodedToBeSigned,
[in] PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
[in] PVOID pvHashAuxInfo,
[out] BYTE *pbSignature,
[in, out] DWORD *pcbSignature
);
14 changes: 14 additions & 0 deletions ctypes_generation/definitions/functions/ncrypt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SECURITY_STATUS NCryptOpenKey(
[in] NCRYPT_PROV_HANDLE hProvider,
[out] NCRYPT_KEY_HANDLE *phKey,
[in] LPCWSTR pszKeyName,
[in] DWORD dwLegacyKeySpec,
[in] DWORD dwFlags
);


SECURITY_STATUS NCryptOpenStorageProvider(
[out] NCRYPT_PROV_HANDLE *phProvider,
[in, optional] LPCWSTR pszProviderName,
[in] DWORD dwFlags
);
2 changes: 2 additions & 0 deletions ctypes_generation/definitions/simple_types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ PWINDBG_EXTENSION_APIS32 = PVOID
PWINDBG_EXTENSION_APIS64 = PVOID
FILEOP_FLAGS = WORD
NET_API_STATUS = DWORD
SECURITY_STATUS = LONG // Return type of ncrypt functions


// 2 custom PFW defintions for bitness-forces structures
Expand All @@ -94,6 +95,7 @@ PVOID64 = DWORD64

NCRYPT_HANDLE = ULONG_PTR
NCRYPT_PROV_HANDLE = ULONG_PTR
BCRYPT_KEY_HANDLE = ULONG_PTR
NCRYPT_KEY_HANDLE = ULONG_PTR
NCRYPT_HASH_HANDLE = ULONG_PTR
NCRYPT_SECRET_HANDLE = ULONG_PTR
Expand Down
10 changes: 9 additions & 1 deletion ctypes_generation/definitions/structures/crypto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -715,4 +715,12 @@ typedef struct _STRUCT_PLAINTEXTKEYBLOB {
BLOBHEADER hdr;
DWORD dwKeySize;
BYTE rgbKeyData[0];
} STRUCT_PLAINTEXTKEYBLOB, *PSTRUCT_PLAINTEXTKEYBLOB;
} STRUCT_PLAINTEXTKEYBLOB, *PSTRUCT_PLAINTEXTKEYBLOB;

typedef struct _CERT_REQUEST_INFO {
DWORD dwVersion;
CERT_NAME_BLOB Subject;
CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo;
DWORD cAttribute;
PCRYPT_ATTRIBUTE rgAttribute;
} CERT_REQUEST_INFO, *PCERT_REQUEST_INFO;
16 changes: 11 additions & 5 deletions docs/build/html/_modules/windows/com.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>windows.com &#8212; PythonForWindows 1.0.2 documentation</title>
<title>windows.com &#8212; PythonForWindows 1.0.3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/classic.css?v=def86cc0" />
<link rel="stylesheet" type="text/css" href="../../_static/css/mbasic.css?v=957880af" />

<script src="../../_static/documentation_options.js?v=1ed6394b"></script>
<script src="../../_static/documentation_options.js?v=baaebd52"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>

Expand All @@ -25,7 +25,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">PythonForWindows 1.0.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="../../index.html">PythonForWindows 1.0.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">windows.com</a></li>
</ul>
Expand Down Expand Up @@ -75,7 +75,13 @@ <h1>Source code for windows.com</h1><div class="highlight"><pre>


<span class="k">def</span> <span class="nf">initsecurity</span><span class="p">():</span> <span class="c1"># Should take some parameters..</span>
<span class="k">return</span> <span class="n">winproxy</span><span class="o">.</span><span class="n">CoInitializeSecurity</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">RPC_C_IMP_LEVEL_IMPERSONATE</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">winproxy</span><span class="o">.</span><span class="n">CoInitializeSecurity</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">RPC_C_IMP_LEVEL_IMPERSONATE</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">winerror</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span> <span class="o">!=</span> <span class="n">gdef</span><span class="o">.</span><span class="n">RPC_E_TOO_LATE</span><span class="p">:</span>
<span class="c1"># RPC_E_TOO_LATE can happen when the python environment invokes CoInitializeSecurity before we get to it</span>
<span class="c1"># mspython builds do this consistently.</span>
<span class="k">raise</span> <span class="n">e</span>


<span class="k">class</span> <span class="nc">Dispatch</span><span class="p">(</span><span class="n">interfaces</span><span class="o">.</span><span class="n">IDispatch</span><span class="p">):</span>
Expand Down Expand Up @@ -489,7 +495,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">PythonForWindows 1.0.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="../../index.html">PythonForWindows 1.0.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">windows.com</a></li>
</ul>
Expand Down
19 changes: 15 additions & 4 deletions docs/build/html/_modules/windows/crypto/certificate.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>windows.crypto.certificate &#8212; PythonForWindows 1.0.2 documentation</title>
<title>windows.crypto.certificate &#8212; PythonForWindows 1.0.3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../../_static/classic.css?v=def86cc0" />
<link rel="stylesheet" type="text/css" href="../../../_static/css/mbasic.css?v=957880af" />

<script src="../../../_static/documentation_options.js?v=1ed6394b"></script>
<script src="../../../_static/documentation_options.js?v=baaebd52"></script>
<script src="../../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>

Expand All @@ -25,7 +25,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">PythonForWindows 1.0.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">PythonForWindows 1.0.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">windows.crypto.certificate</a></li>
</ul>
Expand Down Expand Up @@ -205,6 +205,17 @@ <h1>Source code for windows.crypto.certificate</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="bp">cls</span><span class="p">)</span></div>


<div class="viewcode-block" id="CertificateStore.from_user_store">
<a class="viewcode-back" href="../../../crypto.html#windows.crypto.CertificateStore.from_user_store">[docs]</a>
<span class="nd">@classmethod</span>
<span class="k">def</span> <span class="nf">from_user_store</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">store_name</span><span class="p">,</span> <span class="n">user</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Create a new :class:`CertificateStore` from system store ``store_name``</span>
<span class="sd"> (see `System Store Locations &lt;https://msdn.microsoft.com/en-us/library/windows/desktop/aa388136(v=vs.85).aspx&gt;`_)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">winproxy</span><span class="o">.</span><span class="n">CertOpenStore</span><span class="p">(</span><span class="n">gdef</span><span class="o">.</span><span class="n">CERT_STORE_PROV_SYSTEM_A</span><span class="p">,</span> <span class="n">DEFAULT_ENCODING</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">gdef</span><span class="o">.</span><span class="n">CERT_SYSTEM_STORE_CURRENT_USER</span> <span class="o">|</span> <span class="n">gdef</span><span class="o">.</span><span class="n">CERT_STORE_READONLY_FLAG</span><span class="p">,</span> <span class="n">store_name</span><span class="p">)</span>
<span class="k">return</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="bp">cls</span><span class="p">)</span></div>


<div class="viewcode-block" id="CertificateStore.new_in_memory">
<a class="viewcode-back" href="../../../crypto.html#windows.crypto.CertificateStore.new_in_memory">[docs]</a>
<span class="nd">@classmethod</span>
Expand Down Expand Up @@ -697,7 +708,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">PythonForWindows 1.0.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">PythonForWindows 1.0.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">windows.crypto.certificate</a></li>
</ul>
Expand Down
24 changes: 9 additions & 15 deletions docs/build/html/_modules/windows/debug/breakpoints.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>windows.debug.breakpoints &#8212; PythonForWindows 1.0.2 documentation</title>
<title>windows.debug.breakpoints &#8212; PythonForWindows 1.0.3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../../_static/classic.css?v=def86cc0" />
<link rel="stylesheet" type="text/css" href="../../../_static/css/mbasic.css?v=957880af" />

<script src="../../../_static/documentation_options.js?v=1ed6394b"></script>
<script src="../../../_static/documentation_options.js?v=baaebd52"></script>
<script src="../../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>

Expand All @@ -25,7 +25,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">PythonForWindows 1.0.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">PythonForWindows 1.0.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">windows.debug.breakpoints</a></li>
</ul>
Expand Down Expand Up @@ -190,17 +190,11 @@ <h1>Source code for windows.debug.breakpoints</h1><div class="highlight"><pre>
<span class="n">t</span> <span class="o">=</span> <span class="n">rt</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">cproc</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">t</span> <span class="o">=</span> <span class="n">rt</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>

<span class="n">content</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">content</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">contents</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="c1"># contents will fail on basic type</span>
<span class="c1"># Not really an expected behavior</span>
<span class="c1"># But it works for now.. (and since a while)</span>
<span class="k">pass</span>
<span class="k">if</span> <span class="n">content</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">t</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">value</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="s2">&quot;contents&quot;</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">t</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">value</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
<span class="k">pass</span>
<span class="n">res</span><span class="p">[</span><span class="n">name</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">t</span>
<span class="k">return</span> <span class="n">res</span>

Expand Down Expand Up @@ -365,7 +359,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">PythonForWindows 1.0.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="../../../index.html">PythonForWindows 1.0.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">windows.debug.breakpoints</a></li>
</ul>
Expand Down
Loading