aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv6/envelope_test.go
blob: 1ee1bec41bad5d086c7f7a8a45c1c5728db8debc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// Contains the tests associated with the Whisper protocol Envelope object.

package whisperv6

import (
    mrand "math/rand"
    "testing"

    "github.com/ethereum/go-ethereum/crypto"
)

func TestEnvelopeOpenAcceptsOnlyOneKeyTypeInFilter(t *testing.T) {
    symKey := make([]byte, aesKeyLength)
    mrand.Read(symKey)

    asymKey, err := crypto.GenerateKey()
    if err != nil {
        t.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
    }

    params := MessageParams{
        PoW:      0.01,
        WorkTime: 1,
        TTL:      uint32(mrand.Intn(1024)),
        Payload:  make([]byte, 50),
        KeySym:   symKey,
        Dst:      nil,
    }

    mrand.Read(params.Payload)

    msg, err := newSentMessage(&params)
    if err != nil {
        t.Fatalf("failed to create new message with seed %d: %s.", seed, err)
    }

    e, err := msg.Wrap(&params)
    if err != nil {
        t.Fatalf("Failed to Wrap the message in an envelope with seed %d: %s", seed, err)
    }

    f := Filter{KeySym: symKey, KeyAsym: asymKey}

    decrypted := e.Open(&f)
    if decrypted != nil {
        t.Fatalf("Managed to decrypt a message with an invalid filter, seed %d", seed)
    }
}
class='deletions'>-13/+42 * Fix build on AMD64arved2004-02-171-0/+4 * Update to 8.2.des2004-02-1710-44/+112 * o Fix installation on bentophilip2004-02-171-5/+2 * BROKEN on 5.x: does not compilekris2004-02-171-1/+7 * Update to 0.98J: add animations. Informed maintainer.linimon2004-02-172-2/+2 * Update to 0.5.3knu2004-02-173-4/+6 * Update to 0.5.7p1 which now supports ruby 1.8.knu2004-02-172-2/+3 * BROKEN: Unfetchable. This port is scheduled for removal on April 16 if itkris2004-02-172-0/+6 * BROKEN: Checksum mismatch. This port is scheduled for removal on April 16kris2004-02-171-0/+2 * Update to 4.3.44bland2004-02-143-14/+4 * - Update to version 20040214krion2004-02-145-569/+611 * During building executables on FreeBSD 4.X the "undefined reference tolinimon2004-02-1310-25/+43 * Update to 1.38clement2004-02-123-4/+5 * Update to 1.69.tobez2004-02-113-3/+6 * - Update to version 5.3.0krion2004-02-109-213/+353 * Enable kdepasswd, depend on kdebase, fix plist.bas*, bump PORTREVISION.lofi2004-02-103-7/+79 * Bento fix: convert the pre-fetch test for the existance of thelinimon2004-02-091-13/+9 * BROKEN with perl 5.8: Does not installkris2004-02-091-1/+7 * BROKEN on 5.x: broken pkg-plistkris2004-02-093-3/+21 * USE_SIZEifylioux2004-02-0812-0/+13 * Update to 1.2.6.marcus2004-02-083-17/+3 * This port is broken on 4.x too, and will be removed after April 7.kris2004-02-081-5/+2 * BROKEN on 5.x: does not compilekris2004-02-082-1/+11 * fix build on currentoliver2004-02-073-15/+52 * Update to 1.2.2. See ChangeLog for complete list of bugfixes. New features:linimon2004-02-073-4/+6 * - Fix build on -currentkrion2004-02-062-7/+21 * Use PLIST_FILES (bento-tested, marcus-reviewed).trevor2004-02-0620-11/+11 * Add NO_LATEST_LINK=yes.ale2004-02-061-0/+1 * Use PLIST_FILES.trevor2004-02-068-5/+5 * RUN_DEPENDS on gnupg, CONFLICTS with kgpg.lofi2004-02-051-1/+5 * BROKEN: Does not compile on 5.xkris2004-02-051-1/+7 * Update to KDE 3.2.0lofi2004-02-0510-115/+253 * Bump PORTREVISION on all ports that depend on gettext to aid with upgrading.marcus2004-02-0464-13/+64 * Add USE_GETTEXT and bump PORTREVISION.marcus2004-02-041-3/+2 * Update to 4.3.42.marcus2004-02-042-2/+2 * . Fix the Java include path (bsd -> freebsd).glewis2004-02-041-1/+1 * - Utilize USE_GNOMEkrion2004-02-032-2/+4 * Add conflictsarved2004-02-021-1/+1 * Remove the broken ruby-gsl portkris2004-02-025-115/+0 * - Add another master sitepav2004-02-021-1/+2 * Upgrade to 0.90.7.1, which contains the patches from the port andfenner2004-02-025-462/+8 * 1) possible build fix on ia64 archsmaho2004-02-012-22/+19 * math/atlas should not LIB_DEPENDS on math/lapack.maho2004-02-011-1/+1 * - Add missed dependency on Perlpav2004-01-311-0/+2 * Workaround for problems installing this port on systems with emacslinimon2004-01-312-7/+6 * Update to 1.1.6, now with AMD64 support.arved2004-01-313-5/+6 * Fix build on AMD64arved2004-01-311-1/+1 * SIZEify.trevor2004-01-3086-0/+97 * Add SIZE fieldmat2004-01-292-0/+2 * - Update to version 1.2.1krion2004-01-275-244/+249 * o) Update to version 5.1.14lkoeller2004-01-273-22/+19 * Add NO_PACKAGE since this port is heavely depended onmaho2004-01-261-0/+1 * Fix broken on alphamaho2004-01-261-2/+6 * - Update to 2.2.7.apav2004-01-266-44/+95 * - Fix build on -STABLEclement2004-01-241-0/+4 * Now gettext 0.12.1 is gettext-old.trevor2004-01-241-1/+1 * - Update to version 1.1.6krion2004-01-233-3/+4 * Use LS macro.trevor2004-01-232-2/+2 * Use the CPIO macro defined in bsd.port.mk.trevor2004-01-221-2/+2 * Add more architectures (result of hw.model)maho2004-01-201-11/+36 * Remove harmful message from Makefilemaho2004-01-201-6/+0 * Remove # to compilemaho2004-01-201-4/+4 * a) update to 3.6.0maho2004-01-205-91/+140 * 1) very minor update, without changing the filenamemaho2004-01-192-1/+2 * - Update to 1.2.5bland2004-01-194-3/+20 * Remove math/simpack.linimon2004-01-191-1/+0 * Remove math/simpack. From my response to PR ports/53193:linimon2004-01-1922-2505/+0 * - Respect CFLAGS and PTHREAD_LIBSclement2004-01-181-5/+5 * Switch to my @FreeBSD.org email address.ale2004-01-184-4/+4 * Update master_sites.edwin2004-01-171-1/+1 * Update to 0.9.4arved2004-01-152-4/+8 * Use intlhack to get this to compile on -STABLE.marcus2004-01-151-1/+1 * Update to 4.3.38bland2004-01-142-2/+2 * Update to 4.3.37.marcus2004-01-133-14/+2 * Move PERL_CONFIGURE before bsd.port.pre.mk.kuriyama2004-01-122-4/+4 * - Upgrade to the latest release;clement2004-01-124-14/+29 * - Update to version 2.6.2krion2004-01-083-13/+41 * - Assign maintainership to Markus Bruefferkrion2004-01-081-1/+1 * - Drop maintainership to ports@krion2004-01-081-1/+1 * Restore part of bland's patch. Certain locales actually don't have amarcus2004-01-072-0/+12 * Fix build of math/libgmp4 on AMD64 systemsedwin2004-01-074-2/+30 * Update to 4.3.35 which should have bland's thousands separator bugmarcus2004-01-075-52/+5 * Add math/itl, the Iterative Template Library. It carries solver andlinimon2004-01-066-0/+84 * Add math/koctave, a KDE GUI for the math/octave package. It containslinimon2004-01-065-0/+55 * - update to 1.7clement2004-01-053-101/+142 * - Update to 1.6.3pav2004-01-053-12/+12 * - Update to 3.7.1pav2004-01-043-7/+12 * NEW port: math/taucsedwin2004-01-037-0/+108 * Add p5-Statistics-Contingency 0.06,vanilla2004-01-035-0/+52 * Fix thousands separator handling bug.bland2004-01-033-3/+25 * Add nsc2ke, a Finite-Volume Galerkin program computing 2D and axisymmetricpav2004-01-037-0/+111 * Add emc2 2.15,krion2004-01-037-0/+115 * Add bamg 0.68, bidimensional Anisotrope Mesh Generator.krion2004-01-0324-0/+829 * Update to 1.2.4.marcus2003-12-312-2/+5 * Update to 2.5.3maho2003-12-283-401/+140 * a) Update to 3.5.22maho2003-12-285-41/+55 * Add p5-AI-DecisionTree 0.08, perl module for Automatically Learningkrion2003-12-285-0/+52 * - Update to 4.3.0pav2003-12-2742-669/+5102 * - Update to version 1.2.0krion2003-12-268-297/+334 * Adopt this port, since I'm using it now for the ports monitoring code.linimon2003-12-251-1/+1 * Update to 1.2.3.marcus2003-12-253-16/+6 * Bugfix. For locales with non "." radix constants list wasn't properlybland2003-12-242-0/+28 * Update to 4.3.31.marcus2003-12-244-48/+4 * - Use canonical form (ports@FreeBSD.org) in MAINTAINER linesergei2003-12-211-1/+1 * Update to 0.8perky2003-12-203-6/+160 * Update to 0.9.3arved2003-12-192-3/+2 * Update to 0.98I of 12/05/2003. The old version had not been fetchablelinimon2003-12-188-66/+42 * Upgrade to 23.1.tg2003-12-172-2/+2 * Update to 1.02.tobez2003-12-172-2/+2 * Update to 0.5.tobez2003-12-173-7/+2 * - Mark RESTRICTED: No resale, contact authors for commercial usepav2003-12-171-0/+2 * - Remove gcc-3.3.1 kludge now that 3.3.3 is standard in -CURRENTpav2003-12-163-30/+3 * The Linux version of the DISLIN scientific data plotting package.des2003-12-1417-0/+955 * - www.code-aster.org was reorganized. fix fetchingpav2003-12-112-2/+5 * USE_MESA -> USE_GLfjoe2003-12-101-2/+2 * - Update to version 2.20krion2003-12-104-139/+137 * . Welcome metis-edf to the math category after a repo copy from cad.glewis2003-12-102-1/+2 * . Update to 3.1 to synchronise with the changes to the cad copy ofglewis2003-12-102-3/+2 * Update to 1.2.2 and remove the obsolete gal2 dependency.marcus2003-12-093-7/+23 * Update to handle tk8.4.linimon2003-12-096-7/+58 * - Update to 1.36pav2003-12-093-3/+11 * Updated to 0.2skv2003-12-092-2/+2 * - In the heat of the battle I mistakenly patched amd64 instead of alpha.pav2003-12-081-1/+1 * Add FreeFem++, an extension of freefem, an implementation of the Gfempav2003-12-077-0/+216 * Add arpack++, an object-oriented version of the ARPACK package.pav2003-12-077-0/+573 * - Unbreak checksum, user guide was updated to October 2003 revision.pav2003-12-071-1/+1 * - Install header filespav2003-12-072-4/+44 * - Link with atlas version of lapackpav2003-12-076-14/+36 * - Add p5-NetCDF, a perl module to read and write netCDF files.pav2003-12-075-0/+40 * Update to 4.3.29bland2003-12-064-2/+49 * - Update to 1.8.1pav2003-12-059-15/+54 * - Update to version 0.9.11krion2003-12-044-17/+7 * - Pretend we don't have ieee functionality on sparc64, amd64 and ia64,pav2003-12-044-60/+28 * - Update to 2.2.1pav2003-12-045-34/+28 * - Fix build with gcc 3.3pav2003-12-043-3/+17 * - Unbreak on 5.x (gcc 3.3 preprocessor)pav2003-12-021-5/+62 * - Fix build on 5.xpav2003-12-011-0/+11 * Unbreak.sobomax2003-11-301-7/+7 * - AMD64 has no APMarved2003-11-261-3/+3 * - Update to 4.3.0pav2003-11-233-2/+3 * - Update to 2.1.5pav2003-11-222-2/+9 * Add -fPIC to fix build on amd64arved2003-11-211-3/+3 * Define USE_PERL5_BUILD, not erroneous USE_PERL.trevor2003-11-205-5/+5 * * Update to 1.0.56marcus2003-11-203-2/+20 * Define USE_PERL to make Perl available for (mostly deprecated)trevor2003-11-205-0/+5 * - Unbreak on 5.xpav2003-11-202-17/+304 * USE_REINPLACE need be defined only when REINPLACE_CMD is used.trevor2003-11-172-2/+0 * . Update to 3.2.1. This also fixes the build on 5.x.glewis2003-11-1514-1446/+234 * fix build on -currentijliao2003-11-151-6/+11 * Use the FIND and XARGS macros introduced in bsd.port.mk 1.391.trevor2003-11-1310-11/+11 * Update to 1.1.4: RPN mode improvements, bugfixes, translation updates.naddy2003-11-134-22/+3 * Correct patch file so that cleanly appled.maho2003-11-101-2/+2 * - Update to 0.7sergei2003-11-095-170/+161 * . Welcome kaskade to the math category (with a secondary of science).glewis2003-11-082-1/+2 * . Change secondary category from cad to science.glewis2003-11-082-2/+2 * Remove post-patch (it breaks build and is no longer needed).fjoe2003-11-071-7/+0 * - update to 0.97.0.5fjoe2003-11-076-35/+9 * Fix the graphing plug-ins so that they can actually load.marcus2003-11-071-0/+3 * - Update to version 1.1.5krion2003-11-074-3/+22 * add CONFLICTSijliao2003-11-061-0/+2 * Chase wxgtk library name (and version) change.fjoe2003-11-051-1/+1 * - Enable building for Python-2.4 by utilizing PYTHON_MASTER_SITES.perky2003-11-051-2/+2 * Chase bsd.python.mk's change PYTHON_SITE_SUBDIR -> PYTHON_MASTER_SITE_SUBDIR.perky2003-11-051-1/+1 * A small bug was found on the multithreaded version of spooles...maho2003-11-041-0/+11 * Correct version number of gsl shared library.sobomax2003-11-041-1/+1 * Add p5-Math-GSL 0.01, a perl interface to GNU Scientific Library.sobomax2003-11-045-0/+39 * Reset maintainer to ports@FreeBSD.org. Requested by: kris.linimon2003-11-032-2/+2 * Mark BROKEN (see bento logs). These ports are scheduled for removalkris2003-11-032-2/+2 * Reset maintainer on ports owned by the following committers who havekris2003-11-031-1/+1 * ports with possibly unreachable MAINTAINERsedwin2003-11-022-2/+2 * introduce MASTER_SITE_GNU_ALPHAijliao2003-10-311-1/+2 * add rpy 0.3.1ijliao2003-10-3111-0/+111 * fix build on -stable (by utilize USE_GETOPT_LONG)ijliao2003-10-312-2/+20 * - PORTVERSION: 1.7.1 -> 1.8.0ijliao2003-10-3112-420/+828 * upgrade to 1.7.1ijliao2003-10-299-1380/+921 * add gracetmpl 0.3.1ijliao2003-10-285-0/+123 * - Fix build on -currentkrion2003-10-284-64/+75 * Per distfile survey, mark the mastersite as gone. Provide a linklinimon2003-10-282-1/+3 * Per distfile survey, note that the mastersite disappeared in June 2003.linimon2003-10-282-3/+2 * Per distfile survey, remove one dead mastersite, and add the true homelinimon2003-10-282-4/+2 * Per distfile survey, note that the mastersites disappeared in April 2000linimon2003-10-282-4/+2 * BROKEN: Does not compilekris2003-10-281-0/+2 * o) Update to version 5.1.13lkoeller2003-10-274-40/+2 * - Update to version 0.9.10krion2003-10-263-2/+12 * Remove the recursive assignment of SITE_PERL to ${SITE_PERL} introducederwin2003-10-242-3/+0 * utilize SITE_PERLijliao2003-10-2454-234/+208 * Update to 3.5.12maho2003-10-242-2/+2 * Change maintainer to vangyzen@stat.duke.eduadamw2003-10-243-3/+3 * Utilize PYTHON_SITE_SUBDIR and USE_PYTHON.perky2003-10-191-1/+1 * upgrade to 0.98ijliao2003-10-182-2/+2 * Before committing the previous BROKEN changes I carefully checked the statuskris2003-10-161-7/+1 * BROKEN on 5.x: does not compilekris2003-10-161-1/+7 * BROKEN on 5.x: does not compilekris2003-10-161-1/+7 * Fix Python detection for Python <= 2.2.marcus2003-10-161-1/+2 * unbreak build problems for math/pspp.edwin2003-10-152-7/+574 * BROKEN on 5.x: does not compilekris2003-10-151-1/+7 * Update to 0.0.4 and fix new compiler error. (wrong cpp syntax)knu2003-10-152-2/+2 * Update to 4.3.16.marcus2003-10-142-2/+2 * Unbreak on 5.xmat2003-10-131-2/+1 * - Chase libraries to actual math/gsl version.krion2003-10-133-3/+3 * Update to 4.3.15.marcus2003-10-113-3/+7 * - Update to version 1.1.3krion2003-10-113-22/+16 * - Add dependency for devel/stlport on 4-stablekrion2003-10-113-37/+52 * math/ploticus-nox11, a slaveport of math/ploticusedwin2003-10-102-0/+18 * make math/ploticus a master-port.edwin2003-10-102-103/+103 * ploticus should not require X11 (patch included)edwin2003-10-101-1/+7 * - Update to version 1.1.4krion2003-10-104-289/+295 * Update to 1.2.1.adamw2003-10-094-23/+3 * Update to ParMetis 3.1.roam2003-10-083-5/+5 * - Fix MASTER_SITESkrion2003-10-081-1/+1 * Add py-fpconst 0.6.0, utilities for handling IEEE 754 floatingkrion2003-10-085-0/+30 * Rename math/drgenuis -> math/drgeokrion2003-10-065-173/+0 * Add math/drgeo, remove math/drgeniuskrion2003-10-061-1/+1 * - Update to 0.9.9krion2003-10-065-136/+206 * new port for mpexpredwin2003-10-067-0/+199 * Add new port math/sdpa.maho2003-10-048-0/+230 * Add new port atlas-devel, developer version of math/atlasmaho2003-10-0412-0/+6276