Software /
code /
prosody
Comparison
util/sasl/scram.lua @ 5835:a5f4de8c0b40
util.sasl.scram: Validate channel binding data of client final message.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Mon, 17 Jan 2011 16:50:21 +0100 |
parent | 5833:b1fa865ee6b2 |
child | 5836:fa8cfe830fef |
comparison
equal
deleted
inserted
replaced
5834:c0cc4e73d9fa | 5835:a5f4de8c0b40 |
---|---|
198 else | 198 else |
199 -- we are processing client_final_message | 199 -- we are processing client_final_message |
200 local client_final_message = message; | 200 local client_final_message = message; |
201 log("debug", "client_final_message: %s", client_final_message); | 201 log("debug", "client_final_message: %s", client_final_message); |
202 self.state["channelbinding"], self.state["nonce"], self.state["proof"] = client_final_message:match("^c=(.*),r=(.*),.*p=(.*)"); | 202 self.state["channelbinding"], self.state["nonce"], self.state["proof"] = client_final_message:match("^c=(.*),r=(.*),.*p=(.*)"); |
203 | 203 |
204 if not self.state.proof or not self.state.nonce or not self.state.channelbinding then | 204 if self.state.gs2_cbind_name then |
205 return "failure", "malformed-request", "Missing an attribute(p, r or c) in SASL message."; | 205 local client_gs2_header = base64.decode(self.state.channelbinding) |
206 local our_client_gs2_header = "p="..self.state.gs2_cbind_name..","..self.state["authzid"]..","..self.profile.cb[self.state.gs2_cbind_name](self); | |
207 | |
208 if client_gs2_header ~= our_client_gs2_header then | |
209 return "failure", "malformed-request", "Invalid channel binding value."; | |
210 end | |
211 else | |
212 if not self.state.proof or not self.state.nonce or not self.state.channelbinding then | |
213 return "failure", "malformed-request", "Missing an attribute(p, r or c) in SASL message."; | |
214 end | |
206 end | 215 end |
207 | 216 |
208 if self.state.nonce ~= self.state.clientnonce..self.state.servernonce then | 217 if self.state.nonce ~= self.state.clientnonce..self.state.servernonce then |
209 return "failure", "malformed-request", "Wrong nonce in client-final-message."; | 218 return "failure", "malformed-request", "Wrong nonce in client-final-message."; |
210 end | 219 end |