2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include "stroke_list.h"
21 #include <utils/linked_list.h>
22 #include <credentials/certificates/x509.h>
23 #include <credentials/certificates/ac.h>
24 #include <credentials/certificates/crl.h>
25 #include <config/peer_cfg.h>
27 /* warning intervals for list functions */
28 #define CERT_WARNING_INTERVAL 30 /* days */
29 #define CRL_WARNING_INTERVAL 7 /* days */
30 #define AC_WARNING_INTERVAL 1 /* day */
32 typedef struct private_stroke_list_t private_stroke_list_t
;
35 * private data of stroke_list
37 struct private_stroke_list_t
{
45 * timestamp of daemon start
51 * get the authentication class of a config
53 auth_class_t
get_auth_class(peer_cfg_t
*config
)
56 auth_info_t
*auth_info
;
58 auth_info
= config
->get_auth(config
);
59 if (auth_info
->get_item(auth_info
, AUTHN_AUTH_CLASS
, (void**)&class))
63 /* fallback to pubkey authentication */
64 return AUTH_CLASS_PUBKEY
;
68 * log an IKE_SA to out
70 static void log_ike_sa(FILE *out
, ike_sa_t
*ike_sa
, bool all
)
72 ike_sa_id_t
*id
= ike_sa
->get_id(ike_sa
);
74 fprintf(out
, "%12s[%d]: %N, %H[%D]...%H[%D]\n",
75 ike_sa
->get_name(ike_sa
), ike_sa
->get_unique_id(ike_sa
),
76 ike_sa_state_names
, ike_sa
->get_state(ike_sa
),
77 ike_sa
->get_my_host(ike_sa
), ike_sa
->get_my_id(ike_sa
),
78 ike_sa
->get_other_host(ike_sa
), ike_sa
->get_other_id(ike_sa
));
82 char *ike_proposal
= ike_sa
->get_proposal(ike_sa
);
84 fprintf(out
, "%12s[%d]: IKE SPIs: %.16llx_i%s %.16llx_r%s",
85 ike_sa
->get_name(ike_sa
), ike_sa
->get_unique_id(ike_sa
),
86 id
->get_initiator_spi(id
), id
->is_initiator(id
) ?
"*" : "",
87 id
->get_responder_spi(id
), id
->is_initiator(id
) ?
"" : "*");
90 if (ike_sa
->get_state(ike_sa
) == IKE_ESTABLISHED
)
92 u_int32_t rekey
, reauth
, now
;
95 rekey
= ike_sa
->get_statistic(ike_sa
, STAT_REKEY
);
96 reauth
= ike_sa
->get_statistic(ike_sa
, STAT_REAUTH
);
101 fprintf(out
, ", rekeying in %V", &rekey
);
106 fprintf(out
, ", %N reauthentication in %V", auth_class_names
,
107 get_auth_class(ike_sa
->get_peer_cfg(ike_sa
)), &reauth
);
109 if (!rekey
&& !reauth
)
111 fprintf(out
, ", rekeying disabled");
118 fprintf(out
, "%12s[%d]: IKE proposal: %s\n",
119 ike_sa
->get_name(ike_sa
), ike_sa
->get_unique_id(ike_sa
),
126 * log an CHILD_SA to out
128 static void log_child_sa(FILE *out
, child_sa_t
*child_sa
, bool all
)
130 u_int32_t rekey
, now
= time(NULL
);
131 u_int32_t use_in
, use_out
;
132 encryption_algorithm_t encr_alg
;
133 integrity_algorithm_t int_alg
;
134 chunk_t encr_key
, int_key
;
136 fprintf(out
, "%12s{%d}: %N, %N",
137 child_sa
->get_name(child_sa
), child_sa
->get_reqid(child_sa
),
138 child_sa_state_names
, child_sa
->get_state(child_sa
),
139 ipsec_mode_names
, child_sa
->get_mode(child_sa
));
141 if (child_sa
->get_state(child_sa
) == CHILD_INSTALLED
)
143 fprintf(out
, ", %N%s SPIs: %.8x_i %.8x_o",
144 protocol_id_names
, child_sa
->get_protocol(child_sa
),
145 child_sa
->has_encap(child_sa
) ?
" in UDP": "",
146 ntohl(child_sa
->get_spi(child_sa
, TRUE
)),
147 ntohl(child_sa
->get_spi(child_sa
, FALSE
)));
149 if (child_sa
->get_ipcomp(child_sa
) != IPCOMP_NONE
)
151 fprintf(out
, ", IPCOMP CPIs: %.4x_i %.4x_o",
152 ntohs(child_sa
->get_cpi(child_sa
, TRUE
)),
153 ntohs(child_sa
->get_cpi(child_sa
, FALSE
)));
158 fprintf(out
, "\n%12s{%d}: ", child_sa
->get_name(child_sa
),
159 child_sa
->get_reqid(child_sa
));
161 if (child_sa
->get_protocol(child_sa
) == PROTO_ESP
)
163 encr_alg
= child_sa
->get_encryption(child_sa
, TRUE
, &encr_key
);
167 /* Algorithms with variable key size.
168 * GCM/CCM keys are actually shorted than their key data. */
169 case ENCR_AES_GCM_ICV8
:
170 case ENCR_AES_GCM_ICV12
:
171 case ENCR_AES_GCM_ICV16
:
174 case ENCR_AES_CCM_ICV8
:
175 case ENCR_AES_CCM_ICV12
:
176 case ENCR_AES_CCM_ICV16
:
180 fprintf(out
, "%N-%d", encryption_algorithm_names
,
181 encr_alg
, encr_key
.len
* 8);
184 fprintf(out
, "%N", encryption_algorithm_names
, encr_alg
);
188 int_alg
= child_sa
->get_integrity(child_sa
, TRUE
, &int_key
);
194 fprintf(out
, "/%N", integrity_algorithm_names
, int_alg
);
197 fprintf(out
, ", rekeying ");
199 rekey
= child_sa
->get_lifetime(child_sa
, FALSE
);
202 fprintf(out
, "in %#V", &now
, &rekey
);
206 fprintf(out
, "disabled");
209 fprintf(out
, ", last use: ");
210 use_in
= child_sa
->get_usetime(child_sa
, TRUE
);
213 fprintf(out
, "%ds_i ", now
- use_in
);
217 fprintf(out
, "no_i ");
219 use_out
= child_sa
->get_usetime(child_sa
, FALSE
);
222 fprintf(out
, "%ds_o ", now
- use_out
);
226 fprintf(out
, "no_o ");
231 fprintf(out
, "\n%12s{%d}: %#R=== %#R\n",
232 child_sa
->get_name(child_sa
), child_sa
->get_reqid(child_sa
),
233 child_sa
->get_traffic_selectors(child_sa
, TRUE
),
234 child_sa
->get_traffic_selectors(child_sa
, FALSE
));
238 * Implementation of stroke_list_t.status.
240 static void status(private_stroke_list_t
*this, stroke_msg_t
*msg
, FILE *out
, bool all
)
242 enumerator_t
*enumerator
, *children
;
244 child_cfg_t
*child_cfg
;
247 char *name
= msg
->status
.name
;
251 peer_cfg_t
*peer_cfg
;
255 time_t uptime
= time(NULL
) - this->uptime
;
257 fprintf(out
, "Performance:\n");
258 fprintf(out
, " uptime: %V, since %#T\n", &uptime
, &this->uptime
, FALSE
);
259 fprintf(out
, " worker threads: %d idle of %d,",
260 charon
->processor
->get_idle_threads(charon
->processor
),
261 charon
->processor
->get_total_threads(charon
->processor
));
262 fprintf(out
, " job queue load: %d,",
263 charon
->processor
->get_job_load(charon
->processor
));
264 fprintf(out
, " scheduled events: %d\n",
265 charon
->scheduler
->get_job_load(charon
->scheduler
));
266 fprintf(out
, " loaded plugins: ");
267 enumerator
= lib
->plugins
->create_plugin_enumerator(lib
->plugins
);
268 while (enumerator
->enumerate(enumerator
, &plugin
))
270 fprintf(out
, "%s ", plugin
);
272 enumerator
->destroy(enumerator
);
275 enumerator
= charon
->kernel_interface
->create_address_enumerator(
276 charon
->kernel_interface
, FALSE
, FALSE
);
277 fprintf(out
, "Listening IP addresses:\n");
278 while (enumerator
->enumerate(enumerator
, (void**)&host
))
280 fprintf(out
, " %H\n", host
);
282 enumerator
->destroy(enumerator
);
284 fprintf(out
, "Connections:\n");
285 enumerator
= charon
->backends
->create_peer_cfg_enumerator(charon
->backends
);
286 while (enumerator
->enumerate(enumerator
, (void**)&peer_cfg
))
292 enumerator_t
*auth_enumerator
;
293 identification_t
*my_ca
= NULL
, *other_ca
= NULL
;
294 identification_t
*eap_identity
= NULL
;
295 u_int32_t
*eap_type
= NULL
;
296 bool ac_groups
= FALSE
;
298 if (peer_cfg
->get_ike_version(peer_cfg
) != 2 ||
299 (name
&& !streq(name
, peer_cfg
->get_name(peer_cfg
))))
304 /* determine any required CAs, EAP type, EAP identity,
305 * and the presence of AC groups
307 auth
= peer_cfg
->get_auth(peer_cfg
);
308 auth_enumerator
= auth
->create_item_enumerator(auth
);
309 while (auth_enumerator
->enumerate(auth_enumerator
, &item
, &ptr
))
314 eap_type
= (u_int32_t
*)ptr
;
316 case AUTHN_EAP_IDENTITY
:
317 eap_identity
= (identification_t
*)ptr
;
320 cert
= (certificate_t
*)ptr
;
321 my_ca
= cert
->get_subject(cert
);
323 case AUTHN_CA_CERT_NAME
:
324 my_ca
= (identification_t
*)ptr
;
327 cert
= (certificate_t
*)ptr
;
328 other_ca
= cert
->get_subject(cert
);
330 case AUTHZ_CA_CERT_NAME
:
331 other_ca
= (identification_t
*)ptr
;
340 auth_enumerator
->destroy(auth_enumerator
);
342 ike_cfg
= peer_cfg
->get_ike_cfg(peer_cfg
);
343 fprintf(out
, "%12s: %s[%D]...%s[%D]\n", peer_cfg
->get_name(peer_cfg
),
344 ike_cfg
->get_my_addr(ike_cfg
), peer_cfg
->get_my_id(peer_cfg
),
345 ike_cfg
->get_other_addr(ike_cfg
), peer_cfg
->get_other_id(peer_cfg
));
346 if (my_ca
|| other_ca
)
348 fprintf(out
, "%12s: CAs: ", peer_cfg
->get_name(peer_cfg
));
351 fprintf(out
, "\"%D\"...", my_ca
);
355 fprintf(out
, "%%any...");
359 fprintf(out
, "\"%D\"\n", other_ca
);
363 fprintf(out
, "%%any\n");
371 fprintf(out
, "%12s: groups: ", peer_cfg
->get_name(peer_cfg
));
372 auth_enumerator
= auth
->create_item_enumerator(auth
);
373 while (auth_enumerator
->enumerate(auth_enumerator
, &item
, &ptr
))
375 if (item
== AUTHZ_AC_GROUP
)
377 identification_t
*group
= (identification_t
*)ptr
;
379 fprintf(out
, "%s%D", first?
"":", ", group
);
383 auth_enumerator
->destroy(auth_enumerator
);
387 fprintf(out
, "%12s: %N ", peer_cfg
->get_name(peer_cfg
),
388 auth_class_names
, get_auth_class(peer_cfg
));
391 fprintf(out
, "and %N ", eap_type_names
, *eap_type
);
393 fprintf(out
, "authentication");
396 fprintf(out
, ", EAP identity: '%D'", eap_identity
);
398 dpd
= peer_cfg
->get_dpd(peer_cfg
);
401 fprintf(out
, ", dpddelay=%us", dpd
);
405 children
= peer_cfg
->create_child_cfg_enumerator(peer_cfg
);
406 while (children
->enumerate(children
, &child_cfg
))
408 linked_list_t
*my_ts
, *other_ts
;
410 my_ts
= child_cfg
->get_traffic_selectors(child_cfg
, TRUE
, NULL
, NULL
);
411 other_ts
= child_cfg
->get_traffic_selectors(child_cfg
, FALSE
, NULL
, NULL
);
412 fprintf(out
, "%12s: %#R=== %#R", child_cfg
->get_name(child_cfg
),
414 my_ts
->destroy_offset(my_ts
, offsetof(traffic_selector_t
, destroy
));
415 other_ts
->destroy_offset(other_ts
, offsetof(traffic_selector_t
, destroy
));
419 fprintf(out
, ", dpdaction=%N", action_names
,
420 child_cfg
->get_dpd_action(child_cfg
));
424 children
->destroy(children
);
426 enumerator
->destroy(enumerator
);
429 fprintf(out
, "Security Associations:\n");
430 enumerator
= charon
->controller
->create_ike_sa_enumerator(charon
->controller
);
431 while (enumerator
->enumerate(enumerator
, &ike_sa
))
433 bool ike_printed
= FALSE
;
434 child_sa_t
*child_sa
;
435 iterator_t
*children
= ike_sa
->create_child_sa_iterator(ike_sa
);
437 if (name
== NULL
|| streq(name
, ike_sa
->get_name(ike_sa
)))
439 log_ike_sa(out
, ike_sa
, all
);
444 while (children
->iterate(children
, (void**)&child_sa
))
446 if (name
== NULL
|| streq(name
, child_sa
->get_name(child_sa
)))
450 log_ike_sa(out
, ike_sa
, all
);
454 log_child_sa(out
, child_sa
, all
);
457 children
->destroy(children
);
459 enumerator
->destroy(enumerator
);
465 fprintf(out
, " no match\n");
469 fprintf(out
, " none\n");
475 * create a unique certificate list without duplicates
476 * certicates having the same issuer are grouped together.
478 static linked_list_t
* create_unique_cert_list(certificate_type_t type
)
480 linked_list_t
*list
= linked_list_create();
481 enumerator_t
*enumerator
= charon
->credentials
->create_cert_enumerator(
482 charon
->credentials
, type
, KEY_ANY
,
486 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
488 iterator_t
*iterator
= list
->create_iterator(list
, TRUE
);
489 identification_t
*issuer
= cert
->get_issuer(cert
);
490 bool previous_same
, same
= FALSE
, last
= TRUE
;
491 certificate_t
*list_cert
;
493 while (iterator
->iterate(iterator
, (void**)&list_cert
))
495 /* exit if we have a duplicate? */
496 if (list_cert
->equals(list_cert
, cert
))
501 /* group certificates with same issuer */
502 previous_same
= same
;
503 same
= list_cert
->has_issuer(list_cert
, issuer
);
504 if (previous_same
&& !same
)
506 iterator
->insert_before(iterator
, (void *)cert
->get_ref(cert
));
511 iterator
->destroy(iterator
);
515 list
->insert_last(list
, (void *)cert
->get_ref(cert
));
518 enumerator
->destroy(enumerator
);
523 * list all raw public keys
525 static void stroke_list_pubkeys(linked_list_t
*list
, bool utc
, FILE *out
)
529 enumerator_t
*enumerator
= list
->create_enumerator(list
);
532 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
534 public_key_t
*public = cert
->get_public_key(cert
);
538 private_key_t
*private = NULL
;
539 identification_t
*id
, *keyid
;
544 fprintf(out
, "List of Raw Public Keys:\n");
549 /* list public key information */
550 id
= public->get_id(public, ID_PUBKEY_SHA1
);
551 keyid
= public->get_id(public, ID_PUBKEY_INFO_SHA1
);
553 private = charon
->credentials
->get_private(
555 public->get_type(public), keyid
, NULL
);
556 fprintf(out
, " pubkey: %N %d bits%s\n",
557 key_type_names
, public->get_type(public),
558 public->get_keysize(public) * 8,
559 private ?
", has private key" : "");
560 fprintf(out
, " keyid: %D\n", keyid
);
561 fprintf(out
, " subjkey: %D\n", id
);
563 public->destroy(public);
566 enumerator
->destroy(enumerator
);
570 * list all X.509 certificates matching the flags
572 static void stroke_list_certs(linked_list_t
*list
, char *label
,
573 x509_flag_t flags
, bool utc
, FILE *out
)
576 time_t now
= time(NULL
);
577 enumerator_t
*enumerator
= list
->create_enumerator(list
);
580 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
582 x509_t
*x509
= (x509_t
*)cert
;
583 x509_flag_t x509_flags
= x509
->get_flags(x509
);
585 /* list only if flag is set, or flags == 0 (ignoring self-signed) */
586 if ((x509_flags
& flags
) || (flags
== (x509_flags
& ~X509_SELF_SIGNED
)))
588 enumerator_t
*enumerator
;
589 identification_t
*altName
;
590 bool first_altName
= TRUE
;
591 chunk_t serial
= x509
->get_serial(x509
);
592 identification_t
*authkey
= x509
->get_authKeyIdentifier(x509
);
593 time_t notBefore
, notAfter
;
594 public_key_t
*public = cert
->get_public_key(cert
);
599 fprintf(out
, "List of %s:\n", label
);
604 /* list subjectAltNames */
605 enumerator
= x509
->create_subjectAltName_enumerator(x509
);
606 while (enumerator
->enumerate(enumerator
, (void**)&altName
))
610 fprintf(out
, " altNames: ");
611 first_altName
= FALSE
;
617 fprintf(out
, "%D", altName
);
623 enumerator
->destroy(enumerator
);
625 fprintf(out
, " subject: \"%D\"\n", cert
->get_subject(cert
));
626 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
627 fprintf(out
, " serial: %#B\n", &serial
);
630 cert
->get_validity(cert
, &now
, ¬Before
, ¬After
);
631 fprintf(out
, " validity: not before %#T, ", ¬Before
, utc
);
634 fprintf(out
, "not valid yet (valid in %#V)\n", &now
, ¬Before
);
638 fprintf(out
, "ok\n");
640 fprintf(out
, " not after %#T, ", ¬After
, utc
);
643 fprintf(out
, "expired (%#V ago)\n", &now
, ¬After
);
648 if (now
> notAfter
- CERT_WARNING_INTERVAL
* 60 * 60 * 24)
650 fprintf(out
, " (expires in %#V)", &now
, ¬After
);
655 /* list public key information */
658 private_key_t
*private = NULL
;
659 identification_t
*id
, *keyid
;
661 id
= public->get_id(public, ID_PUBKEY_SHA1
);
662 keyid
= public->get_id(public, ID_PUBKEY_INFO_SHA1
);
664 private = charon
->credentials
->get_private(
666 public->get_type(public), keyid
, NULL
);
667 fprintf(out
, " pubkey: %N %d bits%s\n",
668 key_type_names
, public->get_type(public),
669 public->get_keysize(public) * 8,
670 private ?
", has private key" : "");
671 fprintf(out
, " keyid: %D\n", keyid
);
672 fprintf(out
, " subjkey: %D\n", id
);
674 public->destroy(public);
677 /* list optional authorityKeyIdentifier */
680 fprintf(out
, " authkey: %D\n", authkey
);
684 enumerator
->destroy(enumerator
);
688 * list all X.509 attribute certificates
690 static void stroke_list_acerts(linked_list_t
*list
, bool utc
, FILE *out
)
693 time_t thisUpdate
, nextUpdate
, now
= time(NULL
);
694 enumerator_t
*enumerator
= list
->create_enumerator(list
);
697 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
699 ac_t
*ac
= (ac_t
*)cert
;
700 chunk_t serial
= ac
->get_serial(ac
);
701 chunk_t holderSerial
= ac
->get_holderSerial(ac
);
702 identification_t
*holderIssuer
= ac
->get_holderIssuer(ac
);
703 identification_t
*authkey
= ac
->get_authKeyIdentifier(ac
);
704 identification_t
*entityName
= cert
->get_subject(cert
);
709 fprintf(out
, "List of X.509 Attribute Certificates:\n");
716 fprintf(out
, " holder: \"%D\"\n", entityName
);
720 fprintf(out
, " hissuer: \"%D\"\n", holderIssuer
);
722 if (holderSerial
.ptr
)
724 fprintf(out
, " hserial: %#B\n", &holderSerial
);
726 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
727 fprintf(out
, " serial: %#B\n", &serial
);
730 cert
->get_validity(cert
, &now
, &thisUpdate
, &nextUpdate
);
731 fprintf(out
, " updates: this %#T\n", &thisUpdate
, utc
);
732 fprintf(out
, " next %#T, ", &nextUpdate
, utc
);
733 if (now
> nextUpdate
)
735 fprintf(out
, "expired (%#V ago)\n", &now
, &nextUpdate
);
740 if (now
> nextUpdate
- AC_WARNING_INTERVAL
* 60 * 60 * 24)
742 fprintf(out
, " (expires in %#V)", &now
, &nextUpdate
);
747 /* list optional authorityKeyIdentifier */
750 fprintf(out
, " authkey: %D\n", authkey
);
753 enumerator
->destroy(enumerator
);
757 * list all X.509 CRLs
759 static void stroke_list_crls(linked_list_t
*list
, bool utc
, FILE *out
)
762 time_t thisUpdate
, nextUpdate
, now
= time(NULL
);
763 enumerator_t
*enumerator
= list
->create_enumerator(list
);
766 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
768 crl_t
*crl
= (crl_t
*)cert
;
769 chunk_t serial
= crl
->get_serial(crl
);
770 identification_t
*authkey
= crl
->get_authKeyIdentifier(crl
);
775 fprintf(out
, "List of X.509 CRLs:\n");
780 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
782 /* list optional crlNumber */
785 fprintf(out
, " serial: %#B\n", &serial
);
788 /* count the number of revoked certificates */
791 enumerator_t
*enumerator
= crl
->create_enumerator(crl
);
793 while (enumerator
->enumerate(enumerator
, NULL
, NULL
, NULL
))
797 fprintf(out
, " revoked: %d certificate%s\n", count
,
798 (count
== 1)?
"" : "s");
799 enumerator
->destroy(enumerator
);
803 cert
->get_validity(cert
, &now
, &thisUpdate
, &nextUpdate
);
804 fprintf(out
, " updates: this %#T\n", &thisUpdate
, utc
);
805 fprintf(out
, " next %#T, ", &nextUpdate
, utc
);
806 if (now
> nextUpdate
)
808 fprintf(out
, "expired (%#V ago)\n", &now
, &nextUpdate
);
813 if (now
> nextUpdate
- CRL_WARNING_INTERVAL
* 60 * 60 * 24)
815 fprintf(out
, " (expires in %#V)", &now
, &nextUpdate
);
820 /* list optional authorityKeyIdentifier */
823 fprintf(out
, " authkey: %D\n", authkey
);
826 enumerator
->destroy(enumerator
);
830 * list all OCSP responses
832 static void stroke_list_ocsp(linked_list_t
* list
, bool utc
, FILE *out
)
835 enumerator_t
*enumerator
= list
->create_enumerator(list
);
838 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
843 fprintf(out
, "List of OCSP responses:\n");
848 fprintf(out
, " signer: \"%D\"\n", cert
->get_issuer(cert
));
850 enumerator
->destroy(enumerator
);
854 * List of registered cryptographical algorithms
856 static void list_algs(FILE *out
)
858 enumerator_t
*enumerator
;
859 encryption_algorithm_t encryption
;
860 integrity_algorithm_t integrity
;
861 hash_algorithm_t hash
;
862 pseudo_random_function_t prf
;
863 diffie_hellman_group_t group
;
866 fprintf(out
, "List of registered IKEv2 Algorithms:\n");
867 fprintf(out
, "\n encryption: ");
868 enumerator
= lib
->crypto
->create_crypter_enumerator(lib
->crypto
);
869 while (enumerator
->enumerate(enumerator
, &encryption
))
871 fprintf(out
, "%N ", encryption_algorithm_names
, encryption
);
873 enumerator
->destroy(enumerator
);
874 fprintf(out
, "\n integrity: ");
875 enumerator
= lib
->crypto
->create_signer_enumerator(lib
->crypto
);
876 while (enumerator
->enumerate(enumerator
, &integrity
))
878 fprintf(out
, "%N ", integrity_algorithm_names
, integrity
);
880 enumerator
->destroy(enumerator
);
881 fprintf(out
, "\n hasher: ");
882 enumerator
= lib
->crypto
->create_hasher_enumerator(lib
->crypto
);
883 while (enumerator
->enumerate(enumerator
, &hash
))
885 fprintf(out
, "%N ", hash_algorithm_names
, hash
);
887 enumerator
->destroy(enumerator
);
888 fprintf(out
, "\n prf: ");
889 enumerator
= lib
->crypto
->create_prf_enumerator(lib
->crypto
);
890 while (enumerator
->enumerate(enumerator
, &prf
))
892 fprintf(out
, "%N ", pseudo_random_function_names
, prf
);
894 enumerator
->destroy(enumerator
);
895 fprintf(out
, "\n dh-group: ");
896 enumerator
= lib
->crypto
->create_dh_enumerator(lib
->crypto
);
897 while (enumerator
->enumerate(enumerator
, &group
))
899 fprintf(out
, "%N ", diffie_hellman_group_names
, group
);
901 enumerator
->destroy(enumerator
);
906 * Implementation of stroke_list_t.list.
908 static void list(private_stroke_list_t
*this, stroke_msg_t
*msg
, FILE *out
)
910 linked_list_t
*cert_list
= NULL
;
912 if (msg
->list
.flags
& LIST_PUBKEYS
)
914 linked_list_t
*pubkey_list
= create_unique_cert_list(CERT_TRUSTED_PUBKEY
);
916 stroke_list_pubkeys(pubkey_list
, msg
->list
.utc
, out
);
917 pubkey_list
->destroy_offset(pubkey_list
, offsetof(certificate_t
, destroy
));
919 if (msg
->list
.flags
& (LIST_CERTS
| LIST_CACERTS
| LIST_OCSPCERTS
| LIST_AACERTS
))
921 cert_list
= create_unique_cert_list(CERT_X509
);
923 if (msg
->list
.flags
& LIST_CERTS
)
925 stroke_list_certs(cert_list
, "X.509 End Entity Certificates",
926 0, msg
->list
.utc
, out
);
928 if (msg
->list
.flags
& LIST_CACERTS
)
930 stroke_list_certs(cert_list
, "X.509 CA Certificates",
931 X509_CA
, msg
->list
.utc
, out
);
933 if (msg
->list
.flags
& LIST_OCSPCERTS
)
935 stroke_list_certs(cert_list
, "X.509 OCSP Signer Certificates",
936 X509_OCSP_SIGNER
, msg
->list
.utc
, out
);
938 if (msg
->list
.flags
& LIST_AACERTS
)
940 stroke_list_certs(cert_list
, "X.509 AA Certificates",
941 X509_AA
, msg
->list
.utc
, out
);
943 if (msg
->list
.flags
& LIST_ACERTS
)
945 linked_list_t
*ac_list
= create_unique_cert_list(CERT_X509_AC
);
947 stroke_list_acerts(ac_list
, msg
->list
.utc
, out
);
948 ac_list
->destroy_offset(ac_list
, offsetof(certificate_t
, destroy
));
950 if (msg
->list
.flags
& LIST_CRLS
)
952 linked_list_t
*crl_list
= create_unique_cert_list(CERT_X509_CRL
);
954 stroke_list_crls(crl_list
, msg
->list
.utc
, out
);
955 crl_list
->destroy_offset(crl_list
, offsetof(certificate_t
, destroy
));
957 if (msg
->list
.flags
& LIST_OCSP
)
959 linked_list_t
*ocsp_list
= create_unique_cert_list(CERT_X509_OCSP_RESPONSE
);
961 stroke_list_ocsp(ocsp_list
, msg
->list
.utc
, out
);
963 ocsp_list
->destroy_offset(ocsp_list
, offsetof(certificate_t
, destroy
));
965 if (msg
->list
.flags
& LIST_ALGS
)
969 DESTROY_OFFSET_IF(cert_list
, offsetof(certificate_t
, destroy
));
973 * Implementation of stroke_list_t.destroy
975 static void destroy(private_stroke_list_t
*this)
983 stroke_list_t
*stroke_list_create()
985 private_stroke_list_t
*this = malloc_thing(private_stroke_list_t
);
987 this->public.list
= (void(*)(stroke_list_t
*, stroke_msg_t
*msg
, FILE *out
))list
;
988 this->public.status
= (void(*)(stroke_list_t
*, stroke_msg_t
*msg
, FILE *out
,bool))status
;
989 this->public.destroy
= (void(*)(stroke_list_t
*))destroy
;
991 this->uptime
= time(NULL
);
993 return &this->public;