Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Commit fe9faea

Browse files
rranjan3Ram-srini
authored andcommitted
Interface for Enclave attributes
Signed-off-by: Rajeev Ranjan <[email protected]>
1 parent c8e5486 commit fe9faea

File tree

4 files changed

+108
-8
lines changed

4 files changed

+108
-8
lines changed

enclave_manager/avalon_enclave_manager/base_enclave_info.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from ssl import SSLError
2020
from requests.exceptions import Timeout
2121
from requests.exceptions import HTTPError
22-
from abc import ABC, abstractmethod
22+
from abc import abstractmethod
23+
from avalon_enclave_manager.enclave_attributes import EnclaveAttributes
2324
import avalon_enclave_manager.ias_client as ias_client
2425

2526
import logging
@@ -29,7 +30,7 @@
2930
SIG_RL_UPDATE_PERIOD = 8 * 60 * 60 # in seconds every 8 hours
3031

3132

32-
class BaseEnclaveInfo(ABC):
33+
class BaseEnclaveInfo(EnclaveAttributes):
3334
"""
3435
Abstract base class to initialize enclave, signup enclave and hold
3536
data obtained post signup.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright 2020 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import logging
16+
from abc import ABC, abstractmethod
17+
18+
logger = logging.getLogger(__name__)
19+
20+
21+
class EnclaveAttributes(ABC):
22+
"""
23+
Interface to be implemented by all enclaves that run within
24+
Intel SGX enclave.
25+
"""
26+
27+
# -----------------------------------------------------------------
28+
29+
@abstractmethod
30+
def get_enclave_measurement(self):
31+
"""
32+
A getter for enclave measurement
33+
34+
Returns :
35+
@returns mr_enclave - Enclave measurement for enclave
36+
"""
37+
pass
38+
39+
# -----------------------------------------------------------------
40+
41+
@abstractmethod
42+
def get_enclave_basename(self):
43+
"""
44+
A getter for enclave basename
45+
46+
Returns :
47+
@returns basename - Basename of enclave
48+
"""
49+
pass
50+
51+
# -----------------------------------------------------------------
52+
53+
@abstractmethod
54+
def get_extended_measurements(self):
55+
"""
56+
A getter for enclave extended measurements which is a tuple of enclave
57+
basename and enclave measurement
58+
59+
Returns :
60+
@returns basename,measurement - A tuple of basename & measurement
61+
"""
62+
pass
63+
64+
# -----------------------------------------------------------------

enclave_manager/avalon_enclave_manager/graphene/graphene_enclave_info.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@
1313
# limitations under the License.
1414

1515
import logging
16+
from avalon_enclave_manager.enclave_attributes import EnclaveAttributes
1617

1718
logger = logging.getLogger(__name__)
1819

1920
# -------------------------------------------------------------------------
2021

2122

22-
class SignupGraphene():
23+
class GrapheneEnclaveInfo(EnclaveAttributes):
2324
"""
24-
Signup Object that will be used by BaseEnclave Manager
25+
Signup Object that will be used by GrapheneEnclaveManager
2526
"""
2627

2728
# -------------------------------------------------------------------------
2829
def __init__(self, worker_signup_json):
2930
"""
30-
Constructor for SignupGraphene.
31+
Constructor for GrapheneEnclaveInfo.
3132
Creates signup object.
3233
"""
3334
self.sealed_data = worker_signup_json["sealed_data"]
@@ -41,3 +42,37 @@ def __init__(self, worker_signup_json):
4142
self.extended_measurements = None
4243

4344
# -------------------------------------------------------------------------
45+
def get_enclave_measurement(self):
46+
"""
47+
A getter for enclave measurement
48+
49+
Returns :
50+
@returns mr_enclave - Enclave measurement for enclave
51+
"""
52+
# Return None as of now. Read from proof_data when enabled.
53+
return None
54+
55+
# -----------------------------------------------------------------
56+
57+
def get_enclave_basename(self):
58+
"""
59+
A getter for enclave basename
60+
61+
Returns :
62+
@returns basename - Basename of enclave
63+
"""
64+
return None
65+
66+
# -----------------------------------------------------------------
67+
68+
def get_extended_measurements(self):
69+
"""
70+
A getter for enclave extended measurements which is a tuple of enclave
71+
basename and enclave measurement
72+
73+
Returns :
74+
@returns basename,measurement - A tuple of basename & measurement
75+
"""
76+
return None
77+
78+
# -----------------------------------------------------------------

enclave_manager/avalon_enclave_manager/graphene/graphene_enclave_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from avalon_enclave_manager.work_order_processor_manager \
2626
import WOProcessorManager
2727
from avalon_enclave_manager.graphene.graphene_enclave_info \
28-
import SignupGraphene
28+
import GrapheneEnclaveInfo
2929
from utility.zmq_comm import ZmqCommunication
3030

3131
logger = logging.getLogger(__name__)
@@ -93,7 +93,7 @@ def _create_signup_data(self):
9393
try:
9494
# Send signup request to Graphene worker
9595
worker_signup = self.zmq_socket.send_request_zmq(
96-
json.dumps(json_request))
96+
json.dumps(json_request))
9797
except Exception as ex:
9898
logger.error("Exception while sending data over ZMQ:" + str(ex))
9999
return None
@@ -108,7 +108,7 @@ def _create_signup_data(self):
108108
logger.error("Exception during signup json creation:" + str(ex))
109109
return None
110110
# Create Signup Graphene object
111-
signup_data = SignupGraphene(worker_signup_json)
111+
signup_data = GrapheneEnclaveInfo(worker_signup_json)
112112
return signup_data
113113

114114
# -------------------------------------------------------------------------

0 commit comments

Comments
 (0)