-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to Fix Ledger APIs used to set Contract Enclave atttestation …
…policy. Changes to address Review Comments have been squashed into the same commit. (#467) Signed-off-by: Prakash Narayana Moorthy <[email protected]>
- Loading branch information
1 parent
0085dab
commit 955e2b7
Showing
10 changed files
with
271 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 0 additions & 90 deletions
90
ledgers/ccf/pdo/ledgers/ccf/scripts/register_enclave_attestation_verification_policy.py
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
ledgers/ccf/pdo/ledgers/ccf/scripts/set_attestation_check_flag.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright 2023 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
import http | ||
import sys | ||
|
||
from loguru import logger as LOG | ||
|
||
from pdo.ledgers.ccf.common import parse_common_arguments | ||
|
||
|
||
# ----------------------------------------------------------------- | ||
def set_contract_enclave_check_attestation_flag(client, options): | ||
|
||
params = {} | ||
params['check_attestation'] = options.attestation | ||
|
||
r = client.post("/app/set_contract_enclave_check_attestatation_flag", params) | ||
if r.status_code != http.HTTPStatus.OK.value: | ||
LOG.error('failed to set contract enclave check-attestation flag: {}, code: {}'.format( | ||
r.body, r.status_code)) | ||
sys.exit(-1) | ||
|
||
# ----------------------------------------------------------------- | ||
def Main() : | ||
|
||
(_, unprocessed_args, member_client) = parse_common_arguments( | ||
sys.argv[1:], 'Set contract enclave attestation check flag', True) | ||
|
||
# Parse the arguments that are unique to the script | ||
parser = argparse.ArgumentParser(description='Set contract enclave attestation check flag') | ||
check_attestation_group = parser.add_mutually_exclusive_group(required=True) | ||
check_attestation_group.add_argument('--attestation', dest='attestation', | ||
help="enable attestation verification", action='store_true') | ||
check_attestation_group.add_argument('--no-attestation', dest='attestation', | ||
help="disable attestation verification", action='store_false') | ||
local_options = parser.parse_args(unprocessed_args) | ||
|
||
# ----------------------------------------------------------------- | ||
try : | ||
|
||
set_contract_enclave_check_attestation_flag(member_client, local_options) | ||
except Exception as e: | ||
while e.__context__ : e = e.__context__ | ||
LOG.error('failed to set contract enclave attestation check flag: {}', str(e)) | ||
sys.exit(-1) | ||
|
||
LOG.info('successfully set contract enclave check-attestation flag ') | ||
sys.exit(0) | ||
|
||
# ----------------------------------------------------------------- | ||
# ----------------------------------------------------------------- | ||
Main() |
74 changes: 74 additions & 0 deletions
74
ledgers/ccf/pdo/ledgers/ccf/scripts/set_expected_sgx_measurements.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright 2023 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
import http | ||
import sys | ||
|
||
from loguru import logger as LOG | ||
|
||
from pdo.ledgers.ccf.common import parse_common_arguments | ||
|
||
|
||
# ----------------------------------------------------------------- | ||
def set_contract_enclave_expected_sgx_measurements(client, options): | ||
|
||
params = {} | ||
params['mrenclave'] = options.mrenclave | ||
params['basename'] = options.basename | ||
params['ias_public_key'] = options.ias_public_key | ||
|
||
r = client.post("/app/set_contract_enclave_expected_sgx_measurements", params) | ||
if r.status_code != http.HTTPStatus.OK.value: | ||
LOG.error('failed to set contract enclave expected sgx measurements: {}, code: {}'.format( | ||
r.body, r.status_code)) | ||
sys.exit(-1) | ||
|
||
# ----------------------------------------------------------------- | ||
def Main() : | ||
|
||
(_, unprocessed_args, member_client) = parse_common_arguments( | ||
sys.argv[1:], 'Set contract enclave expected sgx measurements', True) | ||
|
||
# Parse the arguments that are unique to the script | ||
|
||
parser = argparse.ArgumentParser(description='Set contract enclave expected sgx measurements') | ||
parser.add_argument('--mrenclave', help="Expected MRENCLAVE of pdo enclaves", type=str) | ||
parser.add_argument('--basename', help="PDO enclave basename", type=str) | ||
parser.add_argument('--ias-public-key', | ||
help="IAS public key derived from cert used to verify report signatures", type=str) | ||
|
||
local_options = parser.parse_args(unprocessed_args) | ||
|
||
if (not local_options.mrenclave) or (not local_options.basename) or (not local_options.ias_public_key): | ||
parser.print_help() | ||
sys.exit(-1) | ||
|
||
|
||
# ----------------------------------------------------------------- | ||
try : | ||
set_contract_enclave_expected_sgx_measurements(member_client, local_options) | ||
except Exception as e: | ||
while e.__context__ : e = e.__context__ | ||
LOG.error('failed to set contract enclave expected sgx measurements: {}', str(e)) | ||
sys.exit(-1) | ||
|
||
LOG.info('successfully set contract enclave expected sgx measurements') | ||
sys.exit(0) | ||
|
||
# ----------------------------------------------------------------- | ||
# ----------------------------------------------------------------- | ||
Main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.