Updating database to return OUT_OF_KEYS
This updates the assign_attestation_key call to throw the new
OUT_OF_KEYS ResponseCode value if the attestation key pool is out of
keys to assign to new apps.
Test: atest RemoteProvisionerUnitTests
Change-Id: I8ee65bea23acc2daa845648a359be59a78d31e2f
diff --git a/keystore2/src/database.rs b/keystore2/src/database.rs
index 40860be..fcfdabe 100644
--- a/keystore2/src/database.rs
+++ b/keystore2/src/database.rs
@@ -1688,11 +1688,11 @@
],
)
.context("Failed to assign attestation key")?;
- if result != 1 {
- return Err(KsError::sys()).context(format!(
- "Expected to update a single entry but instead updated {}.",
- result
- ));
+ if result == 0 {
+ return Err(KsError::Rc(ResponseCode::OUT_OF_KEYS)).context("Out of keys.");
+ } else if result > 1 {
+ return Err(KsError::sys())
+ .context(format!("Expected to update 1 entry, instead updated {}", result));
}
Ok(()).no_gc()
})