Next: , Previous: Procedure Names, Up: Guile API Conventions


11.2.3 Representation of Binary Data

Many procedures operate on binary data. For instance, pkcs3-import-dh-parameters expects binary data as input and, similarly, procedures like pkcs1-export-rsa-parameters return binary data.

Binary data is represented on the Scheme side using SRFI-4 homogeneous vectors (see SRFI-4). Although any type of homogeneous vector may be used, u8vectors (i.e., vectors of bytes) are highly recommended.

As an example, generating and then exporting RSA parameters in the PEM format can be done as follows:

     (let* ((rsa-params (make-rsa-parameters 1024))
            (raw-data
             (pkcs1-export-rsa-parameters rsa-params
                                          x509-certificate-format/pem)))
       (uniform-vector-write raw-data (open-output-file "some-file.pem")))

For an example of OpenPGP key import from a file, see Importing OpenPGP Keys Guile Example.