Verified Commit 4afbb024 authored by Samuel Elliott's avatar Samuel Elliott
Browse files

Move test data

parent 411e765f
......@@ -7,9 +7,7 @@ import {
efficientCharsSizes,
} from '../armor';
const INPUT_STRING = 'Two roads diverged in a yellow wood, and sorry I could not travel both\n' +
'and be one traveller, long I stood, and looked down one as far as I\n' +
'could, to where it bent in the undergrowth.';
import {INPUT_STRING} from './data/common';
test('round trip', () => {
const encoded = armor(INPUT_STRING);
......
export const INPUT_STRING =
'Two roads diverged in a yellow wood, and sorry I could not travel both\n' +
'and be one traveller, long I stood, and looked down one as far as I\n' +
'could, to where it bent in the undergrowth.';
import * as tweetnacl from 'tweetnacl';
export const KEYPAIR = tweetnacl.box.keyPair.fromSecretKey(Buffer.from(
'5046adc1dba838867b2bbbfdd0c3423e58b57970b5267a90f57960924a87f196', 'hex'));
export const KEYPAIR_ALICE = tweetnacl.box.keyPair.fromSecretKey(Buffer.from(
'5ce86efb75fa4e2c410f46e16de9f6acae1a1703528651b69bc176c088bef3ee', 'hex'));
export const KEYPAIR_BOB = tweetnacl.box.keyPair.fromSecretKey(Buffer.from(
'aa3c626bc9c38c8c201878ebb1d5b0b50ac40e8986c78793db1d4ef369fca1ce', 'hex'));
export const KEYPAIR_MALLORY = tweetnacl.box.keyPair.fromSecretKey(Buffer.from(
'98aebbb178a551876bfaf8e1e530dac6aaf6c2ea1c8f8406a3ab37dfb40fbc25', 'hex'));
export {INPUT_STRING} from './common';
// Encrypted with a hardcoded keypair (in encryption-keys.ts)
export const ENCRYPTED_HEX =
'c4b896a873616c747061636b92020000c4205bf55c73b82ebe22be80f3430667' +
'af570fae2556a6415e6b30d4065300aa947dc43094992d83ef6d054728b19b77' +
'f91640d4b6fc921440138f7d571fb1796e44fd8f780f153e4507d3ed7f500b48' +
'b6e752df9192c42060346e7c911a5f6ba154129174cafe75b294ac3bbd554963' +
'2f48cec6266f8410c4302159708fbf1824787d5872df43734dd567672f70eab9' +
'663ef62165ca5653e24de796b9f2951c87971d4c23a649984dc693c391c42020' +
'755fe80a6ccb4486993bf69cc8f5050f26ec8850fb776fca4ce22ef665f056c4' +
'c64d6cbc4477493be11cb91110ead53afd99f227025700b3d93f6fea2f2bcd90' +
'5c170488bbb342b33fad6c3b8037e787d7f310a6a4240bfaca5ba3867e42a685' +
'a0de9eb12c5c7d51b13749c5e7607e5ab187b584e0bc35ac6a9b17e3a1bd717f' +
'b4f7c6ffad48afad5fa1d44faef31554c2fce0f2dbc6a215761eb10e664bd353' +
'156eb13da776b51c049d1ead133542cbdf8b5ffb124bbe82184bce9c0d9da611' +
'0e47f69a40d3c365f9c2e3fc4178ac36deadd61bbc0817a8cf7cf5bf944c228b' +
'e675888b05c84e';
export const ENCRYPTED = Buffer.from(ENCRYPTED_HEX, 'hex');
import * as tweetnacl from 'tweetnacl';
export const KEYPAIR = tweetnacl.sign.keyPair.fromSecretKey(Buffer.from(
'0000000000000000000000000000000000000000000000000000000000000000' +
'3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29', 'hex'));
export {INPUT_STRING} from './common';
// Signed with a hardcoded keypair (in signing-keys.ts)
export const SIGNATURE_HEADER_HEX =
'c45295a873616c747061636b92020001c4203b6a27bcceb6a42d62a3a8d02a6f' +
'0d73653215771de243a63ac048a18b59da29c420000000000000000000000000' +
'0000000000000000000000000000000000000000';
export const SIGNED_HEX =
'c45295a873616c747061636b92020001c4203b6a27bcceb6a42d62a3a8d02a6f' +
'0d73653215771de243a63ac048a18b59da29c420000000000000000000000000' +
'000000000000000000000000000000000000000093c3c4404a77380837fb4ec6' +
'2480e76c59b735a6287e85b54afe7793531ff70076c51fc23b1f078e6700b85b' +
'eb9fc091d69c8826b5268765b7eded317d943fed99bb560fc4b654776f20726f' +
'61647320646976657267656420696e20612079656c6c6f7720776f6f642c2061' +
'6e6420736f727279204920636f756c64206e6f742074726176656c20626f7468' +
'0a616e64206265206f6e652074726176656c6c65722c206c6f6e672049207374' +
'6f6f642c20616e64206c6f6f6b656420646f776e206f6e652061732066617220' +
'617320490a636f756c642c20746f2077686572652069742062656e7420696e20' +
'74686520756e64657267726f7774682e';
export const SIGNED = Buffer.from(SIGNED_HEX, 'hex');
export const DETACHED_SIGNATURE_HEADER_HEX =
'c45295a873616c747061636b92020002c4203b6a27bcceb6a42d62a3a8d02a6f' +
'0d73653215771de243a63ac048a18b59da29c420000000000000000000000000' +
'0000000000000000000000000000000000000000';
export const DETACHED_SIGNATURE_HEX =
'c45295a873616c747061636b92020002c4203b6a27bcceb6a42d62a3a8d02a6f' +
'0d73653215771de243a63ac048a18b59da29c420000000000000000000000000' +
'0000000000000000000000000000000000000000c4403d452b27bfc69543e20c' +
'bf3a139fd689450f26e4084660f66090de422f2e438931efd159c9101c99e070' +
'f3de277330b51940a7583f8c925085b1f86f38693f06';
export const DETACHED_SIGNATURE = Buffer.from(DETACHED_SIGNATURE_HEX, 'hex');
......@@ -4,40 +4,17 @@ global.Uint8Array = Buffer.__proto__;
import * as Encryption from '../encryption';
import {encrypt, decrypt, EncryptStream, DecryptStream} from '../encryption';
import * as tweetnacl from 'tweetnacl';
const INPUT_STRING = 'Two roads diverged in a yellow wood, and sorry I could not travel both\n' +
'and be one traveller, long I stood, and looked down one as far as I\n' +
'could, to where it bent in the undergrowth.';
// Encrypted with a hardcoded keypair
const ENCRYPTED_HEX = 'c4b896a873616c747061636b92020000c4205bf55c73b82ebe22be80f3430667' +
'af570fae2556a6415e6b30d4065300aa947dc43094992d83ef6d054728b19b77' +
'f91640d4b6fc921440138f7d571fb1796e44fd8f780f153e4507d3ed7f500b48' +
'b6e752df9192c42060346e7c911a5f6ba154129174cafe75b294ac3bbd554963' +
'2f48cec6266f8410c4302159708fbf1824787d5872df43734dd567672f70eab9' +
'663ef62165ca5653e24de796b9f2951c87971d4c23a649984dc693c391c42020' +
'755fe80a6ccb4486993bf69cc8f5050f26ec8850fb776fca4ce22ef665f056c4' +
'c64d6cbc4477493be11cb91110ead53afd99f227025700b3d93f6fea2f2bcd90' +
'5c170488bbb342b33fad6c3b8037e787d7f310a6a4240bfaca5ba3867e42a685' +
'a0de9eb12c5c7d51b13749c5e7607e5ab187b584e0bc35ac6a9b17e3a1bd717f' +
'b4f7c6ffad48afad5fa1d44faef31554c2fce0f2dbc6a215761eb10e664bd353' +
'156eb13da776b51c049d1ead133542cbdf8b5ffb124bbe82184bce9c0d9da611' +
'0e47f69a40d3c365f9c2e3fc4178ac36deadd61bbc0817a8cf7cf5bf944c228b' +
'e675888b05c84e';
const ENCRYPTED = Buffer.from(ENCRYPTED_HEX, 'hex');
const KEYPAIR_ALICE = tweetnacl.box.keyPair.fromSecretKey(Buffer.from('5ce86efb75fa4e2c410f46e16de9f6acae1a1703528651b69bc176c088bef3ee', 'hex'));
const KEYPAIR_BOB = tweetnacl.box.keyPair.fromSecretKey(Buffer.from('aa3c626bc9c38c8c201878ebb1d5b0b50ac40e8986c78793db1d4ef369fca1ce', 'hex'));
const KEYPAIR_MALLORY = tweetnacl.box.keyPair.fromSecretKey(Buffer.from('98aebbb178a551876bfaf8e1e530dac6aaf6c2ea1c8f8406a3ab37dfb40fbc25', 'hex'));
import {KEYPAIR, KEYPAIR_ALICE, KEYPAIR_BOB, KEYPAIR_MALLORY} from './data/encryption-keys';
import {INPUT_STRING, ENCRYPTED} from './data/encryption-tests';
// @ts-ignore
Encryption.debug_fix_key = Buffer.alloc(32).fill('\x00');
// @ts-ignore
Encryption.debug_fix_keypair = tweetnacl.box.keyPair.fromSecretKey(Buffer.from('5046adc1dba838867b2bbbfdd0c3423e58b57970b5267a90f57960924a87f196', 'hex'));
Encryption.debug_fix_keypair = KEYPAIR;
test('encrypt', async () => {
const encrypted = await encrypt(Buffer.from(INPUT_STRING), KEYPAIR_ALICE, [
const encrypted = await encrypt(INPUT_STRING, KEYPAIR_ALICE, [
KEYPAIR_BOB.publicKey,
]);
......
......@@ -4,40 +4,10 @@ global.Uint8Array = Buffer.__proto__;
import {sign, verify, SignStream, VerifyStream, signDetached, verifyDetached} from '../signing';
import SignedMessageHeader from '../signing/header';
import * as tweetnacl from 'tweetnacl';
const INPUT_STRING = 'Two roads diverged in a yellow wood, and sorry I could not travel both\n' +
'and be one traveller, long I stood, and looked down one as far as I\n' +
'could, to where it bent in the undergrowth.';
// Signed with a hardcoded keypair
const SIGNATURE_HEADER_HEX = 'c45295a873616c747061636b92020001c4203b6a27bcceb6a42d62a3a8d02a6f' +
'0d73653215771de243a63ac048a18b59da29c420000000000000000000000000' +
'0000000000000000000000000000000000000000';
const SIGNED_HEX = 'c45295a873616c747061636b92020001c4203b6a27bcceb6a42d62a3a8d02a6f' +
'0d73653215771de243a63ac048a18b59da29c420000000000000000000000000' +
'000000000000000000000000000000000000000093c3c4404a77380837fb4ec6' +
'2480e76c59b735a6287e85b54afe7793531ff70076c51fc23b1f078e6700b85b' +
'eb9fc091d69c8826b5268765b7eded317d943fed99bb560fc4b654776f20726f' +
'61647320646976657267656420696e20612079656c6c6f7720776f6f642c2061' +
'6e6420736f727279204920636f756c64206e6f742074726176656c20626f7468' +
'0a616e64206265206f6e652074726176656c6c65722c206c6f6e672049207374' +
'6f6f642c20616e64206c6f6f6b656420646f776e206f6e652061732066617220' +
'617320490a636f756c642c20746f2077686572652069742062656e7420696e20' +
'74686520756e64657267726f7774682e';
const SIGNED = Buffer.from(SIGNED_HEX, 'hex');
const DETACHED_SIGNATURE_HEADER_HEX = 'c45295a873616c747061636b92020002c4203b6a27bcceb6a42d62a3a8d02a6f' +
'0d73653215771de243a63ac048a18b59da29c420000000000000000000000000' +
'0000000000000000000000000000000000000000';
const DETACHED_SIGNATURE_HEX = 'c45295a873616c747061636b92020002c4203b6a27bcceb6a42d62a3a8d02a6f' +
'0d73653215771de243a63ac048a18b59da29c420000000000000000000000000' +
'0000000000000000000000000000000000000000c4403d452b27bfc69543e20c' +
'bf3a139fd689450f26e4084660f66090de422f2e438931efd159c9101c99e070' +
'f3de277330b51940a7583f8c925085b1f86f38693f06';
const DETACHED_SIGNATURE = Buffer.from(DETACHED_SIGNATURE_HEX, 'hex');
const KEYPAIR = tweetnacl.sign.keyPair.fromSecretKey(Buffer.from('00000000000000000000000000000000000000000000000000000000000000003b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29', 'hex'));
import {KEYPAIR} from './data/signing-keys';
import {INPUT_STRING, SIGNED, DETACHED_SIGNATURE} from './data/signing-tests';
SignedMessageHeader.debug_fix_nonce = Buffer.alloc(32).fill('\x00');
test('sign', () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment