[hopefully] fixed pathlen problem on ARM platforms
[strongswan.git] / src / libstrongswan / plugins / revocation / revocation_validator.c
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 * Copyright (C) 2009 Andreas Steffen
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18 #include "revocation_validator.h"
19
20 #include <debug.h>
21 #include <credentials/certificates/x509.h>
22 #include <credentials/certificates/crl.h>
23 #include <credentials/certificates/ocsp_request.h>
24 #include <credentials/certificates/ocsp_response.h>
25 #include <credentials/sets/ocsp_response_wrapper.h>
26 #include <selectors/traffic_selector.h>
27
28 typedef struct private_revocation_validator_t private_revocation_validator_t;
29
30 /**
31 * Private data of an revocation_validator_t object.
32 */
33 struct private_revocation_validator_t {
34
35 /**
36 * Public revocation_validator_t interface.
37 */
38 revocation_validator_t public;
39 };
40
41 /**
42 * Do an OCSP request
43 */
44 static certificate_t *fetch_ocsp(char *url, certificate_t *subject,
45 certificate_t *issuer)
46 {
47 certificate_t *request, *response;
48 chunk_t send, receive;
49
50 /* TODO: requestor name, signature */
51 request = lib->creds->create(lib->creds,
52 CRED_CERTIFICATE, CERT_X509_OCSP_REQUEST,
53 BUILD_CA_CERT, issuer,
54 BUILD_CERT, subject, BUILD_END);
55 if (!request)
56 {
57 DBG1(DBG_CFG, "generating ocsp request failed");
58 return NULL;
59 }
60
61 if (!request->get_encoding(request, CERT_ASN1_DER, &send))
62 {
63 DBG1(DBG_CFG, "encoding ocsp request failed");
64 request->destroy(request);
65 return NULL;
66 }
67 request->destroy(request);
68
69 DBG1(DBG_CFG, " requesting ocsp status from '%s' ...", url);
70 if (lib->fetcher->fetch(lib->fetcher, url, &receive,
71 FETCH_REQUEST_DATA, send,
72 FETCH_REQUEST_TYPE, "application/ocsp-request",
73 FETCH_END) != SUCCESS)
74 {
75 DBG1(DBG_CFG, "ocsp request to %s failed", url);
76 chunk_free(&send);
77 return NULL;
78 }
79 chunk_free(&send);
80
81 response = lib->creds->create(lib->creds,
82 CRED_CERTIFICATE, CERT_X509_OCSP_RESPONSE,
83 BUILD_BLOB_ASN1_DER, receive, BUILD_END);
84 chunk_free(&receive);
85 if (!response)
86 {
87 DBG1(DBG_CFG, "parsing ocsp response failed");
88 return NULL;
89 }
90 return response;
91 }
92
93 /**
94 * check the signature of an OCSP response
95 */
96 static bool verify_ocsp(ocsp_response_t *response, auth_cfg_t *auth)
97 {
98 certificate_t *issuer, *subject;
99 identification_t *responder;
100 ocsp_response_wrapper_t *wrapper;
101 enumerator_t *enumerator;
102 auth_cfg_t *current;
103 bool verified = FALSE;
104
105 wrapper = ocsp_response_wrapper_create((ocsp_response_t*)response);
106 lib->credmgr->add_local_set(lib->credmgr, &wrapper->set);
107
108 subject = &response->certificate;
109 responder = subject->get_issuer(subject);
110 enumerator = lib->credmgr->create_trusted_enumerator(lib->credmgr,
111 KEY_ANY, responder, FALSE);
112 while (enumerator->enumerate(enumerator, &issuer, &current))
113 {
114 if (lib->credmgr->issued_by(lib->credmgr, subject, issuer))
115 {
116 DBG1(DBG_CFG, " ocsp response correctly signed by \"%Y\"",
117 issuer->get_subject(issuer));
118 if (auth)
119 {
120 auth->merge(auth, current, FALSE);
121 }
122 verified = TRUE;
123 break;
124 }
125 }
126 enumerator->destroy(enumerator);
127
128 lib->credmgr->remove_local_set(lib->credmgr, &wrapper->set);
129 wrapper->destroy(wrapper);
130 return verified;
131 }
132
133 /**
134 * Get the better of two OCSP responses, and check for usable OCSP info
135 */
136 static certificate_t *get_better_ocsp(certificate_t *cand, certificate_t *best,
137 x509_t *subject, x509_t *issuer, cert_validation_t *valid,
138 auth_cfg_t *auth, bool cache)
139 {
140 ocsp_response_t *response;
141 time_t revocation, this_update, next_update, valid_until;
142 crl_reason_t reason;
143 bool revoked = FALSE;
144
145 response = (ocsp_response_t*)cand;
146
147 /* check ocsp signature */
148 if (!verify_ocsp(response, auth))
149 {
150 DBG1(DBG_CFG, "ocsp response verification failed");
151 cand->destroy(cand);
152 return best;
153 }
154 /* check if response contains our certificate */
155 switch (response->get_status(response, subject, issuer, &revocation, &reason,
156 &this_update, &next_update))
157 {
158 case VALIDATION_REVOKED:
159 /* subject has been revoked by a valid OCSP response */
160 DBG1(DBG_CFG, "certificate was revoked on %T, reason: %N",
161 &revocation, TRUE, crl_reason_names, reason);
162 revoked = TRUE;
163 break;
164 case VALIDATION_GOOD:
165 /* results in either good or stale */
166 break;
167 default:
168 case VALIDATION_FAILED:
169 /* candidate unusable, does not contain our cert */
170 DBG1(DBG_CFG, " ocsp response contains no status on our certificate");
171 cand->destroy(cand);
172 return best;
173 }
174
175 /* select the better of the two responses */
176 if (best == NULL || certificate_is_newer(cand, best))
177 {
178 DESTROY_IF(best);
179 best = cand;
180 if (best->get_validity(best, NULL, NULL, &valid_until))
181 {
182 DBG1(DBG_CFG, " ocsp response is valid: until %T",
183 &valid_until, FALSE);
184 *valid = VALIDATION_GOOD;
185 if (cache)
186 { /* cache non-stale only, stale certs get refetched */
187 lib->credmgr->cache_cert(lib->credmgr, best);
188 }
189 }
190 else
191 {
192 DBG1(DBG_CFG, " ocsp response is stale: since %T",
193 &valid_until, FALSE);
194 *valid = VALIDATION_STALE;
195 }
196 }
197 else
198 {
199 *valid = VALIDATION_STALE;
200 cand->destroy(cand);
201 }
202 if (revoked)
203 { /* revoked always counts, even if stale */
204 *valid = VALIDATION_REVOKED;
205 }
206 return best;
207 }
208
209 /**
210 * validate a x509 certificate using OCSP
211 */
212 static cert_validation_t check_ocsp(x509_t *subject, x509_t *issuer,
213 auth_cfg_t *auth)
214 {
215 enumerator_t *enumerator;
216 cert_validation_t valid = VALIDATION_SKIPPED;
217 certificate_t *best = NULL, *current;
218 identification_t *keyid = NULL;
219 public_key_t *public;
220 chunk_t chunk;
221 char *uri = NULL;
222
223 /** lookup cache for valid OCSP responses */
224 enumerator = lib->credmgr->create_cert_enumerator(lib->credmgr,
225 CERT_X509_OCSP_RESPONSE, KEY_ANY, NULL, FALSE);
226 while (enumerator->enumerate(enumerator, &current))
227 {
228 current->get_ref(current);
229 best = get_better_ocsp(current, best, subject, issuer,
230 &valid, auth, FALSE);
231 if (best && valid != VALIDATION_STALE)
232 {
233 DBG1(DBG_CFG, " using cached ocsp response");
234 break;
235 }
236 }
237 enumerator->destroy(enumerator);
238
239 /* derive the authorityKeyIdentifier from the issuer's public key */
240 current = &issuer->interface;
241 public = current->get_public_key(current);
242 if (public && public->get_fingerprint(public, KEYID_PUBKEY_SHA1, &chunk))
243 {
244 keyid = identification_create_from_encoding(ID_KEY_ID, chunk);
245 }
246 /** fetch from configured OCSP responder URLs */
247 if (keyid && valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
248 {
249 enumerator = lib->credmgr->create_cdp_enumerator(lib->credmgr,
250 CERT_X509_OCSP_RESPONSE, keyid);
251 while (enumerator->enumerate(enumerator, &uri))
252 {
253 current = fetch_ocsp(uri, &subject->interface, &issuer->interface);
254 if (current)
255 {
256 best = get_better_ocsp(current, best, subject, issuer,
257 &valid, auth, TRUE);
258 if (best && valid != VALIDATION_STALE)
259 {
260 break;
261 }
262 }
263 }
264 enumerator->destroy(enumerator);
265 }
266 DESTROY_IF(public);
267 DESTROY_IF(keyid);
268
269 /* fallback to URL fetching from subject certificate's URIs */
270 if (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
271 {
272 enumerator = subject->create_ocsp_uri_enumerator(subject);
273 while (enumerator->enumerate(enumerator, &uri))
274 {
275 current = fetch_ocsp(uri, &subject->interface, &issuer->interface);
276 if (current)
277 {
278 best = get_better_ocsp(current, best, subject, issuer,
279 &valid, auth, TRUE);
280 if (best && valid != VALIDATION_STALE)
281 {
282 break;
283 }
284 }
285 }
286 enumerator->destroy(enumerator);
287 }
288 /* an uri was found, but no result. switch validation state to failed */
289 if (valid == VALIDATION_SKIPPED && uri)
290 {
291 valid = VALIDATION_FAILED;
292 }
293 if (auth)
294 {
295 auth->add(auth, AUTH_RULE_OCSP_VALIDATION, valid);
296 if (valid == VALIDATION_GOOD)
297 { /* successful OCSP check fulfills also CRL constraint */
298 auth->add(auth, AUTH_RULE_CRL_VALIDATION, VALIDATION_GOOD);
299 }
300 }
301 DESTROY_IF(best);
302 return valid;
303 }
304
305 /**
306 * fetch a CRL from an URL
307 */
308 static certificate_t* fetch_crl(char *url)
309 {
310 certificate_t *crl;
311 chunk_t chunk;
312
313 DBG1(DBG_CFG, " fetching crl from '%s' ...", url);
314 if (lib->fetcher->fetch(lib->fetcher, url, &chunk, FETCH_END) != SUCCESS)
315 {
316 DBG1(DBG_CFG, "crl fetching failed");
317 return NULL;
318 }
319 crl = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509_CRL,
320 BUILD_BLOB_ASN1_DER, chunk, BUILD_END);
321 chunk_free(&chunk);
322 if (!crl)
323 {
324 DBG1(DBG_CFG, "crl fetched successfully but parsing failed");
325 return NULL;
326 }
327 return crl;
328 }
329
330 /**
331 * check the signature of an CRL
332 */
333 static bool verify_crl(certificate_t *crl, auth_cfg_t *auth)
334 {
335 certificate_t *issuer;
336 enumerator_t *enumerator;
337 bool verified = FALSE;
338 auth_cfg_t *current;
339
340 enumerator = lib->credmgr->create_trusted_enumerator(lib->credmgr,
341 KEY_ANY, crl->get_issuer(crl), FALSE);
342 while (enumerator->enumerate(enumerator, &issuer, &current))
343 {
344 if (lib->credmgr->issued_by(lib->credmgr, crl, issuer))
345 {
346 DBG1(DBG_CFG, " crl correctly signed by \"%Y\"",
347 issuer->get_subject(issuer));
348 if (auth)
349 {
350 auth->merge(auth, current, FALSE);
351 }
352 verified = TRUE;
353 break;
354 }
355 }
356 enumerator->destroy(enumerator);
357
358 return verified;
359 }
360
361 /**
362 * Get the better of two CRLs, and check for usable CRL info
363 */
364 static certificate_t *get_better_crl(certificate_t *cand, certificate_t *best,
365 x509_t *subject, cert_validation_t *valid, auth_cfg_t *auth,
366 bool cache, crl_t *base)
367 {
368 enumerator_t *enumerator;
369 time_t revocation, valid_until;
370 crl_reason_t reason;
371 chunk_t serial;
372 crl_t *crl = (crl_t*)cand;
373
374 if (base)
375 {
376 if (!crl->is_delta_crl(crl, &serial) ||
377 !chunk_equals(serial, base->get_serial(base)))
378 {
379 cand->destroy(cand);
380 return best;
381 }
382 }
383 else
384 {
385 if (crl->is_delta_crl(crl, NULL))
386 {
387 cand->destroy(cand);
388 return best;
389 }
390 }
391
392 /* check CRL signature */
393 if (!verify_crl(cand, auth))
394 {
395 DBG1(DBG_CFG, "crl response verification failed");
396 cand->destroy(cand);
397 return best;
398 }
399
400 enumerator = crl->create_enumerator(crl);
401 while (enumerator->enumerate(enumerator, &serial, &revocation, &reason))
402 {
403 if (chunk_equals(serial, subject->get_serial(subject)))
404 {
405 DBG1(DBG_CFG, "certificate was revoked on %T, reason: %N",
406 &revocation, TRUE, crl_reason_names, reason);
407 *valid = VALIDATION_REVOKED;
408 enumerator->destroy(enumerator);
409 DESTROY_IF(best);
410 return cand;
411 }
412 }
413 enumerator->destroy(enumerator);
414
415 /* select the better of the two CRLs */
416 if (best == NULL || crl_is_newer(crl, (crl_t*)best))
417 {
418 DESTROY_IF(best);
419 best = cand;
420 if (best->get_validity(best, NULL, NULL, &valid_until))
421 {
422 DBG1(DBG_CFG, " crl is valid: until %T", &valid_until, FALSE);
423 *valid = VALIDATION_GOOD;
424 if (cache)
425 { /* we cache non-stale crls only, as a stale crls are refetched */
426 lib->credmgr->cache_cert(lib->credmgr, best);
427 }
428 }
429 else
430 {
431 DBG1(DBG_CFG, " crl is stale: since %T", &valid_until, FALSE);
432 *valid = VALIDATION_STALE;
433 }
434 }
435 else
436 {
437 *valid = VALIDATION_STALE;
438 cand->destroy(cand);
439 }
440 return best;
441 }
442
443 /**
444 * Find or fetch a certificate for a given crlIssuer
445 */
446 static cert_validation_t find_crl(x509_t *subject, identification_t *issuer,
447 auth_cfg_t *auth, crl_t *base,
448 certificate_t **best, bool *uri_found)
449 {
450 cert_validation_t valid = VALIDATION_SKIPPED;
451 enumerator_t *enumerator;
452 certificate_t *current;
453 char *uri;
454
455 /* find a cached (delta) crl */
456 enumerator = lib->credmgr->create_cert_enumerator(lib->credmgr,
457 CERT_X509_CRL, KEY_ANY, issuer, FALSE);
458 while (enumerator->enumerate(enumerator, &current))
459 {
460 current->get_ref(current);
461 *best = get_better_crl(current, *best, subject, &valid,
462 auth, FALSE, base);
463 if (*best && valid != VALIDATION_STALE)
464 {
465 DBG1(DBG_CFG, " using cached crl");
466 break;
467 }
468 }
469 enumerator->destroy(enumerator);
470
471 /* fallback to fetching crls from credential sets cdps */
472 if (!base && valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
473 {
474 enumerator = lib->credmgr->create_cdp_enumerator(lib->credmgr,
475 CERT_X509_CRL, issuer);
476 while (enumerator->enumerate(enumerator, &uri))
477 {
478 *uri_found = TRUE;
479 current = fetch_crl(uri);
480 if (current)
481 {
482 if (!current->has_issuer(current, issuer))
483 {
484 DBG1(DBG_CFG, "issuer of fetched CRL '%Y' does not match CRL "
485 "issuer '%Y'", current->get_issuer(current), issuer);
486 current->destroy(current);
487 continue;
488 }
489 *best = get_better_crl(current, *best, subject,
490 &valid, auth, TRUE, base);
491 if (*best && valid != VALIDATION_STALE)
492 {
493 break;
494 }
495 }
496 }
497 enumerator->destroy(enumerator);
498 }
499 return valid;
500 }
501
502 /**
503 * Look for a delta CRL for a given base CRL
504 */
505 static cert_validation_t check_delta_crl(x509_t *subject, x509_t *issuer,
506 crl_t *base, cert_validation_t base_valid, auth_cfg_t *auth)
507 {
508 cert_validation_t valid = VALIDATION_SKIPPED;
509 certificate_t *best = NULL, *current;
510 enumerator_t *enumerator;
511 identification_t *id;
512 x509_cdp_t *cdp;
513 chunk_t chunk;
514 bool uri;
515
516 /* find cached delta CRL via subjectKeyIdentifier */
517 chunk = issuer->get_subjectKeyIdentifier(issuer);
518 if (chunk.len)
519 {
520 id = identification_create_from_encoding(ID_KEY_ID, chunk);
521 valid = find_crl(subject, id, auth, base, &best, &uri);
522 id->destroy(id);
523 }
524
525 /* find delta CRL by CRLIssuer */
526 enumerator = subject->create_crl_uri_enumerator(subject);
527 while (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED &&
528 enumerator->enumerate(enumerator, &cdp))
529 {
530 if (cdp->issuer)
531 {
532 valid = find_crl(subject, cdp->issuer, auth, base, &best, &uri);
533 }
534 }
535 enumerator->destroy(enumerator);
536
537 /* fetch from URIs found in Freshest CRL extension */
538 enumerator = base->create_delta_crl_uri_enumerator(base);
539 while (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED &&
540 enumerator->enumerate(enumerator, &cdp))
541 {
542 current = fetch_crl(cdp->uri);
543 if (current)
544 {
545 if (cdp->issuer && !current->has_issuer(current, cdp->issuer))
546 {
547 DBG1(DBG_CFG, "issuer of fetched delta CRL '%Y' does not match "
548 "certificates CRL issuer '%Y'",
549 current->get_issuer(current), cdp->issuer);
550 current->destroy(current);
551 continue;
552 }
553 best = get_better_crl(current, best, subject, &valid,
554 auth, TRUE, base);
555 if (best && valid != VALIDATION_STALE)
556 {
557 break;
558 }
559 }
560 }
561 enumerator->destroy(enumerator);
562
563 if (best)
564 {
565 best->destroy(best);
566 return valid;
567 }
568 return base_valid;
569 }
570
571
572 /**
573 * validate a x509 certificate using CRL
574 */
575 static cert_validation_t check_crl(x509_t *subject, x509_t *issuer,
576 auth_cfg_t *auth)
577 {
578 cert_validation_t valid = VALIDATION_SKIPPED;
579 certificate_t *best = NULL;
580 identification_t *id;
581 x509_cdp_t *cdp;
582 bool uri_found = FALSE;
583 certificate_t *current;
584 enumerator_t *enumerator;
585 chunk_t chunk;
586
587 /* use issuers subjectKeyIdentifier to find a cached CRL / fetch from CDP */
588 chunk = issuer->get_subjectKeyIdentifier(issuer);
589 if (chunk.len)
590 {
591 id = identification_create_from_encoding(ID_KEY_ID, chunk);
592 valid = find_crl(subject, id, auth, NULL, &best, &uri_found);
593 id->destroy(id);
594 }
595
596 /* find a cached CRL or fetch via configured CDP via CRLIssuer */
597 enumerator = subject->create_crl_uri_enumerator(subject);
598 while (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED &&
599 enumerator->enumerate(enumerator, &cdp))
600 {
601 if (cdp->issuer)
602 {
603 valid = find_crl(subject, cdp->issuer, auth, NULL,
604 &best, &uri_found);
605 }
606 }
607 enumerator->destroy(enumerator);
608
609 /* fallback to fetching CRLs from CDPs found in subjects certificate */
610 if (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
611 {
612 enumerator = subject->create_crl_uri_enumerator(subject);
613 while (enumerator->enumerate(enumerator, &cdp))
614 {
615 uri_found = TRUE;
616 current = fetch_crl(cdp->uri);
617 if (current)
618 {
619 if (cdp->issuer && !current->has_issuer(current, cdp->issuer))
620 {
621 DBG1(DBG_CFG, "issuer of fetched CRL '%Y' does not match "
622 "certificates CRL issuer '%Y'",
623 current->get_issuer(current), cdp->issuer);
624 current->destroy(current);
625 continue;
626 }
627 best = get_better_crl(current, best, subject, &valid,
628 auth, TRUE, NULL);
629 if (best && valid != VALIDATION_STALE)
630 {
631 break;
632 }
633 }
634 }
635 enumerator->destroy(enumerator);
636 }
637
638 /* look for delta CRLs */
639 if (best && (valid == VALIDATION_GOOD || valid == VALIDATION_STALE))
640 {
641 valid = check_delta_crl(subject, issuer, (crl_t*)best, valid, auth);
642 }
643
644 /* an uri was found, but no result. switch validation state to failed */
645 if (valid == VALIDATION_SKIPPED && uri_found)
646 {
647 valid = VALIDATION_FAILED;
648 }
649 if (auth)
650 {
651 if (valid == VALIDATION_SKIPPED)
652 { /* if we skipped CRL validation, we use the result of OCSP for
653 * constraint checking */
654 auth->add(auth, AUTH_RULE_CRL_VALIDATION,
655 auth->get(auth, AUTH_RULE_OCSP_VALIDATION));
656 }
657 else
658 {
659 auth->add(auth, AUTH_RULE_CRL_VALIDATION, valid);
660 }
661 }
662 DESTROY_IF(best);
663 return valid;
664 }
665
666 METHOD(cert_validator_t, validate, bool,
667 private_revocation_validator_t *this, certificate_t *subject,
668 certificate_t *issuer, bool online, u_int pathlen, bool anchor,
669 auth_cfg_t *auth)
670 {
671 if (subject->get_type(subject) == CERT_X509 &&
672 issuer->get_type(issuer) == CERT_X509 &&
673 online)
674 {
675 DBG1(DBG_CFG, "checking certificate status of \"%Y\"",
676 subject->get_subject(subject));
677 switch (check_ocsp((x509_t*)subject, (x509_t*)issuer,
678 pathlen ? NULL : auth))
679 {
680 case VALIDATION_GOOD:
681 DBG1(DBG_CFG, "certificate status is good");
682 return TRUE;
683 case VALIDATION_REVOKED:
684 /* has already been logged */
685 return FALSE;
686 case VALIDATION_SKIPPED:
687 DBG2(DBG_CFG, "ocsp check skipped, no ocsp found");
688 break;
689 case VALIDATION_STALE:
690 DBG1(DBG_CFG, "ocsp information stale, fallback to crl");
691 break;
692 case VALIDATION_FAILED:
693 DBG1(DBG_CFG, "ocsp check failed, fallback to crl");
694 break;
695 }
696 switch (check_crl((x509_t*)subject, (x509_t*)issuer,
697 pathlen ? NULL : auth))
698 {
699 case VALIDATION_GOOD:
700 DBG1(DBG_CFG, "certificate status is good");
701 return TRUE;
702 case VALIDATION_REVOKED:
703 /* has already been logged */
704 return FALSE;
705 case VALIDATION_FAILED:
706 case VALIDATION_SKIPPED:
707 DBG1(DBG_CFG, "certificate status is not available");
708 break;
709 case VALIDATION_STALE:
710 DBG1(DBG_CFG, "certificate status is unknown, crl is stale");
711 break;
712 }
713 }
714 return TRUE;
715 }
716
717 METHOD(revocation_validator_t, destroy, void,
718 private_revocation_validator_t *this)
719 {
720 free(this);
721 }
722
723 /**
724 * See header
725 */
726 revocation_validator_t *revocation_validator_create()
727 {
728 private_revocation_validator_t *this;
729
730 INIT(this,
731 .public = {
732 .validator.validate = _validate,
733 .destroy = _destroy,
734 },
735 );
736
737 return &this->public;
738 }