Keystore 2.0 Crypto: Add try_clone to ZVec.

Add the function try_clone to ZVec. Cloning may fail because mlock may
fail during the allocation of a new memory region.

Test: N/A
Change-Id: I1dc3f098d8c02d3bf9116ab86527eca6793d0bfe
diff --git a/keystore2/src/crypto/zvec.rs b/keystore2/src/crypto/zvec.rs
index 43e6dd5..5a173c3 100644
--- a/keystore2/src/crypto/zvec.rs
+++ b/keystore2/src/crypto/zvec.rs
@@ -58,6 +58,14 @@
             self.len = len;
         }
     }
+
+    /// Attempts to make a clone of the Zvec. This may fail due trying to mlock
+    /// the new memory region.
+    pub fn try_clone(&self) -> Result<Self, Error> {
+        let mut result = Self::new(self.len())?;
+        result[..].copy_from_slice(&self[..]);
+        Ok(result)
+    }
 }
 
 impl Drop for ZVec {