~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/mod/sec/tst/SEC0010.als

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ---------------------------------------------------------------------------
 
2
# - SEC0010.als                                                             -
 
3
# - afnix:sec module test unit                                              -
 
4
# ---------------------------------------------------------------------------
 
5
# - This program is free software;  you can redistribute it  and/or  modify -
 
6
# - it provided that this copyright notice is kept intact.                  -
 
7
# -                                                                         -
 
8
# - This program  is  distributed in  the hope  that it will be useful, but -
 
9
# - without  any  warranty;  without  even   the   implied    warranty   of -
 
10
# - merchantability or fitness for a particular purpose.  In no event shall -
 
11
# - the copyright holder be liable for any  direct, indirect, incidental or -
 
12
# - special damages arising in any way out of the use of this software.     -
 
13
# ---------------------------------------------------------------------------
 
14
# - copyright (c) 1999-2011 amaury darsch                                   -
 
15
# ---------------------------------------------------------------------------
 
16
 
 
17
# @info   rc4 serial cipher test unit
 
18
# @author amaury darsch
 
19
 
 
20
# get the module
 
21
interp:library "afnix-sec"
 
22
 
 
23
# this procedure test the rc4 cipher
 
24
const test-rc4-cipher (kbuf ivec ovec) {
 
25
  # create the key
 
26
  const key  (afnix:sec:Key kbuf)
 
27
  # create the cipher and check
 
28
  const  rc4   (afnix:sec:Rc4 key)
 
29
  assert "RC4" (rc4:get-name)
 
30
  assert true  (afnix:sec:rc4-p rc4)
 
31
  # bind the buffers
 
32
  trans ib   (Buffer ivec)
 
33
  trans ob   (Buffer)
 
34
  # encode the vector
 
35
  trans blen (rc4:stream ob ib)
 
36
  trans vb   (Buffer ovec)
 
37
  # verify the output buffer
 
38
  loop (trans i 0) (< i blen) (i:++) {
 
39
    assert (vb:get i) (ob:get i)
 
40
  }
 
41
  # reset in decode mode
 
42
  trans vb (Buffer ivec)
 
43
  rc4:set-reverse true
 
44
  # decode and verify
 
45
  trans blen (rc4:stream ib ob)
 
46
  loop (trans i 0) (< i blen) (i:++) {
 
47
    assert (vb:get i) (ib:get i)
 
48
  }
 
49
}
 
50
 
 
51
# test 0 
 
52
trans kbuf "0123456789ABCDEF"
 
53
trans ivec (Vector
 
54
  0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
 
55
)
 
56
trans ovec (Vector
 
57
  0x74 0x94 0xc2 0xe7 0x10 0x4b 0x08 0x79
 
58
)
 
59
test-rc4-cipher kbuf ivec ovec
 
60
 
 
61
# test 1 
 
62
trans kbuf "618A63D2FB"
 
63
trans ivec (Vector
 
64
  0xdc 0xee 0x4c 0xf9 0x2c
 
65
)
 
66
trans ovec (Vector
 
67
  0xf1 0x38 0x29 0xc9 0xde
 
68
)
 
69
test-rc4-cipher kbuf ivec ovec