1 ;;; GnuTLS --- Guile bindings for GnuTLS.
2 ;;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
4 ;;; GnuTLS is free software; you can redistribute it and/or
5 ;;; modify it under the terms of the GNU Lesser General Public
6 ;;; License as published by the Free Software Foundation; either
7 ;;; version 2.1 of the License, or (at your option) any later version.
9 ;;; GnuTLS is distributed in the hope that it will be useful,
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ;;; Lesser General Public License for more details.
14 ;;; You should have received a copy of the GNU Lesser General Public
15 ;;; License along with GnuTLS; if not, write to the Free Software
16 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 ;;; Written by Ludovic Courtès <ludo@gnu.org>
20 (define-module (gnutls)
21 ;; Note: The export list must be manually kept in sync with the build
23 :export (;; versioning
28 make-session bye handshake rehandshake
30 session-cipher session-kx session-mac session-protocol
31 session-compression-method session-certificate-type
32 session-authentication-type session-server-authentication-type
33 session-client-authentication-type
34 session-peer-certificate-chain session-our-certificate-chain
35 set-session-transport-fd! set-session-transport-port!
36 set-session-credentials! set-server-session-certificate-request!
38 ;; anonymous credentials
39 anonymous-client-credentials? anonymous-server-credentials?
40 make-anonymous-client-credentials make-anonymous-server-credentials
41 set-anonymous-server-dh-parameters!
43 ;; certificate credentials
44 certificate-credentials? make-certificate-credentials
45 set-certificate-credentials-dh-parameters!
46 set-certificate-credentials-rsa-export-parameters!
47 set-certificate-credentials-x509-key-files!
48 set-certificate-credentials-x509-trust-file!
49 set-certificate-credentials-x509-crl-file!
50 set-certificate-credentials-x509-key-data!
51 set-certificate-credentials-x509-trust-data!
52 set-certificate-credentials-x509-crl-data!
53 set-certificate-credentials-x509-keys!
54 set-certificate-credentials-verify-limits!
55 set-certificate-credentials-verify-flags!
56 peer-certificate-status
59 srp-client-credentials? srp-server-credentials?
60 make-srp-client-credentials make-srp-server-credentials
61 set-srp-client-credentials!
62 set-srp-server-credentials-files!
63 server-session-srp-username
64 srp-base64-encode srp-base64-decode
67 psk-client-credentials? psk-server-credentials?
68 make-psk-client-credentials make-psk-server-credentials
69 set-psk-client-credentials!
70 set-psk-server-credentials-file!
71 server-session-psk-username
74 set-session-priorities!
76 ;; priority functions (deprecated)
77 set-session-cipher-priority! set-session-mac-priority!
78 set-session-compression-method-priority!
79 set-session-kx-priority! set-session-protocol-priority!
80 set-session-certificate-type-priority!
81 set-session-default-priority! set-session-default-export-priority!
84 set-session-dh-prime-bits!
85 make-dh-parameters dh-parameters?
86 pkcs3-import-dh-parameters pkcs3-export-dh-parameters
89 make-rsa-parameters rsa-parameters?
90 pkcs1-import-rsa-parameters pkcs1-export-rsa-parameters
93 x509-certificate? x509-private-key?
94 import-x509-certificate x509-certificate-matches-hostname?
95 x509-certificate-dn x509-certificate-dn-oid
96 x509-certificate-issuer-dn x509-certificate-issuer-dn-oid
97 x509-certificate-signature-algorithm x509-certificate-version
98 x509-certificate-key-id x509-certificate-authority-key-id
99 x509-certificate-subject-key-id
100 x509-certificate-subject-alternative-name
101 x509-certificate-public-key-algorithm x509-certificate-key-usage
102 import-x509-private-key pkcs8-import-x509-private-key
105 record-send record-receive!
109 set-log-procedure! set-log-level!
111 ;; enum->string functions
112 cipher->string kx->string params->string credentials->string
113 mac->string digest->string compression-method->string
114 connection-end->string alert-level->string
115 alert-description->string handshake-description->string
116 certificate-status->string certificate-request->string
117 close-request->string
118 protocol->string certificate-type->string
119 x509-certificate-format->string
120 x509-subject-alternative-name->string pk-algorithm->string
121 sign-algorithm->string psk-key-format->string key-usage->string
122 certificate-verify->string error->string
127 cipher/arcfour cipher/arcfour-128
129 cipher/aes-128-cbc cipher/rijndael-cbc cipher/rijndael-128-cbc
130 cipher/aes-256-cbc cipher/rijndael-256-cbc
146 credentials/certificate
148 credentials/anonymous
163 compression-method/null
164 compression-method/deflate
165 compression-method/lzo
166 connection-end/server
167 connection-end/client
170 alert-description/close-notify
171 alert-description/unexpected-message
172 alert-description/bad-record-mac
173 alert-description/decryption-failed
174 alert-description/record-overflow
175 alert-description/decompression-failure
176 alert-description/handshake-failure
177 alert-description/ssl3-no-certificate
178 alert-description/bad-certificate
179 alert-description/unsupported-certificate
180 alert-description/certificate-revoked
181 alert-description/certificate-expired
182 alert-description/certificate-unknown
183 alert-description/illegal-parameter
184 alert-description/unknown-ca
185 alert-description/access-denied
186 alert-description/decode-error
187 alert-description/decrypt-error
188 alert-description/export-restriction
189 alert-description/protocol-version
190 alert-description/insufficient-security
191 alert-description/internal-error
192 alert-description/user-canceled
193 alert-description/no-renegotiation
194 alert-description/unsupported-extension
195 alert-description/certificate-unobtainable
196 alert-description/unrecognized-name
197 alert-description/unknown-psk-identity
198 alert-description/inner-application-failure
199 alert-description/inner-application-verification
200 handshake-description/hello-request
201 handshake-description/client-hello
202 handshake-description/server-hello
203 handshake-description/certificate-pkt
204 handshake-description/server-key-exchange
205 handshake-description/certificate-request
206 handshake-description/server-hello-done
207 handshake-description/certificate-verify
208 handshake-description/client-key-exchange
209 handshake-description/finished
210 certificate-status/invalid
211 certificate-status/revoked
212 certificate-status/signer-not-found
213 certificate-status/signer-not-ca
214 certificate-status/insecure-algorithm
215 certificate-request/ignore
216 certificate-request/request
217 certificate-request/require
223 protocol/version-unknown
224 certificate-type/x509
225 certificate-type/openpgp
226 x509-certificate-format/der
227 x509-certificate-format/pem
228 x509-subject-alternative-name/dnsname
229 x509-subject-alternative-name/rfc822name
230 x509-subject-alternative-name/uri
231 x509-subject-alternative-name/ipaddress
235 sign-algorithm/unknown
236 sign-algorithm/rsa-sha1
237 sign-algorithm/dsa-sha1
238 sign-algorithm/rsa-md5
239 sign-algorithm/rsa-md2
240 sign-algorithm/rsa-rmd160
243 key-usage/digital-signature
244 key-usage/non-repudiation
245 key-usage/key-encipherment
246 key-usage/data-encipherment
247 key-usage/key-agreement
248 key-usage/key-cert-sign
250 key-usage/encipher-only
251 key-usage/decipher-only
252 certificate-verify/disable-ca-sign
253 certificate-verify/allow-x509-v1-ca-crt
254 certificate-verify/allow-x509-v1-ca-certificate
255 certificate-verify/do-not-allow-same
256 certificate-verify/allow-any-x509-v1-ca-crt
257 certificate-verify/allow-any-x509-v1-ca-certificate
258 certificate-verify/allow-sign-rsa-md2
259 certificate-verify/allow-sign-rsa-md5
261 ;; FIXME: Automate this:
262 ;; grep '^#define GNUTLS_E_' ../../lib/includes/gnutls/gnutls.h.in | \
263 ;; sed -r -e 's|^#define GNUTLS_E_([^ ]+).*$|error/\1|' | tr A-Z_ a-z-
265 error/unsupported-version-packet
266 error/unexpected-packet-length
267 error/invalid-session
268 error/fatal-alert-received
269 error/unexpected-packet
270 error/warning-alert-received
271 error/error-in-finished-packet
272 error/unexpected-handshake-packet
273 error/decryption-failed
275 error/decompression-failed
276 error/compression-failed
281 error/insufficient-credentials
282 error/insuficient-credentials
283 error/insufficient-cred
284 error/insuficient-cred
286 error/base64-decoding-error
288 error/got-application-data
289 error/record-limit-reached
290 error/encryption-failed
291 error/pk-encryption-failed
292 error/pk-decryption-failed
294 error/x509-unsupported-critical-extension
295 error/key-usage-violation
296 error/no-certificate-found
297 error/invalid-request
298 error/short-memory-buffer
302 error/received-illegal-parameter
303 error/requested-data-not-available
304 error/pkcs1-wrong-pad
305 error/received-illegal-extension
307 error/dh-prime-unacceptable
309 error/too-many-empty-packets
310 error/unknown-pk-algorithm
311 error/too-many-handshake-packets
312 error/no-temporary-rsa-params
313 error/no-compression-algorithms
314 error/no-cipher-suites
315 error/openpgp-getkey-failed
316 error/pk-sig-verify-failed
317 error/illegal-srp-username
318 error/srp-pwd-parsing-error
319 error/no-temporary-dh-params
320 error/asn1-element-not-found
321 error/asn1-identifier-not-found
323 error/asn1-value-not-found
324 error/asn1-generic-error
325 error/asn1-value-not-valid
327 error/asn1-tag-implicit
328 error/asn1-type-any-error
329 error/asn1-syntax-error
330 error/asn1-der-overflow
331 error/openpgp-uid-revoked
332 error/certificate-error
333 error/x509-certificate-error
334 error/certificate-key-mismatch
335 error/unsupported-certificate-type
336 error/x509-unknown-san
337 error/openpgp-fingerprint-unsupported
338 error/x509-unsupported-attribute
339 error/unknown-hash-algorithm
340 error/unknown-pkcs-content-type
341 error/unknown-pkcs-bag-type
342 error/invalid-password
343 error/mac-verify-failed
344 error/constraint-error
345 error/warning-ia-iphf-received
346 error/warning-ia-fphf-received
347 error/ia-verify-failed
348 error/unknown-algorithm
349 error/unsupported-signature-algorithm
350 error/safe-renegotiation-failed
351 error/unsafe-renegotiation-denied
352 error/unknown-srp-username
353 error/premature-termination
354 error/base64-encoding-error
355 error/incompatible-gcrypt-library
356 error/incompatible-crypto-library
357 error/incompatible-libtasn1-library
358 error/openpgp-keyring-error
359 error/x509-unsupported-oid
361 error/base64-unexpected-header-error
362 error/openpgp-subkey-error
363 error/crypto-already-registered
364 error/handshake-too-large
365 error/cryptodev-ioctl-error
366 error/cryptodev-device-error
367 error/channel-binding-not-available
369 error/openpgp-preferred-key-error
370 error/incompat-dsa-key-with-tls-protocol
372 error/pkcs11-load-error
374 error/pkcs11-pin-error
375 error/pkcs11-slot-error
377 error/pkcs11-attribute-error
378 error/pkcs11-device-error
379 error/pkcs11-data-error
380 error/pkcs11-unsupported-feature-error
381 error/pkcs11-key-error
382 error/pkcs11-pin-expired
383 error/pkcs11-pin-locked
384 error/pkcs11-session-error
385 error/pkcs11-signature-error
386 error/pkcs11-token-error
387 error/pkcs11-user-error
388 error/crypto-init-failed
391 error/ecc-no-supported-curves
392 error/ecc-unsupported-curve
393 error/pkcs11-requested-object-not-availble
394 error/certificate-list-unsorted
395 error/illegal-parameter
396 error/no-priorities-were-set
397 error/unimplemented-feature
398 error/application-error-max
399 error/application-error-min
401 ;; OpenPGP keys (formerly in GnuTLS-extra)
402 openpgp-certificate? openpgp-private-key?
403 import-openpgp-certificate import-openpgp-private-key
404 openpgp-certificate-id openpgp-certificate-id!
405 openpgp-certificate-fingerprint openpgp-certificate-fingerprint!
406 openpgp-certificate-name openpgp-certificate-names
407 openpgp-certificate-algorithm openpgp-certificate-version
408 openpgp-certificate-usage
411 openpgp-keyring? import-openpgp-keyring
412 openpgp-keyring-contains-key-id?
414 ;; certificate credentials
415 set-certificate-credentials-openpgp-keys!
417 ;; enum->string functions
418 openpgp-certificate-format->string
421 openpgp-certificate-format/raw
422 openpgp-certificate-format/base64))
425 (or (getenv "GNUTLS_GUILE_EXTENSION_DIR")
426 "@guileextensiondir@"))
428 (load-extension (string-append %libdir "/guile-gnutls-v-2")
432 (define protocol/ssl-3 protocol/ssl3)
433 (define protocol/tls-1.0 protocol/tls1-0)
434 (define protocol/tls-1.1 protocol/tls1-1)
437 (define credentials/anonymous credentials/anon)
438 (define cipher/rijndael-256-cbc cipher/aes-256-cbc)
439 (define cipher/rijndael-128-cbc cipher/aes-128-cbc)
440 (define cipher/rijndael-cbc cipher/aes-128-cbc)
441 (define cipher/arcfour-128 cipher/arcfour)
442 (define certificate-verify/allow-any-x509-v1-ca-certificate
443 certificate-verify/allow-any-x509-v1-ca-crt)
444 (define certificate-verify/allow-x509-v1-ca-certificate
445 certificate-verify/allow-x509-v1-ca-crt)
452 ;;; arch-tag: 3394732c-d9fa-48dd-a093-9fba3a325b8b