Next: , Previous: , Up: Guile API Conventions   [Contents][Index]


3.3 Representation of Binary Data

Many procedures operate on binary data. For instance, pkcs3-import-dh-parameters expects binary data as input.

Binary data is represented on the Scheme side using SRFI-4 homogeneous vectors (see SRFI-4 in The GNU Guile Reference Manual). 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 Diffie-Hellman parameters in the PEM format can be done as follows:

(let* ((dh  (make-dh-parameters 1024))
       (pem (pkcs3-export-dh-parameters dh 
                                        x509-certificate-format/pem)))
  (call-with-output-file "some-file.pem"
    (lambda (port)
      (uniform-vector-write pem port))))

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