Block action if BIB and BCB conflict on the same target - #299
Block action if BIB and BCB conflict on the same target#299william-fei wants to merge 4 commits into
Conversation
BrianSipos
left a comment
There was a problem hiding this comment.
It could be good to capture a valid/invalid use of this in an mock BPA test, which would be a stand-alone example of what works and what does not.
From the standpoint of real use cases, I don't know that a verifier role for both ops with the same target makes sense anyway. Verifying a BCB will check the integrity of the target plaintext because all encrypt algos available to BSL are AEAD and use an auth tag for integrity.
jeronstone
left a comment
There was a problem hiding this comment.
#292 is now merged, which includes a MockBPA test for this. Remove the _ from _test_json_verify_bib_bcb in test_json_policy (and, you may need to change the failure condition / expected output)
jeronstone
left a comment
There was a problem hiding this comment.
In general, there needs to be a refactor of the Query function. That can be a separate ticket, though.
One idea is to add a map { target : secop (list) } to make it easier to determine conflicts/invalid ops/etc. That would prevent the n^2 search for conflicting secops
|
| static bool BSLP_SecOperHasConflict(const BSL_SecOper_t *sec_oper, const BSLP_SecOperPtrList_t secops) | ||
| { | ||
| if (!BSL_SecOper_IsBIB(sec_oper) | ||
| || (!BSL_SecOper_IsRoleVerifier(sec_oper) && !BSL_SecOper_IsRoleAcceptor(sec_oper))) |
There was a problem hiding this comment.
not-verifier and not-acceptor is the same as source role, correct?
| const uint64_t target_block_num = BSL_SecOper_GetTargetBlockNum(sec_oper); | ||
| for (size_t i = 0; i < BSLP_SecOperPtrList_size(secops); i++) | ||
| { | ||
| const BSL_SecOper_t *comp = *BSLP_SecOperPtrList_cget(secops, i); |
There was a problem hiding this comment.
Does this logic properly handle the case when the oper instance is already in the list (by-pointer equality comp == sec_oper)?
| for (size_t j = 0; j < BSLP_SecOperPtrList_size(secops); j++) | ||
| { | ||
| BSL_SecOper_t *discarded_secop = *BSLP_SecOperPtrList_get(secops, j); | ||
| BSL_SecOper_Deinit(discarded_secop); | ||
| BSL_free(discarded_secop); | ||
| } |
There was a problem hiding this comment.
I think this is duplicative of the BSLP_SecOperPtrList_clear below, since shared pointers are used.
Also, there is a little bit of backward logic here; it may be more readable to have a scope-local bool valid = true and then if conflict valid = false; and outside of this loop an if !valid clear/deinit/free/return.



Closes #290