xref: /haiku/src/apps/drivesetup/EncryptionUtils.cpp (revision fc8ec821164223c6707e69654cadaee5b897de01)
1 /*
2  * Copyright 2014, Dancsó Róbert <dancso.robert@d-rendszer.hu>
3  *
4  * Distributed under terms of the MIT license.
5  */
6 
7 
8 #include "EncryptionUtils.h"
9 
10 #include <Catalog.h>
11 #include <File.h>
12 #include <Locale.h>
13 #include <String.h>
14 
15 
16 #define B_TRANSLATION_CONTEXT "Encryption utils"
17 
18 
19 const char*
EncryptionType(const char * path)20 EncryptionType(const char* path)
21 {
22 	char buffer[11];
23 	BString encrypter;
24 	off_t length = BFile(path, B_READ_ONLY).Read(&buffer, 11);
25 	if (length != 11)
26 		return NULL;
27 	encrypter.Append(buffer, 11);
28 
29 	if (encrypter.FindFirst("-FVE-FS-") >= 0) {
30 		return B_TRANSLATE("BitLocker encrypted");
31 	} else if (encrypter.FindFirst("PGPGUARD") >= 0) {
32 		return B_TRANSLATE("PGP encrypted");
33 	} else if (encrypter.FindFirst("SafeBoot") >= 0) {
34 		return B_TRANSLATE("SafeBoot encrypted");
35 	} else if (encrypter.FindFirst("LUKS") >= 0) {
36 		return B_TRANSLATE("LUKS encrypted");
37 	}
38 
39 	return NULL;
40 }
41 
42 
43