odp icon indicating copy to clipboard operation
odp copied to clipboard

[PATCH v4] api: crypto: clarify current API and add new "operation types"

Open JannePeltonen opened this issue 2 years ago • 4 comments

This PR has the following patches:

  • api: crypto: clarify that input packet is fully copied to output packet

    • no functional changes but better description on the expected functionality
  • api: crypto: introduce a session parameter to control output packet handling

    • add "operation type" session parameter with three values:
      • legacy: backward compatible behaviour
      • copy: output packet allocated by ODP, copied from input packet and processed
  • api: crypto: add an operation type that combines two packets

    • add combine crypto op type: crypto output of input packet is written into a second packet (a copy of it), preserving other data and metadata of the second packet
  • api: crypto: do not always consume input packets

    • add a per-packet flag to tell if a processed input packet should not be consumed but returned untouched.

JannePeltonen avatar Sep 13 '22 09:09 JannePeltonen

v2: fixed a couple of typos.

JannePeltonen avatar Sep 13 '22 09:09 JannePeltonen

v3: Split the second commit to two commits so that the addition of ODP_CRYPTO_OP_TYPE_COMBINE is now separate from the addition of the crypto op type. There are no actual code changes.

JannePeltonen avatar Sep 14 '22 08:09 JannePeltonen

v4:

  • Dropped the combine operation type and the input packet preservation from this PR.
  • Renamed ODP_CRYPTO_OP_TYPE_COPY to ODP_CRYPTO_OP_TYPE_BASIC.
  • Rebased

JannePeltonen avatar Oct 11 '22 09:10 JannePeltonen

The combine operation type and input packet preservation patches (rebased on this PR) can be found in crypto-api-impr-2 branch for reference.

JannePeltonen avatar Oct 11 '22 09:10 JannePeltonen

v5: Added new patch that adds an out-of-place crypto operation type that does not consume the input packet and writes output to a caller provided packet.

JannePeltonen avatar Dec 13 '22 11:12 JannePeltonen

v6: fixed typos

JannePeltonen avatar Dec 21 '22 07:12 JannePeltonen

v7: rebased

JannePeltonen avatar Jan 02 '23 08:01 JannePeltonen

v8: fixed whitespace errors introduced during rebase

JannePeltonen avatar Jan 02 '23 09:01 JannePeltonen

API changes look fine. Reviewed-by: Anoob Joseph [email protected]

@JannePeltonen Do you have plans to introduce unit tests?

anoobj avatar Jan 03 '23 11:01 anoobj

v9:

  • Clarify that the OOP mode works as if crypto-range and auth range were copied to the output packet and then the output packet was processed
  • Clarify that output packets in the OOP mode must be separate
  • Add input packet (in the OOP mode) in the result provided by odp_crypto_result() and make it clear that the input packet may not be used until the operation is complete
  • Add a patch that allows post processing in odp_crypto_result() by requiring that the result function is called before packet data of the output packet can be assumed to be valid

JannePeltonen avatar Jan 04 '23 12:01 JannePeltonen

v10: clarified the text regarding changing memory layout and removed the ambiguous "data offset" term.

JannePeltonen avatar Jan 04 '23 16:01 JannePeltonen

API change looks fine.

anoobj avatar Jan 20 '23 06:01 anoobj

v11:

This PR now depends on the commits of PR 1743 (removal of deprecated per-session IVs) and includes those commits as the first five commits. Those commits are not part of the review in this PR and will disappear as soon as they get merged to master and this PR then gets rebased.

Changes in V11:

  • API changes regarding the out-of-place op type: clarify that dst_offset_shift is in bytes, specify that ignored crypto and auth ranges are not copied in the output packet, specify that the bytes in hash result location are not modified in the input packet but may be undefined in the corresponding location of the output packet if the hash result location overlaps the cipher or auth ranges.
  • Added implementations: basic type is implemented by all crypto modules. OOP type only by the openssl module and in a very simple way.

JannePeltonen avatar Jan 30 '23 18:01 JannePeltonen

v12

  • fixed casting warnings on 32-bit systems
  • added commits that revamp validation test code a bit and add tests for the new operation types

JannePeltonen avatar Feb 01 '23 19:02 JannePeltonen

v13: Fixed clang warning about possibly uninitialized variable

JannePeltonen avatar Feb 01 '23 19:02 JannePeltonen

v14: rebased to get rid of the prerequisite commits that are now in master

JannePeltonen avatar Feb 06 '23 09:02 JannePeltonen

Reviewed API spec changes in v14. Those are OK.

Reviewed implementation patches also. Only one comment on those.

psavol avatar Feb 06 '23 16:02 psavol

v15: rebased, added review-tags in the API commits, made the grammar improvement in the API sentence, changed the type of the variable to signed (does not change the outcome).

JannePeltonen avatar Feb 10 '23 08:02 JannePeltonen

Reviewed-by: Anoob Joseph [email protected]

anoobj avatar Feb 13 '23 13:02 anoobj

v16: updated review-tags

JannePeltonen avatar Feb 13 '23 13:02 JannePeltonen