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