manifest.h revision 9bea9a09b4088cfc317600e7d63c41bd6abc63d6
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync/** @file
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * IPRT - Manifest file handling.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync */
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync/*
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * available from http://www.virtualbox.org. This file is free software;
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * General Public License (GPL) as published by the Free Software
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * The contents of this file may alternatively be used under the terms
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * of the Common Development and Distribution License Version 1.0
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * VirtualBox OSE distribution, in which case the provisions of the
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * CDDL are applicable instead of those of the GPL.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * You may elect to license modified versions of this file under the
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * terms and conditions of either the GPL or the CDDL or both.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * additional information or have any questions.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync */
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync#ifndef ___iprt_manifest_h
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync#define ___iprt_manifest_h
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync#include <iprt/cdefs.h>
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync#include <iprt/types.h>
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsyncRT_C_DECLS_BEGIN
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync/** @group grp_rt_manifest RTManifest - Manifest file creation and checking.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @ingroup grp_rt
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @{
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync */
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync/**
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * Input structure for RTManifestVerify which contains the filename & the SHA1
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * digest.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync */
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsynctypedef struct RTMANIFESTTEST
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync{
731832c43e76dea65af377cb59ad45e5bc251655vboxsync char *pszTestFile; /** The filename */
731832c43e76dea65af377cb59ad45e5bc251655vboxsync char *pszTestDigest; /** The SHA1 digest of the file */
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync} RTMANIFESTTEST;
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync/** Pointer to the input structure. */
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsynctypedef RTMANIFESTTEST* PRTMANIFESTTEST;
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync/**
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * Verify the given SHA1 digests to the entries in the manifest file.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * Please note that not only the various digest have to much, but the filenames
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * as well. If there are more or even less files listed in the manifest file
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * than provided by pTestList, VERR_MANIFEST_FILE_MISMATCH will be returned.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @returns VBox status code.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param pszManifestFile Filename of the manifest file to verify.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param pTestList List of files & SHA1 sums.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param cTests Number of entries in pTestList
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param piFailed A index to pTestList in the
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * VERR_MANIFEST_DIGEST_MISMATCH error case
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * (optional).
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync */
731832c43e76dea65af377cb59ad45e5bc251655vboxsyncRTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST pTestList, size_t cTests, size_t *piFailed);
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
731832c43e76dea65af377cb59ad45e5bc251655vboxsync/**
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * This is analogous to function RTManifestVerify, but calculates the SHA1 sums
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * of the given files itself.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @returns VBox status code.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param pszManifestFile Filename of the manifest file to verify.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param ppszFiles List of files to check SHA1 sums.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param cFiles Number of entries in ppszFiles.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param piFailed A index to ppszFiles in the
731832c43e76dea65af377cb59ad45e5bc251655vboxsync * VERR_MANIFEST_DIGEST_MISMATCH error case
731832c43e76dea65af377cb59ad45e5bc251655vboxsync * (optional).
731832c43e76dea65af377cb59ad45e5bc251655vboxsync */
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsyncRTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *pcFailed);
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync/**
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * Creates a manifest file for a set of files. The manifest file contains SHA1
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * sums of every provided file and could be used to verify the data integrity
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * of them.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @returns VBox status code.
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync *
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync * @param pszManifestFile Filename of the manifest file to create.
731832c43e76dea65af377cb59ad45e5bc251655vboxsync * @param ppszFiles List of files to create SHA1 sums for.
731832c43e76dea65af377cb59ad45e5bc251655vboxsync * @param cFiles Number of entries in ppszFiles.
731832c43e76dea65af377cb59ad45e5bc251655vboxsync */
731832c43e76dea65af377cb59ad45e5bc251655vboxsyncRTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles);
731832c43e76dea65af377cb59ad45e5bc251655vboxsync
731832c43e76dea65af377cb59ad45e5bc251655vboxsync/** @} */
731832c43e76dea65af377cb59ad45e5bc251655vboxsync
731832c43e76dea65af377cb59ad45e5bc251655vboxsyncRT_C_DECLS_END
731832c43e76dea65af377cb59ad45e5bc251655vboxsync
731832c43e76dea65af377cb59ad45e5bc251655vboxsync#endif /* ___iprt_manifest_h */
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync
33b0e5fd502b10034575ffa7c8a30c6816222ce2vboxsync