Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
improve ring aead implementation, Fix #38
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoyuxlu <xiaoyu1.lu@intel.com>
  • Loading branch information
xiaoyuxlu committed Aug 15, 2023
1 parent ee0a962 commit 9bd7c37
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions spdmlib/src/crypto/spdm_ring/aead_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ fn encrypt(
d.copy_from_slice(&iv.data[..ring::aead::NONCE_LEN]);
let nonce = ring::aead::Nonce::assume_unique_for_key(d);

let mut in_out = BytesMutStrubbed::new();
in_out.extend_from_slice(plain_text);
cipher_text.copy_from_slice(plain_text);

let mut s_key: ring::aead::SealingKey<OneNonceSequence> =
if let Ok(k) = make_key(aead_algo, key, nonce) {
k
} else {
return Err(SPDM_STATUS_CRYPTO_ERROR);
};
match s_key.seal_in_place_append_tag(ring::aead::Aad::from(aad), &mut in_out) {
Ok(()) => {
cipher_text.copy_from_slice(&in_out[..plain_text_size]);
tag.copy_from_slice(&in_out[plain_text_size..(plain_text_size + tag_size)]);

match s_key.seal_in_place_separate_tag(ring::aead::Aad::from(aad), cipher_text) {
Ok((t)) => {

Check warning on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

unnecessary parentheses around pattern

Check failure on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

unnecessary parentheses around pattern

Check warning on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / Format

unnecessary parentheses around pattern

Check failure on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / Clippy

unnecessary parentheses around pattern

Check warning on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

unnecessary parentheses around pattern

Check failure on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

unnecessary parentheses around pattern

Check warning on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / Format

unnecessary parentheses around pattern

Check failure on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / Clippy

unnecessary parentheses around pattern

Check warning on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / fuzzing_test (false, false)

unnecessary parentheses around pattern

Check warning on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / fuzzing_test (true, true)

unnecessary parentheses around pattern

Check warning on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / fuzzing_test (true, false)

unnecessary parentheses around pattern

Check warning on line 59 in spdmlib/src/crypto/spdm_ring/aead_impl.rs

View workflow job for this annotation

GitHub Actions / fuzzing_test (false, true)

unnecessary parentheses around pattern
tag.copy_from_slice(t.as_ref());
Ok((plain_text_size, tag_size))
}
Err(_) => Err(SPDM_STATUS_CRYPTO_ERROR),
Expand Down

0 comments on commit 9bd7c37

Please sign in to comment.