-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API modernization PK_KEM_Encryptor/Decryptor #3611
API modernization PK_KEM_Encryptor/Decryptor #3611
Conversation
8114c87
to
df38d18
Compare
3a42644
to
9d48910
Compare
9d48910
to
a976632
Compare
190db8f
to
2f586e0
Compare
The new return struct looks good. I'm leery of the It does have the advantage of allowing precise placement of a KEM output in some network buffer, etc. We do support something very similar in the cipher modes where you pass a buffer along with a ignored offset, for the precise reason of supporting such usage. I would argue that a KEM is a bit different because KEM encapsulation or decapsulation is much slower relative to say AES/GCM. So the additional overhead of an extra copy is pretty trivial compared to the KEM operation itself. Also, it completely precludes supporting a KEM which has a variable length output in its unprocessed form. I don't think we have any such KEMs currently and it is hard to imagine one being standardized in the future, but I don't like boxing ourselves in on this point. |
Frankly, I think we're already somewhat boxed into fixed-size KEM outputs because of the Otherwise, I agree though: It isn't exactly obvious for a user what buffer length is required for the This leaves the potential for memory issues which we need to keep in mind with explicit bounds checks (e.g. by religiously using |
Oh indeed. Every other function of similar form is documented as returning the upper bound of the length, but here we claim it's the exact length... |
Either that or just an explicit check that the span is equal in length to the return value of |
That's already implemented with Additionally, the internal implementations of |
Sorry I had missed the checks at the top level - that was what I had in mind. LGTM |
Can you update the KEM docs to mention the new signatures? |
Done. I don't have my YubiKey handy right now. Will sign and re-push tomorrow or Monday morning. |
d876dc4
to
6175eec
Compare
Done. |
Can you rebase to pick up the regular CI run |
6175eec
to
a9bdf73
Compare
Let's hold off on merging this to master until after I can release 3.1.1 with #3623 addressed |
This is in response of #3608 (comment). It modernizes the
PK_KEM_Encryptor
interface usingstd::span<>
. Also, it introducesPK_KEM_Encryptor::encrypt
without out-params that returns aKEM_Encapsulation
struct containing the encapsulated and plaintext shared secrets.General Question/Discussion
Do we actually want to use
std::span<>
as out-params like that? It provides maximum flexibility, but comes with some draw-backs. Note, though, that thestd::span
out-param overloads are not mandatory. Users may use the managed overload that returns a pre-allocatedKEM_Encapsulation
, for instance.Advantages
secure_vector<>
or anything they wantDrawbacks
BOTAN_ASSERT
s)std::span
out-params, copies are still necessary.