Tidied up and added tests for RSA operations

This commit is contained in:
n1474335 2021-02-01 19:15:32 +00:00
parent 99eb1cced5
commit 74ae77f17a
11 changed files with 70 additions and 50 deletions

View file

@ -101,12 +101,11 @@ import "./tests/CipherSaber2.mjs";
import "./tests/Colossus.mjs";
import "./tests/ParseObjectIDTimestamp.mjs";
import "./tests/Unicode.mjs";
import "./tests/RSA.mjs";
// Cannot test operations that use the File type yet
// import "./tests/SplitColourChannels.mjs";
// Cannot test as minified forge does not support node
// import "./tests/RSA.mjs";
const testStatus = {
allTestsPassing: true,
counts: {

View file

@ -1,3 +1,12 @@
/**
* Various types of input data for use in tests
*
* @author n1474335 [n1474335@gmail.com]
* @author Matt C [me@mitt.dev]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
export const ASCII_TEXT = "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.";
export const UTF8_TEXT = "Шанцы на высвятленне таго, што адбываецца на самай справе ў сусвеце настолькі выдаленыя, адзінае, што трэба зрабіць, гэта павесіць пачуццё яго і трымаць сябе занятымі.";

View file

@ -79,8 +79,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, UTF-8",
input: UTF8_TEXT,
expectedOutput: UTF8_TEXT,
input: UTF8_TEXT.substr(0, 100),
expectedOutput: UTF8_TEXT.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -94,8 +94,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, All bytes",
input: ALL_BYTES,
expectedOutput: ALL_BYTES,
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -139,8 +139,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, UTF-8",
input: UTF8_TEXT,
expectedOutput: UTF8_TEXT,
input: UTF8_TEXT.substr(0, 100),
expectedOutput: UTF8_TEXT.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -154,8 +154,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, All bytes",
input: ALL_BYTES,
expectedOutput: ALL_BYTES,
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -199,8 +199,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, UTF-8",
input: UTF8_TEXT,
expectedOutput: UTF8_TEXT,
input: UTF8_TEXT.substr(0, 100),
expectedOutput: UTF8_TEXT.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -214,8 +214,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, All bytes",
input: ALL_BYTES,
expectedOutput: ALL_BYTES,
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -259,8 +259,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, UTF-8",
input: UTF8_TEXT,
expectedOutput: UTF8_TEXT,
input: UTF8_TEXT.substr(0, 80),
expectedOutput: UTF8_TEXT.substr(0, 80),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -274,8 +274,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, All bytes",
input: ALL_BYTES,
expectedOutput: ALL_BYTES,
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -304,8 +304,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, ASCII",
input: ASCII_TEXT,
expectedOutput: ASCII_TEXT,
input: ASCII_TEXT.substr(0, 100),
expectedOutput: ASCII_TEXT.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -319,8 +319,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, UTF-8",
input: UTF8_TEXT,
expectedOutput: UTF8_TEXT,
input: UTF8_TEXT.substr(0, 60),
expectedOutput: UTF8_TEXT.substr(0, 60),
recipeConfig: [
{
"op": "RSA Encrypt",
@ -334,8 +334,8 @@ TestRegister.addTests([
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, All bytes",
input: ALL_BYTES,
expectedOutput: ALL_BYTES,
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",