~ubuntu-branches/debian/sid/postgresql-9.3/sid

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 05:39:52 UTC
  • Revision ID: package-import@ubuntu.com-20130508053952-1j7uilp7mjtrvq8q
Tags: upstream-9.3~beta1
ImportĀ upstreamĀ versionĀ 9.3~beta1

Show diffs side-by-side

added added

removed removed

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