~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to contrib/pgcrypto/expected/cast5.out

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- Cast5 cipher
 
3
--
 
4
-- test vectors from RFC2144
 
5
-- 128 bit key
 
6
SELECT encode(encrypt(
 
7
decode('01 23 45 67 89 AB CD EF', 'hex'),
 
8
decode('01 23 45 67 12 34 56 78 23 45 67 89 34 56 78 9A', 'hex'),
 
9
'cast5-ecb/pad:none'), 'hex');
 
10
      encode      
 
11
------------------
 
12
 238b4fe5847e44b2
 
13
(1 row)
 
14
 
 
15
-- result: 23 8B 4F E5 84 7E 44 B2
 
16
-- 80 bit key
 
17
SELECT encode(encrypt(
 
18
decode('01 23 45 67 89 AB CD EF', 'hex'),
 
19
decode('01 23 45 67 12 34 56 78 23 45', 'hex'),
 
20
'cast5-ecb/pad:none'), 'hex');
 
21
      encode      
 
22
------------------
 
23
 eb6a711a2c02271b
 
24
(1 row)
 
25
 
 
26
-- result: EB 6A 71 1A 2C 02 27 1B
 
27
-- 40 bit key
 
28
SELECT encode(encrypt(
 
29
decode('01 23 45 67 89 AB CD EF', 'hex'),
 
30
decode('01 23 45 67 12', 'hex'),
 
31
'cast5-ecb/pad:none'), 'hex');
 
32
      encode      
 
33
------------------
 
34
 7ac816d16e9b302e
 
35
(1 row)
 
36
 
 
37
-- result: 7A C8 16 D1 6E 9B 30 2E
 
38
-- cbc
 
39
-- empty data
 
40
select encode(  encrypt('', 'foo', 'cast5'), 'hex');
 
41
      encode      
 
42
------------------
 
43
 a48bd1aabde4de10
 
44
(1 row)
 
45
 
 
46
-- 10 bytes key
 
47
select encode(  encrypt('foo', '0123456789', 'cast5'), 'hex');
 
48
      encode      
 
49
------------------
 
50
 b07f19255e60cb6d
 
51
(1 row)
 
52
 
 
53
-- decrypt
 
54
select decrypt(encrypt('foo', '0123456', 'cast5'), '0123456', 'cast5');
 
55
 decrypt 
 
56
---------
 
57
 foo
 
58
(1 row)
 
59
 
 
60
-- iv
 
61
select encode(encrypt_iv('foo', '0123456', 'abcd', 'cast5'), 'hex');
 
62
      encode      
 
63
------------------
 
64
 384a970695ce016a
 
65
(1 row)
 
66
 
 
67
select decrypt_iv(decode('384a970695ce016a', 'hex'),
 
68
                '0123456', 'abcd', 'cast5');
 
69
 decrypt_iv 
 
70
------------
 
71
 foo
 
72
(1 row)
 
73
 
 
74
-- long message
 
75
select encode(encrypt('Lets try a longer message.', '0123456789', 'cast5'), 'hex');
 
76
                              encode                              
 
77
------------------------------------------------------------------
 
78
 04fcffc91533e1505dadcb10766d9fed0937818e663e402384e049942ba60fff
 
79
(1 row)
 
80
 
 
81
select decrypt(encrypt('Lets try a longer message.', '0123456789', 'cast5'), '0123456789', 'cast5');
 
82
          decrypt           
 
83
----------------------------
 
84
 Lets try a longer message.
 
85
(1 row)
 
86