|
Packit |
aea12f |
/*
|
|
Packit |
aea12f |
* Copyright (C) 2018 Hugo Beauzée-Luyssen
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* Author: Hugo Beauzée-Luyssen
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* This file is part of GnuTLS.
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* GnuTLS is free software; you can redistribute it and/or modify it
|
|
Packit |
aea12f |
* under the terms of the GNU General Public License as published by
|
|
Packit |
aea12f |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
aea12f |
* (at your option) any later version.
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit |
aea12f |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
aea12f |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
aea12f |
* General Public License for more details.
|
|
Packit |
aea12f |
*
|
|
Packit |
aea12f |
* You should have received a copy of the GNU General Public License
|
|
Packit |
aea12f |
* along with GnuTLS; if not, write to the Free Software Foundation,
|
|
Packit |
aea12f |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
Packit |
aea12f |
*/
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
/*
|
|
Packit |
aea12f |
* This test verifies the assumptions about CertOpenStore and
|
|
Packit |
aea12f |
* CertOpenSystemStore to be equivalent when passed some specific flags
|
|
Packit |
aea12f |
*/
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
#ifdef HAVE_CONFIG_H
|
|
Packit |
aea12f |
#include <config.h>
|
|
Packit |
aea12f |
#endif
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
#ifndef _WIN32
|
|
Packit |
aea12f |
#error "This test shouldn't have been included"
|
|
Packit |
aea12f |
#endif
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
#include <windows.h>
|
|
Packit |
aea12f |
#include <wincrypt.h>
|
|
Packit |
aea12f |
#include <assert.h>
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
void doit(void)
|
|
Packit |
aea12f |
{
|
|
Packit |
aea12f |
HCERTSTORE hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER , L"ROOT");
|
|
Packit |
aea12f |
assert(hStore != NULL);
|
|
Packit |
aea12f |
HCERTSTORE hSystemStore = CertOpenSystemStore(0, "ROOT");
|
|
Packit |
aea12f |
assert(hSystemStore != NULL);
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
PCCERT_CONTEXT prevCtx = NULL;
|
|
Packit |
aea12f |
PCCERT_CONTEXT ctx = NULL;
|
|
Packit |
aea12f |
PCCERT_CONTEXT sysPrevCtx = NULL;
|
|
Packit |
aea12f |
PCCERT_CONTEXT sysCtx = NULL;
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
while (1)
|
|
Packit |
aea12f |
{
|
|
Packit |
aea12f |
ctx = CertEnumCertificatesInStore(hStore, prevCtx);
|
|
Packit |
aea12f |
sysCtx = CertEnumCertificatesInStore(hSystemStore, sysPrevCtx);
|
|
Packit |
aea12f |
if (ctx == NULL || sysCtx == NULL)
|
|
Packit |
aea12f |
break;
|
|
Packit |
aea12f |
if (CertCompareIntegerBlob(&ctx->pCertInfo->SerialNumber,
|
|
Packit |
aea12f |
&sysCtx->pCertInfo->SerialNumber) != TRUE)
|
|
Packit |
aea12f |
assert(0);
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
prevCtx = ctx;
|
|
Packit |
aea12f |
sysPrevCtx = sysCtx;
|
|
Packit |
aea12f |
}
|
|
Packit |
aea12f |
assert(ctx == NULL && sysCtx == NULL);
|
|
Packit |
aea12f |
|
|
Packit |
aea12f |
CertCloseStore(hStore, 0);
|
|
Packit |
aea12f |
CertCloseStore(hSystemStore, 0);
|
|
Packit |
aea12f |
}
|
|
Packit |
aea12f |
|