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 proposal_t
*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");
120 snprintf(buf
, BUF_LEN
, "%P", ike_proposal
);
121 fprintf(out
, "%12s[%d]: IKE proposal: %s\n",
122 ike_sa
->get_name(ike_sa
), ike_sa
->get_unique_id(ike_sa
),
129 * log an CHILD_SA to out
131 static void log_child_sa(FILE *out
, child_sa_t
*child_sa
, bool all
)
133 u_int32_t rekey
, now
= time(NULL
);
134 u_int32_t use_in
, use_out
;
135 encryption_algorithm_t encr_alg
;
136 integrity_algorithm_t int_alg
;
137 chunk_t encr_key
, int_key
;
139 fprintf(out
, "%12s{%d}: %N, %N",
140 child_sa
->get_name(child_sa
), child_sa
->get_reqid(child_sa
),
141 child_sa_state_names
, child_sa
->get_state(child_sa
),
142 ipsec_mode_names
, child_sa
->get_mode(child_sa
));
144 if (child_sa
->get_state(child_sa
) == CHILD_INSTALLED
)
146 fprintf(out
, ", %N%s SPIs: %.8x_i %.8x_o",
147 protocol_id_names
, child_sa
->get_protocol(child_sa
),
148 child_sa
->has_encap(child_sa
) ?
" in UDP": "",
149 ntohl(child_sa
->get_spi(child_sa
, TRUE
)),
150 ntohl(child_sa
->get_spi(child_sa
, FALSE
)));
152 if (child_sa
->get_ipcomp(child_sa
) != IPCOMP_NONE
)
154 fprintf(out
, ", IPCOMP CPIs: %.4x_i %.4x_o",
155 ntohs(child_sa
->get_cpi(child_sa
, TRUE
)),
156 ntohs(child_sa
->get_cpi(child_sa
, FALSE
)));
161 fprintf(out
, "\n%12s{%d}: ", child_sa
->get_name(child_sa
),
162 child_sa
->get_reqid(child_sa
));
164 if (child_sa
->get_protocol(child_sa
) == PROTO_ESP
)
166 encr_alg
= child_sa
->get_encryption(child_sa
, TRUE
, &encr_key
);
170 /* Algorithms with variable key size.
171 * GCM/CCM keys are actually shorted than their key data. */
172 case ENCR_AES_GCM_ICV8
:
173 case ENCR_AES_GCM_ICV12
:
174 case ENCR_AES_GCM_ICV16
:
177 case ENCR_AES_CCM_ICV8
:
178 case ENCR_AES_CCM_ICV12
:
179 case ENCR_AES_CCM_ICV16
:
183 fprintf(out
, "%N-%d", encryption_algorithm_names
,
184 encr_alg
, encr_key
.len
* 8);
187 fprintf(out
, "%N", encryption_algorithm_names
, encr_alg
);
191 int_alg
= child_sa
->get_integrity(child_sa
, TRUE
, &int_key
);
197 fprintf(out
, "/%N", integrity_algorithm_names
, int_alg
);
200 fprintf(out
, ", rekeying ");
202 rekey
= child_sa
->get_lifetime(child_sa
, FALSE
);
205 fprintf(out
, "in %#V", &now
, &rekey
);
209 fprintf(out
, "disabled");
212 fprintf(out
, ", last use: ");
213 use_in
= child_sa
->get_usetime(child_sa
, TRUE
);
216 fprintf(out
, "%ds_i ", now
- use_in
);
220 fprintf(out
, "no_i ");
222 use_out
= child_sa
->get_usetime(child_sa
, FALSE
);
225 fprintf(out
, "%ds_o ", now
- use_out
);
229 fprintf(out
, "no_o ");
234 fprintf(out
, "\n%12s{%d}: %#R=== %#R\n",
235 child_sa
->get_name(child_sa
), child_sa
->get_reqid(child_sa
),
236 child_sa
->get_traffic_selectors(child_sa
, TRUE
),
237 child_sa
->get_traffic_selectors(child_sa
, FALSE
));
241 * Implementation of stroke_list_t.status.
243 static void status(private_stroke_list_t
*this, stroke_msg_t
*msg
, FILE *out
, bool all
)
245 enumerator_t
*enumerator
, *children
;
247 child_cfg_t
*child_cfg
;
250 char *name
= msg
->status
.name
;
254 peer_cfg_t
*peer_cfg
;
258 time_t uptime
= time(NULL
) - this->uptime
;
260 fprintf(out
, "Performance:\n");
261 fprintf(out
, " uptime: %V, since %#T\n", &uptime
, &this->uptime
, FALSE
);
262 fprintf(out
, " worker threads: %d idle of %d,",
263 charon
->processor
->get_idle_threads(charon
->processor
),
264 charon
->processor
->get_total_threads(charon
->processor
));
265 fprintf(out
, " job queue load: %d,",
266 charon
->processor
->get_job_load(charon
->processor
));
267 fprintf(out
, " scheduled events: %d\n",
268 charon
->scheduler
->get_job_load(charon
->scheduler
));
269 fprintf(out
, " loaded plugins: ");
270 enumerator
= lib
->plugins
->create_plugin_enumerator(lib
->plugins
);
271 while (enumerator
->enumerate(enumerator
, &plugin
))
273 fprintf(out
, "%s ", plugin
);
275 enumerator
->destroy(enumerator
);
278 enumerator
= charon
->kernel_interface
->create_address_enumerator(
279 charon
->kernel_interface
, FALSE
, FALSE
);
280 fprintf(out
, "Listening IP addresses:\n");
281 while (enumerator
->enumerate(enumerator
, (void**)&host
))
283 fprintf(out
, " %H\n", host
);
285 enumerator
->destroy(enumerator
);
287 fprintf(out
, "Connections:\n");
288 enumerator
= charon
->backends
->create_peer_cfg_enumerator(charon
->backends
);
289 while (enumerator
->enumerate(enumerator
, (void**)&peer_cfg
))
295 enumerator_t
*auth_enumerator
;
296 identification_t
*my_ca
= NULL
, *other_ca
= NULL
;
297 identification_t
*eap_identity
= NULL
;
298 u_int32_t
*eap_type
= NULL
;
299 bool ac_groups
= FALSE
;
301 if (peer_cfg
->get_ike_version(peer_cfg
) != 2 ||
302 (name
&& !streq(name
, peer_cfg
->get_name(peer_cfg
))))
307 /* determine any required CAs, EAP type, EAP identity,
308 * and the presence of AC groups
310 auth
= peer_cfg
->get_auth(peer_cfg
);
311 auth_enumerator
= auth
->create_item_enumerator(auth
);
312 while (auth_enumerator
->enumerate(auth_enumerator
, &item
, &ptr
))
317 eap_type
= (u_int32_t
*)ptr
;
319 case AUTHN_EAP_IDENTITY
:
320 eap_identity
= (identification_t
*)ptr
;
323 cert
= (certificate_t
*)ptr
;
324 my_ca
= cert
->get_subject(cert
);
326 case AUTHN_CA_CERT_NAME
:
327 my_ca
= (identification_t
*)ptr
;
330 cert
= (certificate_t
*)ptr
;
331 other_ca
= cert
->get_subject(cert
);
333 case AUTHZ_CA_CERT_NAME
:
334 other_ca
= (identification_t
*)ptr
;
343 auth_enumerator
->destroy(auth_enumerator
);
345 ike_cfg
= peer_cfg
->get_ike_cfg(peer_cfg
);
346 fprintf(out
, "%12s: %s[%D]...%s[%D]\n", peer_cfg
->get_name(peer_cfg
),
347 ike_cfg
->get_my_addr(ike_cfg
), peer_cfg
->get_my_id(peer_cfg
),
348 ike_cfg
->get_other_addr(ike_cfg
), peer_cfg
->get_other_id(peer_cfg
));
349 if (my_ca
|| other_ca
)
351 fprintf(out
, "%12s: CAs: ", peer_cfg
->get_name(peer_cfg
));
354 fprintf(out
, "\"%D\"...", my_ca
);
358 fprintf(out
, "%%any...");
362 fprintf(out
, "\"%D\"\n", other_ca
);
366 fprintf(out
, "%%any\n");
374 fprintf(out
, "%12s: groups: ", peer_cfg
->get_name(peer_cfg
));
375 auth_enumerator
= auth
->create_item_enumerator(auth
);
376 while (auth_enumerator
->enumerate(auth_enumerator
, &item
, &ptr
))
378 if (item
== AUTHZ_AC_GROUP
)
380 identification_t
*group
= (identification_t
*)ptr
;
382 fprintf(out
, "%s%D", first?
"":", ", group
);
386 auth_enumerator
->destroy(auth_enumerator
);
390 fprintf(out
, "%12s: %N ", peer_cfg
->get_name(peer_cfg
),
391 auth_class_names
, get_auth_class(peer_cfg
));
394 fprintf(out
, "and %N ", eap_type_names
, *eap_type
);
396 fprintf(out
, "authentication");
399 fprintf(out
, ", EAP identity: '%D'", eap_identity
);
401 dpd
= peer_cfg
->get_dpd(peer_cfg
);
404 fprintf(out
, ", dpddelay=%us", dpd
);
408 children
= peer_cfg
->create_child_cfg_enumerator(peer_cfg
);
409 while (children
->enumerate(children
, &child_cfg
))
411 linked_list_t
*my_ts
, *other_ts
;
413 my_ts
= child_cfg
->get_traffic_selectors(child_cfg
, TRUE
, NULL
, NULL
);
414 other_ts
= child_cfg
->get_traffic_selectors(child_cfg
, FALSE
, NULL
, NULL
);
415 fprintf(out
, "%12s: %#R=== %#R", child_cfg
->get_name(child_cfg
),
417 my_ts
->destroy_offset(my_ts
, offsetof(traffic_selector_t
, destroy
));
418 other_ts
->destroy_offset(other_ts
, offsetof(traffic_selector_t
, destroy
));
422 fprintf(out
, ", dpdaction=%N", action_names
,
423 child_cfg
->get_dpd_action(child_cfg
));
427 children
->destroy(children
);
429 enumerator
->destroy(enumerator
);
432 fprintf(out
, "Security Associations:\n");
433 enumerator
= charon
->controller
->create_ike_sa_enumerator(charon
->controller
);
434 while (enumerator
->enumerate(enumerator
, &ike_sa
))
436 bool ike_printed
= FALSE
;
437 child_sa_t
*child_sa
;
438 iterator_t
*children
= ike_sa
->create_child_sa_iterator(ike_sa
);
440 if (name
== NULL
|| streq(name
, ike_sa
->get_name(ike_sa
)))
442 log_ike_sa(out
, ike_sa
, all
);
447 while (children
->iterate(children
, (void**)&child_sa
))
449 if (name
== NULL
|| streq(name
, child_sa
->get_name(child_sa
)))
453 log_ike_sa(out
, ike_sa
, all
);
457 log_child_sa(out
, child_sa
, all
);
460 children
->destroy(children
);
462 enumerator
->destroy(enumerator
);
468 fprintf(out
, " no match\n");
472 fprintf(out
, " none\n");
478 * create a unique certificate list without duplicates
479 * certicates having the same issuer are grouped together.
481 static linked_list_t
* create_unique_cert_list(certificate_type_t type
)
483 linked_list_t
*list
= linked_list_create();
484 enumerator_t
*enumerator
= charon
->credentials
->create_cert_enumerator(
485 charon
->credentials
, type
, KEY_ANY
,
489 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
491 iterator_t
*iterator
= list
->create_iterator(list
, TRUE
);
492 identification_t
*issuer
= cert
->get_issuer(cert
);
493 bool previous_same
, same
= FALSE
, last
= TRUE
;
494 certificate_t
*list_cert
;
496 while (iterator
->iterate(iterator
, (void**)&list_cert
))
498 /* exit if we have a duplicate? */
499 if (list_cert
->equals(list_cert
, cert
))
504 /* group certificates with same issuer */
505 previous_same
= same
;
506 same
= list_cert
->has_issuer(list_cert
, issuer
);
507 if (previous_same
&& !same
)
509 iterator
->insert_before(iterator
, (void *)cert
->get_ref(cert
));
514 iterator
->destroy(iterator
);
518 list
->insert_last(list
, (void *)cert
->get_ref(cert
));
521 enumerator
->destroy(enumerator
);
526 * list all raw public keys
528 static void stroke_list_pubkeys(linked_list_t
*list
, bool utc
, FILE *out
)
532 enumerator_t
*enumerator
= list
->create_enumerator(list
);
535 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
537 public_key_t
*public = cert
->get_public_key(cert
);
541 private_key_t
*private = NULL
;
542 identification_t
*id
, *keyid
;
547 fprintf(out
, "List of Raw Public Keys:\n");
552 /* list public key information */
553 id
= public->get_id(public, ID_PUBKEY_SHA1
);
554 keyid
= public->get_id(public, ID_PUBKEY_INFO_SHA1
);
556 private = charon
->credentials
->get_private(
558 public->get_type(public), keyid
, NULL
);
559 fprintf(out
, " pubkey: %N %d bits%s\n",
560 key_type_names
, public->get_type(public),
561 public->get_keysize(public) * 8,
562 private ?
", has private key" : "");
563 fprintf(out
, " keyid: %D\n", keyid
);
564 fprintf(out
, " subjkey: %D\n", id
);
566 public->destroy(public);
569 enumerator
->destroy(enumerator
);
573 * list all X.509 certificates matching the flags
575 static void stroke_list_certs(linked_list_t
*list
, char *label
,
576 x509_flag_t flags
, bool utc
, FILE *out
)
579 time_t now
= time(NULL
);
580 enumerator_t
*enumerator
= list
->create_enumerator(list
);
583 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
585 x509_t
*x509
= (x509_t
*)cert
;
586 x509_flag_t x509_flags
= x509
->get_flags(x509
);
588 /* list only if flag is set, or flags == 0 (ignoring self-signed) */
589 if ((x509_flags
& flags
) || (flags
== (x509_flags
& ~X509_SELF_SIGNED
)))
591 enumerator_t
*enumerator
;
592 identification_t
*altName
;
593 bool first_altName
= TRUE
;
594 chunk_t serial
= x509
->get_serial(x509
);
595 identification_t
*authkey
= x509
->get_authKeyIdentifier(x509
);
596 time_t notBefore
, notAfter
;
597 public_key_t
*public = cert
->get_public_key(cert
);
602 fprintf(out
, "List of %s:\n", label
);
607 /* list subjectAltNames */
608 enumerator
= x509
->create_subjectAltName_enumerator(x509
);
609 while (enumerator
->enumerate(enumerator
, (void**)&altName
))
613 fprintf(out
, " altNames: ");
614 first_altName
= FALSE
;
620 fprintf(out
, "%D", altName
);
626 enumerator
->destroy(enumerator
);
628 fprintf(out
, " subject: \"%D\"\n", cert
->get_subject(cert
));
629 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
630 fprintf(out
, " serial: %#B\n", &serial
);
633 cert
->get_validity(cert
, &now
, ¬Before
, ¬After
);
634 fprintf(out
, " validity: not before %#T, ", ¬Before
, utc
);
637 fprintf(out
, "not valid yet (valid in %#V)\n", &now
, ¬Before
);
641 fprintf(out
, "ok\n");
643 fprintf(out
, " not after %#T, ", ¬After
, utc
);
646 fprintf(out
, "expired (%#V ago)\n", &now
, ¬After
);
651 if (now
> notAfter
- CERT_WARNING_INTERVAL
* 60 * 60 * 24)
653 fprintf(out
, " (expires in %#V)", &now
, ¬After
);
658 /* list public key information */
661 private_key_t
*private = NULL
;
662 identification_t
*id
, *keyid
;
664 id
= public->get_id(public, ID_PUBKEY_SHA1
);
665 keyid
= public->get_id(public, ID_PUBKEY_INFO_SHA1
);
667 private = charon
->credentials
->get_private(
669 public->get_type(public), keyid
, NULL
);
670 fprintf(out
, " pubkey: %N %d bits%s\n",
671 key_type_names
, public->get_type(public),
672 public->get_keysize(public) * 8,
673 private ?
", has private key" : "");
674 fprintf(out
, " keyid: %D\n", keyid
);
675 fprintf(out
, " subjkey: %D\n", id
);
677 public->destroy(public);
680 /* list optional authorityKeyIdentifier */
683 fprintf(out
, " authkey: %D\n", authkey
);
687 enumerator
->destroy(enumerator
);
691 * list all X.509 attribute certificates
693 static void stroke_list_acerts(linked_list_t
*list
, bool utc
, FILE *out
)
696 time_t thisUpdate
, nextUpdate
, now
= time(NULL
);
697 enumerator_t
*enumerator
= list
->create_enumerator(list
);
700 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
702 ac_t
*ac
= (ac_t
*)cert
;
703 chunk_t serial
= ac
->get_serial(ac
);
704 chunk_t holderSerial
= ac
->get_holderSerial(ac
);
705 identification_t
*holderIssuer
= ac
->get_holderIssuer(ac
);
706 identification_t
*authkey
= ac
->get_authKeyIdentifier(ac
);
707 identification_t
*entityName
= cert
->get_subject(cert
);
712 fprintf(out
, "List of X.509 Attribute Certificates:\n");
719 fprintf(out
, " holder: \"%D\"\n", entityName
);
723 fprintf(out
, " hissuer: \"%D\"\n", holderIssuer
);
725 if (holderSerial
.ptr
)
727 fprintf(out
, " hserial: %#B\n", &holderSerial
);
729 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
730 fprintf(out
, " serial: %#B\n", &serial
);
733 cert
->get_validity(cert
, &now
, &thisUpdate
, &nextUpdate
);
734 fprintf(out
, " updates: this %#T\n", &thisUpdate
, utc
);
735 fprintf(out
, " next %#T, ", &nextUpdate
, utc
);
736 if (now
> nextUpdate
)
738 fprintf(out
, "expired (%#V ago)\n", &now
, &nextUpdate
);
743 if (now
> nextUpdate
- AC_WARNING_INTERVAL
* 60 * 60 * 24)
745 fprintf(out
, " (expires in %#V)", &now
, &nextUpdate
);
750 /* list optional authorityKeyIdentifier */
753 fprintf(out
, " authkey: %D\n", authkey
);
756 enumerator
->destroy(enumerator
);
760 * list all X.509 CRLs
762 static void stroke_list_crls(linked_list_t
*list
, bool utc
, FILE *out
)
765 time_t thisUpdate
, nextUpdate
, now
= time(NULL
);
766 enumerator_t
*enumerator
= list
->create_enumerator(list
);
769 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
771 crl_t
*crl
= (crl_t
*)cert
;
772 chunk_t serial
= crl
->get_serial(crl
);
773 identification_t
*authkey
= crl
->get_authKeyIdentifier(crl
);
778 fprintf(out
, "List of X.509 CRLs:\n");
783 fprintf(out
, " issuer: \"%D\"\n", cert
->get_issuer(cert
));
785 /* list optional crlNumber */
788 fprintf(out
, " serial: %#B\n", &serial
);
791 /* count the number of revoked certificates */
794 enumerator_t
*enumerator
= crl
->create_enumerator(crl
);
796 while (enumerator
->enumerate(enumerator
, NULL
, NULL
, NULL
))
800 fprintf(out
, " revoked: %d certificate%s\n", count
,
801 (count
== 1)?
"" : "s");
802 enumerator
->destroy(enumerator
);
806 cert
->get_validity(cert
, &now
, &thisUpdate
, &nextUpdate
);
807 fprintf(out
, " updates: this %#T\n", &thisUpdate
, utc
);
808 fprintf(out
, " next %#T, ", &nextUpdate
, utc
);
809 if (now
> nextUpdate
)
811 fprintf(out
, "expired (%#V ago)\n", &now
, &nextUpdate
);
816 if (now
> nextUpdate
- CRL_WARNING_INTERVAL
* 60 * 60 * 24)
818 fprintf(out
, " (expires in %#V)", &now
, &nextUpdate
);
823 /* list optional authorityKeyIdentifier */
826 fprintf(out
, " authkey: %D\n", authkey
);
829 enumerator
->destroy(enumerator
);
833 * list all OCSP responses
835 static void stroke_list_ocsp(linked_list_t
* list
, bool utc
, FILE *out
)
838 enumerator_t
*enumerator
= list
->create_enumerator(list
);
841 while (enumerator
->enumerate(enumerator
, (void**)&cert
))
846 fprintf(out
, "List of OCSP responses:\n");
851 fprintf(out
, " signer: \"%D\"\n", cert
->get_issuer(cert
));
853 enumerator
->destroy(enumerator
);
857 * List of registered cryptographical algorithms
859 static void list_algs(FILE *out
)
861 enumerator_t
*enumerator
;
862 encryption_algorithm_t encryption
;
863 integrity_algorithm_t integrity
;
864 hash_algorithm_t hash
;
865 pseudo_random_function_t prf
;
866 diffie_hellman_group_t group
;
869 fprintf(out
, "List of registered IKEv2 Algorithms:\n");
870 fprintf(out
, "\n encryption: ");
871 enumerator
= lib
->crypto
->create_crypter_enumerator(lib
->crypto
);
872 while (enumerator
->enumerate(enumerator
, &encryption
))
874 fprintf(out
, "%N ", encryption_algorithm_names
, encryption
);
876 enumerator
->destroy(enumerator
);
877 fprintf(out
, "\n integrity: ");
878 enumerator
= lib
->crypto
->create_signer_enumerator(lib
->crypto
);
879 while (enumerator
->enumerate(enumerator
, &integrity
))
881 fprintf(out
, "%N ", integrity_algorithm_names
, integrity
);
883 enumerator
->destroy(enumerator
);
884 fprintf(out
, "\n hasher: ");
885 enumerator
= lib
->crypto
->create_hasher_enumerator(lib
->crypto
);
886 while (enumerator
->enumerate(enumerator
, &hash
))
888 fprintf(out
, "%N ", hash_algorithm_names
, hash
);
890 enumerator
->destroy(enumerator
);
891 fprintf(out
, "\n prf: ");
892 enumerator
= lib
->crypto
->create_prf_enumerator(lib
->crypto
);
893 while (enumerator
->enumerate(enumerator
, &prf
))
895 fprintf(out
, "%N ", pseudo_random_function_names
, prf
);
897 enumerator
->destroy(enumerator
);
898 fprintf(out
, "\n dh-group: ");
899 enumerator
= lib
->crypto
->create_dh_enumerator(lib
->crypto
);
900 while (enumerator
->enumerate(enumerator
, &group
))
902 fprintf(out
, "%N ", diffie_hellman_group_names
, group
);
904 enumerator
->destroy(enumerator
);
909 * Implementation of stroke_list_t.list.
911 static void list(private_stroke_list_t
*this, stroke_msg_t
*msg
, FILE *out
)
913 linked_list_t
*cert_list
= NULL
;
915 if (msg
->list
.flags
& LIST_PUBKEYS
)
917 linked_list_t
*pubkey_list
= create_unique_cert_list(CERT_TRUSTED_PUBKEY
);
919 stroke_list_pubkeys(pubkey_list
, msg
->list
.utc
, out
);
920 pubkey_list
->destroy_offset(pubkey_list
, offsetof(certificate_t
, destroy
));
922 if (msg
->list
.flags
& (LIST_CERTS
| LIST_CACERTS
| LIST_OCSPCERTS
| LIST_AACERTS
))
924 cert_list
= create_unique_cert_list(CERT_X509
);
926 if (msg
->list
.flags
& LIST_CERTS
)
928 stroke_list_certs(cert_list
, "X.509 End Entity Certificates",
929 0, msg
->list
.utc
, out
);
931 if (msg
->list
.flags
& LIST_CACERTS
)
933 stroke_list_certs(cert_list
, "X.509 CA Certificates",
934 X509_CA
, msg
->list
.utc
, out
);
936 if (msg
->list
.flags
& LIST_OCSPCERTS
)
938 stroke_list_certs(cert_list
, "X.509 OCSP Signer Certificates",
939 X509_OCSP_SIGNER
, msg
->list
.utc
, out
);
941 if (msg
->list
.flags
& LIST_AACERTS
)
943 stroke_list_certs(cert_list
, "X.509 AA Certificates",
944 X509_AA
, msg
->list
.utc
, out
);
946 if (msg
->list
.flags
& LIST_ACERTS
)
948 linked_list_t
*ac_list
= create_unique_cert_list(CERT_X509_AC
);
950 stroke_list_acerts(ac_list
, msg
->list
.utc
, out
);
951 ac_list
->destroy_offset(ac_list
, offsetof(certificate_t
, destroy
));
953 if (msg
->list
.flags
& LIST_CRLS
)
955 linked_list_t
*crl_list
= create_unique_cert_list(CERT_X509_CRL
);
957 stroke_list_crls(crl_list
, msg
->list
.utc
, out
);
958 crl_list
->destroy_offset(crl_list
, offsetof(certificate_t
, destroy
));
960 if (msg
->list
.flags
& LIST_OCSP
)
962 linked_list_t
*ocsp_list
= create_unique_cert_list(CERT_X509_OCSP_RESPONSE
);
964 stroke_list_ocsp(ocsp_list
, msg
->list
.utc
, out
);
966 ocsp_list
->destroy_offset(ocsp_list
, offsetof(certificate_t
, destroy
));
968 if (msg
->list
.flags
& LIST_ALGS
)
972 DESTROY_OFFSET_IF(cert_list
, offsetof(certificate_t
, destroy
));
976 * Implementation of stroke_list_t.destroy
978 static void destroy(private_stroke_list_t
*this)
986 stroke_list_t
*stroke_list_create()
988 private_stroke_list_t
*this = malloc_thing(private_stroke_list_t
);
990 this->public.list
= (void(*)(stroke_list_t
*, stroke_msg_t
*msg
, FILE *out
))list
;
991 this->public.status
= (void(*)(stroke_list_t
*, stroke_msg_t
*msg
, FILE *out
,bool))status
;
992 this->public.destroy
= (void(*)(stroke_list_t
*))destroy
;
994 this->uptime
= time(NULL
);
996 return &this->public;