Refactor Update operation to return amount of input consumed.

Per the keymaster "update" API documentation, implementations need not
consume all provided input, and must return information about how much
they did consume, so the caller knows to resend the unprocessed portion.
It's convenient for the AES OCB mode encryption to sometimes process
less than is provided, but the Update operation interfaces didn't
account for not consuming all data.

This change was already reviewed, merged and reverted, so I'm skipping
the review step this time.

Change-Id: Ida401453a6af6c751ea7093e283a101bd8527709
diff --git a/ecdsa_operation.cpp b/ecdsa_operation.cpp
index 3987394..aa41095 100644
--- a/ecdsa_operation.cpp
+++ b/ecdsa_operation.cpp
@@ -26,24 +26,28 @@
         EC_KEY_free(ecdsa_key_);
 }
 
-keymaster_error_t EcdsaOperation::Update(const Buffer& input, Buffer* /* output */) {
+keymaster_error_t EcdsaOperation::Update(const Buffer& input, Buffer* /* output */,
+                                         size_t* input_consumed) {
+    assert(input_consumed);
     switch (purpose()) {
     default:
         return KM_ERROR_UNIMPLEMENTED;
     case KM_PURPOSE_SIGN:
     case KM_PURPOSE_VERIFY:
-        return StoreData(input);
+        return StoreData(input, input_consumed);
     }
 }
 
-keymaster_error_t EcdsaOperation::StoreData(const Buffer& input) {
+keymaster_error_t EcdsaOperation::StoreData(const Buffer& input, size_t* input_consumed) {
     if (!data_.reserve(data_.available_read() + input.available_read()) ||
         !data_.write(input.peek_read(), input.available_read()))
         return KM_ERROR_MEMORY_ALLOCATION_FAILED;
+    *input_consumed = input.available_read();
     return KM_ERROR_OK;
 }
 
 keymaster_error_t EcdsaSignOperation::Finish(const Buffer& /* signature */, Buffer* output) {
+    assert(output);
     output->Reinitialize(ECDSA_size(ecdsa_key_));
     unsigned int siglen;
     if (!ECDSA_sign(0 /* type -- ignored */, data_.peek_read(), data_.available_read(),