Skip to content

Commit

Permalink
unit test longer alibaba quote
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Sep 13, 2023
1 parent a17fce9 commit 3786009
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions teerex/sgx-verify/src/test_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ pub mod dcap {
];
pub const TEST1_DCAP_QUOTE_MRENCLAVE: [u8; 32] =
hex!("6f90120b5c1f03619112eac855e29d6e0be4f35b2902aa169affff7719277ebc");

// reproduce error for alibaba machine https://github.com/integritee-network/attesteer/issues/18
pub const TEST2_DCAP_QUOTE: [u8; 4730] = hex!("030002000000000009000e00939a7233f79c4ca9940a0db3957f0607da9377f95a1d5206b7a4febf23cbeb78000000000c0c100fffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000e70000000000000021f21b2c3a7db9bff95e96a391182fc79adb14f1e7251f3398aa9430c3c47f21000000000000000000000000000000000000000000000000000000000000000032dd20d9a859a4098ef221c9397573ee330fecbac79014b1fdf85c9d9194e5e40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c6100000b9a6b0efea12f4ac3d29a27498dec2166db8e02fbec7fc095acbc190e072bffdefd8b05df404ebbf23c54196b24e52d78acb75cd8b58dd008b63af19b449b08482bde232d5b01aed8aa6c1b36d44964d079894c484d25164f44854c3742d33015645e5ee1e11f404538888e5464c1b6b507b8edaa74d4fde1f32b25cbe3ba2d70c0c100fffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000001500000000000000e700000000000000192aa50ce1c0cef03ccf89e7b5b16b0d7978f5c2b1edcf774d87702e8154d8bf00000000000000000000000000000000000000000000000000000000000000008c4f5775d796503e96137f77c68a829a0056ac8ded70140b081b094490c57bff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023ff6fa0590a9036f3e3d2d68dec54299907c66ac5344c6c66ffa836078c1bc80000000000000000000000000000000000000000000000000000000000000000b0a5a8d2227b33084607dc4c4561127a93fea6d23ff839e37ae50d6017dfd530119f825ced65b1bc94689c9d8edec923d49f6b8ae7b2865ebb1fbae2821d8b2a2000000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f05005e0e00002d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d49494538544343424a69674177494241674955666455777976756c336c3255774c593670473646563245344b625577436759494b6f5a497a6a3045417749770a634445694d434147413155454177775a535735305a577767553064594946424453794251624746305a6d397962534244515445614d42674741315545436777520a535735305a577767513239796347397959585270623234784644415342674e564241634d43314e68626e526849454e7359584a684d51737743515944565151490a44414a445154454c4d416b474131554542684d4356564d774868634e4d6a4d774f444d784d446b304e444d7a5768634e4d7a41774f444d784d446b304e444d7a0a576a42774d534977494159445651514444426c4a626e526c624342545231676755454e4c49454e6c636e52705a6d6c6a5958526c4d526f77474159445651514b0a4442464a626e526c6243424462334a7762334a6864476c76626a45554d424947413155454277774c553246756447456751327868636d4578437a414a42674e560a4241674d416b4e424d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424e71310a6b2f396a32527335637630774c573870766279515846342b523555476650313777685756475236453162596e536f627662323649734932325453666a374373320a51545031716c585746756e764e513730616f6d6a67674d4f4d494944436a416642674e5648534d4547444157674253566231334e765276683655424a796454300a4d383442567776655644427242674e56485238455a4442694d47436758714263686c706f64485277637a6f764c32467761533530636e567a6447566b633256790a646d6c6a5a584d75615735305a577775593239744c334e6e6543396a5a584a3061575a7059324630615739754c3359304c33426a61324e796244396a595431770a624746305a6d397962535a6c626d4e765a476c755a7a316b5a584977485159445652304f4242594546474c4c2b6454396d72724d53687a5675412b534b3272370a6e352f774d41344741315564447745422f775145417749477744414d42674e5648524d4241663845416a41414d4949434f77594a4b6f5a496876684e415130420a424949434c444343416967774867594b4b6f5a496876684e41513042415151517173654b6158565a4b656c68436f304733393870347a434341575547436971470a534962345451454e41514977676746564d42414743797147534962345451454e415149424167454d4d42414743797147534962345451454e415149434167454d0a4d42414743797147534962345451454e41514944416745444d42414743797147534962345451454e41514945416745444d42454743797147534962345451454e0a41514946416749412f7a415242677371686b69472b4530424451454342674943415038774541594c4b6f5a496876684e4151304241676343415141774541594c0a4b6f5a496876684e4151304241676743415141774541594c4b6f5a496876684e4151304241676b43415141774541594c4b6f5a496876684e4151304241676f430a415141774541594c4b6f5a496876684e4151304241677343415141774541594c4b6f5a496876684e4151304241677743415141774541594c4b6f5a496876684e0a4151304241673043415141774541594c4b6f5a496876684e4151304241673443415141774541594c4b6f5a496876684e4151304241673843415141774541594c0a4b6f5a496876684e4151304241684143415141774541594c4b6f5a496876684e4151304241684543415130774877594c4b6f5a496876684e41513042416849450a4541774d4177502f2f7741414141414141414141414141774541594b4b6f5a496876684e4151304241775143414141774641594b4b6f5a496876684e415130420a4241514741474271414141414d41384743697147534962345451454e4151554b415145774867594b4b6f5a496876684e41513042426751512b4138382f7672380a4c643478644a7a5a7a5a78783844424542676f71686b69472b453042445145484d4459774541594c4b6f5a496876684e4151304242774542416638774541594c0a4b6f5a496876684e4151304242774942416638774541594c4b6f5a496876684e4151304242774d4241663877436759494b6f5a497a6a304541774944527741770a524149676554454b73645652783836654a2f67305073624366764462484953484e756f387a61466c6d464a6a302b774349436c78444e6433322f57752b6d584d0a68724d5277326a68356b2f3577694f2b72734f774d4969745575766c0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a2d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d4949436c6a4343416a32674177494241674956414a567658633239472b487051456e4a3150517a7a674658433935554d416f4743437147534d343942414d430a4d476778476a415942674e5642414d4d45556c756447567349464e48574342536232393049454e424d526f77474159445651514b4442464a626e526c624342440a62334a7762334a6864476c76626a45554d424947413155454277774c553246756447456751327868636d4578437a414a42674e564241674d416b4e424d5173770a435159445651514745774a56557a4165467730784f4441314d6a45784d4455774d5442614677307a4d7a41314d6a45784d4455774d5442614d484178496a41670a42674e5642414d4d47556c756447567349464e4857434251513073675547786864475a76636d306751304578476a415942674e5642416f4d45556c75644756730a49454e76636e4276636d4630615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b474131554543417743513045780a437a414a42674e5642415954416c56544d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741454e53422f377432316c58534f0a3243757a7078773734654a423732457944476757357258437478327456544c7136684b6b367a2b5569525a436e71523770734f766771466553786c6d546c4a6c0a65546d693257597a33714f42757a43427544416642674e5648534d4547444157674251695a517a575770303069664f44744a5653763141624f536347724442530a42674e5648523845537a424a4d45656752614244686b466f64485277637a6f764c324e6c636e52705a6d6c6a5958526c63793530636e567a6447566b633256790a646d6c6a5a584d75615735305a577775593239744c306c756447567355306459556d397664454e424c6d526c636a416442674e5648513445466751556c5739640a7a62306234656c4153636e553944504f4156634c336c517744675944565230504151482f42415144416745474d42494741315564457745422f7751494d4159420a4166384341514177436759494b6f5a497a6a30454177494452774177524149675873566b6930772b6936565947573355462f32327561586530594a446a3155650a6e412b546a44316169356343494359623153416d4435786b66545670766f34556f79695359787244574c6d5552344349394e4b7966504e2b0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a2d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d4949436a7a4343416a53674177494241674955496d554d316c71644e496e7a6737535655723951477a6b6e42717777436759494b6f5a497a6a3045417749770a614445614d4267474131554541777752535735305a5777675530645949464a766233516751304578476a415942674e5642416f4d45556c756447567349454e760a636e4276636d4630615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b47413155454341774351304578437a414a0a42674e5642415954416c56544d423458445445344d4455794d5445774e4455784d466f58445451354d54497a4d54497a4e546b314f566f77614445614d4267470a4131554541777752535735305a5777675530645949464a766233516751304578476a415942674e5642416f4d45556c756447567349454e76636e4276636d46300a615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b47413155454341774351304578437a414a42674e56424159540a416c56544d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414543366e45774d4449595a4f6a2f69505773437a61454b69370a314f694f534c52466857476a626e42564a66566e6b59347533496a6b4459594c304d784f346d717379596a6c42616c54565978465032734a424b357a6c4b4f420a757a43427544416642674e5648534d4547444157674251695a517a575770303069664f44744a5653763141624f5363477244425342674e5648523845537a424a0a4d45656752614244686b466f64485277637a6f764c324e6c636e52705a6d6c6a5958526c63793530636e567a6447566b63325679646d6c6a5a584d75615735300a5a577775593239744c306c756447567355306459556d397664454e424c6d526c636a416442674e564851344546675155496d554d316c71644e496e7a673753560a55723951477a6b6e4271777744675944565230504151482f42415144416745474d42494741315564457745422f7751494d4159424166384341514577436759490a4b6f5a497a6a3045417749445351417752674968414f572f35516b522b533943695344634e6f6f774c7550524c735747662f59693747535839344267775477670a41694541344a306c72486f4d732b586f356f2f7358364f39515778485241765a55474f6452513763767152586171493d0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a00");
pub const TEST2_DCAP_TIMESTAMP: u64 = 1693498018000;

