file_cmds-321.40.3.tar.gz
[apple/file_cmds.git] / mtree / commoncrypto.h
1
2 #ifndef _COMMON_CRYPTO_H_
3 #define _COMMON_CRYPTO_H_
4
5 #include <CommonCrypto/CommonDigestSPI.h>
6
7 #define kNone "none"
8
9 extern const int kSHA256NullTerminatedBuffLen;
10
11 #define MD5File(f, b) Digest_File(kCCDigestMD5, f, b)
12 #define SHA1_File(f, b) Digest_File(kCCDigestSHA1, f, b)
13 #define RIPEMD160_File(f, b) Digest_File(kCCDigestRMD160, f, b)
14 #define SHA256_File(f, b) Digest_File(kCCDigestSHA256, f, b)
15
16 typedef struct {
17 char *digest;
18 uint64_t xdstream_priv_id;
19 } xattr_info;
20
21 struct attrbuf {
22 uint32_t info_length;
23 uint64_t sibling_id;
24 } __attribute__((aligned, packed));
25
26 typedef struct attrbuf attrbuf_t;
27
28 char *Digest_File(CCDigestAlg algorithm, const char *filename, char *buf);
29
30 xattr_info *calculate_SHA256_XATTRs(char *path, char *buf);
31 xattr_info *SHA256_Path_XATTRs(char *path, char *buf);
32 xattr_info *get_xdstream_privateid(char *path, char *buf);
33 char *SHA256_Path_ACL(char *path, char *buf);
34 uint64_t get_sibling_id(const char *path);
35
36 #endif /* _COMMON_CRYPTO_H_ */