-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
d7c6fd0
commit df6cb66
Showing
2 changed files
with
114 additions
and
0 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 @@ | ||
test_that("envelope with Kyber512", { | ||
|
||
key <- keygen_kyber(512) | ||
env <- envelope_create("Very important message.", key$public) | ||
|
||
expect_true(inherits(env, "pqcrypto_cms_id_enveloped_data")) | ||
expect_equal(length(env), 3) | ||
}) | ||
|
||
test_that("envelope with Kyber768", { | ||
|
||
key <- keygen_kyber(768) | ||
env <- envelope_create("Very important message.", key$public) | ||
|
||
expect_true(inherits(env, "pqcrypto_cms_id_enveloped_data")) | ||
expect_equal(length(env), 3) | ||
}) | ||
|
||
test_that("envelope with Kyber1024", { | ||
|
||
key <- keygen_kyber(1024) | ||
env <- envelope_create("Very important message.", key$public) | ||
|
||
expect_true(inherits(env, "pqcrypto_cms_id_enveloped_data")) | ||
expect_equal(length(env), 3) | ||
}) | ||
|
||
test_that("fails on bad parameters", { | ||
|
||
key <- keygen_kyber() | ||
expect_error(envelope_create("My Message.", key$private)) | ||
|
||
key <- keygen_dilithium() | ||
expect_error(envelope_create("My Message.", key$public)) | ||
|
||
}) |
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,78 @@ | ||
test_that("Open envelope Kyber512", { | ||
|
||
key <- keygen_kyber(512) | ||
|
||
env <- envelope_create("My very important message.", key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, "My very important message.") | ||
|
||
env <- envelope_create(1234567890, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, 1234567890) | ||
|
||
env <- envelope_create(TRUE, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, TRUE) | ||
|
||
obj <- data.frame(x = 1:3, y = letters[1:3]) | ||
env <- envelope_create(obj, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, obj) | ||
}) | ||
|
||
test_that("Open envelope Kyber768", { | ||
|
||
key <- keygen_kyber(768) | ||
|
||
env <- envelope_create("My very important message.", key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, "My very important message.") | ||
|
||
env <- envelope_create(1234567890, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, 1234567890) | ||
|
||
env <- envelope_create(TRUE, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, TRUE) | ||
|
||
obj <- data.frame(x = 1:3, y = letters[1:3]) | ||
env <- envelope_create(obj, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, obj) | ||
}) | ||
|
||
test_that("Open envelope Kyber1024", { | ||
|
||
key <- keygen_kyber(1024) | ||
|
||
env <- envelope_create("My very important message.", key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, "My very important message.") | ||
|
||
env <- envelope_create(1234567890, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, 1234567890) | ||
|
||
env <- envelope_create(TRUE, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, TRUE) | ||
|
||
obj <- data.frame(x = 1:3, y = letters[1:3]) | ||
env <- envelope_create(obj, key$public) | ||
msg <- envelope_open(env, key$private) | ||
expect_identical(msg, obj) | ||
}) | ||
|
||
test_that("Failure on wrong data", { | ||
|
||
key <- keygen_kyber(512) | ||
env <- envelope_create("My very important message.", key$public) | ||
|
||
expect_error(envelope_open(env, key$public)) | ||
expect_error(envelope_open("not_an_envelope", key$public)) | ||
|
||
key <- keygen_dilithium() | ||
expect_error(envelope_open(env, key$private)) | ||
|
||
}) |