Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit814e1d9

Browse files
committed
pgcrypto: Remove explicit hex encoding/decoding from tests
This was from before the hex format was available in bytea. Now wecan remove the extra explicit encoding/decoding calls and rely on thedefault output format.Discussion:https://www.postgresql.org/message-id/flat/17dcb4f7-7ac1-e2b6-d5f7-2dfba06cd9ee%40enterprisedb.com
1 parent00029de commit814e1d9

34 files changed

+820
-1055
lines changed

‎contrib/pgcrypto/expected/3des.out

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,64 @@
11
--
22
-- 3DES cipher
33
--
4-
-- ensure consistent test output regardless of the default bytea format
5-
SET bytea_output TO escape;
64
-- test vector from somewhere
7-
SELECT encode(encrypt(
8-
decode('80 00 00 00 00 00 00 00', 'hex'),
9-
decode('01 01 01 01 01 01 01 01
10-
01 01 01 01 01 01 01 01
11-
01 01 01 01 01 01 01 01', 'hex'),
12-
'3des-ecb/pad:none'), 'hex');
13-
encode
14-
------------------
15-
95f8a5e5dd31d900
5+
SELECT encrypt('\x8000000000000000',
6+
'\x010101010101010101010101010101010101010101010101',
7+
'3des-ecb/pad:none');
8+
encrypt
9+
--------------------
10+
\x95f8a5e5dd31d900
1611
(1 row)
1712

18-
-- val 95 F8 A5 E5 DD 31 D9 00
19-
select encode(encrypt('', 'foo', '3des'), 'hex');
20-
encode
21-
------------------
22-
752111e37a2d7ac3
13+
select encrypt('', 'foo', '3des');
14+
encrypt
15+
--------------------
16+
\x752111e37a2d7ac3
2317
(1 row)
2418

2519
-- 10 bytes key
26-
selectencode(encrypt('foo', '0123456789', '3des'), 'hex');
27-
encode
28-
------------------
29-
d2fb8baa1717cb02
20+
select encrypt('foo', '0123456789', '3des');
21+
encrypt
22+
--------------------
23+
\xd2fb8baa1717cb02
3024
(1 row)
3125

3226
-- 22 bytes key
33-
selectencode(encrypt('foo', '0123456789012345678901', '3des'), 'hex');
34-
encode
35-
------------------
36-
a44360e699269817
27+
select encrypt('foo', '0123456789012345678901', '3des');
28+
encrypt
29+
--------------------
30+
\xa44360e699269817
3731
(1 row)
3832

3933
-- decrypt
40-
select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des');
41-
decrypt
42-
---------
34+
selectencode(decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des'), 'escape');
35+
encode
36+
--------
4337
foo
4438
(1 row)
4539

4640
-- iv
47-
selectencode(encrypt_iv('foo', '0123456', 'abcd', '3des'), 'hex');
48-
encode
49-
------------------
50-
50735067b073bb93
41+
select encrypt_iv('foo', '0123456', 'abcd', '3des');
42+
encrypt_iv
43+
--------------------
44+
\x50735067b073bb93
5145
(1 row)
5246

53-
select decrypt_iv(decode('50735067b073bb93', 'hex'), '0123456', 'abcd', '3des');
54-
decrypt_iv
55-
------------
47+
selectencode(decrypt_iv('\x50735067b073bb93', '0123456', 'abcd', '3des'), 'escape');
48+
encode
49+
--------
5650
foo
5751
(1 row)
5852

5953
-- long message
60-
selectencode(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), 'hex');
61-
encode
62-
------------------------------------------------------------------
63-
b71e3422269d0ded19468f33d65cd663c28e0871984792a7b3ba0ddcecec8d2c
54+
select encrypt('Lets try a longer message.', '0123456789012345678901', '3des');
55+
encrypt
56+
--------------------------------------------------------------------
57+
\xb71e3422269d0ded19468f33d65cd663c28e0871984792a7b3ba0ddcecec8d2c
6458
(1 row)
6559

66-
select decrypt(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), '0123456789012345678901', '3des');
67-
decrypt
60+
selectencode(decrypt(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), '0123456789012345678901', '3des'), 'escape');
61+
encode
6862
----------------------------
6963
Lets try a longer message.
7064
(1 row)

‎contrib/pgcrypto/expected/blowfish.out

