|
Packit Service |
4684c1 |
;;; GnuTLS --- Guile bindings for GnuTLS
|
|
Packit Service |
4684c1 |
;;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;; GnuTLS is free software; you can redistribute it and/or modify
|
|
Packit Service |
4684c1 |
;;; it under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
;;; the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
4684c1 |
;;; (at your option) any later version.
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;; GnuTLS is distributed in the hope that it will be useful,
|
|
Packit Service |
4684c1 |
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
4684c1 |
;;; GNU General Public License for more details.
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;; You should have received a copy of the GNU General Public License
|
|
Packit Service |
4684c1 |
;;; along with GnuTLS-EXTRA; if not, write to the Free Software
|
|
Packit Service |
4684c1 |
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
Packit Service |
4684c1 |
;;; USA.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
;;; Written by Ludovic Courtès <ludo@gnu.org>.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
;;; Exercise the priority API of GnuTLS.
|
|
Packit Service |
4684c1 |
;;;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(use-modules (gnutls)
|
|
Packit Service |
4684c1 |
(gnutls build tests)
|
|
Packit Service |
4684c1 |
(srfi srfi-1)
|
|
Packit Service |
4684c1 |
(srfi srfi-26))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(define %valid-priority-strings
|
|
Packit Service |
4684c1 |
;; Valid priority strings (from the manual).
|
|
Packit Service |
4684c1 |
'("NONE:+VERS-TLS1.2:+MAC-ALL:+RSA:+AES-128-CBC:+SIGN-ALL:+COMP-NULL"
|
|
Packit Service |
4684c1 |
"NORMAL:-ARCFOUR-128"
|
|
Packit Service |
4684c1 |
"SECURE128:-VERS-SSL3.0:+COMP-NULL"
|
|
Packit Service |
4684c1 |
"NONE:+VERS-TLS1.2:+AES-128-CBC:+RSA:+SHA1:+COMP-NULL:+SIGN-RSA-SHA1"))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(define %invalid-priority-strings
|
|
Packit Service |
4684c1 |
;; Invalid strings: the prefix and the suffix that leads to a parse error.
|
|
Packit Service |
4684c1 |
'(("" . "THIS-DOES-NOT-WORK")
|
|
Packit Service |
4684c1 |
("NORMAL:" . "FAIL-HERE")
|
|
Packit Service |
4684c1 |
("SECURE128:-VERS-SSL3.0:" . "+FAIL-HERE")
|
|
Packit Service |
4684c1 |
("NONE:+VERS-TLS1.2:+AES-128-CBC:"
|
|
Packit Service |
4684c1 |
. "+FAIL-HERE:+SHA1:+COMP-NULL:+SIGN-RSA-SHA1")))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(run-test
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(lambda ()
|
|
Packit Service |
4684c1 |
(let ((s (make-session connection-end/client)))
|
|
Packit Service |
4684c1 |
;; We shouldn't have any exception with the valid priority strings.
|
|
Packit Service |
4684c1 |
(for-each (cut set-session-priorities! s <>)
|
|
Packit Service |
4684c1 |
%valid-priority-strings)
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
(every (lambda (prefix+suffix)
|
|
Packit Service |
4684c1 |
(let* ((prefix (car prefix+suffix))
|
|
Packit Service |
4684c1 |
(suffix (cdr prefix+suffix))
|
|
Packit Service |
4684c1 |
(pos (string-length prefix))
|
|
Packit Service |
4684c1 |
(string (string-append prefix suffix)))
|
|
Packit Service |
4684c1 |
(catch 'gnutls-error
|
|
Packit Service |
4684c1 |
(lambda ()
|
|
Packit Service |
4684c1 |
(let ((s (make-session connection-end/client)))
|
|
Packit Service |
4684c1 |
;; The following call should raise an exception.
|
|
Packit Service |
4684c1 |
(set-session-priorities! s string)
|
|
Packit Service |
4684c1 |
#f))
|
|
Packit Service |
4684c1 |
(lambda (key err function error-location . unused)
|
|
Packit Service |
4684c1 |
(and (eq? key 'gnutls-error)
|
|
Packit Service |
4684c1 |
(eq? err error/invalid-request)
|
|
Packit Service |
4684c1 |
(eq? function 'set-session-priorities!)
|
|
Packit Service |
4684c1 |
(= error-location pos))))))
|
|
Packit Service |
4684c1 |
%invalid-priority-strings))))
|