-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_generator.py
More file actions
128 lines (115 loc) · 5.68 KB
/
Copy pathjson_generator.py
File metadata and controls
128 lines (115 loc) · 5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# ---------------------------------------------------
# Auxiliary file to generate the json structures for the attestation reports
# ---------------------------------------------------
import json
# Json structure of the Edge Accelerator Report
def generate_att_report_json(
edge_server_id, fpga_id,
att_service_claim, att_service_timestamp, att_service_appraisal,
kernel_claim, kernel_type, kernel_timestamp, kernel_appraisal,
puf_claim, puf_timestamp, puf_appraisal, puf_value
):
# data = {
# "EdgeAcceleratorReports": [
# {
# "EdgeServerID" : edge_server_id, # "Edge-Server-1"
# "FPGAID" : fpga_id, # "FPGA-1"
# "attestationReport": [
# {
# "claim": att_service_claim, # "edge_accelerator_att_service",
# "timestamp": att_service_timestamp, # timestamp1,
# "appraisal": att_service_appraisal, # 1
# },
# {
# "claim": kernel_claim, # "edge_accelerator_kernel",
# "kernel_type" : kernel_type, # 0,
# "timestamp": kernel_timestamp, # timestamp2,
# "appraisal": kernel_appraisal # 0
# }
# ]
# }
# ]
# }
# -------------------------------------------------------------------- #
# -------------------------------------------------------------------- #
# -------------------------------------------------------------------- #
# -------------------------------------------------------------------- #
# data = [
# {
# "EdgeServerID" : edge_server_id, # "Edge-Server-1"
# "FPGAID" : fpga_id, # "FPGA-1"
# "attestationReport": [
# {
# "claim": att_service_claim, # "edge_accelerator_att_service",
# "timestamp": att_service_timestamp, # timestamp1,
# "appraisal": att_service_appraisal, # 1
# },
# {
# "claim": kernel_claim, # "edge_accelerator_kernel",
# "kernel_type" : kernel_type, # 0,
# "timestamp": kernel_timestamp, # timestamp2,
# "appraisal": kernel_appraisal # 0
# }
# ]
# }
# ]
# ------------------------------------------------------------------------ #
# ------------------------------------------------------------------------ #
data = [
{
"EdgeServerID" : edge_server_id,
"FPGAID" : fpga_id,
"attestationReport": [
{
"claim": att_service_claim,
"timestamp": att_service_timestamp,
"appraisal": att_service_appraisal,
},
{
"claim": kernel_claim,
"kernel_type" : kernel_type,
"timestamp": kernel_timestamp,
"appraisal": kernel_appraisal
},
{
"claim": puf_claim,
"timestamp": puf_timestamp,
"appraisal": puf_appraisal,
"puf": puf_value
}
]
}
]
# ------------------------------------------------------------------------ #
# ------------------------------------------------------------------------ #
# Convert the dictionary to a JSON string
# json_data = json.dumps(data, indent=2)
# json_data = json.dumps(data) # <===
json_data = data
return json_data
# Json structure of the Attestation Server Evidence
# Note: This includes the attestation report from the Edge Accelerator
def generate_att_server_evidence_json(
att_evidence_timestamp, att_evidence_nonce, att_evidence_signature_type, att_evidence_signature, att_evidence_keyref
):
# Calculate the input JSON structure checksum to include it in the evidence
# data = {
# "AttestationServerEvidence": { # Attestation Server / Verification Service
# "timestamp" : att_evidence_timestamp, # stigmh pou stelnei to json
# "nonce" : att_evidence_nonce, # auto pou paragei o verification server
# "signatureAlgorithmType": att_evidence_signature_type, # ECDSA-SHA256
# "signature" : att_evidence_signature, # Sign(Nonce + attestation_report)
# "keyRef" : att_evidence_keyref # "ecdsa_public_key_71" antallagh kleidiou me SCB/secure oracle
# }
# }
data = {
"timestamp" : att_evidence_timestamp, # stigmh pou stelnei to json
"nonce" : att_evidence_nonce, # auto pou paragei o verification server
"signatureAlgorithmType": att_evidence_signature_type, # ECDSA-SHA256
"signature" : att_evidence_signature, # Sign(Nonce + attestation_report)
"keyRef" : att_evidence_keyref # "ecdsa_public_key_71" antallagh kleidiou me SCB/secure oracle
}
# Convert the dictionary to a JSON string
# json_data = json.dumps(data)
json_data = data
return json_data