Lines changed: 94 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,141 @@
11
--
22
-- Blowfish cipher
33
--
4-
-- ensure consistent test output regardless of the default bytea format
5-
SET bytea_output TO escape;
64
-- some standard Blowfish testvalues
7-
SELECT encode(encrypt(
8-
decode('0000000000000000', 'hex'),
9-
decode('0000000000000000', 'hex'),
10-
'bf-ecb/pad:none'), 'hex');
11-
encode
12-
------------------
13-
4ef997456198dd78
14-
(1 row)
15-
16-
SELECT encode(encrypt(
17-
decode('ffffffffffffffff', 'hex'),
18-
decode('ffffffffffffffff', 'hex'),
19-
'bf-ecb/pad:none'), 'hex');
20-
encode
21-
------------------
22-
51866fd5b85ecb8a
23-
(1 row)
24-
25-
SELECT encode(encrypt(
26-
decode('1000000000000001', 'hex'),
27-
decode('3000000000000000', 'hex'),
28-
'bf-ecb/pad:none'), 'hex');
29-
encode
30-
------------------
31-
7d856f9a613063f2
32-
(1 row)
33-
34-
SELECT encode(encrypt(
35-
decode('1111111111111111', 'hex'),
36-
decode('1111111111111111', 'hex'),
37-
'bf-ecb/pad:none'), 'hex');
38-
encode
39-
------------------
40-
2466dd878b963c9d
41-
(1 row)
42-
43-
SELECT encode(encrypt(
44-
decode('0123456789abcdef', 'hex'),
45-
decode('fedcba9876543210', 'hex'),
46-
'bf-ecb/pad:none'), 'hex');
47-
encode
48-
------------------
49-
0aceab0fc6a0a28d
50-
(1 row)
51-
52-
SELECT encode(encrypt(
53-
decode('01a1d6d039776742', 'hex'),
54-
decode('fedcba9876543210', 'hex'),
55-
'bf-ecb/pad:none'), 'hex');
56-
encode
57-
------------------
58-
3273b8badc9e9e15
59-
(1 row)
60-
61-
SELECT encode(encrypt(
62-
decode('ffffffffffffffff', 'hex'),
63-
decode('0000000000000000', 'hex'),
64-
'bf-ecb/pad:none'), 'hex');
65-
encode
66-
------------------
67-
014933e0cdaff6e4
5+
SELECT encrypt('\x0000000000000000', '\x0000000000000000', 'bf-ecb/pad:none');
6+
encrypt
7+
--------------------
8+
\x4ef997456198dd78
9+
(1 row)
10+
11+
SELECT encrypt('\xffffffffffffffff', '\xffffffffffffffff', 'bf-ecb/pad:none');
12+
encrypt
13+
--------------------
14+
\x51866fd5b85ecb8a
15+
(1 row)
16+
17+
SELECT encrypt('\x1000000000000001', '\x3000000000000000', 'bf-ecb/pad:none');
18+
encrypt
19+
--------------------
20+
\x7d856f9a613063f2
21+
(1 row)
22+
23+
SELECT encrypt('\x1111111111111111', '\x1111111111111111', 'bf-ecb/pad:none');
24+
encrypt
25+
--------------------
26+
\x2466dd878b963c9d
27+
(1 row)
28+
29+
SELECT encrypt('\x0123456789abcdef', '\xfedcba9876543210', 'bf-ecb/pad:none');
30+
encrypt
31+
--------------------
32+
\x0aceab0fc6a0a28d
33+
(1 row)
34+
35+
SELECT encrypt('\x01a1d6d039776742', '\xfedcba9876543210', 'bf-ecb/pad:none');
36+
encrypt
37+
--------------------
38+
\x3273b8badc9e9e15
39+
(1 row)
40+
41+
SELECT encrypt('\xffffffffffffffff', '\x0000000000000000', 'bf-ecb/pad:none');
42+
encrypt
43+
--------------------
44+
\x014933e0cdaff6e4
6845
(1 row)
6946

7047
-- setkey
71-
SELECT encode(encrypt(
72-
decode('fedcba9876543210', 'hex'),
73-
decode('f0e1d2c3b4a5968778695a4b3c2d1e0f', 'hex'),
74-
'bf-ecb/pad:none'), 'hex');
75-
encode
76-
------------------
77-
93142887ee3be15c
48+
SELECT encrypt('\xfedcba9876543210', '\xf0e1d2c3b4a5968778695a4b3c2d1e0f', 'bf-ecb/pad:none');
49+
encrypt
50+
--------------------
51+
\x93142887ee3be15c
7852
(1 row)
7953

8054
-- with padding
81-
SELECT encode(encrypt(
82-
decode('01234567890123456789', 'hex'),
83-
decode('33443344334433443344334433443344', 'hex'),
84-
'bf-ecb'), 'hex');
85-
encode
86-
----------------------------------
87-
0d04a43a20456dee5ede6ed9e4dcaaa6
55+
SELECT encrypt('\x01234567890123456789', '\x33443344334433443344334433443344', 'bf-ecb');
56+
encrypt
57+
------------------------------------
58+
\x0d04a43a20456dee5ede6ed9e4dcaaa6
8859
(1 row)
8960

9061
-- cbc
9162
-- 28 bytes key
92-
SELECT encode(encrypt(
93-
decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5', 'hex'),
94-
decode('37363534333231204e6f77206973207468652074696d6520666f7220', 'hex'),
95-
'bf-cbc'), 'hex');
96-
encode
97-
------------------------------------------------------------------
98-
4f2beb748c4f689ec755edb9dc252a41b93a3786850b4c75d6a702b6a8e48825
63+
SELECT encrypt('\x6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5',
64+
'\x37363534333231204e6f77206973207468652074696d6520666f7220',
65+
'bf-cbc');
66+
encrypt
67+
--------------------------------------------------------------------
68+
\x4f2beb748c4f689ec755edb9dc252a41b93a3786850b4c75d6a702b6a8e48825
9969
(1 row)
10070

