File: yescrypt.out

package info (click to toggle)
pg-pwhash 1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,636 kB
  • sloc: ansic: 2,014; sql: 233; makefile: 36; sh: 1
file content (53 lines) | stat: -rw-r--r-- 2,278 bytes parent folder | download
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
-- -------------------------------------------------------------------------------------------------
-- Checks for yescrypt hashing
--
-- Currently this is supported on platforms with advanced libxcrypt support only (Linux, BSD).
-- So checks might fail in case support wasn't available during compilation of the extension
-- -------------------------------------------------------------------------------------------------
--
-- Compare hashes derived via test/crypt_gensalt_yescrypt password '$y$jAT$ymqO.hmB133abiOGZqA4f/'
-- (parameter rounds=6)
--
SELECT pwhash_yescrypt_crypt('password', '$y$jAT$ymqO.hmB133abiOGZqA4f/') = '$y$jAT$ymqO.hmB133abiOGZqA4f/$ff0GrluBLpVssGRjSIYMUG2E7JWH722mSyalZT3o3E3';
 ?column? 
----------
 t
(1 row)

-- Following tests should fail
-- Note: We need lc_messages set to C, otherwise we get localized errors from libxcrypt
SET lc_messages TO 'C';
SELECT pwhash_yescrypt_crypt('password', '$y$');
ERROR:  error creating password hash with crypt()
DETAIL:  Internal error using crypt(): Invalid argument
SELECT pwhash_yescrypt_crypt('password', '$y$$');
ERROR:  error creating password hash with crypt()
DETAIL:  Internal error using crypt(): Invalid argument
SELECT pwhash_yescrypt_crypt('password', '');
ERROR:  invalid magic string for crypt()
RESET lc_messages;
----------------------------------------------------------
-- Test generating yescrypt hashes with pwhash_gen_salt()
----------------------------------------------------------
CREATE TABLE pwhash_test_yescrypt(pw text NOT NULL, salt text NOT NULL, hash text);
INSERT INTO pwhash_test_yescrypt(pw, salt) VALUES('password', pwhash_gen_salt('yescrypt', 'rounds=3'));
UPDATE pwhash_test_yescrypt SET hash = pwhash_yescrypt_crypt('password', salt) WHERE pw = 'password';
SELECT hash = pwhash_yescrypt_crypt(pw, salt) FROM pwhash_test_yescrypt;
 ?column? 
----------
 t
(1 row)

DROP TABLE pwhash_test_yescrypt;
-- ----------------------------------------------------
-- Test crypt() compatible interface pwhash_crypt()
-- ----------------------------------------------------
--
-- yescrypt via crypt()
--
SELECT pwhash_crypt('password', '$y$jAT$ymqO.hmB133abiOGZqA4f/') = '$y$jAT$ymqO.hmB133abiOGZqA4f/$ff0GrluBLpVssGRjSIYMUG2E7JWH722mSyalZT3o3E3' AS hash;
 hash 
------
 t
(1 row)