Add CryptoInterface library by aerlon · Pull Request #6961 · esp8266/Arduino (original) (raw)
Other than minor comments already made, I have two thoughts:
- If it makes sense to use this from the core, then it should be moved to core files. If it's a library, it's off limits for the core, because the core can't be dependent on a library.
- I envisioned a different structure, i.e.: have interface objects within the namespace, one for each algorithm, with usage similar to the base64 class: one class for sha1, one for sha256, one for md5, etc. For example:
class md5 { String hash(blah); void *hmac(blah); void *hmacCT(blah); ... }; class sha1 { String hash(blah); void *hmac(blah); void *hmacCT(blah); ... }; ...
If it makes sense, each class could hold context for successive calls, or if it doesn't, the methods could be static.
But, I don't want to delay moving forward for this, so if you want to leave that for another PR it's ok. The choice is yours.
However, please put everything in namespace experimental to not get tied down with maintaining compatibility for the moment while we get around to reworking that.
Other things that could be unified behind this CryptoInterface in the future:
crc16, unify crc32 use, move base64, implement base58, unify md5 use.