Debian Codegraph @

guile/modules/gnutls/build/enums.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 library is free software; you can redistribute it and/or
7 ;;; modify it under the terms of the GNU Lesser General Public
8 ;;; License as published by the Free Software Foundation; either
9 ;;; version 2.1 of the License, or (at your option) any later version.
10 ;;;
11 ;;; This library 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 GNU
14 ;;; Lesser General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU Lesser General Public
17 ;;; License along with this library; if not, see <https://www.gnu.org/licenses/>.
18
19 ;;; Written by Ludovic Courtès <[email protected]>
20
21 (define-module (gnutls build enums)
22 :use-module (srfi srfi-1)
23 :use-module (srfi srfi-9)
24 :use-module (gnutls build utils)
25
26 :export (make-enum-type
27 enum-type-subsystem
28 enum-type-value-alist
29 enum-type-c-type
30 enum-type-get-name-function
31 enum-type-automatic-get-name-function
32 enum-type-smob-name
33 enum-type-to-c-function
34 enum-type-from-c-function
35
36 output-enum-smob-definitions
37 output-enum-definitions
38 output-enum-declarations
39 output-enum-definition-function
40 output-c->enum-converter
41 output-enum->c-converter
42
43 %cipher-enum
44 %mac-enum
45 %compression-method-enum
46 %kx-enum
47 %protocol-enum
48 %certificate-type-enum
49
50 %gnutls-enums))
51
52 ;;;
53 ;;; This module helps with the creation of bindings for the C enumerate
54 ;;; types. It aims at providing strong typing (i.e., one cannot use an
55 ;;; enumerate value of the wrong type) along with authenticity checks (i.e.,
56 ;;; values of a given enumerate type cannot be forged---for instance, one
57 ;;; cannot use some random integer as an enumerate value). Additionally,
58 ;;; Scheme enums representing the same C enum value should be `eq?'.
59 ;;;
60 ;;; To that end, Scheme->C conversions are optimized (a simple
61 ;;; `SCM_SMOB_DATA'), since that is the most common usage pattern.
62 ;;; Conversely, C->Scheme conversions take time proportional to the number of
63 ;;; value in the enum type.
64 ;;;
65
66
67 ;;;
68 ;;; Enumeration tools.
69 ;;;
70
71 (define-record-type <enum-type>
72 (%make-enum-type subsystem c-type enum-map get-name value-prefix)
73 enum-type?
74 (subsystem enum-type-subsystem)
75 (enum-map enum-type-value-alist)
76 (c-type enum-type-c-type)
77 (get-name enum-type-get-name-function)
78 (value-prefix enum-type-value-prefix))
79
80
81 (define (make-enum-type subsystem c-type values get-name . value-prefix)
82 ;; Return a new enumeration type.
83 (let ((value-prefix (if (null? value-prefix)
84 #f
85 (car value-prefix))))
86 (%make-enum-type subsystem c-type
87 (make-enum-map subsystem values value-prefix)
88 get-name value-prefix)))
89
90
91 (define (make-enum-map subsystem values value-prefix)
92 ;; Return an alist mapping C enum values (strings) to Scheme symbols.
93 (define (value-symbol->string value)
94 (string-upcase (scheme-symbol->c-name value)))
95
96 (define (make-c-name value)
97 (case value-prefix
98 ((#f)
99 ;; automatically derive the C value name.
100 (string-append "GNUTLS_" (string-upcase (symbol->string subsystem))
101 "_" (value-symbol->string value)))
102 (else
103 (string-append value-prefix (value-symbol->string value)))))
104
105 (map (lambda (value)
106 (cons (make-c-name value) value))
107 values))
108
109 (define (enum-type-smob-name enum)
110 ;; Return the C name of the smob type for ENUM.
111 (string-append "scm_tc16_gnutls_"
112 (scheme-symbol->c-name (enum-type-subsystem enum))
113 "_enum"))
114
115 (define (enum-type-smob-list enum)
116 ;; Return the name of the C variable holding a list of value (SMOBs) for
117 ;; ENUM. This list is used when converting from C to Scheme.
118 (string-append "scm_gnutls_"
119 (scheme-symbol->c-name (enum-type-subsystem enum))
120 "_enum_values"))
121
122 (define (enum-type-to-c-function enum)
123 ;; Return the name of the C `scm_to_' function for ENUM.
124 (string-append "scm_to_gnutls_"
125 (scheme-symbol->c-name (enum-type-subsystem enum))))
126
127 (define (enum-type-from-c-function enum)
128 ;; Return the name of the C `scm_from_' function for ENUM.
129 (string-append "scm_from_gnutls_"
130 (scheme-symbol->c-name (enum-type-subsystem enum))))
131
132 (define (enum-type-automatic-get-name-function enum)
133 ;; Return the name of an automatically-generated C function that returns a
134 ;; string describing the given enum value of type ENUM.
135 (string-append "scm_gnutls_"
136 (scheme-symbol->c-name (enum-type-subsystem enum))
137 "_to_c_string"))
138
139
140 ;;;
141 ;;; C code generation.
142 ;;;
143
144 (define (output-enum-smob-definitions enum port)
145 (let ((smob (enum-type-smob-name enum))
146 (get-name (enum-type-get-name-function enum)))
147 (format port "SCM_GLOBAL_SMOB (~a, \"~a\", 0);~%"
148 smob (enum-type-subsystem enum))
149 (format port "SCM ~a = SCM_EOL;~%"
150 (enum-type-smob-list enum))
151
152 (if (not (string? get-name))
153 ;; Generate a "get name" function.
154 (output-enum-get-name-function enum port))
155
156 ;; Generate the printer and `->string' function.
157 (let ((get-name (or get-name
158 (enum-type-automatic-get-name-function enum))))
159 (let ((subsystem (scheme-symbol->c-name (enum-type-subsystem enum))))
160 ;; SMOB printer.
161 (format port "SCM_SMOB_PRINT (~a, ~a_print, obj, port, pstate)~%{~%"
162 smob subsystem)
163 (format port " scm_puts (\"#<gnutls-~a-enum \", port);~%"
164 (enum-type-subsystem enum))
165 (format port " scm_puts (~a (~a (obj, 1, \"~a_print\")), port);~%"
166 get-name (enum-type-to-c-function enum) subsystem)
167 (format port " scm_puts (\">\", port);~%")
168 (format port " return 1;~%")
169 (format port "}~%")
170
171 ;; Enum-to-string.
172 (format port "SCM_DEFINE (scm_gnutls_~a_to_string, \"~a->string\", "
173 subsystem (enum-type-subsystem enum))
174 (format port "1, 0, 0,~%")
175 (format port " (SCM enumval),~%")
176 (format port " \"Return a string describing ")
177 (format port "@var{enumval}, a @code{~a} value.\")~%"
178 (enum-type-subsystem enum))
179 (format port "#define FUNC_NAME s_scm_gnutls_~a_to_string~%"
180 subsystem)
181 (format port "{~%")
182 (format port " ~a c_enum;~%"
183 (enum-type-c-type enum))
184 (format port " const char *c_string;~%")
185 (format port " c_enum = ~a (enumval, 1, FUNC_NAME);~%"
186 (enum-type-to-c-function enum))
187 (format port " c_string = ~a (c_enum);~%"
188 get-name)
189 (format port " return (scm_from_locale_string (c_string));~%")
190 (format port "}~%")
191 (format port "#undef FUNC_NAME~%")))))
192
193 (define (output-enum-definitions enum port)
194 ;; Output to PORT the Guile C code that defines the values of ENUM-ALIST.
195 (let ((subsystem (scheme-symbol->c-name (enum-type-subsystem enum))))
196 (format port " enum_values = SCM_EOL;~%")
197 (for-each (lambda (c+scheme)
198 (format port "#ifndef NO_~a~%"
199 (car c+scheme))
200 (format port " SCM_NEWSMOB (enum_smob, ~a, "
201 (enum-type-smob-name enum))
202 (format port "(scm_t_bits) ~a);~%"
203 (car c+scheme))
204 (format port " enum_values = scm_cons (enum_smob, ")
205 (format port "enum_values);~%")
206 (format port " scm_c_define (\"~a\", enum_smob);~%"
207 (symbol-append (enum-type-subsystem enum) '/
208 (cdr c+scheme)))
209 (format port "#endif /* not NO_~a */~%"
210 (car c+scheme)))
211 (enum-type-value-alist enum))
212 (format port " ~a = scm_permanent_object (enum_values);~%"
213 (enum-type-smob-list enum))))
214
215 (define (output-enum-declarations enum port)
216 ;; Issue header file declarations needed for the inline functions that
217 ;; handle ENUM values.
218 (format port "SCM_API scm_t_bits ~a;~%"
219 (enum-type-smob-name enum))
220 (format port "SCM_API SCM ~a;~%"
221 (enum-type-smob-list enum)))
222
223 (define (output-enum-definition-function enums port)
224 ;; Output a C function that does all the `scm_c_define ()' for the enums
225 ;; listed in ENUMS.
226 (format port "static inline void~%scm_gnutls_define_enums (void)~%{~%")
227 (format port " SCM enum_values, enum_smob;~%")
228 (for-each (lambda (enum)
229 (output-enum-definitions enum port))
230 enums)
231 (format port "}~%"))
232
233 (define (output-c->enum-converter enum port)
234 ;; Output a C->Scheme converted for ENUM. This works by walking the list
235 ;; of available enum values (SMOBs) for ENUM and then returning the
236 ;; matching SMOB, so that users can then compare enums using `eq?'. While
237 ;; this may look inefficient, this shouldn't be a problem since (i)
238 ;; conversion in that direction is rarely needed and (ii) the number of
239 ;; values per enum is expected to be small.
240 (format port "static inline SCM~%~a (~a c_obj)~%{~%"
241 (enum-type-from-c-function enum)
242 (enum-type-c-type enum))
243 (format port " SCM pair, result = SCM_BOOL_F;~%")
244 (format port " for (pair = ~a; scm_is_pair (pair); "
245 (enum-type-smob-list enum))
246 (format port "pair = SCM_CDR (pair))~%")
247 (format port " {~%")
248 (format port " SCM enum_smob;~%")
249 (format port " enum_smob = SCM_CAR (pair);~%")
250 (format port " if ((~a) SCM_SMOB_DATA (enum_smob) == c_obj)~%"
251 (enum-type-c-type enum))
252 (format port " {~%")
253 (format port " result = enum_smob;~%")
254 (format port " break;~%")
255 (format port " }~%")
256 (format port " }~%")
257 (format port " return result;~%")
258 (format port "}~%"))
259
260 (define (output-enum->c-converter enum port)
261 (let* ((c-type-name (enum-type-c-type enum))
262 (subsystem (scheme-symbol->c-name (enum-type-subsystem enum))))
263
264 (format port
265 "static inline ~a~%~a (SCM obj, unsigned pos, const char *func)~%"
266 c-type-name (enum-type-to-c-function enum))
267 (format port "#define FUNC_NAME func~%")
268 (format port "{~%")
269 (format port " SCM_VALIDATE_SMOB (pos, obj, ~a);~%"
270 (string-append "gnutls_" subsystem "_enum"))
271 (format port " return ((~a) SCM_SMOB_DATA (obj));~%"
272 c-type-name)
273 (format port "}~%")
274 (format port "#undef FUNC_NAME~%")))
275
276 (define (output-enum-get-name-function enum port)
277 ;; Output a C function that, when passed a C ENUM value, returns a C string
278 ;; representing that value.
279 (let ((function (enum-type-automatic-get-name-function enum)))
280 (format port
281 "static const char *~%~a (~a c_obj)~%"
282 function (enum-type-c-type enum))
283 (format port "{~%")
284 (format port " static const struct ")
285 (format port "{ ~a value; const char *name; } "
286 (enum-type-c-type enum))
287 (format port "table[] =~%")
288 (format port " {~%")
289 (for-each (lambda (c+scheme)
290 (format port "#ifndef NO_~a~%"
291 (car c+scheme))
292 (format port " { ~a, \"~a\" },~%"
293 (car c+scheme) (cdr c+scheme))
294 (format port "#endif /* not NO_~a */~%"
295 (car c+scheme)))
296 (enum-type-value-alist enum))
297 (format port " };~%")
298 (format port " unsigned i;~%")
299 (format port " const char *name = NULL;~%")
300 (format port " for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)~%")
301 (format port " {~%")
302 (format port " if (table[i].value == c_obj)~%")
303 (format port " {~%")
304 (format port " name = table[i].name;~%")
305 (format port " break;~%")
306 (format port " }~%")
307 (format port " }~%")
308 (format port " return (name);~%")
309 (format port "}~%")))
310
311
312 ;;;
313 ;;; Actual enumerations.
314 ;;;
315
316 (define %cipher-enum
317 (make-enum-type 'cipher "gnutls_cipher_algorithm_t"
318 '(null
319 arcfour
320 arcfour-128
321 3des-cbc
322 aes-128-cbc
323 aes-256-cbc
324 arcfour-40
325 camellia-128-cbc
326 camellia-256-cbc
327 aes-192-cbc
328 aes-128-gcm
329 aes-256-gcm
330 camellia-192-cbc
331 salsa20-256
332 estream-salsa20-256
333 camellia-128-gcm
334 camellia-256-gcm
335 rc2-40-cbc
336 des-cbc
337 aes-128-ccm
338 aes-256-ccm
339 aes-128-ccm-8
340 aes-256-ccm-8
341 chacha20-poly1305
342 gost28147-tc26z-cfb
343 gost28147-cpa-cfb
344 gost28147-cpb-cfb
345 gost28147-cpc-cfb
346 gost28147-cpd-cfb
347 aes-128-cfb8
348 aes-192-cfb8
349 aes-256-cfb8
350 aes-128-xts
351 aes-256-xts
352 gost28147-tc26z-cnt
353 chacha20-64
354 chacha20-32
355 aes-128-siv
356 aes-256-siv
357 aes-192-gcm
358 magma-ctr-acpkm
359 kuznyechik-ctr-acpkm
360 idea-pgp-cfb
361 3des-pgp-cfb
362 cast5-pgp-cfb
363 blowfish-pgp-cfb
364 safer-sk128-pgp-cfb
365 aes128-pgp-cfb
366 aes192-pgp-cfb
367 aes256-pgp-cfb
368 twofish-pgp-cfb)
369 "gnutls_cipher_get_name"))
370
371 (define %kx-enum
372 (make-enum-type 'kx "gnutls_kx_algorithm_t"
373 '(rsa
374 dhe-dss
375 dhe-rsa
376 anon-dh
377 srp
378 rsa-export
379 srp-rsa
380 srp-dss
381 psk
382 dhe-dss)
383 "gnutls_kx_get_name"))
384
385 (define %params-enum
386 (make-enum-type 'params "gnutls_params_type_t"
387 '(rsa-export
388 dh)
389 #f))
390
391 (define %credentials-enum
392 (make-enum-type 'credentials "gnutls_credentials_type_t"
393 '(certificate
394 anon
395 srp
396 psk
397 ia)
398 #f
399 "GNUTLS_CRD_"))
400
401 (define %mac-enum
402 (make-enum-type 'mac "gnutls_mac_algorithm_t"
403 '(unknown
404 null
405 md5
406 sha1
407 rmd160
408 md2
409 sha256
410 sha384
411 sha512
412 sha224
413 sha3-224
414 sha3-256
415 sha3-384
416 sha3-512
417 md5-sha1
418 gostr-94
419 streebog-256
420 streebog-512
421 aead
422 umac-96
423 umac-128
424 aes-cmac-128
425 aes-cmac-256
426 aes-gmac-128
427 aes-gmac-192
428 aes-gmac-256
429 gost28147-tc26z-imit
430 shake-128
431 shake-256
432 magma-omac
433 kuznyechik-omac)
434 "gnutls_mac_get_name"))
435
436 (define %digest-enum
437 (make-enum-type 'digest "gnutls_digest_algorithm_t"
438 '(null
439 md5
440 sha1
441 rmd160
442 md2
443 sha256
444 sha384
445 sha512
446 sha224
447 sha3-224
448 sha3-256
449 sha3-384
450 sha3-512
451 md5-sha1
452 gostr-94
453 streebog-256
454 streebog-512)
455 #f
456 "GNUTLS_DIG_"))
457
458 (define %compression-method-enum
459 (make-enum-type 'compression-method "gnutls_compression_method_t"
460 '(null deflate)
461 "gnutls_compression_get_name"
462 "GNUTLS_COMP_"))
463
464 (define %connection-end-enum
465 (make-enum-type 'connection-end "gnutls_connection_end_t"
466 '(server client)
467 #f
468 "GNUTLS_"))
469
470 (define %connection-flag-enum
471 (make-enum-type 'connection-flag "gnutls_init_flags_t"
472 '(datagram
473 nonblock
474 no-extensions
475 no-replay-protection
476 no-signal
477 allow-id-change
478 enable-false-start
479 force-client-cert
480 no-tickets
481 key-share-top
482 key-share-top2
483 key-share-top3
484 post-handshake-auth
485 no-auto-rekey
486 safe-padding-check
487 enable-early-start
488 enable-rawpk
489 auto-reauth
490 enable-early-data)
491 #f
492 "GNUTLS_"))
493
494 (define %alert-level-enum
495 (make-enum-type 'alert-level "gnutls_alert_level_t"
496 '(warning fatal)
497 #f
498 "GNUTLS_AL_"))
499
500 (define %alert-description-enum
501 (make-enum-type 'alert-description "gnutls_alert_description_t"
502 '(close-notify
503 unexpected-message
504 bad-record-mac
505 decryption-failed
506 record-overflow
507 decompression-failure
508 handshake-failure
509 ssl3-no-certificate
510 bad-certificate
511 unsupported-certificate
512 certificate-revoked
513 certificate-expired
514 certificate-unknown
515 illegal-parameter
516 unknown-ca
517 access-denied
518 decode-error
519 decrypt-error
520 export-restriction
521 protocol-version
522 insufficient-security
523 internal-error
524 user-canceled
525 no-renegotiation
526 unsupported-extension
527 certificate-unobtainable
528 unrecognized-name
529 unknown-psk-identity)
530 #f
531 "GNUTLS_A_"))
532
533 (define %handshake-description-enum
534 (make-enum-type 'handshake-description "gnutls_handshake_description_t"
535 '(hello-request
536 client-hello
537 server-hello
538 certificate-pkt
539 server-key-exchange
540 certificate-request
541 server-hello-done
542 certificate-verify
543 client-key-exchange finished)
544 #f
545 "GNUTLS_HANDSHAKE_"))
546
547 (define %certificate-status-enum
548 (make-enum-type 'certificate-status "gnutls_certificate_status_t"
549 '(invalid
550 revoked
551 signer-not-found
552 signer-not-ca
553 insecure-algorithm
554 not-activated
555 expired
556 signature-failure
557 revocation-data-superseded
558 unexpected-owner
559 revocation-data-issued-in-future
560 signer-constraints-failure
561 mismatch
562 purpose-mismatch
563 missing-ocsp-status
564 invalid-ocsp-status
565 unknown-crit-extensions)
566 #f
567 "GNUTLS_CERT_"))
568
569 (define %certificate-request-enum
570 (make-enum-type 'certificate-request "gnutls_certificate_request_t"
571 '(ignore
572 request
573 require)
574 #f
575 "GNUTLS_CERT_"))
576
577 ;; XXX: Broken naming convention.
578 ; (define %openpgp-key-status-enum
579 ; (make-enum-type 'openpgp-key-status "gnutls_openpgp_key_status_t"
580 ; '(key fingerprint)
581 ; #f
582 ; "GNUTLS_OPENPGP_"))
583
584 (define %close-request-enum
585 (make-enum-type 'close-request "gnutls_close_request_t"
586 '(rdwr
587 wr) ;; FIXME: Check the meaning and rename
588 #f
589 "GNUTLS_SHUT_"))
590
591 (define %protocol-enum
592 (make-enum-type 'protocol "gnutls_protocol_t"
593 '(ssl3
594 tls1-0
595 tls1-1
596 version-unknown)
597 #f
598 "GNUTLS_"))
599
600 (define %certificate-type-enum
601 (make-enum-type 'certificate-type "gnutls_certificate_type_t"
602 '(x509
603 openpgp
604 rawpk)
605 "gnutls_certificate_type_get_name"
606 "GNUTLS_CRT_"))
607
608 (define %x509-certificate-format-enum
609 (make-enum-type 'x509-certificate-format "gnutls_x509_crt_fmt_t"
610 '(der
611 pem)
612 #f
613 "GNUTLS_X509_FMT_"))
614
615 (define %x509-subject-alternative-name-enum
616 (make-enum-type 'x509-subject-alternative-name
617 "gnutls_x509_subject_alt_name_t"
618 '(dnsname
619 rfc822name
620 uri
621 ipaddress)
622 #f
623 "GNUTLS_SAN_"))
624
625 (define %certificate-print-format
626 (make-enum-type 'certificate-print-format "gnutls_certificate_print_formats_t"
627 '(full
628 oneline
629 unsigned-full
630 compact
631 full-numbers)
632 #f
633 "GNUTLS_CRT_PRINT_"))
634
635 (define %pk-algorithm-enum
636 (make-enum-type 'pk-algorithm "gnutls_pk_algorithm_t"
637 '(unknown
638 rsa
639 dsa
640 dh
641 ecdsa
642 ecc
643 ec
644 ecdh-x25519
645 ecdhx
646 rsa-pss
647 eddsa-ed25519
648 gost-01
649 gost-12-256
650 gost-12-512
651 ecdh-x448
652 eddsa-ed448
653 rsa-oaep
654 mlkem768
655 mldsa44
656 mldsa65
657 mldsa87
658 mlkem1024)
659 "gnutls_pk_algorithm_get_name"
660 "GNUTLS_PK_"))
661
662 (define %sign-algorithm-enum
663 (make-enum-type 'sign-algorithm "gnutls_sign_algorithm_t"
664 '(unknown
665 rsa-sha1
666 dsa-sha1
667 rsa-md5
668 rsa-md2
669 rsa-rmd160
670 rsa-sha256
671 rsa-sha384
672 rsa-sha512
673 rsa-sha224
674 dsa-sha224
675 dsa-sha256
676 ecdsa-sha1
677 ecdsa-sha224
678 ecdsa-sha256
679 ecdsa-sha384
680 ecdsa-sha512
681 dsa-sha384
682 dsa-sha512
683 ecdsa-sha3-224
684 ecdsa-sha3-256
685 ecdsa-sha3-384
686 ecdsa-sha3-512
687
688 dsa-sha3-224
689 dsa-sha3-256
690 dsa-sha3-384
691 dsa-sha3-512
692 rsa-sha3-224
693 rsa-sha3-256
694 rsa-sha3-384
695 rsa-sha3-512
696
697 rsa-pss-sha256
698 rsa-pss-sha384
699 rsa-pss-sha512
700 eddsa-ed25519
701 rsa-raw
702
703 ecdsa-secp256r1-sha256
704 ecdsa-secp384r1-sha384
705 ecdsa-secp521r1-sha512
706
707 rsa-pss-rsae-sha256
708 rsa-pss-rsae-sha384
709 rsa-pss-rsae-sha512
710
711 gost-94
712 gost-256
713 gost-512
714 eddsa-ed448
715
716 mldsa44
717 mldsa65
718 mldsa87)
719 "gnutls_sign_algorithm_get_name"
720 "GNUTLS_SIGN_"))
721
722 (define %psk-key-format-enum
723 (make-enum-type 'psk-key-format "gnutls_psk_key_flags"
724 '(raw hex)
725 #f
726 "GNUTLS_PSK_KEY_"))
727
728 (define %random-level-enum
729 (make-enum-type 'random-level "gnutls_rnd_level_t"
730 '(nonce random key)
731 #f
732 "GNUTLS_RND_"))
733
734 (define %key-usage-enum
735 ;; Not actually an enum on the C side.
736 (make-enum-type 'key-usage "int"
737 '(digital-signature
738 non-repudiation
739 key-encipherment
740 data-encipherment
741 key-agreement
742 key-cert-sign
743 crl-sign
744 encipher-only
745 decipher-only)
746 #f
747 "GNUTLS_KEY_"))
748
749 (define %certificate-verify-enum
750 (make-enum-type 'certificate-verify "gnutls_certificate_verify_flags"
751 '(disable-ca-sign
752 allow-x509-v1-ca-crt
753 do-not-allow-same
754 allow-any-x509-v1-ca-crt
755 allow-sign-rsa-md2
756 allow-sign-rsa-md5)
757 #f
758 "GNUTLS_VERIFY_"))
759
760 (define %error-enum
761 (make-enum-type 'error "int"
762 '(
763 ;; FIXME: Automate this:
764 ;; grep '^#define GNUTLS_E_' ../../../lib/includes/gnutls/gnutls.h.in \
765 ;; | sed -r -e 's/^#define GNUTLS_E_([^ ]+).*$/\1/' | tr A-Z_ a-z-
766 success
767 unsupported-version-packet
768 tls-packet-decoding-error
769 unexpected-packet-length
770 invalid-session
771 fatal-alert-received
772 unexpected-packet
773 warning-alert-received
774 error-in-finished-packet
775 unexpected-handshake-packet
776 decryption-failed
777 memory-error
778 decompression-failed
779 compression-failed
780 again
781 expired
782 db-error
783 srp-pwd-error
784 keyfile-error
785 insufficient-credentials
786 insuficient-credentials
787 insufficient-cred
788 insuficient-cred
789 hash-failed
790 base64-decoding-error
791 rehandshake
792 got-application-data
793 record-limit-reached
794 encryption-failed
795 pk-encryption-failed
796 pk-decryption-failed
797 pk-sign-failed
798 x509-unsupported-critical-extension
799 key-usage-violation
800 no-certificate-found
801 invalid-request
802 short-memory-buffer
803 interrupted
804 push-error
805 pull-error
806 received-illegal-parameter
807 requested-data-not-available
808 pkcs1-wrong-pad
809 received-illegal-extension
810 internal-error
811 dh-prime-unacceptable
812 file-error
813 too-many-empty-packets
814 unknown-pk-algorithm
815 too-many-handshake-packets
816 received-disallowed-name
817 certificate-required
818 no-temporary-rsa-params
819 no-compression-algorithms
820 no-cipher-suites
821 openpgp-getkey-failed
822 pk-sig-verify-failed
823 illegal-srp-username
824 srp-pwd-parsing-error
825 keyfile-parsing-error
826 no-temporary-dh-params
827 asn1-element-not-found
828 asn1-identifier-not-found
829 asn1-der-error
830 asn1-value-not-found
831 asn1-generic-error
832 asn1-value-not-valid
833 asn1-tag-error
834 asn1-tag-implicit
835 asn1-type-any-error
836 asn1-syntax-error
837 asn1-der-overflow
838 openpgp-uid-revoked
839 certificate-error
840 x509-certificate-error
841 certificate-key-mismatch
842 unsupported-certificate-type
843 x509-unknown-san
844 openpgp-fingerprint-unsupported
845 x509-unsupported-attribute
846 unknown-hash-algorithm
847 unknown-pkcs-content-type
848 unknown-pkcs-bag-type
849 invalid-password
850 mac-verify-failed
851 constraint-error
852 warning-ia-iphf-received
853 warning-ia-fphf-received
854 ia-verify-failed
855 unknown-algorithm
856 unsupported-signature-algorithm
857 safe-renegotiation-failed
858 unsafe-renegotiation-denied
859 unknown-srp-username
860 premature-termination
861 malformed-cidr
862 base64-encoding-error
863 incompatible-gcrypt-library
864 incompatible-crypto-library
865 incompatible-libtasn1-library
866 openpgp-keyring-error
867 x509-unsupported-oid
868 random-failed
869 base64-unexpected-header-error
870 openpgp-subkey-error
871 crypto-already-registered
872 already-registered
873 handshake-too-large
874 cryptodev-ioctl-error
875 cryptodev-device-error
876 channel-binding-not-available
877 bad-cookie
878 openpgp-preferred-key-error
879 incompat-dsa-key-with-tls-protocol
880 insufficient-security
881 heartbeat-pong-received
882 heartbeat-ping-received
883 unrecognized-name
884 pkcs11-error
885 pkcs11-load-error
886 parsing-error
887 pkcs11-pin-error
888 pkcs11-slot-error
889 locking-error
890 pkcs11-attribute-error
891 pkcs11-device-error
892 pkcs11-data-error
893 pkcs11-unsupported-feature-error
894 pkcs11-key-error
895 pkcs11-pin-expired
896 pkcs11-pin-locked
897 pkcs11-session-error
898 pkcs11-signature-error
899 pkcs11-token-error
900 pkcs11-user-error
901 crypto-init-failed
902 timedout
903 user-error
904 ecc-no-supported-curves
905 ecc-unsupported-curve
906 pkcs11-requested-object-not-availble
907 certificate-list-unsorted
908 illegal-parameter
909 no-priorities-were-set
910 x509-unsupported-extension
911 session-eof
912 tpm-error
913 tpm-key-password-error
914 tpm-srk-password-error
915 tpm-session-error
916 tpm-key-not-found
917 tpm-uninitialized
918 tpm-no-lib
919 no-certificate-status
920 ocsp-response-error
921 random-device-error
922 auth-error
923 no-application-protocol
924 sockets-init-error
925 key-import-failed
926 inappropriate-fallback
927 certificate-verification-error
928 privkey-verification-error
929 unexpected-extensions-length
930 asn1-embedded-null-in-string
931 self-test-error
932 no-self-test
933 lib-in-error-state
934 pk-generation-error
935 idna-error
936 need-fallback
937 session-user-id-changed
938 handshake-during-false-start
939 unavailable-during-handshake
940 pk-invalid-pubkey
941 pk-invalid-privkey
942 not-yet-activated
943 invalid-utf8-string
944 no-embedded-data
945 invalid-utf8-email
946 invalid-password-string
947 certificate-time-error
948 record-overflow
949 asn1-time-error
950 incompatible-sig-with-key
951 pk-invalid-pubkey-params
952 pk-no-validation-params
953 ocsp-mismatch-with-certs
954 no-common-key-share
955 reauth-request
956 too-many-matches
957 crl-verification-error
958 missing-extension
959 db-entry-exists
960 early-data-rejected
961 unimplemented-feature
962 int-ret-0
963 int-check-again
964 application-error-max
965 application-error-min
966 )
967 "gnutls_strerror"
968 "GNUTLS_E_"))
969
970
971 (define %openpgp-certificate-format-enum
972 (make-enum-type 'openpgp-certificate-format "gnutls_openpgp_crt_fmt_t"
973 '(raw
974 base64)
975 #f
976 "GNUTLS_OPENPGP_FMT_"))
977
978 (define %server-name-type-enum
979 (make-enum-type 'server-name-type "gnutls_server_name_type_t"
980 '(dns)
981 #f
982 "GNUTLS_NAME_"))
983
984 (define %privkey-enum
985 (make-enum-type 'privkey "gnutls_privkey_flags_t"
986 '(import-auto-release
987 import-copy
988 disable-callbacks
989 sign-flag-tls1-rsa
990 flag-provable
991 flag-export-compat
992 sign-flag-rsa-pss
993 flag-reproducible flag-ca)
994 #f
995 "GNUTLS_PRIVKEY_"))
996
997 (define %oid-enum
998 ;; Not actually an enum on the C side.
999 (make-enum-type 'oid "const char *"
1000 '(x520-country-name
1001 x520-organization-name
1002 x520-organizational-unit-name
1003 x520-common-name
1004 x520-locality-name
1005 x520-state-or-province-name
1006 x520-initials
1007 x520-generation-qualifier
1008 x520-surname
1009 x520-given-name
1010 x520-title
1011 x520-dn-qualifier
1012 x520-pseudonym
1013 x520-postalcode
1014 x520-name
1015 ldap-dc
1016 ldap-uid
1017 pkcs9-email
1018 pkix-date-of-birth
1019 pkix-place-of-birth
1020 pkix-gender
1021 pkix-country-of-citizenship
1022 pkix-country-of-residence
1023 aia
1024 ad-ocsp
1025 ad-caissuers)
1026 #f
1027 "GNUTLS_OID_"))
1028
1029 (define %ecc-curve-enum
1030 (make-enum-type 'ecc-curve "gnutls_ecc_curve_t"
1031 '(invalid
1032 secp224r1
1033 secp256r1
1034 secp384r1
1035 secp521r1
1036 secp192r1
1037 x25519
1038 ed25519
1039 gost256cpa
1040 gost256cpb
1041 gost256cpc
1042 gost256cpxa
1043 gost256cpxb
1044 gost512a
1045 gost512b
1046 gost512c
1047 gost256a
1048 gost256b
1049 gost256c
1050 gost256d
1051 x448
1052 ed448)
1053 "gnutls_ecc_curve_get_name"
1054 "GNUTLS_ECC_CURVE_"))
1055
1056 (define %gnutls-enums
1057 ;; All enums.
1058 (list
1059 %cipher-enum
1060 %kx-enum
1061 %params-enum
1062 %credentials-enum
1063 %mac-enum
1064 %digest-enum
1065 %compression-method-enum
1066 %connection-end-enum
1067 %connection-flag-enum
1068 %alert-level-enum
1069 %alert-description-enum
1070 %handshake-description-enum
1071 %certificate-status-enum
1072 %certificate-request-enum
1073 %close-request-enum
1074 %protocol-enum
1075 %certificate-type-enum
1076 %x509-certificate-format-enum
1077 %x509-subject-alternative-name-enum
1078 %certificate-print-format
1079 %pk-algorithm-enum
1080 %sign-algorithm-enum
1081 %server-name-type-enum
1082 %psk-key-format-enum
1083 %key-usage-enum
1084 %certificate-verify-enum
1085 %error-enum
1086 %privkey-enum
1087 %oid-enum
1088 %ecc-curve-enum
1089 %random-level-enum
1090 %openpgp-certificate-format-enum))
1091
1092 ;;; Local Variables:
1093 ;;; mode: scheme
1094 ;;; coding: utf-8
1095 ;;; End:
1096
1097 ;;; arch-tag: 9e3eb6bb-61a5-4e85-861f-1914ab9677b0