~ubuntu-branches/ubuntu/precise/postgresql-9.1/precise-security

« back to all changes in this revision

Viewing changes to contrib/pgcrypto/sql/3des.sql

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- 3DES cipher
 
3
--
 
4
-- ensure consistent test output regardless of the default bytea format
 
5
SET bytea_output TO escape;
 
6
 
 
7
-- test vector from somewhere
 
8
SELECT encode(encrypt(
 
9
decode('80 00 00 00 00 00 00 00', 'hex'),
 
10
decode('01 01 01 01 01 01 01 01
 
11
        01 01 01 01 01 01 01 01
 
12
        01 01 01 01 01 01 01 01', 'hex'),
 
13
'3des-ecb/pad:none'), 'hex');
 
14
-- val 95 F8 A5 E5 DD 31 D9 00
 
15
 
 
16
select encode(  encrypt('', 'foo', '3des'), 'hex');
 
17
-- 10 bytes key
 
18
select encode(  encrypt('foo', '0123456789', '3des'), 'hex');
 
19
-- 22 bytes key
 
20
select encode(  encrypt('foo', '0123456789012345678901', '3des'), 'hex');
 
21
 
 
22
-- decrypt
 
23
select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des');
 
24
 
 
25
-- iv
 
26
select encode(encrypt_iv('foo', '0123456', 'abcd', '3des'), 'hex');
 
27
select decrypt_iv(decode('50735067b073bb93', 'hex'), '0123456', 'abcd', '3des');
 
28
 
 
29
-- long message
 
30
select encode(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), 'hex');
 
31
select decrypt(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), '0123456789012345678901', '3des');