mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-27 05:38:02 +00:00
Add LMS import/export negative tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
This commit is contained in:
parent
4511055511
commit
f9b8502865
tests/suites
@ -224,11 +224,51 @@ LMS negative test (invalid leaf ID)
|
||||
lms_verify_test:"bfff9cd687351db88a98c71fd2f9b927a0ee600130a112533b791041d30cb91665fc369a5ac7cc9a04547414ac45288081d19d4a600579c73ac4bc953de03ad6":"0000040000000004e474c96c496b231ecedcd92566ab3e1cdfac83f7e56abaae6571401e212e59bdbcc18105e0709249510d13d7ae1091558c217033316ac70a36aae764bd0f4032e369453c634b81061079d216d03d3c55976a1aabc00287b307297ae03587ba20839460daae85d26dfcef7638c10a1d8559612e5e9ced1a4205a52ca0ce88e58602e59cf9ab34adf2e958e56570573297b99f733fbbf58d2440526fd4dc15c5509e8a11405f6c08772abcf58731fbf9a73642670e3247c5f70905f0fa81f6174bf32977209923507525a170fcd260e81f04193583fbcd305ac245c80eb337ca326fd1105e73748fab8a1f0c8d8a99f011718e7aae027a34d2a85ff18769fa277810126a86b51b096a04d8e28a4fb8c5e14e50a67cb1ee88e43e5cc077902442f5d9c55ac2b8acdd76c67bc740c6083aba4e3cb404c23f1f3118337563fef6a4b01fb476810c5b5682d0aecdccd55c85a4af50e9150f7d83dcccd8e822a302e6e5a52e00505e6e65338dcfb9cfbe22594e9e18ebde36af29450c5ea31523019cf64fd6eca8c77d98c2a146dcedd51bf6c61c1f7cacbce3ab20c8606930cc42737e17f2703cf0980aef560768d1ac5585c05a60a5f94db15f5ac4d4df5cbd81430878d4e9b77346e3a6538b80b80873e3e6c37860470091979296631440adb8cc71991aba2a4dd2884764878306fe774a25512cfbf080f2829ea2903ffa748dd187c21aef918ee3436a1bd336c3d09cc1f748d7528db90a98f69078b82c4d23de7bcec092a292d2b8cac71a5c87d008f128b89a5e608a4501aef41e9f17e4056ed4767957188f780159daebf327751386980b0fca5a2d36b141acff957f46ce2381897099619475db9d3a613e7ef98b056f42b4d6eafb1d62eebbe46a7502f893fbd36ccfb12a280f45ffb93f050eb280bf0a6cd640abdea8590bffb98bdb29ee3a31daa0fa3ab35fee11dc1b7d1fcea82b0e284b2e35b34e77c3f401ed887e7fc6c97b327f76f99caca2f355afa2753a8923bfb06fb2a9df08d31c93882e34ef5a3cccc9d078855334bdf909ae418b177724c42fb1d586d212c4474932acce295236030f4379158957300fe9fdc5cc9145e3ded50cf9f5a8e19321961536c4a47fffc3eb4383fb78a5d2aeed5b45b92132b5e2a53e3b67841fa2e1bd217ee2c30812c4eb1bd4f8c85b328e23d27f12a2fad5c6b236c87f8fd1aad441416e53ebd4d45d4bf601b94eb37dc9a065218ae58e69dba1250bb20626baeda961b3ef11d217697e73f41fa3870d726a032bc4a388fb12c023822945df058e22f54e5f6377eab34297c57883515204fc189d0d4b0ad9bacb24acf7f9d55e7c6368bb8ababd7622f586ec22683306c5d88d5244219a3952adbd85c89893a441a58b532e15600cd5afdbb5b441e1670b72656c7995189bdf993154e09912db8c4ddaff0e75591720230cf99c8b71cd841dffc4372c5e0f9ff906a379d28d6884351609bf7c849ebfabfb049ae986bbb8467251dbf5ccdd05a86ff6ce1392f7ca1bd49595ad9ad805d71b389afab1865f7f69dc24662af19934f025ced212536509500c132aec000000068b991bed50319a6cb9ff040b92f1563889b3787c37145fc9737d4643f66ade33ebd85a2c29b8c64a581cff01b89d59807d6fade2d2c88872f77d0ed83d97c4b5438681d0b95feb973125e4ee70ebe11699290b831e86571e36513a71f159d48ce563f6814cc2a89851d2520c5275b34cc83614cab14c0d197166580d800ee6b9004b8fd72daac8d73c36c1623c37be93ba49a06c4efde238a3a10a05daba5d4942f7de52648af2be31f33e723b3605346282f5d5e356c5d0004eea40fe0b80abf658f6c96c56319ab53d7fefb5879e0136d1cf320973a2f47c1ee3d21554910f09d17afac4607657c4309890957a4954bf86e2a8491ba37dd88b2c3fe3c7edebd767c400bc23e40d165b27133c726b90bc26cbb2a86a6aa400c47aa7ffc538388de8490b9349afa53b814ffe2a56ff16a496e9648284193754f989f6f12aeb6e":"0000000600000004d96bb26744d99ef624e32161c36d3d6efcdd0484e2b17a6dd183125be4b1af1cda931a91a3acb1151877c174f7943fd9":MBEDTLS_ERR_LMS_VERIFY_FAILED
|
||||
|
||||
LMS import/export test
|
||||
# This test uses a randomly generated LMS public key. It imports the key, and
|
||||
# then exports it, and verifies that the exported key is identical to the
|
||||
# original key. It also tests handling of too-small key export buffers.
|
||||
lms_import_export_test:"0000000600000004d96bb26744d99ef624e32161c36d3d6efcdd0484e2b17a6dd183125be4b1af1cda931a91a3acb1151877c174f7943fd9":0
|
||||
# This test uses the key from hsslms interop test 1, imports it, exports it and
|
||||
# tests that it is the same. It also checks if the export correctly fail when
|
||||
# the buffer is too small.
|
||||
lms_import_export_test:"000000060000000447cc5b29dd0cecd01c382434a6d16864d51b60cdb2a9eed2419015d8524c717ce38a865d7a37da6c84f94621ad595f5d":0
|
||||
|
||||
LMS import/export negative test #1
|
||||
# This test uses the randomly generated LMS public key
|
||||
lms_import_export_test:"0000000600000004d96bb26744d99ef624e32161c36d3d6efcdd0484e2b17a6dd183125be4b1af1cda931a91a3acb1151877c174f7943fd9":0
|
||||
LMS key import too large key test
|
||||
# This test uses the valid public key for hsslms interop test 1, add an extra
|
||||
# byte, and then imports it. This should fail.
|
||||
lms_import_export_test:"000000060000000447cc5b29dd0cecd01c382434a6d16864d51b60cdb2a9eed2419015d8524c717ce38a865d7a37da6c84f94621ad595f5d00":MBEDTLS_ERR_LMS_BAD_INPUT_DATA
|
||||
|
||||
LMS key import too small key test
|
||||
# This test uses the valid public key for hsslms interop test 1, removes a byte,
|
||||
# and then imports it. This should fail.
|
||||
lms_import_export_test:"000000060000000447cc5b29dd0cecd01c382434a6d16864d51b60cdb2a9eed2419015d8524c717ce38a865d7a37da6c84f94621ad595f":MBEDTLS_ERR_LMS_BAD_INPUT_DATA
|
||||
|
||||
LMS key import no LMS type test
|
||||
# This test uses the valid public key for hsslms interop test 1, cuts it down so
|
||||
# it's smaller than the LMS type offset, and imports it. This should fail, and
|
||||
# not attempt to read invalidly outside the buffer.
|
||||
lms_import_export_test:"000000":MBEDTLS_ERR_LMS_BAD_INPUT_DATA
|
||||
|
||||
LMS key import no LMOTS type test
|
||||
# This test uses the valid public key for hsslms interop test 1, cuts it down so
|
||||
# it's smaller than the LMOTS type offset, and imports it. This should fail, and
|
||||
# not attempt to read invalidly outside the buffer.
|
||||
lms_import_export_test:"00000006000000":MBEDTLS_ERR_LMS_BAD_INPUT_DATA
|
||||
|
||||
LMS key import invalid LMS type test #1
|
||||
# This test uses the valid public key for hsslms interop test 1, alters the
|
||||
# LMS type to 0x7, and imports it. This should fail.
|
||||
lms_import_export_test:"000000050000000447cc5b29dd0cecd01c382434a6d16864d51b60cdb2a9eed2419015d8524c717ce38a865d7a37da6c84f94621ad595f5d":MBEDTLS_ERR_LMS_BAD_INPUT_DATA
|
||||
|
||||
LMS key import invalid LMS type test #2
|
||||
# This test uses the valid public key for hsslms interop test 1, alters the
|
||||
# LMS type to 0x5, and imports it. This should fail, and not attempt to read
|
||||
# invalidly outside the buffer.
|
||||
lms_import_export_test:"000000070000000447cc5b29dd0cecd01c382434a6d16864d51b60cdb2a9eed2419015d8524c717ce38a865d7a37da6c84f94621ad595f5d":MBEDTLS_ERR_LMS_BAD_INPUT_DATA
|
||||
|
||||
LMS key import invalid LMOTS type test #1
|
||||
# This test uses the valid public key for hsslms interop test 1, alters the
|
||||
# LMS type to 0x7, and imports it. This should fail.
|
||||
lms_import_export_test:"000000060000000347cc5b29dd0cecd01c382434a6d16864d51b60cdb2a9eed2419015d8524c717ce38a865d7a37da6c84f94621ad595f5d":MBEDTLS_ERR_LMS_BAD_INPUT_DATA
|
||||
|
||||
LMS key import invalid LMOTS type test #2
|
||||
# This test uses the valid public key for hsslms interop test 1, alters the
|
||||
# LMS type to 0x5, and imports it. This should fail, and not attempt to read
|
||||
# invalidly outside the buffer.
|
||||
lms_import_export_test:"000000060000000547cc5b29dd0cecd01c382434a6d16864d51b60cdb2a9eed2419015d8524c717ce38a865d7a37da6c84f94621ad595f5d":MBEDTLS_ERR_LMS_BAD_INPUT_DATA
|
||||
|
@ -157,7 +157,8 @@ void lms_import_export_test ( data_t * pub_key, int expected_import_rc )
|
||||
unsigned char *exported_pub_key = NULL;
|
||||
|
||||
mbedtls_lms_public_init(&ctx);
|
||||
TEST_EQUAL( mbedtls_lms_import_public_key( &ctx, pub_key->x, pub_key->len ), 0 );
|
||||
TEST_EQUAL( mbedtls_lms_import_public_key( &ctx, pub_key->x, pub_key->len ),
|
||||
expected_import_rc );
|
||||
|
||||
if( expected_import_rc == 0 )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user