1 | /** @file
|
---|
2 | * IPRT - Manifest file handling.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2009 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_manifest_h
|
---|
27 | #define ___iprt_manifest_h
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 |
|
---|
32 | RT_C_DECLS_BEGIN
|
---|
33 |
|
---|
34 | /** @defgroup grp_rt_manifest RTManifest - Manifest file creation and checking
|
---|
35 | * @ingroup grp_rt
|
---|
36 | * @{
|
---|
37 | */
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Input structure for RTManifestVerify() which contains the filename & the
|
---|
41 | * SHA1 digest.
|
---|
42 | */
|
---|
43 | typedef struct RTMANIFESTTEST
|
---|
44 | {
|
---|
45 | /** The filename. */
|
---|
46 | char *pszTestFile;
|
---|
47 | /** The SHA1 digest of the file. */
|
---|
48 | char *pszTestDigest;
|
---|
49 | } RTMANIFESTTEST;
|
---|
50 | /** Pointer to the input structure. */
|
---|
51 | typedef RTMANIFESTTEST* PRTMANIFESTTEST;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Verify the given SHA1 digests against the entries in the manifest file.
|
---|
55 | *
|
---|
56 | * Please note that not only the various digest have to match, but the
|
---|
57 | * filenames as well. If there are more or even less files listed in the
|
---|
58 | * manifest file than provided by paTests, VERR_MANIFEST_FILE_MISMATCH will be
|
---|
59 | * returned.
|
---|
60 | *
|
---|
61 | * @returns iprt status code.
|
---|
62 | *
|
---|
63 | * @param pszManifestFile Filename of the manifest file to verify.
|
---|
64 | * @param paTests Array of files & SHA1 sums.
|
---|
65 | * @param cTests Number of entries in paTests.
|
---|
66 | * @param piFailed A index to paTests in the
|
---|
67 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
68 | * (optional).
|
---|
69 | */
|
---|
70 | RTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * This is analogous to function RTManifestVerify(), but calculates the SHA1
|
---|
74 | * sums of the given files itself.
|
---|
75 | *
|
---|
76 | * @returns iprt status code.
|
---|
77 | *
|
---|
78 | * @param pszManifestFile Filename of the manifest file to verify.
|
---|
79 | * @param papszFiles Array of files to check SHA1 sums.
|
---|
80 | * @param cFiles Number of entries in papszFiles.
|
---|
81 | * @param piFailed A index to papszFiles in the
|
---|
82 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
83 | * (optional).
|
---|
84 | */
|
---|
85 | RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed);
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * Creates a manifest file for a set of files. The manifest file contains SHA1
|
---|
89 | * sums of every provided file and could be used to verify the data integrity
|
---|
90 | * of them.
|
---|
91 | *
|
---|
92 | * @returns iprt status code.
|
---|
93 | *
|
---|
94 | * @param pszManifestFile Filename of the manifest file to create.
|
---|
95 | * @param papszFiles Array of files to create SHA1 sums for.
|
---|
96 | * @param cFiles Number of entries in papszFiles.
|
---|
97 | */
|
---|
98 | RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles);
|
---|
99 |
|
---|
100 | /** @} */
|
---|
101 |
|
---|
102 | RT_C_DECLS_END
|
---|
103 |
|
---|
104 | #endif /* ___iprt_manifest_h */
|
---|
105 |
|
---|