From 7ae535f5f0cb9750ea13a7c4efa0a4d1a0ba834f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Gon=C3=A7alves?= Date: Sun, 24 Sep 2023 21:52:18 +0200 Subject: [PATCH] Add new tests and fix 2 of the existing ones. --- tests/testthat/_snaps/key_write.md | 177 +++++++++++++++++++++++++ tests/testthat/test-decap_kyber.R | 6 + tests/testthat/test-encap_kyber.R | 5 + tests/testthat/test-key_write.R | 12 ++ tests/testthat/test-sign_dillitium.R | 2 +- tests/testthat/test-sign_sphincs.R | 2 +- tests/testthat/test-verify_dilithium.R | 6 + tests/testthat/test-verify_sphincs.R | 6 + tests/testthat/testdata/key | Bin 0 -> 2842 bytes 9 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 tests/testthat/_snaps/key_write.md create mode 100644 tests/testthat/testdata/key diff --git a/tests/testthat/_snaps/key_write.md b/tests/testthat/_snaps/key_write.md new file mode 100644 index 0000000..c511cac --- /dev/null +++ b/tests/testthat/_snaps/key_write.md @@ -0,0 +1,177 @@ +# Display sample key + + Code + write_key(key, NULL) + Output + -----BEGIN PRIVATE KEY----- + MIIJpQIBADASBg4rBgEEAYOoeAWOQwEBAgUABIIJYAC3S+CnQiQksKYiYn9jshHE + kOk0P1com0rokhFaaVxFOaNRdOkSefRnPkxbbytZk20KrWmiWj51Q2bikOUKOsXR + fyPmZo76PfEjUe7DjwRIrLpAX2SFznx8a9wCUEBbTbW2MNl2JaPSSZwFTB6zRaCg + DWBLJZfcXo48FophFFybu5Ippp/EkXrxmjuVJXXEQOLHCLhmRAx7v1T6MCmLc3FK + ZPzck+hVP6P8Vhr4xtc3h0Acdm5sjxdVu8pHseDxLWUTDCJWFvG4jZ3ReDIZrk0J + HaZMBrujNyiRZMTKZafbeHeMJrchzqYwvaNylWrcWXfUZQxUufSCFNdaczdTlhYy + L9pUB/mJgekSMtUGiv62MVLXP1uqcY9EJ8DBlzmhl/vKq+ZRANsHkaL2bIdrMJwZ + J50cKhxUgZ2G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XfwJ6VeH89qCLJd8Jz6KPrQnq96r71QYvzZSwtYZ4q + QA5k/JofjHeJslpk5Rz7u4UXF0NV9i4kFaFzKpDdtptfyHta5aCnCWQoRaMSQYBn + QMAoB3BNN1aqEa4Uu8rTxyYqK7cv+bkXnIQEQVBVwxm8rH6EiU4BimSxzAng23NY + MGA/mcYtkgsw0S2POFQGsBGk/M2E2iZtdoQ1dYJw6oTPhAjeZ4mr5c6b8Qz59yyD + kMW4MBna97GMCboFFW9Ohbo32QN1ZyRvhYz9cc5qSTicghPV+++pfZKnMT8zwI8A + DXfoT4V8v7kRk3X+QQ== + -----END PUBLIC KEY----- + Code + write_key(key$private, NULL) + Output + -----BEGIN PRIVATE KEY----- + MIIJpQIBADASBg4rBgEEAYOoeAWOQwEBAgUABIIJYAC3S+CnQiQksKYiYn9jshHE + kOk0P1com0rokhFaaVxFOaNRdOkSefRnPkxbbytZk20KrWmiWj51Q2bikOUKOsXR + fyPmZo76PfEjUe7DjwRIrLpAX2SFznx8a9wCUEBbTbW2MNl2JaPSSZwFTB6zRaCg + DWBLJZfcXo48FophFFybu5Ippp/EkXrxmjuVJXXEQOLHCLhmRAx7v1T6MCmLc3FK + ZPzck+hVP6P8Vhr4xtc3h0Acdm5sjxdVu8pHseDxLWUTDCJWFvG4jZ3ReDIZrk0J + HaZMBrujNyiRZMTKZafbeHeMJrchzqYwvaNylWrcWXfUZQxUufSCFNdaczdTlhYy + L9pUB/mJgekSMtUGiv62MVLXP1uqcY9EJ8DBlzmhl/vKq+ZRANsHkaL2bIdrMJwZ + J50cKhxUgZ2GYFd5FRbXL9fcjq7gRkwJzu9bG1CDhhM5XHWBVLQJd2wcSVDRBtzp + mxliNjJkkqrIoPSTMvNTq9jbWzjVlXAoS4dsdo7lhDBczmP6YO3MpRrIlDFxQUkj + hJLIoGq5WLeFNak1r1GFWoD2jGFie/aZGHipTifzbp3WanU1kstsb6xBt0PMNeej + Fs4mYrYihb3qNH1jO+cGCYPFwKUrVIMjqwv8JQ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pnc2pE0rHCI2MTUqGi7VLnEosM/kyAuKJbEhZMx8kSjwGyDVS6Ymf7q6JVhA + O9Z8YDVLiVcbj7TpRO28Nm9MBd/AnpV4fz2oIsl3wnPoo+tCer3qvvVBi/NlLC1h + nipADmT8mh+Md4myWmTlHPu7hRcXQ1X2LiQVoXMqkN22m1/Ie1rloKcJZChFoxJB + gGdAwCgHcE03VqoRrhS7ytPHJiorty/5uRechARBUFXDGbysfoSJTgGKZLHMCeDb + c1gwYD+Zxi2SCzDRLY84VAawEaT8zYTaJm12hDV1gnDqhM+ECN5niavlzpvxDPn3 + LIOQxbgwGdr3sYwJugUVb06FujfZA3VnJG+FjP1xzmpJOJyCE9X776l9kqcxPzPA + jwANd+hPhXy/uRGTdf5BTTMjYhTT/wxd5yFgK3O45M5PjmvzbrrMeF4GKEND0OHK + PJCwXdXFhxB+LXign3jeYpbxaIp+f2Wszn40NBRgeDAoMCYGA1UdDgEBAAQc5FtV + U3I6p8F05mM0AM6hQ/RA7l9l3Pmh0ma5bQ== + -----END PRIVATE KEY----- + Code + write_key(key$public, NULL) + Output + -----BEGIN PUBLIC KEY----- + MIIEuTASBg4rBgEEAYOoeAWOQwEBAgUAA4IEoQDhfDz8CaZNOxoP9cPinCVMbCEu + /AM7uldKhQ1Va0Cg1VF0OksD+Q3U5S30sKq8OovRlj7MBBZug0B89jwSBCI+e3rG + 8aQ1sJX9gYNEUptfdjYLzCyv5LFdBsfvpXf4EQZ84CO0Npq8TIryE3n3+VjR+QEB + 65WoIKfGeDrxw4mPMDkq5SwdoqpdB4M9EZ7RMpRSA8srDLK+OE+hRAdmSTuD7HKv + FrP9QaS1s3tRyBrohra3UwSemcxx/B57x3ZSdg5ZEiNoJrkHi1IGG1TkUpRWd1XA + e4Jb4UVywX/A0GDQMcF2Ww85uh0goY5vwjTTp5DtcGKlCCqggwglTGakoGIWBgcw + XEDQ5nobC2kvyXGg6WlIzF5KEyBE+5pgZw73F1dhNcBTknRiwjTBUmakqp2L5jFO + E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E2iZtdoQ1dYJw6oTPhAjeZ4mr5c6b8Qz59yyD + kMW4MBna97GMCboFFW9Ohbo32QN1ZyRvhYz9cc5qSTicghPV+++pfZKnMT8zwI8A + DXfoT4V8v7kRk3X+QQ== + -----END PUBLIC KEY----- + diff --git a/tests/testthat/test-decap_kyber.R b/tests/testthat/test-decap_kyber.R index ac74a03..d3b13d5 100644 --- a/tests/testthat/test-decap_kyber.R +++ b/tests/testthat/test-decap_kyber.R @@ -72,6 +72,7 @@ test_that("kyber-x decapsulation fails on wrong parameter", { # Bad key expect_error(decap_kyber(ss$encapsulation, "not_a_key")) + # wrong family manipulated_key <- key attr(manipulated_key$private, "algorithm") <- "1.3.6.1.4.1.54392.5.1859.0" expect_error(decap_kyber(ss$encapsulation, manipulated_key$private)) @@ -79,6 +80,11 @@ test_that("kyber-x decapsulation fails on wrong parameter", { invalid_key_algo <- keygen_dilithium() expect_error(decap_kyber(ss$encapsulation, invalid_key_algo$private)) # invalid algorithm + # undefined algorithm, on the right 'family' + manipulated_key <- key + attr(manipulated_key$private, "algorithm") <- "1.3.6.1.4.1.54392.5.1859.1.1.99" + expect_error(decap_kyber(ss$encapsulation, manipulated_key$private)) + # Bad encapsulation bad_encapsulation <- as.integer(runif(768, 0, 256)) # wrong type, right size expect_error(decap_kyber(bad_encapsulation, key$private)) diff --git a/tests/testthat/test-encap_kyber.R b/tests/testthat/test-encap_kyber.R index 1478d5c..8debde2 100644 --- a/tests/testthat/test-encap_kyber.R +++ b/tests/testthat/test-encap_kyber.R @@ -40,6 +40,11 @@ test_that("kyber-x encapsulation fails on wrong parameter", { attr(manipulated_key$public, "algorithm") <- "1.3.6.1.4.1.54392.5.1859.0" expect_error(encap_kyber(manipulated_key$public)) + # undefined algorithm, on the right 'family' + manipulated_key <- key + attr(manipulated_key$public, "algorithm") <- "1.3.6.1.4.1.54392.5.1859.1.1.99" + expect_error(encap_kyber(manipulated_key$public)) + invalid_key_algo <- keygen_dilithium() expect_error(encap_kyber(invalid_key_algo$public)) # invalid algorithm }) diff --git a/tests/testthat/test-key_write.R b/tests/testthat/test-key_write.R index a4851bc..2fbb923 100644 --- a/tests/testthat/test-key_write.R +++ b/tests/testthat/test-key_write.R @@ -126,3 +126,15 @@ test_that("Write Sphincs+ key-pair", { expect_error(write_key("not_a_key", path)) expect_error(write_key(key, "not_a_path")) }) + +test_that("Display sample key", { + + key <- readRDS(test_path("testdata", "key")) + + expect_snapshot({ + write_key(key, NULL) + write_key(key$private, NULL) + write_key(key$public, NULL) + }) + +}) diff --git a/tests/testthat/test-sign_dillitium.R b/tests/testthat/test-sign_dillitium.R index 5f929b8..c700c80 100644 --- a/tests/testthat/test-sign_dillitium.R +++ b/tests/testthat/test-sign_dillitium.R @@ -88,6 +88,6 @@ test_that("Dilithium digital signature fails on wrong parameters", { small_key <- key$private[1:25] class(small_key) <- "pqcrypto_private_key" - attr(small_key, "algorithm") <- "dilithium" + attr(small_key, "algorithm") <- "1.3.6.1.4.1.54392.5.1859.1.2.1" expect_error(sign_dilithium(small_key, "text_message")) # c++ error }) diff --git a/tests/testthat/test-sign_sphincs.R b/tests/testthat/test-sign_sphincs.R index ce3b82f..d7035df 100644 --- a/tests/testthat/test-sign_sphincs.R +++ b/tests/testthat/test-sign_sphincs.R @@ -312,6 +312,6 @@ test_that("Sphincs+ digital signature fails on wrong parameters", { small_key <- key$private[1:25] class(small_key) <- "pqcrypto_private_key" - attr(small_key, "algorithm") <- "sphincs+" + attr(small_key, "algorithm") <- "1.3.6.1.4.1.54392.5.1859.1.3.11" expect_error(sign_sphincs(small_key, "text_message")) # wrong key size }) diff --git a/tests/testthat/test-verify_dilithium.R b/tests/testthat/test-verify_dilithium.R index 6616246..cd03d76 100644 --- a/tests/testthat/test-verify_dilithium.R +++ b/tests/testthat/test-verify_dilithium.R @@ -72,4 +72,10 @@ test_that("Digital signatures verification fails with bad parameters", { key <- keygen_kyber() expect_error(verify_dilithium(important_message, signature, key$public)) # bad key algorithm + + key <- keygen_sphincs() + expect_error(verify_dilithium(important_message, signature, key$public)) # bad key algorithm + + key <- keygen_dilithium() + expect_error(verify_dilithium(important_message, signature, key$public)) # mismatching key }) diff --git a/tests/testthat/test-verify_sphincs.R b/tests/testthat/test-verify_sphincs.R index 35c9330..12ea02c 100644 --- a/tests/testthat/test-verify_sphincs.R +++ b/tests/testthat/test-verify_sphincs.R @@ -246,4 +246,10 @@ test_that("Sphincs+ digital signatures verification fails with bad parameters", key <- keygen_dilithium() expect_error(verify_sphincs(important_message, signature, key$public)) # bad key algorithm + key <- keygen_kyber() + expect_error(verify_sphincs(important_message, signature, key$public)) # bad key algorithm + + key <- keygen_sphincs() + expect_error(verify_sphincs(important_message, signature, key$public)) # mismatching key + }) diff --git a/tests/testthat/testdata/key b/tests/testthat/testdata/key new file mode 100644 index 0000000000000000000000000000000000000000..9c4bfacc618c7f9186247762b44b667a3a680288 GIT binary patch literal 2842 zcmV+#3+415iwFP!000001MQc4Jk$Fh$Hy3p%4Nu{MDENs8)i<7Q9`-QB`Vw8@5VNB zDY7k$&@ytVCYK4PsN6;(Ldzk?QEsPGqR{DdM1`FC>70J&((mzmJbr)v{^)_o z=ly+u-mlMJ&(G`QvjqSE00Ck^5dctpGX#ix;vI}FHgod7{{R4GHfIrl7y!IE??Av1 zrp7R|F#?H)TUa9DmI!mGnVG3C03as%w>k-GbQs;A62BR4`;^8`;53>Rq|s;n!jM+41B9fg96j=RK_}HoR0; z`yQHS*r?H>BlDCz+lBiYA1@gP$xCZ`DK531K0iW7C|_{_t5-XN+AGZU&II-fgZNYQ zgdClg-9y!|n-y`~@ae+|KLknR+g8#c4}Ig!Jqi^OCX;xHwXBm1a)>by`$IF_{h_sA zEjbUT+tpo!E-!j7tb67Ln36bi>1||21guP1_q>{c8vf+@Qv~ls1;vLZ52tglJa%vf z554kJb!D8AM<1b{#NPlXM5;Nuj)0~YN|i}wh(J#50B_|iV%ei^e9F&aj2o-xlo3hG zonyj|33i0SVt`;XMh*p=F`GLT}EAXWBI1N%^{MK-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