#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
pub struct QuotingEnclave {
pub qe_identity_cert: &'static str,
Expand Down
12 changes: 11 additions & 1 deletion teerex/sgx-verify/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use crate::{
collateral::{EnclaveIdentitySigned, TcbInfoSigned},
test_data::{
consts::{TEST4_CERT, TEST4_MRENCLAVE, TEST4_SIGNER_PUB, TEST4_TIMESTAMP, TEST8_CERT},
dcap::{DCAP_QUOTE_CERT, PCK_CRL, QE_IDENTITY_CERT, TEST_VALID_COLLATERAL_TIMESTAMP},
dcap::{
DCAP_QUOTE_CERT, PCK_CRL, QE_IDENTITY_CERT, TEST2_DCAP_QUOTE, TEST2_DCAP_TIMESTAMP,
TEST_VALID_COLLATERAL_TIMESTAMP,
},
},
};
use codec::Decode;
Expand All @@ -39,6 +42,13 @@ fn verify_ias_report_should_work() {
assert_eq!(report.build_mode, SgxBuildMode::Debug);
}

#[test]
fn decode_dcap_quote_should_work() {
let quote_bytes = TEST2_DCAP_QUOTE.clone();
let quote: Result<DcapQuote, _> = Decode::decode(&mut quote_bytes.as_slice());
assert!(quote.is_ok());
}

#[test]
fn verify_zero_length_cert_returns_err() {
assert!(verify_ias_report(&Vec::new()[..]).is_err())
Expand Down

0 comments on commit 3786009

Please sign in to comment.