~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-updates

« back to all changes in this revision

Viewing changes to contrib/pgcrypto/sql/cast5.sql

  • 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
 
 
5
-- test vectors from RFC2144
 
6
 
 
7
-- 128 bit key
 
8
SELECT encode(encrypt(
 
9
decode('01 23 45 67 89 AB CD EF', 'hex'),
 
10
decode('01 23 45 67 12 34 56 78 23 45 67 89 34 56 78 9A', 'hex'),
 
11
'cast5-ecb/pad:none'), 'hex');
 
12
-- result: 23 8B 4F E5 84 7E 44 B2
 
13
 
 
14
-- 80 bit key
 
15
SELECT encode(encrypt(
 
16
decode('01 23 45 67 89 AB CD EF', 'hex'),
 
17
decode('01 23 45 67 12 34 56 78 23 45', 'hex'),
 
18
'cast5-ecb/pad:none'), 'hex');
 
19
-- result: EB 6A 71 1A 2C 02 27 1B
 
20
 
 
21
-- 40 bit key
 
22
SELECT encode(encrypt(
 
23
decode('01 23 45 67 89 AB CD EF', 'hex'),
 
24
decode('01 23 45 67 12', 'hex'),
 
25
'cast5-ecb/pad:none'), 'hex');
 
26
-- result: 7A C8 16 D1 6E 9B 30 2E
 
27
 
 
28
-- cbc
 
29
 
 
30
-- empty data
 
31
select encode(  encrypt('', 'foo', 'cast5'), 'hex');
 
32
-- 10 bytes key
 
33
select encode(  encrypt('foo', '0123456789', 'cast5'), 'hex');
 
34
 
 
35
-- decrypt
 
36
select decrypt(encrypt('foo', '0123456', 'cast5'), '0123456', 'cast5');
 
37
 
 
38
-- iv
 
39
select encode(encrypt_iv('foo', '0123456', 'abcd', 'cast5'), 'hex');
 
40
select decrypt_iv(decode('384a970695ce016a', 'hex'),
 
41
                '0123456', 'abcd', 'cast5');
 
42
 
 
43
-- long message
 
44
select encode(encrypt('Lets try a longer message.', '0123456789', 'cast5'), 'hex');
 
45
select decrypt(encrypt('Lets try a longer message.', '0123456789', 'cast5'), '0123456789', 'cast5');
 
46