Skip to content

Commit a0dc683

Browse files
committed
fixed c++ formatting
1 parent 032442e commit a0dc683

File tree

9 files changed

+120
-90
lines changed

9 files changed

+120
-90
lines changed

sample_apps/simple_app_java/native/cf_shims.cc

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,58 @@
44

55
// --- TRUST MANAGER FLAGS ---
66

7-
int cf_tm_auth_key_initialized(TrustManager* tm) {
8-
if (!tm) return 0;
7+
int cf_tm_auth_key_initialized(TrustManager *tm) {
8+
if (!tm)
9+
return 0;
910
// TODO: If there is a public getter like tm->auth_key_initialized() use it.
1011
// If not, try to infer from print_trust_data() or a status API.
1112
// Placeholder assumption:
1213
return tm->auth_key_initialized() ? 1 : 0;
1314
}
1415

15-
int cf_tm_primary_admissions_cert_valid(TrustManager* tm) {
16-
if (!tm) return 0;
16+
int cf_tm_primary_admissions_cert_valid(TrustManager *tm) {
17+
if (!tm)
18+
return 0;
1719
// TODO: Replace with actual public getter if different name exists.
1820
return tm->primary_admissions_cert_valid() ? 1 : 0;
1921
}
2022

2123
// --- CHANNEL PEER INFO ---
2224

23-
static int copy_str_to_out(const std::string& s, char* out, int out_len) {
24-
if (!out || out_len <= 0) return -1;
25-
int n = (int) s.size();
26-
if (n > out_len) n = out_len;
25+
static int copy_str_to_out(const std::string &s, char *out, int out_len) {
26+
if (!out || out_len <= 0)
27+
return -1;
28+
int n = (int)s.size();
29+
if (n > out_len)
30+
n = out_len;
2731
memcpy(out, s.data(), n);
2832
return n;
2933
}
3034

31-
int cf_channel_peer_id(SecureAuthenticatedChannel* ch, char* out_buf, int out_buf_len) {
32-
if (!ch) return -1;
33-
// TODO: If there is a public method like ch->peer_id() that returns std::string, use it.
34-
std::string id = ch->peer_id(); // <-- adjust if needed
35+
int cf_channel_peer_id(SecureAuthenticatedChannel *ch,
36+
char *out_buf,
37+
int out_buf_len) {
38+
if (!ch)
39+
return -1;
40+
// TODO: If there is a public method like ch->peer_id() that returns
41+
// std::string, use it.
42+
std::string id = ch->peer_id(); // <-- adjust if needed
3543
return copy_str_to_out(id, out_buf, out_buf_len);
3644
}
3745

38-
int cf_channel_peer_cert(SecureAuthenticatedChannel* ch, unsigned char* out_buf, int out_buf_len) {
39-
if (!ch) return -1;
46+
int cf_channel_peer_cert(SecureAuthenticatedChannel *ch,
47+
unsigned char *out_buf,
48+
int out_buf_len) {
49+
if (!ch)
50+
return -1;
4051
// TODO: If there is a public method to fetch peer cert bytes, use it.
4152
// If it returns std::string/bytes, copy into out_buf.
4253
std::string cert_der = ch->peer_cert_der(); // <-- adjust if needed
43-
if (!out_buf || out_buf_len <= 0) return -1;
44-
int n = (int) cert_der.size();
45-
if (n > out_buf_len) n = out_buf_len;
54+
if (!out_buf || out_buf_len <= 0)
55+
return -1;
56+
int n = (int)cert_der.size();
57+
if (n > out_buf_len)
58+
n = out_buf_len;
4659
memcpy(out_buf, cert_der.data(), n);
4760
return n;
4861
}

sample_apps/simple_app_java/native/cf_shims.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ extern "C" {
88

99
// ---- TrustManager flags ----
1010
// Return 1/0, not throwing exceptions across the JNI boundary.
11-
int cf_tm_auth_key_initialized(TrustManager* tm);
12-
int cf_tm_primary_admissions_cert_valid(TrustManager* tm);
11+
int cf_tm_auth_key_initialized(TrustManager *tm);
12+
int cf_tm_primary_admissions_cert_valid(TrustManager *tm);
1313

1414
// ---- Channel peek fields ----
1515
// Returns length of peer_id into out_buf (<= out_buf_len), or -1 on error.
16-
int cf_channel_peer_id(SecureAuthenticatedChannel* ch, char* out_buf, int out_buf_len);
17-
18-
// Returns length of peer_cert DER/PEM into out_buf (<= out_buf_len), or -1 on error.
19-
int cf_channel_peer_cert(SecureAuthenticatedChannel* ch, unsigned char* out_buf, int out_buf_len);
16+
int cf_channel_peer_id(SecureAuthenticatedChannel *ch,
17+
char *out_buf,
18+
int out_buf_len);
2019

20+
// Returns length of peer_cert DER/PEM into out_buf (<= out_buf_len), or -1 on
21+
// error.
22+
int cf_channel_peer_cert(SecureAuthenticatedChannel *ch,
23+
unsigned char *out_buf,
24+
int out_buf_len);
2125
}
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
bool generate_rsa_key(int key_size, key_message* key);
2-
bool sign_message(const key_message& key, int in_size, byte* in, int* out_size, byte* out);
3-
bool verify_message(const key_message& key, int in_size, byte* in, int sig_size, byte* sig);
1+
bool generate_rsa_key(int key_size, key_message *key);
2+
bool sign_message(const key_message &key,
3+
int in_size,
4+
byte *in,
5+
int *out_size,
6+
byte *out);
7+
bool verify_message(const key_message &key,
8+
int in_size,
9+
byte *in,
10+
int sig_size,
11+
byte *sig);

src/java/Certifier Algorithms/key_wrapper.cc

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,53 @@ KeyWrapper::KeyWrapper() {}
1010
KeyWrapper::~KeyWrapper() {}
1111

1212
bool KeyWrapper::generate(int key_size) {
13-
key_message key;
14-
if (!generate_rsa_key(key_size, &key))
15-
return false;
13+
key_message key;
14+
if (!generate_rsa_key(key_size, &key))
15+
return false;
1616

17-
key.SerializeToString(&key_bytes);
18-
return true;
17+
key.SerializeToString(&key_bytes);
18+
return true;
1919
}
2020

21-
bool KeyWrapper::sign(const string& message, string& signature) {
22-
key_message key;
23-
if (!key.ParseFromString(key_bytes))
24-
return false;
21+
bool KeyWrapper::sign(const string &message, string &signature) {
22+
key_message key;
23+
if (!key.ParseFromString(key_bytes))
24+
return false;
2525

26-
const byte* in = reinterpret_cast<const byte*>(message.data());
27-
int in_size = message.size();
28-
byte sig[512]; // max size buffer
29-
int sig_size = 0;
26+
const byte *in = reinterpret_cast<const byte *>(message.data());
27+
int in_size = message.size();
28+
byte sig[512]; // max size buffer
29+
int sig_size = 0;
3030

31-
if (!sign_message(key, in_size, (byte*)in, &sig_size, sig))
32-
return false;
31+
if (!sign_message(key, in_size, (byte *)in, &sig_size, sig))
32+
return false;
3333

34-
signature.assign((char*)sig, sig_size);
35-
return true;
34+
signature.assign((char *)sig, sig_size);
35+
return true;
3636
}
3737

38-
bool KeyWrapper::verify(const string& message, const string& signature) {
39-
key_message key;
40-
if (!key.ParseFromString(key_bytes))
41-
return false;
38+
bool KeyWrapper::verify(const string &message, const string &signature) {
39+
key_message key;
40+
if (!key.ParseFromString(key_bytes))
41+
return false;
4242

43-
const byte* in = reinterpret_cast<const byte*>(message.data());
44-
int in_size = message.size();
45-
const byte* sig = reinterpret_cast<const byte*>(signature.data());
46-
int sig_size = signature.size();
43+
const byte *in = reinterpret_cast<const byte *>(message.data());
44+
int in_size = message.size();
45+
const byte *sig = reinterpret_cast<const byte *>(signature.data());
46+
int sig_size = signature.size();
4747

48-
return verify_message(key, in_size, (byte*)in, sig_size, (byte*)sig);
48+
return verify_message(key, in_size, (byte *)in, sig_size, (byte *)sig);
4949
}
5050

5151
string KeyWrapper::export_key() {
52-
return key_bytes;
52+
return key_bytes;
5353
}
5454

55-
bool KeyWrapper::import_key(const string& serialized_key) {
56-
key_message key;
57-
if (!key.ParseFromString(serialized_key))
58-
return false;
55+
bool KeyWrapper::import_key(const string &serialized_key) {
56+
key_message key;
57+
if (!key.ParseFromString(serialized_key))
58+
return false;
5959

60-
key_bytes = serialized_key;
61-
return true;
60+
key_bytes = serialized_key;
61+
return true;
6262
}

src/java/Certifier Algorithms/key_wrapper.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
#include <string>
55

66
class KeyWrapper {
7-
public:
8-
KeyWrapper();
9-
~KeyWrapper();
7+
public:
8+
KeyWrapper();
9+
~KeyWrapper();
1010

11-
bool generate(int key_size); // Generates RSA key
12-
bool sign(const std::string& message, std::string& signature);
13-
bool verify(const std::string& message, const s:string& signature);
11+
bool generate(int key_size); // Generates RSA key
12+
bool sign(const std::string &message, std::string &signature);
13+
bool verify(const std::string &message, const s : string &signature);
1414

15-
std::string export_key(); // Returns key serialized to string
16-
bool import_key(const std::string& serialized_key); // Loads from string
15+
std::string export_key(); // Returns key serialized to string
16+
bool import_key(const std::string &serialized_key); // Loads from string
1717

18-
private:
19-
std::string key_bytes; // Serialized key
18+
private:
19+
std::string key_bytes; // Serialized key
2020
};
2121

2222
#endif

src/java/Claim Verifier/claim_verifier.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ ClaimVerifier::ClaimVerifier() {}
66

77
ClaimVerifier::~ClaimVerifier() {}
88

9-
bool ClaimVerifier::verify(const std::string& serialized_claim, const std::string& serialized_key) {
10-
signed_claim_message claim;
11-
key_message key;
9+
bool ClaimVerifier::verify(const std::string &serialized_claim,
10+
const std::string &serialized_key) {
11+
signed_claim_message claim;
12+
key_message key;
1213

13-
if (!claim.ParseFromString(serialized_claim) || !key.ParseFromString(serialized_key)) {
14-
return false;
15-
}
14+
if (!claim.ParseFromString(serialized_claim)
15+
|| !key.ParseFromString(serialized_key)) {
16+
return false;
17+
}
1618

17-
return verify_signed_claim(claim, key);
19+
return verify_signed_claim(claim, key);
1820

1921

20-
// verify_signed_claim(...) is the real framework function from support.cc
22+
// verify_signed_claim(...) is the real framework function from support.cc

src/java/Claim Verifier/claim_verifier.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
#include <string>
55

66
class ClaimVerifier {
7-
public:
8-
ClaimVerifier();
9-
~ClaimVerifier();
7+
public:
8+
ClaimVerifier();
9+
~ClaimVerifier();
1010

11-
// Accepts serialized protobufs as strings
12-
bool verify(const std::string& serialized_claim, const std::string& serialized_key);
11+
// Accepts serialized protobufs as strings
12+
bool verify(const std::string &serialized_claim,
13+
const std::string &serialized_key);
1314
};
1415

1516
#endif

src/java/Policy Store/policy_store_dummy.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ class policy_store {
77
~policy_store();
88

99
unsigned get_num_entries();
10-
bool add_entry(const std::string& tag, const std::string& type, const std::string& value);
11-
int find_entry(const std::string& tag, const std::string& type);
12-
bool get(unsigned ent, std::string* v);
13-
bool put(unsigned ent, const std::string v);
10+
bool add_entry(const std::string &tag,
11+
const std::string &type,
12+
const std::string &value);
13+
int find_entry(const std::string &tag, const std::string &type);
14+
bool get(unsigned ent, std::string *v);
15+
bool put(unsigned ent, const std::string v);
1416
};
1517

16-
}
18+
} // namespace certifier::framework
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
bool simulated_init();
2-
bool simulated_attest(std::string* out);
3-
bool simulated_get_platform_cert(std::string* out_cert);
4-
bool simulated_get_measurement(std::string* out_measurement);
2+
bool simulated_attest(std::string *out);
3+
bool simulated_get_platform_cert(std::string *out_cert);
4+
bool simulated_get_measurement(std::string *out_measurement);

0 commit comments

Comments
 (0)