10171
-- 29 bytes key
102-
SELECT encode(encrypt(
103-
decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc', 'hex'),
104-
decode('37363534333231204e6f77206973207468652074696d6520666f722000', 'hex'),
105-
'bf-cbc'), 'hex');
106-
encode
107-
----------------------------------------------------------------------------------
108-
3ea6357a0ee7fad6d0c4b63464f2aafa40c2e91b4b7e1bba8114932fd92b5c8f111e7e50e7b2e541
72+
SELECT encrypt('\x6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc',
73+
'\x37363534333231204e6f77206973207468652074696d6520666f722000',
74+
'bf-cbc');
75+
encrypt
76+
------------------------------------------------------------------------------------
77+
\x3ea6357a0ee7fad6d0c4b63464f2aafa40c2e91b4b7e1bba8114932fd92b5c8f111e7e50e7b2e541
10978
(1 row)
11079

11180
-- blowfish-448
112-
SELECT encode(encrypt(
113-
decode('fedcba9876543210', 'hex'),
114-
decode('f0e1d2c3b4a5968778695a4b3c2d1e0f001122334455667704689104c2fd3b2f584023641aba61761f1f1f1f0e0e0e0effffffffffffffff', 'hex'),
115-
'bf-ecb/pad:none'), 'hex');
116-
encode
117-
------------------
118-
c04504012e4e1f53
81+
SELECT encrypt('\xfedcba9876543210',
82+
'\xf0e1d2c3b4a5968778695a4b3c2d1e0f001122334455667704689104c2fd3b2f584023641aba61761f1f1f1f0e0e0e0effffffffffffffff',
83+
'bf-ecb/pad:none');
84+
encrypt
85+
--------------------
86+
\xc04504012e4e1f53
11987
(1 row)
12088

121-
-- result: c04504012e4e1f53
12289
-- empty data
123-
selectencode(encrypt('', 'foo', 'bf'), 'hex');
124-
encode
125-
------------------
126-
1871949bb2311c8e
90+
select encrypt('', 'foo', 'bf');
91+
encrypt
92+
--------------------
93+
\x1871949bb2311c8e
12794
(1 row)
12895

12996
-- 10 bytes key
130-
selectencode(encrypt('foo', '0123456789', 'bf'), 'hex');
131-
encode
132-
------------------
133-
42f58af3b2c03f46
97+
select encrypt('foo', '0123456789', 'bf');
98+
encrypt
99+
--------------------
100+
\x42f58af3b2c03f46
134101
(1 row)
135102

136103
-- 22 bytes key
137-
selectencode(encrypt('foo', '0123456789012345678901', 'bf'), 'hex');
138-
encode
139-
------------------
140-
86ab6f0bc72b5f22
104+
select encrypt('foo', '0123456789012345678901', 'bf');
105+
encrypt
106+
--------------------
107+
\x86ab6f0bc72b5f22
141108
(1 row)
142109

143110
-- decrypt
144-
select decrypt(encrypt('foo', '0123456', 'bf'), '0123456', 'bf');
145-
decrypt
146-
---------
111+
selectencode(decrypt(encrypt('foo', '0123456', 'bf'), '0123456', 'bf'), 'escape');
112+
encode
113+
--------
147114
foo
148115
(1 row)
149116

150117
-- iv
151-
selectencode(encrypt_iv('foo', '0123456', 'abcd', 'bf'), 'hex');
152-
encode
153-
------------------
154-
95c7e89322525d59
118+
select encrypt_iv('foo', '0123456', 'abcd', 'bf');
119+
encrypt_iv
120+
--------------------
121+
\x95c7e89322525d59
155122
(1 row)
156123

157-
select decrypt_iv(decode('95c7e89322525d59', 'hex'), '0123456', 'abcd', 'bf');
158-
decrypt_iv
159-
------------
124+
selectencode(decrypt_iv('\x95c7e89322525d59', '0123456', 'abcd', 'bf'), 'escape');
125+
encode
126+
--------
160127
foo
161128
(1 row)
162129

163130
-- long message
164-
selectencode(encrypt('Lets try a longer message.', '0123456789', 'bf'), 'hex');
165-
encode
166-
------------------------------------------------------------------
167-
a76059f7a1b627b5b84080d9beb337714c7a7f8b70300023e5feb6dfa6813536
131+
select encrypt('Lets try a longer message.', '0123456789', 'bf');
132+
encrypt
133+
--------------------------------------------------------------------
134+
\xa76059f7a1b627b5b84080d9beb337714c7a7f8b70300023e5feb6dfa6813536
168135
(1 row)
169136

170-
select decrypt(encrypt('Lets try a longer message.', '0123456789', 'bf'), '0123456789', 'bf');
171-
decrypt
137+
selectencode(decrypt(encrypt('Lets try a longer message.', '0123456789', 'bf'), '0123456789', 'bf'), 'escape');
138+
encode
172139
----------------------------
173140
Lets try a longer message.
174141
(1 row)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp