The interface I imagine is something like
Crypto.AES()->set_encrypt_key(the_key)->crypt(data)
The basic AES object will only encrypt complete blocks. Then you can wrap CBC on top of that, but that would still probably handle complete blocks.
In order to handle arbitrary length input, one must use some padding convention. An object implementing padding could also do buffering. I'm not sure I see the point of feed/drain, the most natural interface to me would be
o->crypt(data) // encrypts or buffers more data. Returns as much // output as is available
o->finish() // Do final padding, return final output.
One could do feed/drain on top of that, but perhaps that's best done in pike rather than C.
For hash functions, the interface would be close to nettles,
o = Crypto.MD5(); o->update("foo"); // Returns self, so that o->update("bar"); // Crypto.MD5()->update("foo)->digest() works too. o->digest(); // Returns digest string
So, that's basically what I've been imagining, but I'm open to suggestions.
/ Niels Möller ()
Previous text:
2003-03-11 23:06: Subject: nettle-1.7
I think it would be nice to have all buffer objects where you can push data several times and then then ask for (perhaps partial) result to have the same API (feed/drain/finish).
Do you mean that you would like to go from Crypto.foo()->feed(jox)->drain(); to Crypto.foo(jox); ?
/ Martin Nilsson (har bott i google)