1
1
--[[ $%BEGINLICENSE%$
2
Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
2
Copyright (C) 2008 MySQL AB, 2008 Sun Microsystems, Inc
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; version 2 of the
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; version 2 of the License.
9
8
This program is distributed in the hope that it will be useful,
10
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
11
GNU General Public License for more details.
14
13
You should have received a copy of the GNU General Public License
15
14
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
17
$%ENDLICENSE%$ --]]
20
18
local proto = assert(require("mysql.proto"))
21
local password = assert(require("mysql.password"))
244
241
assert( proto.to_masterinfo_string(masterinfofile) ==
245
242
"14\nhostname-bin.000024\n2143897\n127.0.0.1\nroot\n123\n3306\n60\n0\nca-cert.pem\n"
246
243
.. "/usr/local/mysql/ssl/ca/\nclient-cert.pem\nssl_cipher\nclient-key.pem\n")
248
local challenge = "01234567890123456789"
249
local cleartext = "123"
250
local hashed = password.hash(cleartext)
251
local dbl_hashed = password.hash(hashed)
252
local response = password.scramble(challenge, hashed)
253
assert(password.unscramble(challenge, response, dbl_hashed) == hashed)
255
assert(password.check(challenge, response, dbl_hashed))
257
local challenge = "01234567890123456789"
258
local cleartext = "123"
259
local hashed = password.hash(cleartext)
260
local dbl_hashed = password.hash(hashed)
261
local response = "09876543210987654321"
262
assert(password.unscramble(challenge, response, dbl_hashed) ~= hashed)
264
assert(false == password.check(challenge, response, dbl_hashed))