pike.git / lib / modules / Crypto.pmod / SCRAM.pike

version» Context lines:

pike.git/lib/modules/Crypto.pmod/SCRAM.pike:87:   //!   //! @param line   //! The received client-first request from the client.   //!   //! @returns   //! The username specified by the client. Returns null   //! if the response could not be parsed.   //!   //! @seealso   //! @[server_2] - string server_1(Stdio.Buffer|string(8bit) line) { + string server_1(string(8bit) line) {    constant format = "n,,n=%s,r=%s";    string username, r;    catch {    first = [string(8bit)]line[3..]; -  [username, r] = stringp(line) -  ? array_sscanf([string]line, format) -  : [array(string)](line->sscanf(format)); +  [username, r] = array_sscanf(line, format);    nonce = [string(8bit)]r;    r = Standards.IDNA.to_unicode(username);    };    return r;   }      //! Server-side step 2 in the SCRAM handshake.   //!   //! @param salt   //! The salt corresponding to the username that has been specified earlier.
pike.git/lib/modules/Crypto.pmod/SCRAM.pike:136:   //!   //! @param pass   //! The password to feed to the server.   //!   //! @returns   //! The client-final response to send to the server. If the response is   //! null, the server sent something unacceptable or unparseable.   //!   //! @seealso   //! @[client_3] - string(7bit) client_2(Stdio.Buffer|string(8bit) line, string pass) { + string(7bit) client_2(string(8bit) line, string pass) {    constant format = "r=%s,s=%s,i=%d";    string r, salt;    int iters; -  if (!catch([r, salt, iters] = stringp(line) -  ? array_sscanf([string]line, format) -  : [array(string)](line->sscanf(format))) +  if (!catch([r, salt, iters] = array_sscanf(line, format))    && iters > 0    && has_prefix(r, nonce)) {    line = [string(8bit)]sprintf("c=biws,r=%s", r);    first = [string(8bit)]sprintf("%s,r=%s,s=%s,i=%d,%s",    first[3..], r, salt, iters, line);    if (pass != "")    pass = Standards.IDNA.to_ascii(pass);    salt = MIME.decode_base64(salt);    nonce = [string(8bit)]sprintf("%s,%s,%d", pass, salt, iters);    if (!(r = .SCRAM_get_salted_password(H, nonce))) {
pike.git/lib/modules/Crypto.pmod/SCRAM.pike:176:   //! The received client-final challenge and response from the client.   //!   //! @param salted_password   //! The salted (using the salt provided earlier) password belonging   //! to the specified username.   //!   //! @returns   //! The server-final response to send to the client. If the response   //! is null, the client did not supply the correct credentials or   //! the response was unparseable. - string(7bit) server_3(Stdio.Buffer|string(8bit) line, + string(7bit) server_3(string(8bit) line,    string(8bit) salted_password) {    constant format = "c=biws,r=%s,p=%s";    string r, p; -  if (!catch([r, p] = stringp(line) -  ? array_sscanf([string]line, format) -  : [array(string)](line->sscanf(format))) +  if (!catch([r, p] = array_sscanf(line, format))    && r == nonce) {    first += sprintf("c=biws,r=%s", r);    p = p == clientproof(salted_password) && sprintf("v=%s", nonce);    }    return [string(7bit)]p;   }      //! Final client-side step in the SCRAM handshake. If we get this far, the   //! server has already verified that we supplied the correct credentials.   //! If this step fails, it means the server does not have our   //! credentials at all and is an imposter.   //!   //! @param line   //! The received server-final verification response.   //!   //! @returns   //! True if the server is valid, false if the server is invalid. - int(0..1) client_3(Stdio.Buffer|string(8bit) line) { + int(0..1) client_3(string(8bit) line) {    constant format = "v=%s";    string v; -  return !catch([v] = stringp(line) -  ? array_sscanf([string]line, format) -  : [array(string)](line->sscanf(format))) +  return !catch([v] = array_sscanf(line, format))    && v == nonce;   }