1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
--
-- Blowfish cipher
--
-- some standard Blowfish testvalues
SELECT encrypt('\x0000000000000000', '\x0000000000000000', 'bf-ecb/pad:none');
encrypt
--------------------
\x4ef997456198dd78
(1 row)
SELECT encrypt('\xffffffffffffffff', '\xffffffffffffffff', 'bf-ecb/pad:none');
encrypt
--------------------
\x51866fd5b85ecb8a
(1 row)
SELECT encrypt('\x1000000000000001', '\x3000000000000000', 'bf-ecb/pad:none');
encrypt
--------------------
\x7d856f9a613063f2
(1 row)
SELECT encrypt('\x1111111111111111', '\x1111111111111111', 'bf-ecb/pad:none');
encrypt
--------------------
\x2466dd878b963c9d
(1 row)
SELECT encrypt('\x0123456789abcdef', '\xfedcba9876543210', 'bf-ecb/pad:none');
encrypt
--------------------
\x0aceab0fc6a0a28d
(1 row)
SELECT encrypt('\x01a1d6d039776742', '\xfedcba9876543210', 'bf-ecb/pad:none');
encrypt
--------------------
\x3273b8badc9e9e15
(1 row)
SELECT encrypt('\xffffffffffffffff', '\x0000000000000000', 'bf-ecb/pad:none');
encrypt
--------------------
\x014933e0cdaff6e4
(1 row)
-- setkey
SELECT encrypt('\xfedcba9876543210', '\xf0e1d2c3b4a5968778695a4b3c2d1e0f', 'bf-ecb/pad:none');
encrypt
--------------------
\x93142887ee3be15c
(1 row)
-- with padding
SELECT encrypt('\x01234567890123456789', '\x33443344334433443344334433443344', 'bf-ecb');
encrypt
------------------------------------
\x0d04a43a20456dee5ede6ed9e4dcaaa6
(1 row)
-- cbc
-- 28 bytes key
SELECT encrypt('\x6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5',
'\x37363534333231204e6f77206973207468652074696d6520666f7220',
'bf-cbc');
encrypt
--------------------------------------------------------------------
\x4f2beb748c4f689ec755edb9dc252a41b93a3786850b4c75d6a702b6a8e48825
(1 row)
-- 29 bytes key
SELECT encrypt('\x6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc',
'\x37363534333231204e6f77206973207468652074696d6520666f722000',
'bf-cbc');
encrypt
------------------------------------------------------------------------------------
\x3ea6357a0ee7fad6d0c4b63464f2aafa40c2e91b4b7e1bba8114932fd92b5c8f111e7e50e7b2e541
(1 row)
-- blowfish-448
SELECT encrypt('\xfedcba9876543210',
'\xf0e1d2c3b4a5968778695a4b3c2d1e0f001122334455667704689104c2fd3b2f584023641aba61761f1f1f1f0e0e0e0effffffffffffffff',
'bf-ecb/pad:none');
encrypt
--------------------
\xc04504012e4e1f53
(1 row)
-- empty data
select encrypt('', 'foo', 'bf');
encrypt
--------------------
\x1871949bb2311c8e
(1 row)
-- 10 bytes key
select encrypt('foo', '0123456789', 'bf');
encrypt
--------------------
\x42f58af3b2c03f46
(1 row)
-- 22 bytes key
select encrypt('foo', '0123456789012345678901', 'bf');
encrypt
--------------------
\x86ab6f0bc72b5f22
(1 row)
-- decrypt
select encode(decrypt(encrypt('foo', '0123456', 'bf'), '0123456', 'bf'), 'escape');
encode
--------
foo
(1 row)
-- iv
select encrypt_iv('foo', '0123456', 'abcd', 'bf');
encrypt_iv
--------------------
\x95c7e89322525d59
(1 row)
select encode(decrypt_iv('\x95c7e89322525d59', '0123456', 'abcd', 'bf'), 'escape');
encode
--------
foo
(1 row)
-- long message
select encrypt('Lets try a longer message.', '0123456789', 'bf');
encrypt
--------------------------------------------------------------------
\xa76059f7a1b627b5b84080d9beb337714c7a7f8b70300023e5feb6dfa6813536
(1 row)
select encode(decrypt(encrypt('Lets try a longer message.', '0123456789', 'bf'), '0123456789', 'bf'), 'escape');
encode
----------------------------
Lets try a longer message.
(1 row)
|