Blame guile/tests/pkcs-import-export.scm

Packit aea12f
;;; GnuTLS --- Guile bindings for GnuTLS.
Packit aea12f
;;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
Packit aea12f
;;;
Packit aea12f
;;; GnuTLS is free software; you can redistribute it and/or
Packit aea12f
;;; modify it under the terms of the GNU Lesser General Public
Packit aea12f
;;; License as published by the Free Software Foundation; either
Packit aea12f
;;; version 2.1 of the License, or (at your option) any later version.
Packit aea12f
;;;
Packit aea12f
;;; GnuTLS is distributed in the hope that it will be useful,
Packit aea12f
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit aea12f
;;; Lesser General Public License for more details.
Packit aea12f
;;;
Packit aea12f
;;; You should have received a copy of the GNU Lesser General Public
Packit aea12f
;;; License along with GnuTLS; if not, write to the Free Software
Packit aea12f
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit aea12f
Packit aea12f
;;; Written by Ludovic Courtès <ludo@chbouib.org>.
Packit aea12f
Packit aea12f
Packit aea12f
;;;
Packit aea12f
;;; Exercise the DH/RSA PKCS3/PKCS1 export/import functions.
Packit aea12f
;;;
Packit aea12f
Packit aea12f
(use-modules (gnutls)
Packit aea12f
             (gnutls build tests)
Packit aea12f
             (srfi srfi-4))
Packit aea12f
Packit aea12f
(define (import-something import-proc file fmt)
Packit aea12f
  (let* ((path (search-path %load-path file))
Packit aea12f
         (size (stat:size (stat path)))
Packit aea12f
         (raw  (make-u8vector size)))
Packit aea12f
    (uniform-vector-read! raw (open-input-file path))
Packit aea12f
    (import-proc raw fmt)))
Packit aea12f
Packit aea12f
(define (import-dh-params file)
Packit aea12f
  (import-something pkcs3-import-dh-parameters file
Packit aea12f
                    x509-certificate-format/pem))
Packit aea12f
Packit aea12f
(run-test
Packit aea12f
    (lambda ()
Packit aea12f
      (let* ((dh-params (import-dh-params "dh-parameters.pem"))
Packit aea12f
             (export
Packit aea12f
              (pkcs3-export-dh-parameters dh-params
Packit aea12f
                                          x509-certificate-format/pem)))
Packit aea12f
        (and (u8vector? export)
Packit aea12f
             (let ((import
Packit aea12f
                    (pkcs3-import-dh-parameters export
Packit aea12f
                                                x509-certificate-format/pem)))
Packit aea12f
               (dh-parameters? import))))))
Packit aea12f
Packit aea12f
;;; arch-tag: adff0f07-479e-421e-b47f-8956e06b9902