Verifier/KBS: Use SHA-512 for report data / runtime_data calculation in IBM SEL#1338
Conversation
0eb4f1f to
96e7447
Compare
Xynnn007
left a comment
There was a problem hiding this comment.
We might also need to change grpc-as to use sha512 to align with https://github.com/confidential-containers/guest-components/pull/1469/changes
96e7447 to
b3eeb95
Compare
a655349 to
8c35c88
Compare
| pub const SUPPORTED_HASH_ALGORITHMS_JSON_KEY: &str = "supported-hash-algorithms"; | ||
| pub const SELECTED_HASH_ALGORITHM_JSON_KEY: &str = "selected-hash-algorithm"; |
There was a problem hiding this comment.
Note that there are also declarations . Maybe we could move that part under attestation/mod.rs
There was a problem hiding this comment.
Yep, you are right. I will move them to attestation/mod.rs. thanks!
| SELECTED_HASH_ALGORITHM_JSON_KEY: needed_algorithm | ||
| }) | ||
| }) | ||
| .unwrap_or_else(|| serde_json::Value::String(String::new())) |
There was a problem hiding this comment.
This will potentially hide the errors when doing the chain calling. Looks like a default value is given whenever there is an error? Note that if a malwared tee_params is given, the function will also return a default value, without telling anything wrong. Please ensure if this is expected.
There was a problem hiding this comment.
Let me get back to the old logic then. Thanks!
| /// and selects a hash algorithm based on the TEE type if available. | ||
| /// Returns a JSON value with the selected algorithm, | ||
| /// or an empty string if negotiation fails or is not applicable. | ||
| pub fn generate_extra_params(tee: Tee, tee_params: &serde_json::Value) -> serde_json::Value { |
There was a problem hiding this comment.
Also, note that extra_params is a conception for KBS's Challenge struct. See the function and it's proper to move the SE-specific logic to that place.
There was a problem hiding this comment.
True. I didn't realize that the extra_params is determined only with tee and tee_params passed to generate_challenge(). I will update the PR. Thanks!
| // Validate runtime_data_digest if provided | ||
| if let ReportData::Value(expected_report_data) = expected_report_data { | ||
| let expected_report_data = | ||
| regularize_data(expected_report_data, 64, "USER_DATA", "IBM SE"); |
There was a problem hiding this comment.
Probably the 64 here could also be made into a const.
There was a problem hiding this comment.
Yep, let's use a constant. Thanks!
| let runtime_data_hash_algorithm = match evidence.tee { | ||
| Tee::Se => HashAlgorithm::Sha512, | ||
| _ => HashAlgorithm::Sha384, | ||
| }; |
There was a problem hiding this comment.
Looks like we need to think about bringing a mechanism to include this parameter via the header parsing from RCAR protocol than harding coding here. This should be a TODO for me and not for this PR. This place in the PR looks good now.
| } | ||
| message ChallengeResponse { | ||
| string attestation_challenge = 1; | ||
| string extra_params = 2; |
There was a problem hiding this comment.
We might not need to change the proto here?
There was a problem hiding this comment.
Yep, we don't need this. Thanks!
| // Generate extra_params for hash algorithm negotiation | ||
| let extra_params = serde_json::from_str::<serde_json::Value>(tee_params) | ||
| .ok() | ||
| .map(|params| generate_extra_params(tee, ¶ms).to_string()) | ||
| .unwrap_or_default(); | ||
|
|
||
| info!("GetAttestationChallenge succeeded."); | ||
| let res = ChallengeResponse { | ||
| attestation_challenge, | ||
| extra_params, |
There was a problem hiding this comment.
See comment about generate_extra_params, and we do not need the part to be changed.
8c35c88 to
6693190
Compare
Xynnn007
left a comment
There was a problem hiding this comment.
LGTM. Although the PR does two things -
- use sha512 for report data in IBM SEL
- select sha512 as runtime data hash algorithm for IBM SE in KBS
So a updation on commit message, or reorg into two commits would either be ok
I would go with the 1st. Thanks! |
Use the more secure SHA-512 algorithm for the selected-hash-algorithm field in extra_params for IBM SEL. Update the verifier validation accordingly. In summary: 1. Use SHA-512 for report data in IBM SEL via extra_params 2. Select SHA-512 as runtime data hash algorithm for IBM SE in KBS Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
6693190 to
5d46fe3
Compare
Use the more secure SHA-512 algorithm for the
selected-hash-algorithmfield inextra_paramsfor IBM SEL.Update the verifier validation accordingly. The logic for configuring
extra_paramsfollows the pattern used by Intel Trust Authority.In summary:
Depends-on: confidential-containers/guest-components#1469
Signed-off-by: Hyounggyu Choi Hyounggyu.Choi@ibm.com