[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
11.3.3 Importing OpenPGP Keys Guile Example
The following example provides a simple way of importing
“ASCII-armored” OpenPGP keys from files, using the
import-openpgp-certificate
and import-openpgp-private-key
procedures provided by the (gnutls extra)
module.
(use-modules (srfi srfi-4) (gnutls extra)) (define (import-key-from-file import-proc file) ;; Import OpenPGP key from FILE using IMPORT-PROC. ;; Prepare a u8vector large enough to hold the raw ;; key contents. (let* ((size (stat:size (stat path))) (raw (make-u8vector size))) ;; Fill in the u8vector with the contents of FILE. (uniform-vector-read! raw (open-input-file file)) ;; Pass the u8vector to the import procedure. (import-proc raw openpgp-certificate-format/base64))) (define (import-public-key-from-file file) (import-key-from-file import-openpgp-certificate file)) (define (import-private-key-from-file file) (import-key-from-file import-openpgp-private-key file)) |
The procedures import-public-key-from-file
and
import-private-key-from-file
can be passed a file name. They
return an OpenPGP public key and private key object, respectively
(see section OpenPGP key objects).