all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 5d53de08ea1080440ca06677ee8ba4d186377dbb 2768 bytes (raw)
name: test/lisp/net/sasl-scram-rfc-tests.el 	 # note: path name is non-authoritative(*)

 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
;;; sasl-scram-rfc-tests.el --- tests for SCRAM-SHA-*       -*- lexical-binding: t; -*-

;; Copyright (C) 2014-2020 Free Software Foundation, Inc.

;; Author: Magnus Henoch <magnus.henoch@gmail.com>

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; Test cases from RFC 5802 and RFC 7677.

;;; Code:

(require 'sasl)
(require 'sasl-scram-rfc)

(ert-deftest sasl-scram-sha-1-test ()
  ;; The following strings are taken from section 5 of RFC 5802.
  (let ((client
	 (sasl-make-client (sasl-find-mechanism '("SCRAM-SHA-1"))
			   "user"
			   "imap"
			   "localhost"))
	(data "r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=4096")
	(c-nonce "fyko+d2lbbFgONRv9qkxdawL")
	(sasl-read-passphrase
	 (lambda (_prompt) (copy-sequence "pencil"))))
    (sasl-client-set-property client 'c-nonce c-nonce)
    (should
     (equal
      (sasl-scram-sha-1-client-final-message client (vector nil data))
      "c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts="))

    ;; This should not throw an error:
    (sasl-scram-sha-1-authenticate-server client (vector nil "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=
"))))

(require 'sasl-scram-sha256)

(ert-deftest sasl-scram-sha-256-test ()
  ;; The following strings are taken from section 3 of RFC 7677.
  (let ((client
         (sasl-make-client (sasl-find-mechanism '("SCRAM-SHA-256"))
                           "user"
                           "imap"
                           "localhost"))
        (data "r=rOprNGfwEbeRWgbNEkqO%hvYDpWUa2RaTCAfuxFIlj)hNlF$k0,s=W22ZaJ0SNY7soEsUEjb6gQ==,i=4096")
        (c-nonce "rOprNGfwEbeRWgbNEkqO")
        (sasl-read-passphrase
         (lambda (_prompt) (copy-sequence "pencil"))))
    (sasl-client-set-property client 'c-nonce c-nonce)
    (should
     (equal
      (sasl-scram-sha-256-client-final-message client (vector nil data))
      "c=biws,r=rOprNGfwEbeRWgbNEkqO%hvYDpWUa2RaTCAfuxFIlj)hNlF$k0,p=dHzbZapWIk4jUhN+Ute9ytag9zjfMHgsqmmiz7AndVQ="))

    ;; This should not throw an error:
    (sasl-scram-sha-256-authenticate-server client (vector nil "v=6rriTRBi23WpRR/wtup+mMhUZUn/dB5nLTJRsjl95G4="))))

;;; sasl-scram-rfc-tests.el ends here

debug log:

solving 5d53de08ea ...
found 5d53de08ea in https://yhetil.org/emacs/87k1684d9r.fsf@latte.josefsson.org/
found af043e9f36 in https://git.savannah.gnu.org/cgit/emacs.git
preparing index
index prepared:
100644 af043e9f363793ed97923ef9840d0309683a5eb2	test/lisp/net/sasl-scram-rfc-tests.el

applying [1/1] https://yhetil.org/emacs/87k1684d9r.fsf@latte.josefsson.org/
diff --git a/test/lisp/net/sasl-scram-rfc-tests.el b/test/lisp/net/sasl-scram-rfc-tests.el
index af043e9f36..5d53de08ea 100644

Checking patch test/lisp/net/sasl-scram-rfc-tests.el...
Applied patch test/lisp/net/sasl-scram-rfc-tests.el cleanly.

index at:
100644 5d53de08ea1080440ca06677ee8ba4d186377dbb	test/lisp/net/sasl-scram-rfc-tests.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.