Debian Codegraph @

guile/tests/pkcs-import-export.scm

raw
1 ;;; GnuTLS --- Guile bindings for GnuTLS.
2 ;;; Copyright (C) 2007-2025 Free Software Foundation, Inc.
3 ;;;
4 ;;; This file is part of Guile-GnuTLS.
5 ;;;
6 ;;; This program is free software: you can redistribute it and/or modify
7 ;;; it under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation, either version 3 of the License, or
9 ;;; (at your option) any later version.
10 ;;;
11 ;;; This program is distributed in the hope that it will be useful,
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19 ;;; Written by Ludovic Courtès <[email protected]>.
20
21
22 ;;;
23 ;;; Exercise the DH/RSA PKCS3/PKCS1 export/import functions.
24 ;;;
25
26 (use-modules (gnutls)
27 (gnutls build tests)
28 (srfi srfi-4))
29
30 (define (import-something import-proc file fmt)
31 (let* ((path (search-path %load-path file))
32 (size (stat:size (stat path)))
33 (raw (make-u8vector size)))
34 (uniform-vector-read! raw (open-input-file path))
35 (import-proc raw fmt)))
36
37 (define (import-dh-params file)
38 (import-something pkcs3-import-dh-parameters file
39 x509-certificate-format/pem))
40
41 (run-test
42 (lambda ()
43 (let* ((dh-params (import-dh-params "dh-parameters.pem"))
44 (export
45 (pkcs3-export-dh-parameters dh-params
46 x509-certificate-format/pem)))
47 (and (u8vector? export)
48 (let ((import
49 (pkcs3-import-dh-parameters export
50 x509-certificate-format/pem)))
51 (dh-parameters? import))))))
52
53 ;;; arch-tag: adff0f07-479e-421e-b47f-8956e06b9902