aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMagnus Henoch2015-02-13 19:54:57 +1100
committerLars Magne Ingebrigtsen2015-02-13 19:57:56 +1100
commite7d21b4ab11e73c709420eeeb32ffe2421fafe98 (patch)
tree67ce2998e3b6c8540e0c468012cdd4d4ce34f4e2 /test
parentf61c87f12a36bb2063c25b6742380b5916618ab5 (diff)
downloademacs-e7d21b4ab11e73c709420eeeb32ffe2421fafe98.tar.gz
emacs-e7d21b4ab11e73c709420eeeb32ffe2421fafe98.zip
Implement SCRAM-SHA-1 SASL mechanism
Fixes: debbugs:17636 * lisp/net/sasl-scram-rfc.el: New file. * lisp/net/sasl.el (sasl-mechanisms): Remove SCRAM-MD5. Add SCRAM-SHA-1 first. (sasl-mechanism-alist): Remove SCRAM-MD5 entry. Add SCRAM-SHA-1 entry. * test/automated/sasl-scram-rfc-tests.el: New file.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog4
-rw-r--r--test/automated/sasl-scram-rfc-tests.el50
2 files changed, 54 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 979214c45da..29b7c7d59ea 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
12015-02-13 Magnus Henoch <magnus.henoch@gmail.com>
2
3 * automated/sasl-scram-rfc-tests.el: New file.
4
12015-02-11 Nicolas Petton <nicolas@petton.fr> 52015-02-11 Nicolas Petton <nicolas@petton.fr>
2 6
3 * automated/seq-tests.el (test-seq-reverse, test-seq-group-by): 7 * automated/seq-tests.el (test-seq-reverse, test-seq-group-by):
diff --git a/test/automated/sasl-scram-rfc-tests.el b/test/automated/sasl-scram-rfc-tests.el
new file mode 100644
index 00000000000..c747e5f65c3
--- /dev/null
+++ b/test/automated/sasl-scram-rfc-tests.el
@@ -0,0 +1,50 @@
1;;; sasl-scram-rfc-tests.el --- tests for SCRAM-SHA-1 -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2014 Free Software Foundation, Inc.
4
5;; Author: Magnus Henoch <magnus.henoch@gmail.com>
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;; Test cases from RFC 5802.
23
24;;; Code:
25
26(require 'sasl)
27(require 'sasl-scram-rfc)
28
29(ert-deftest sasl-scram-sha-1-test ()
30 ;; The following strings are taken from section 5 of RFC 5802.
31 (let ((client
32 (sasl-make-client (sasl-find-mechanism '("SCRAM-SHA-1"))
33 "user"
34 "imap"
35 "localhost"))
36 (data "r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=4096")
37 (c-nonce "fyko+d2lbbFgONRv9qkxdawL")
38 (sasl-read-passphrase
39 (lambda (_prompt) (copy-sequence "pencil"))))
40 (sasl-client-set-property client 'c-nonce c-nonce)
41 (should
42 (equal
43 (sasl-scram-sha-1-client-final-message client (vector nil data))
44 "c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts="))
45
46 ;; This should not throw an error:
47 (sasl-scram-sha-1-authenticate-server client (vector nil "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=
48"))))
49
50;;; sasl-scram-rfc-tests.el ends here