This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit 3c378cd4dc9b45fe9ef5eee5c9b27a75f2d748af
Author: Mingshen Sun <[email protected]>
AuthorDate: Sun Feb 2 16:35:39 2020 -0800

    [proto] Rename try_new to new, follow Rust naming convention
---
 services/proto/src/teaclave_common.rs |  6 +++---
 types/src/crypto.rs                   | 10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/services/proto/src/teaclave_common.rs 
b/services/proto/src/teaclave_common.rs
index b14ca30..9d140c9 100644
--- a/services/proto/src/teaclave_common.rs
+++ b/services/proto/src/teaclave_common.rs
@@ -51,11 +51,11 @@ impl std::convert::TryFrom<proto::FileCryptoInfo> for 
TeaclaveFileCryptoInfo {
     fn try_from(proto: proto::FileCryptoInfo) -> Result<Self> {
         let info = match proto.schema.as_str() {
             "aes_gcm_128" => {
-                let info = AesGcm128CryptoInfo::try_new(&proto.key, 
&proto.iv)?;
+                let info = AesGcm128CryptoInfo::new(&proto.key, &proto.iv)?;
                 TeaclaveFileCryptoInfo::AesGcm128(info)
             }
             "aes_gcm_256" => {
-                let info = AesGcm256CryptoInfo::try_new(&proto.key, 
&proto.iv)?;
+                let info = AesGcm256CryptoInfo::new(&proto.key, &proto.iv)?;
                 TeaclaveFileCryptoInfo::AesGcm256(info)
             }
             "teaclave_file_root_key_128" => {
@@ -63,7 +63,7 @@ impl std::convert::TryFrom<proto::FileCryptoInfo> for 
TeaclaveFileCryptoInfo {
                     proto.iv.is_empty(),
                     "IV is not empty for teaclave_file_root_key_128"
                 );
-                let info = TeaclaveFileRootKey128::try_new(&proto.key)?;
+                let info = TeaclaveFileRootKey128::new(&proto.key)?;
                 TeaclaveFileCryptoInfo::TeaclaveFileRootKey128(info)
             }
             _ => bail!("Invalid crypto schema: {}", proto.schema.as_str()),
diff --git a/types/src/crypto.rs b/types/src/crypto.rs
index 41d0b80..6399bdb 100644
--- a/types/src/crypto.rs
+++ b/types/src/crypto.rs
@@ -11,12 +11,12 @@ const AES_GCM_256_IV_LENGTH: usize = 12;
 
 #[derive(Default, Debug, Serialize, Deserialize)]
 pub struct AesGcm256CryptoInfo {
-    pub key: [u8; 32],
-    pub iv: [u8; 12],
+    pub key: [u8; AES_GCM_256_KEY_LENGTH],
+    pub iv: [u8; AES_GCM_256_IV_LENGTH],
 }
 
 impl AesGcm256CryptoInfo {
-    pub fn try_new(key: &[u8], iv: &[u8]) -> anyhow::Result<Self> {
+    pub fn new(key: &[u8], iv: &[u8]) -> anyhow::Result<Self> {
         anyhow::ensure!(
             key.len() == AES_GCM_256_KEY_LENGTH,
             "Invalid key length for AesGcm256: {}",
@@ -55,7 +55,7 @@ pub struct AesGcm128CryptoInfo {
 }
 
 impl AesGcm128CryptoInfo {
-    pub fn try_new(key: &[u8], iv: &[u8]) -> anyhow::Result<Self> {
+    pub fn new(key: &[u8], iv: &[u8]) -> anyhow::Result<Self> {
         anyhow::ensure!(
             key.len() == AES_GCM_128_KEY_LENGTH,
             "Invalid key length for AesGcm128: {}",
@@ -94,7 +94,7 @@ pub struct TeaclaveFileRootKey128 {
 }
 
 impl TeaclaveFileRootKey128 {
-    pub fn try_new(key: &[u8]) -> anyhow::Result<Self> {
+    pub fn new(key: &[u8]) -> anyhow::Result<Self> {
         anyhow::ensure!(
             key.len() == TEACLAVE_FILE_ROOT_KEY_128_LENGTH,
             "Invalid key length for teaclave_file_root_key_128: {}",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to