Chore: Symmetric_Algorithm can deal with generic containers#3297
Chore: Symmetric_Algorithm can deal with generic containers#3297
Conversation
That was the original idea behind you can just as easily write which is why The real errors, the subtle problems that cause systems to actually fail: nonce reuse, reusing a key in two different contexts, allowing cut-and-paste attacks, etc etc are not fixable with the typesystem, and the way to prevent those is to provide good out of the box tools, for those who don't really know what they are doing (eg, TLS, PGP, Signal protocol, whatever) and for those who need low level functionality (ie, implementations of different protocols), offer that functionality with as little mess and inconvenience as possible. I'm all in favor of using the type system to prevent errors when that is feasible but in this instance I think the costs (syntactic, performance overhead, etc) outweigh the benefits (which tbh seem near zero, in terms of real bugs prevented). |
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #3297 +/- ##
==========================================
- Coverage 88.10% 88.10% -0.01%
==========================================
Files 615 610 -5
Lines 70315 68655 -1660
Branches 6997 6844 -153
==========================================
- Hits 61949 60486 -1463
+ Misses 5422 5307 -115
+ Partials 2944 2862 -82
... and 215 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
Agreed. Bottom line: Low-level programming convenience over type safety in this particular case. You nailed my concern regarding "intrusive API" with your example, btw. 😏 I'll close #3296 on this basis. Thanks. One more thing: Making |
d43d565 to
d179783
Compare
randombit
left a comment
There was a problem hiding this comment.
I think some of these changes point to areas where SymmetricKey can/should be outright removed from the API. But the change to set_key and making the constructors explicit is fine.
d179783 to
2ae13f6
Compare
|
Rebased to master to solve conflicts. Now waiting for CI, then merging. Re:SymmetricKey: Yeah, I think it isn't used consistently throughout the API and causes more confusion than its actually useful. |
2ae13f6 to
293887d
Compare
Introducing
::set_key(std::span)would have caused an ambiguous overload with::set_key(SymmetricKey). That's what initially side-tracked me resulting in the OctetString question.To resolve this ambiguity, I made the c'tors of
OctetStringexplicit.Burried under this is a bigger question, though: Should the API even allow anything else than a
SymmetricKeycontainer for::set_key()? Or should Botan's public API leverage the type system to try and prevent programming errors?The latter would probably mean that we'd eventually ask library users to use our strong types as part of the public API. That might or might not be intrusive for some people.