-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
272 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
use crate::crypto::SpdmAead; | ||
use crate::error::{SpdmResult}; | ||
|
||
use crate::protocol::{SpdmAeadAlgo, SpdmAeadIvStruct, SpdmAeadKeyStruct}; | ||
|
||
pub static DEFAULT: SpdmAead = SpdmAead { | ||
encrypt_cb: encrypt, | ||
decrypt_cb: decrypt, | ||
}; | ||
|
||
fn encrypt( | ||
aead_algo: SpdmAeadAlgo, | ||
key: &SpdmAeadKeyStruct, | ||
iv: &SpdmAeadIvStruct, | ||
aad: &[u8], | ||
plain_text: &[u8], | ||
tag: &mut [u8], | ||
cipher_text: &mut [u8], | ||
) -> SpdmResult<(usize, usize)> { | ||
unimplemented!() | ||
} | ||
|
||
fn decrypt( | ||
aead_algo: SpdmAeadAlgo, | ||
key: &SpdmAeadKeyStruct, | ||
iv: &SpdmAeadIvStruct, | ||
aad: &[u8], | ||
cipher_text: &[u8], | ||
tag: &[u8], | ||
plain_text: &mut [u8], | ||
) -> SpdmResult<usize> { | ||
unimplemented!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
use crate::crypto::{SpdmAsymVerify}; | ||
use crate::error::{SpdmResult}; | ||
use crate::protocol::{SpdmBaseAsymAlgo, SpdmBaseHashAlgo, SpdmSignatureStruct}; | ||
|
||
pub static DEFAULT: SpdmAsymVerify = SpdmAsymVerify { | ||
verify_cb: asym_verify, | ||
}; | ||
|
||
fn asym_verify( | ||
base_hash_algo: SpdmBaseHashAlgo, | ||
base_asym_algo: SpdmBaseAsymAlgo, | ||
public_cert_der: &[u8], | ||
data: &[u8], | ||
signature: &SpdmSignatureStruct, | ||
) -> SpdmResult { | ||
unimplemented!() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
use crate::crypto::SpdmCertOperation; | ||
use crate::error::{SpdmResult}; | ||
|
||
pub static DEFAULT: SpdmCertOperation = SpdmCertOperation { | ||
get_cert_from_cert_chain_cb: get_cert_from_cert_chain, | ||
verify_cert_chain_cb: verify_cert_chain, | ||
}; | ||
|
||
fn get_cert_from_cert_chain(cert_chain: &[u8], index: isize) -> SpdmResult<(usize, usize)> { | ||
unimplemented!() | ||
} | ||
|
||
fn verify_cert_chain(cert_chain: &[u8]) -> SpdmResult { | ||
unimplemented!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
extern crate alloc; | ||
use alloc::boxed::Box; | ||
|
||
use crate::crypto::{SpdmDhe, SpdmDheKeyExchange}; | ||
use crate::protocol::{SpdmDheAlgo, SpdmDheExchangeStruct, SpdmDheFinalKeyStruct}; | ||
use bytes::{BufMut, BytesMut}; | ||
|
||
pub static DEFAULT: SpdmDhe = SpdmDhe { | ||
generate_key_pair_cb: generate_key_pair, | ||
}; | ||
|
||
fn generate_key_pair( | ||
dhe_algo: SpdmDheAlgo, | ||
) -> Option<(SpdmDheExchangeStruct, Box<dyn SpdmDheKeyExchange + Send>)> { | ||
unimplemented!() | ||
} | ||
|
||
impl SpdmDheKeyExchange for SpdmDheKeyExchangeP256 { | ||
fn compute_final_key( | ||
self: Box<Self>, | ||
peer_pub_key: &SpdmDheExchangeStruct, | ||
) -> Option<SpdmDheFinalKeyStruct> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
struct SpdmDheKeyExchangeP256(); | ||
|
||
impl SpdmDheKeyExchangeP256 { | ||
fn generate_key_pair() -> Option<(SpdmDheExchangeStruct, Box<dyn SpdmDheKeyExchange + Send>)> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
struct SpdmDheKeyExchangeP384(); | ||
|
||
impl SpdmDheKeyExchange for SpdmDheKeyExchangeP384 { | ||
fn compute_final_key( | ||
self: Box<Self>, | ||
peer_pub_key: &SpdmDheExchangeStruct, | ||
) -> Option<SpdmDheFinalKeyStruct> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
impl SpdmDheKeyExchangeP384 { | ||
fn generate_key_pair() -> Option<(SpdmDheExchangeStruct, Box<dyn SpdmDheKeyExchange + Send>)> { | ||
unimplemented!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
|
||
use crate::crypto::SpdmHash; | ||
use crate::protocol::{SpdmBaseHashAlgo, SpdmDigestStruct}; | ||
|
||
#[cfg(not(feature = "hashed-transcript-data"))] | ||
pub static DEFAULT: SpdmHash = SpdmHash { | ||
hash_all_cb: hash_all, | ||
}; | ||
#[cfg(feature = "hashed-transcript-data")] | ||
pub static DEFAULT: SpdmHash = SpdmHash { | ||
hash_all_cb: hash_all, | ||
hash_ctx_init_cb: hash_ext::hash_ctx_init, | ||
hash_ctx_update_cb: hash_ext::hash_ctx_update, | ||
hash_ctx_finalize_cb: hash_ext::hash_ctx_finalize, | ||
hash_ctx_dup_cb: hash_ext::hash_ctx_dup, | ||
}; | ||
|
||
fn hash_all(base_hash_algo: SpdmBaseHashAlgo, data: &[u8]) -> Option<SpdmDigestStruct> { | ||
unimplemented!() | ||
} | ||
|
||
#[cfg(feature = "hashed-transcript-data")] | ||
mod hash_ext { | ||
use crate::error::{SpdmResult}; | ||
|
||
pub fn hash_ctx_update(handle: usize, data: &[u8]) -> SpdmResult { | ||
unimplemented!() | ||
} | ||
|
||
pub fn hash_ctx_finalize(handle: usize) -> Option<SpdmDigestStruct> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn hash_ctx_dup(handle: usize) -> Option<usize> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn hash_ctx_init(base_hash_algo: SpdmBaseHashAlgo) -> Option<usize> { | ||
unimplemented!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
use crate::crypto::SpdmHkdf; | ||
use crate::protocol::{ | ||
SpdmBaseHashAlgo, SpdmHkdfInputKeyingMaterial, SpdmHkdfOutputKeyingMaterial, | ||
SpdmHkdfPseudoRandomKey | ||
}; | ||
|
||
pub static DEFAULT: SpdmHkdf = SpdmHkdf { | ||
hkdf_extract_cb: hkdf_extract, | ||
hkdf_expand_cb: hkdf_expand, | ||
}; | ||
|
||
fn hkdf_extract( | ||
hash_algo: SpdmBaseHashAlgo, | ||
salt: &[u8], | ||
ikm: &SpdmHkdfInputKeyingMaterial, | ||
) -> Option<SpdmHkdfPseudoRandomKey> { | ||
unimplemented!() | ||
} | ||
|
||
fn hkdf_expand( | ||
hash_algo: SpdmBaseHashAlgo, | ||
prk: &SpdmHkdfPseudoRandomKey, | ||
info: &[u8], | ||
out_size: u16, | ||
) -> Option<SpdmHkdfOutputKeyingMaterial> { | ||
unimplemented!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
use crate::crypto::SpdmHmac; | ||
use crate::error::{SpdmResult}; | ||
use crate::protocol::{SpdmBaseHashAlgo, SpdmDigestStruct}; | ||
|
||
pub static DEFAULT: SpdmHmac = SpdmHmac { | ||
hmac_cb: hmac, | ||
hmac_verify_cb: hmac_verify, | ||
}; | ||
|
||
fn hmac(base_hash_algo: SpdmBaseHashAlgo, key: &[u8], data: &[u8]) -> Option<SpdmDigestStruct> { | ||
unimplemented!() | ||
} | ||
|
||
fn hmac_verify( | ||
base_hash_algo: SpdmBaseHashAlgo, | ||
key: &[u8], | ||
data: &[u8], | ||
hmac: &SpdmDigestStruct, | ||
) -> SpdmResult { | ||
unimplemented!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
pub mod aead_impl; | ||
pub mod asym_verify_impl; | ||
pub mod cert_operation_impl; | ||
pub mod dhe_impl; | ||
pub mod hash_impl; | ||
pub mod hkdf_impl; | ||
pub mod hmac_impl; | ||
pub mod rand_impl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
use crate::crypto::SpdmCryptoRandom; | ||
use crate::error::{SpdmResult}; | ||
|
||
pub static DEFAULT: SpdmCryptoRandom = SpdmCryptoRandom { | ||
get_random_cb: get_random, | ||
}; | ||
|
||
fn get_random(data: &mut [u8]) -> SpdmResult<usize> { | ||
unimplemented!() | ||
} |
Oops, something went wrong.