|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2015 Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Author: Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is free software; you can redistribute it and/or modify it
|
|
Packit Service |
4684c1 |
* under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
4684c1 |
* (at your option) any later version.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit Service |
4684c1 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
* General Public License for more details.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
4684c1 |
* along with GnuTLS; if not, write to the Free Software Foundation,
|
|
Packit Service |
4684c1 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Parts copied from GnuTLS example programs. */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
4684c1 |
#include <config.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#undef DECLSPEC_IMPORT
|
|
Packit Service |
4684c1 |
#define DECLSPEC_IMPORT
|
|
Packit Service |
4684c1 |
#include <windows.h>
|
|
Packit Service |
4684c1 |
#include <wincrypt.h>
|
|
Packit Service |
4684c1 |
#include <winbase.h>
|
|
Packit Service |
4684c1 |
#include <ncrypt.h>
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/x509.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/abstract.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/system-keys.h>
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <assert.h>
|
|
Packit Service |
4684c1 |
#include "ncrypt-int.h"
|
|
Packit Service |
4684c1 |
#include <utils.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define VALID_PTR (void*)0x0001
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* This is dummy crypt32 replacement with stub functions. It pretends
|
|
Packit Service |
4684c1 |
* to load the key store and find a single certificate in the store
|
|
Packit Service |
4684c1 |
* of which it will return some arbitrary but valid values in CertGetCertificateContextProperty.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
HCERTSTORE WINAPI CertOpenSystemStore(
|
|
Packit Service |
4684c1 |
HCRYPTPROV_LEGACY hprov, LPCSTR szSubsystemProtocol)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return VALID_PTR;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
HCERTSTORE WINAPI CertOpenStore(
|
|
Packit Service |
4684c1 |
LPCSTR lpszStoreProvider, DWORD dwEncodingType,
|
|
Packit Service |
4684c1 |
HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags,
|
|
Packit Service |
4684c1 |
const void *pvPara)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return VALID_PTR;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
assert_int_nequal(hCertStore, VALID_PTR);
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(
|
|
Packit Service |
4684c1 |
HCERTSTORE hCertStore, DWORD dwCertEncodingType,
|
|
Packit Service |
4684c1 |
DWORD dwFindFlags, DWORD dwFindType,
|
|
Packit Service |
4684c1 |
const void *pvFindPara, PCCERT_CONTEXT pPrevCertContext)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
//CRYPT_HASH_BLOB *blob = (void*)pvFindPara;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert_int_nequal(hCertStore, VALID_PTR);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert_int_nequal(dwCertEncodingType, X509_ASN_ENCODING);
|
|
Packit Service |
4684c1 |
assert_int_nequal(dwFindType, CERT_FIND_KEY_IDENTIFIER);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return VALID_PTR;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
|
|
Packit Service |
4684c1 |
DWORD dwPropId, void *pvData, DWORD *pcbData)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
if (dwPropId == CERT_FRIENDLY_NAME_PROP_ID) {
|
|
Packit Service |
4684c1 |
*pcbData = snprintf(pvData, *pcbData, "friendly");
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (dwPropId == CERT_KEY_IDENTIFIER_PROP_ID) {
|
|
Packit Service |
4684c1 |
*pcbData = snprintf(pvData, *pcbData, "\xff\xff\x01\xff");
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (dwPropId == CERT_NCRYPT_KEY_HANDLE_TRANSFER_PROP_ID) {
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (dwPropId == CERT_KEY_PROV_INFO_PROP_ID) {
|
|
Packit Service |
4684c1 |
if (pvData == NULL) {
|
|
Packit Service |
4684c1 |
*pcbData = sizeof(CRYPT_KEY_PROV_INFO);
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
assert(*pcbData >= sizeof(CRYPT_KEY_PROV_INFO));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
memset(pvData, 0, sizeof(CRYPT_KEY_PROV_INFO));
|
|
Packit Service |
4684c1 |
*pcbData = sizeof(CRYPT_KEY_PROV_INFO);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(0);
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
PCCRL_CONTEXT WINAPI CertEnumCRLsInStore(HCERTSTORE hCertStore, PCCRL_CONTEXT pPrevCrlContext)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return NULL;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
HCERTSTORE WINAPI PFXImportCertStore(CRYPT_DATA_BLOB *pPFX, LPCWSTR szPassword, DWORD dwFlags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return NULL;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore,
|
|
Packit Service |
4684c1 |
PCCERT_CONTEXT pPrevCertContext)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return NULL;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* These are for CAPI, and are placeholders */
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CryptGetProvParam(HCRYPTPROV hProv, DWORD dwParam,
|
|
Packit Service |
4684c1 |
BYTE *pbData, DWORD *pdwDataLen,
|
|
Packit Service |
4684c1 |
DWORD dwFlags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR szContainer,
|
|
Packit Service |
4684c1 |
LPCWSTR szProvider, DWORD dwProvType, DWORD dwFlags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CryptDecrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
|
|
Packit Service |
4684c1 |
DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CryptSignHash(
|
|
Packit Service |
4684c1 |
HCRYPTHASH hHash,
|
|
Packit Service |
4684c1 |
DWORD dwKeySpec,
|
|
Packit Service |
4684c1 |
LPCTSTR sDescription,
|
|
Packit Service |
4684c1 |
DWORD dwFlags,
|
|
Packit Service |
4684c1 |
BYTE *pbSignature,
|
|
Packit Service |
4684c1 |
DWORD *pdwSigLen)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam,
|
|
Packit Service |
4684c1 |
BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CryptSetHashParam(HCRYPTHASH hHash, DWORD dwParam,
|
|
Packit Service |
4684c1 |
const BYTE *pbData, DWORD dwFlags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
__declspec(dllexport)
|
|
Packit Service |
4684c1 |
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey,
|
|
Packit Service |
4684c1 |
DWORD dwFlags, HCRYPTHASH *phHash)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|