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
= ike_sa
->get_statistic(ike_sa
, STAT_REKEY_TIME
);
93 u_int32_t reauth
= ike_sa
->get_statistic(ike_sa
, STAT_REAUTH_TIME
);
97 fprintf(out
, ", rekeying in %V", &rekey
);
101 fprintf(out
, ", %N reauthentication in %V", auth_class_names
,
102 get_auth_class(ike_sa
->get_peer_cfg(ike_sa
)), &reauth
);
104 if (!rekey
&& !reauth
)
106 fprintf(out
, ", rekeying disabled");
113 fprintf(out
, "%12s[%d]: IKE proposal: %s\n",
114 ike_sa
->get_name(ike_sa
), ike_sa
->get_unique_id(ike_sa
),
121 * log an CHILD_SA to out
123 static void log_child_sa(FILE *out
, child_sa_t
*child_sa
, bool all
)
125 u_int32_t rekey
, now
= time(NULL
);
126 u_int32_t use_in
, use_out
;
127 encryption_algorithm_t encr_alg
;
128 integrity_algorithm_t int_alg
;
129 chunk_t encr_key
, int_key
;
131 fprintf(out
, "%12s{%d}: %N, %N",
132 child_sa
->get_name(child_sa
), child_sa
->get_reqid(child_sa
),
133 child_sa_state_names
, child_sa
->get_state(child_sa
),
134 ipsec_mode_names
, child_sa
->get_mode(child_sa
));
136 if (child_sa
->get_state(child_sa
) == CHILD_INSTALLED
)
138 fprintf(out
, ", %N%s SPIs: %.8x_i %.8x_o",
139 protocol_id_names
, child_sa
->get_protocol(child_sa
),
140 child_sa
->has_encap(child_sa
) ?
" in UDP": "",
141 ntohl(child_sa
->get_spi(child_sa
, TRUE
)),
142 ntohl(child_sa
->get_spi(child_sa
, FALSE
)));
144 if (child_sa
->get_ipcomp(child_sa
) != IPCOMP_NONE
)
146 fprintf(out
, ", IPCOMP CPIs: %.4x_i %.4x_o",
147 ntohs(child_sa
->get_cpi(child_sa
, TRUE
)),
148 ntohs(child_sa
->get_cpi(child_sa
, FALSE
)));
153 fprintf(out
, "\n%12s{%d}: ", child_sa
->get_name(child_sa
),
154 child_sa
->get_reqid(child_sa
));
156 if (child_sa
->get_protocol(child_sa
) == PROTO_ESP
)
158 encr_alg
= child_sa
->get_encryption(child_sa
, TRUE
, &encr_key
);
162 /* Algorithms with variable key size.
163 * GCM/CCM keys are actually shorted than their key data. */
164 case ENCR_AES_GCM_ICV8
:
165 case ENCR_AES_GCM_ICV12
:
166 case ENCR_AES_GCM_ICV16
:
169 case ENCR_AES_CCM_ICV8
:
170 case ENCR_AES_CCM_ICV12
:
171 case ENCR_AES_CCM_ICV16
:
175 fprintf(out
, "%N-%d", encryption_algorithm_names
,
176 encr_alg
, encr_key
.len
* 8);
179 fprintf(out
, "%N", encryption_algorithm_names
, encr_alg
);
183 int_alg
= child_sa
->get_integrity(child_sa
, TRUE
, &int_key
);
189 fprintf(out
, "/%N", integrity_algorithm_names
, int_alg
);
192 fprintf(out
, ", rekeying ");
194 rekey
= child_sa
->get_lifetime(child_sa
, FALSE
);
197 fprintf(out
, "in %#V", &now
, &rekey
);
201 fprintf(out
, "disabled");
204 fprintf(out
, ", last use: ");
205 use_in
= child_sa
->get_usetime(child_sa
, TRUE
);
208 fprintf(out
, "%ds_i ", now
- use_in
);
212 fprintf(out
, "no_i ");
214 use_out
= child_sa
->get_usetime(child_sa
, FALSE
);
217 fprintf(out
, "%ds_o ", now
- use_out
);
221 fprintf(out
, "no_o ");
226 fprintf(out
, "\n%12s{%d}: %#R=== %#R\n",
227 child_sa
->get_name(child_sa
), child_sa
->get_reqid(child_sa
),
228 child_sa
->get_traffic_selectors(child_sa
, TRUE
),
229 child_sa
->get_traffic_selectors(child_sa
, FALSE
));
233 * Implementation of stroke_list_t.status.
235 static void status(private_stroke_list_t
*this, stroke_msg_t
*msg
, FILE *out
, bool all
)
237 enumerator_t
*enumerator
, *children
;
239 child_cfg_t
*child_cfg
;
242 char *name
= msg
->status
.name
;
246 peer_cfg_t
*peer_cfg
;
250 time_t uptime
= time(NULL
) - this->uptime
;
252 fprintf(out
, "Performance:\n");
253 fprintf(out
, " uptime: %V, since %#T\n", &uptime
, &this->uptime
, FALSE
);
254 fprintf(out
, " worker threads: %d idle of %d,",
255 charon
->processor
->get_idle_threads(charon
->processor
),
256 charon
->processor
->get_total_threads(charon
->processor
));
257 fprintf(out
, " job queue load: %d,",
258 charon
->processor
->get_job_load(charon
->processor
));
259 fprintf(out
, " scheduled events: %d\n",
260 charon
->scheduler
->get_job_load(charon
->scheduler
));
261 fprintf(out
, " loaded plugins: ");
262 enumerator
= lib
->plugins
->create_plugin_enumerator(lib
->plugins
);
263 while (enumerator
->enumerate(enumerator
, &plugin
))
265 fprintf(out
, "%s ", plugin
);
267 enumerator
->destroy(enumerator
);
270 enumerator
= charon
->kernel_interface
->create_address_enumerator(
271 charon
->kernel_interface
, FALSE
, FALSE
);
272 fprintf(out
, "Listening IP addresses:\n");
273 while (enumerator
->enumerate(enumerator
, (void**)&host
))
275 fprintf(out
, " %H\n", host
);
277 enumerator
->destroy(enumerator
);
279 fprintf(out
, "Connections:\n");
280 enumerator
= charon
->backends
->create_peer_cfg_enumerator(charon
->backends
);
281 while (enumerator
->enumerate(enumerator
, (void**)&peer_cfg
))
287 enumerator_t
*auth_enumerator
;
288 identification_t
*my_ca
= NULL
, *other_ca
= NULL
;
289 identification_t
*eap_identity
= NULL
;
290 u_int32_t
*eap_type
= NULL
;
291 bool ac_groups
= FALSE
;
293 if (peer_cfg
->get_ike_version(peer_cfg
) != 2 ||
294 (name
&& !streq(name
, peer_cfg
->get_name(peer_cfg
))))
299 /* determine any required CAs, EAP type, EAP identity,
300 * and the presence of AC groups
302 auth
= peer_cfg
->get_auth(peer_cfg
);
303 auth_enumerator
= auth
->create_item_enumerator(auth
);
304 while (auth_enumerator
->enumerate(auth_enumerator
, &item
, &ptr
))
309 eap_type
= (u_int32_t
*)ptr
;
311 case AUTHN_EAP_IDENTITY
:
312 eap_identity
= (identification_t
*)ptr
;
315 cert
= (certificate_t
*)ptr
;
316 my_ca
= cert
->get_subject(cert
);
318 case AUTHN_CA_CERT_NAME
:
319 my_ca
= (identification_t
*)ptr
;
322 cert
= (certificate_t
*)ptr
;
323 other_ca
= cert
->get_subject(cert
);
325 case AUTHZ_CA_CERT_NAME
:
326 other_ca
= (identification_t
*)ptr
;
335 auth_enumerator
->destroy(auth_enumerator
);
337 ike_cfg
= peer_cfg
->get_ike_cfg(peer_cfg
);
338 fprintf(out
, "%12s: %s[%D]...%s[%D]\n", peer_cfg
->get_name(peer_cfg
),
339 ike_cfg
->get_my_addr(ike_cfg
), peer_cfg
->get_my_id(peer_cfg
),
340 ike_cfg
->get_other_addr(ike_cfg
), peer_cfg
->get_other_id(peer_cfg
));
341 if (my_ca
|| other_ca
)
343 fprintf(out
, "%12s: CAs: ", peer_cfg
->get_name(peer_cfg
));
346 fprintf(out
, "\"%D\"...", my_ca
);
350 fprintf(out
, "%%any...");
354 fprintf(out
, "\"%D\"\n", other_ca
);
358 fprintf(out
, "%%any\n");
366 fprintf(out
, "%12s: groups: ", peer_cfg
->get_name(peer_cfg
));
367 auth_enumerator
= auth
->create_item_enumerator(auth
);
368 while (auth_enumerator
->enumerate(auth_enumerator
, &item
, &ptr
))
370 if (item
== AUTHZ_AC_GROUP
)
372 identification_t
*group
= (identification_t
*)ptr
;
374 fprintf(out
, "%s%D", first?
"":", ", group
);
378 auth_enumerator
->destroy(auth_enumerator
);
382 fprintf(out
, "%12s: %N ", peer_cfg
->get_name(peer_cfg
),
383 auth_class_names
, get_auth_class(peer_cfg
));
386 fprintf(out
, "and %N ", eap_type_names
, *eap_type
);
388 fprintf(out
, "authentication");
391 fprintf(out
, ", EAP identity: '%D'", eap_identity
);
393 dpd
= peer_cfg
->get_dpd(peer_cfg
);
396 fprintf(out
, ", dpddelay=%us", dpd
);
400 children
= peer_cfg
->create_child_cfg_enumerator(peer_cfg
);
401 while (children
->enumerate(children
, &child_cfg
))
403 linked_list_t
*my_ts
, *other_ts
;
405 my_ts
= child_cfg
->get_traffic_selectors(child_cfg
, TRUE
, NULL
, NULL
);
406 other_ts
= child_cfg
->get_traffic_selectors(child_cfg
, FALSE
, NULL
, NULL
);
407 fprintf(out
, "%12s: %#R=== %#R", child_cfg
->get_name(child_cfg
),
409 my_ts
->destroy_offset(my_ts
, offsetof(traffic_selector_t
, destroy
));
410 other_ts
->destroy_offset(other_ts
, offsetof(traffic_selector_t
, destroy
));
414 fprintf(out
, ", dpdaction=%N", action_names
,
415 child_cfg
->get_dpd_action(child_cfg
));
419 children
->destroy(children
);
421 enumerator
->destroy(enumerator
);
424 fprintf(out
, "Security Associations:\n");
425 enumerator
= charon
->controller
->create_ike_sa_enumerator(charon
->controller
);
426 while (enumerator
->enumerate(enumerator
, &ike_sa
))
428 bool ike_printed
= FALSE
;
429 child_sa_t
*child_sa
;
430 iterator_t
*children
= ike_sa
->create_child_sa_iterator(ike_sa
);
432 if (name
== NULL
|| streq(name
, ike_sa
->get_name(ike_sa
)))
434 log_ike_sa(out
, ike_sa
, all
);
439 while (children
->iterate(children
, (void**)&child_sa
))
441 if (name
== NULL
|| streq(name
, child_sa
->get_name(child_sa
)))
445 log_ike_sa(out
, ike_sa
, all
);
449 log_child_sa(out
, child_sa
, all
);
452 children
->destroy(children
);
454 enumerator
->destroy(enumerator
);
460 fprintf(out
, " no match\n");
464 fprintf(out
, " none\n");
470 * create a unique certificate list without duplicates
471 * certicates having the same issuer are grouped together.
473 static linked_list_t
* create_unique_cert_list(certificate_type_t type
)
475 linked_list_t
*list
= linked_list_create();
476 enumerator_t
*enumerator
= charon
->credentials
->create_cert_enumerator(
477 charon
->credentials
, type
, KEY_ANY
,
481 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
483 iterator_t
*iterator
= list
->create_iterator(list
, TRUE
);
484 identification_t
*issuer
= cert
->get_issuer(cert
);
485 bool previous_same
, same
= FALSE
, last
= TRUE
;
486 certificate_t
*list_cert
;
488 while (iterator
->iterate(iterator
, (void**)&list_cert
))
490 /* exit if we have a duplicate? */
491 if (list_cert
->equals(list_cert
, cert
))
496 /* group certificates with same issuer */
497 previous_same
= same
;
498 same
= list_cert
->has_issuer(list_cert
, issuer
);
499 if (previous_same
&& !same
)
501 iterator
->insert_before(iterator
, (void *)cert
->get_ref(cert
));
506 iterator
->destroy(iterator
);
510 list
->insert_last(list
, (void *)cert
->get_ref(cert
));
513 enumerator
->destroy(enumerator
);
518 * list all raw public keys
520 static void stroke_list_pubkeys(linked_list_t
*list
, bool utc
, FILE *out
)
524 enumerator_t
*enumerator
= list
->create_enumerator(list
);
527 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
529 public_key_t
*public = cert
->get_public_key(cert
);
533 private_key_t
*private = NULL
;
534 identification_t
*id
, *keyid
;
539 fprintf(out
, "List of Raw Public Keys:\n");
544 /* list public key information */
545 id
= public->get_id(public, ID_PUBKEY_SHA1
);
546 keyid
= public->get_id(public, ID_PUBKEY_INFO_SHA1
);
548 private = charon
->credentials
->get_private(
550 public->get_type(public), keyid
, NULL
);
551 fprintf(out
, " pubkey: %N %d bits%s\n",
552 key_type_names
, public->get_type(public),
553 public->get_keysize(public) * 8,
554 private ?
", has private key" : "");
555 fprintf(out
, " keyid: %D\n", keyid
);
556 fprintf(out
, " subjkey: %D\n", id
);
558 public->destroy(public);
561 enumerator
->destroy(enumerator
);
565 * list all X.509 certificates matching the flags
567 static void stroke_list_certs(linked_list_t
*list
, char *label
,
568 x509_flag_t flags
, bool utc
, FILE *out
)
571 time_t now
= time(NULL
);
572 enumerator_t
*enumerator
= list
->create_enumerator(list
);
575 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
577 x509_t
*x509
= (x509_t
*)cert
;
578 x509_flag_t x509_flags
= x509
->get_flags(x509
);
580 /* list only if flag is set, or flags == 0 (ignoring self-signed) */
581 if ((x509_flags
& flags
) || (flags
== (x509_flags
& ~X509_SELF_SIGNED
)))
583 enumerator_t
*enumerator
;
584 identification_t
*altName
;
585 bool first_altName
= TRUE
;
586 chunk_t serial
= x509
->get_serial(x509
);
587 identification_t
*authkey
= x509
->get_authKeyIdentifier(x509
);
588 time_t notBefore
, notAfter
;
589 public_key_t
*public = cert
->get_public_key(cert
);
594 fprintf(out
, "List of %s:\n", label
);
599 /* list subjectAltNames */
600 enumerator
= x509
->create_subjectAltName_enumerator(x509
);
601 while (enumerator
->enumerate(enumerator
, (void**)&altName
))
605 fprintf(out
, " altNames: ");
606 first_altName
= FALSE
;
612 fprintf(out
, "%D", altName
);
618 enumerator
->destroy(enumerator
);
620 fprintf(out
, " subject: \"%D\"\n", cert
->get_subject(cert
));
621 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
622 fprintf(out
, " serial: %#B\n", &serial
);
625 cert
->get_validity(cert
, &now
, ¬Before
, ¬After
);
626 fprintf(out
, " validity: not before %#T, ", ¬Before
, utc
);
629 fprintf(out
, "not valid yet (valid in %#V)\n", &now
, ¬Before
);
633 fprintf(out
, "ok\n");
635 fprintf(out
, " not after %#T, ", ¬After
, utc
);
638 fprintf(out
, "expired (%#V ago)\n", &now
, ¬After
);
643 if (now
> notAfter
- CERT_WARNING_INTERVAL
* 60 * 60 * 24)
645 fprintf(out
, " (expires in %#V)", &now
, ¬After
);
650 /* list public key information */
653 private_key_t
*private = NULL
;
654 identification_t
*id
, *keyid
;
656 id
= public->get_id(public, ID_PUBKEY_SHA1
);
657 keyid
= public->get_id(public, ID_PUBKEY_INFO_SHA1
);
659 private = charon
->credentials
->get_private(
661 public->get_type(public), keyid
, NULL
);
662 fprintf(out
, " pubkey: %N %d bits%s\n",
663 key_type_names
, public->get_type(public),
664 public->get_keysize(public) * 8,
665 private ?
", has private key" : "");
666 fprintf(out
, " keyid: %D\n", keyid
);
667 fprintf(out
, " subjkey: %D\n", id
);
669 public->destroy(public);
672 /* list optional authorityKeyIdentifier */
675 fprintf(out
, " authkey: %D\n", authkey
);
679 enumerator
->destroy(enumerator
);
683 * list all X.509 attribute certificates
685 static void stroke_list_acerts(linked_list_t
*list
, bool utc
, FILE *out
)
688 time_t thisUpdate
, nextUpdate
, now
= time(NULL
);
689 enumerator_t
*enumerator
= list
->create_enumerator(list
);
692 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
694 ac_t
*ac
= (ac_t
*)cert
;
695 chunk_t serial
= ac
->get_serial(ac
);
696 chunk_t holderSerial
= ac
->get_holderSerial(ac
);
697 identification_t
*holderIssuer
= ac
->get_holderIssuer(ac
);
698 identification_t
*authkey
= ac
->get_authKeyIdentifier(ac
);
699 identification_t
*entityName
= cert
->get_subject(cert
);
704 fprintf(out
, "List of X.509 Attribute Certificates:\n");
711 fprintf(out
, " holder: \"%D\"\n", entityName
);
715 fprintf(out
, " hissuer: \"%D\"\n", holderIssuer
);
717 if (holderSerial
.ptr
)
719 fprintf(out
, " hserial: %#B\n", &holderSerial
);
721 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
722 fprintf(out
, " serial: %#B\n", &serial
);
725 cert
->get_validity(cert
, &now
, &thisUpdate
, &nextUpdate
);
726 fprintf(out
, " updates: this %#T\n", &thisUpdate
, utc
);
727 fprintf(out
, " next %#T, ", &nextUpdate
, utc
);
728 if (now
> nextUpdate
)
730 fprintf(out
, "expired (%#V ago)\n", &now
, &nextUpdate
);
735 if (now
> nextUpdate
- AC_WARNING_INTERVAL
* 60 * 60 * 24)
737 fprintf(out
, " (expires in %#V)", &now
, &nextUpdate
);
742 /* list optional authorityKeyIdentifier */
745 fprintf(out
, " authkey: %D\n", authkey
);
748 enumerator
->destroy(enumerator
);
752 * list all X.509 CRLs
754 static void stroke_list_crls(linked_list_t
*list
, bool utc
, FILE *out
)
757 time_t thisUpdate
, nextUpdate
, now
= time(NULL
);
758 enumerator_t
*enumerator
= list
->create_enumerator(list
);
761 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
763 crl_t
*crl
= (crl_t
*)cert
;
764 chunk_t serial
= crl
->get_serial(crl
);
765 identification_t
*authkey
= crl
->get_authKeyIdentifier(crl
);
770 fprintf(out
, "List of X.509 CRLs:\n");
775 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
777 /* list optional crlNumber */
780 fprintf(out
, " serial: %#B\n", &serial
);
783 /* count the number of revoked certificates */
786 enumerator_t
*enumerator
= crl
->create_enumerator(crl
);
788 while (enumerator
->enumerate(enumerator
, NULL
, NULL
, NULL
))
792 fprintf(out
, " revoked: %d certificate%s\n", count
,
793 (count
== 1)?
"" : "s");
794 enumerator
->destroy(enumerator
);
798 cert
->get_validity(cert
, &now
, &thisUpdate
, &nextUpdate
);
799 fprintf(out
, " updates: this %#T\n", &thisUpdate
, utc
);
800 fprintf(out
, " next %#T, ", &nextUpdate
, utc
);
801 if (now
> nextUpdate
)
803 fprintf(out
, "expired (%#V ago)\n", &now
, &nextUpdate
);
808 if (now
> nextUpdate
- CRL_WARNING_INTERVAL
* 60 * 60 * 24)
810 fprintf(out
, " (expires in %#V)", &now
, &nextUpdate
);
815 /* list optional authorityKeyIdentifier */
818 fprintf(out
, " authkey: %D\n", authkey
);
821 enumerator
->destroy(enumerator
);
825 * list all OCSP responses
827 static void stroke_list_ocsp(linked_list_t
* list
, bool utc
, FILE *out
)
830 enumerator_t
*enumerator
= list
->create_enumerator(list
);
833 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
838 fprintf(out
, "List of OCSP responses:\n");
843 fprintf(out
, " signer: \"%D\"\n", cert
->get_issuer(cert
));
845 enumerator
->destroy(enumerator
);
849 * List of registered cryptographical algorithms
851 static void list_algs(FILE *out
)
853 enumerator_t
*enumerator
;
854 encryption_algorithm_t encryption
;
855 integrity_algorithm_t integrity
;
856 hash_algorithm_t hash
;
857 pseudo_random_function_t prf
;
858 diffie_hellman_group_t group
;
861 fprintf(out
, "List of registered IKEv2 Algorithms:\n");
862 fprintf(out
, "\n encryption: ");
863 enumerator
= lib
->crypto
->create_crypter_enumerator(lib
->crypto
);
864 while (enumerator
->enumerate(enumerator
, &encryption
))
866 fprintf(out
, "%N ", encryption_algorithm_names
, encryption
);
868 enumerator
->destroy(enumerator
);
869 fprintf(out
, "\n integrity: ");
870 enumerator
= lib
->crypto
->create_signer_enumerator(lib
->crypto
);
871 while (enumerator
->enumerate(enumerator
, &integrity
))
873 fprintf(out
, "%N ", integrity_algorithm_names
, integrity
);
875 enumerator
->destroy(enumerator
);
876 fprintf(out
, "\n hasher: ");
877 enumerator
= lib
->crypto
->create_hasher_enumerator(lib
->crypto
);
878 while (enumerator
->enumerate(enumerator
, &hash
))
880 fprintf(out
, "%N ", hash_algorithm_names
, hash
);
882 enumerator
->destroy(enumerator
);
883 fprintf(out
, "\n prf: ");
884 enumerator
= lib
->crypto
->create_prf_enumerator(lib
->crypto
);
885 while (enumerator
->enumerate(enumerator
, &prf
))
887 fprintf(out
, "%N ", pseudo_random_function_names
, prf
);
889 enumerator
->destroy(enumerator
);
890 fprintf(out
, "\n dh-group: ");
891 enumerator
= lib
->crypto
->create_dh_enumerator(lib
->crypto
);
892 while (enumerator
->enumerate(enumerator
, &group
))
894 fprintf(out
, "%N ", diffie_hellman_group_names
, group
);
896 enumerator
->destroy(enumerator
);
901 * Implementation of stroke_list_t.list.
903 static void list(private_stroke_list_t
*this, stroke_msg_t
*msg
, FILE *out
)
905 linked_list_t
*cert_list
= NULL
;
907 if (msg
->list
.flags
& LIST_PUBKEYS
)
909 linked_list_t
*pubkey_list
= create_unique_cert_list(CERT_TRUSTED_PUBKEY
);
911 stroke_list_pubkeys(pubkey_list
, msg
->list
.utc
, out
);
912 pubkey_list
->destroy_offset(pubkey_list
, offsetof(certificate_t
, destroy
));
914 if (msg
->list
.flags
& (LIST_CERTS
| LIST_CACERTS
| LIST_OCSPCERTS
| LIST_AACERTS
))
916 cert_list
= create_unique_cert_list(CERT_X509
);
918 if (msg
->list
.flags
& LIST_CERTS
)
920 stroke_list_certs(cert_list
, "X.509 End Entity Certificates",
921 0, msg
->list
.utc
, out
);
923 if (msg
->list
.flags
& LIST_CACERTS
)
925 stroke_list_certs(cert_list
, "X.509 CA Certificates",
926 X509_CA
, msg
->list
.utc
, out
);
928 if (msg
->list
.flags
& LIST_OCSPCERTS
)
930 stroke_list_certs(cert_list
, "X.509 OCSP Signer Certificates",
931 X509_OCSP_SIGNER
, msg
->list
.utc
, out
);
933 if (msg
->list
.flags
& LIST_AACERTS
)
935 stroke_list_certs(cert_list
, "X.509 AA Certificates",
936 X509_AA
, msg
->list
.utc
, out
);
938 if (msg
->list
.flags
& LIST_ACERTS
)
940 linked_list_t
*ac_list
= create_unique_cert_list(CERT_X509_AC
);
942 stroke_list_acerts(ac_list
, msg
->list
.utc
, out
);
943 ac_list
->destroy_offset(ac_list
, offsetof(certificate_t
, destroy
));
945 if (msg
->list
.flags
& LIST_CRLS
)
947 linked_list_t
*crl_list
= create_unique_cert_list(CERT_X509_CRL
);
949 stroke_list_crls(crl_list
, msg
->list
.utc
, out
);
950 crl_list
->destroy_offset(crl_list
, offsetof(certificate_t
, destroy
));
952 if (msg
->list
.flags
& LIST_OCSP
)
954 linked_list_t
*ocsp_list
= create_unique_cert_list(CERT_X509_OCSP_RESPONSE
);
956 stroke_list_ocsp(ocsp_list
, msg
->list
.utc
, out
);
958 ocsp_list
->destroy_offset(ocsp_list
, offsetof(certificate_t
, destroy
));
960 if (msg
->list
.flags
& LIST_ALGS
)
964 DESTROY_OFFSET_IF(cert_list
, offsetof(certificate_t
, destroy
));
968 * Implementation of stroke_list_t.destroy
970 static void destroy(private_stroke_list_t
*this)
978 stroke_list_t
*stroke_list_create()
980 private_stroke_list_t
*this = malloc_thing(private_stroke_list_t
);
982 this->public.list
= (void(*)(stroke_list_t
*, stroke_msg_t
*msg
, FILE *out
))list
;
983 this->public.status
= (void(*)(stroke_list_t
*, stroke_msg_t
*msg
, FILE *out
,bool))status
;
984 this->public.destroy
= (void(*)(stroke_list_t
*))destroy
;
986 this->uptime
= time(NULL
);
988 return &this->public;