@@ -622,21 +622,6 @@ struct lookup dkimf_values[] =
622
622
{ NULL , -1 },
623
623
};
624
624
625
- struct lookup dkimf_canon [] =
626
- {
627
- { "relaxed" , DKIM_CANON_RELAXED },
628
- { "simple" , DKIM_CANON_SIMPLE },
629
- { NULL , -1 },
630
- };
631
-
632
- struct lookup dkimf_sign [] =
633
- {
634
- { "rsa-sha1" , DKIM_SIGN_RSASHA1 },
635
- { "rsa-sha256" , DKIM_SIGN_RSASHA256 },
636
- { "ed25519-sha256" , DKIM_SIGN_ED25519SHA256 },
637
- { NULL , -1 },
638
- };
639
-
640
625
struct lookup dkimf_atpshash [] =
641
626
{
642
627
#ifdef HAVE_SHA256
@@ -7697,8 +7682,8 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
7697
7682
7698
7683
if (conf -> conf_signalgstr != NULL )
7699
7684
{
7700
- conf -> conf_signalg = dkimf_lookup_strtoint ( conf -> conf_signalgstr ,
7701
- dkimf_sign );
7685
+ conf -> conf_signalg = dkim_name_to_code ( dkim_table_algorithms ,
7686
+ conf -> conf_signalgstr );
7702
7687
if (conf -> conf_signalg == -1 )
7703
7688
{
7704
7689
snprintf (err , errlen ,
@@ -7719,8 +7704,8 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
7719
7704
p = strchr (conf -> conf_canonstr , '/' );
7720
7705
if (p == NULL )
7721
7706
{
7722
- conf -> conf_hdrcanon = dkimf_lookup_strtoint ( conf -> conf_canonstr ,
7723
- dkimf_canon );
7707
+ conf -> conf_hdrcanon = dkim_name_to_code ( dkim_table_canonicalizations ,
7708
+ conf -> conf_canonstr );
7724
7709
if (conf -> conf_hdrcanon == -1 )
7725
7710
{
7726
7711
snprintf (err , errlen ,
@@ -7735,8 +7720,8 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
7735
7720
{
7736
7721
* p = '\0' ;
7737
7722
7738
- conf -> conf_hdrcanon = dkimf_lookup_strtoint ( conf -> conf_canonstr ,
7739
- dkimf_canon );
7723
+ conf -> conf_hdrcanon = dkim_name_to_code ( dkim_table_canonicalizations ,
7724
+ conf -> conf_canonstr );
7740
7725
if (conf -> conf_hdrcanon == -1 )
7741
7726
{
7742
7727
snprintf (err , errlen ,
@@ -7745,8 +7730,8 @@ dkimf_config_load(struct config *data, struct dkimf_config *conf,
7745
7730
return -1 ;
7746
7731
}
7747
7732
7748
- conf -> conf_bodycanon = dkimf_lookup_strtoint ( p + 1 ,
7749
- dkimf_canon );
7733
+ conf -> conf_bodycanon = dkim_name_to_code ( dkim_table_canonicalizations ,
7734
+ p + 1 );
7750
7735
if (conf -> conf_bodycanon == -1 )
7751
7736
{
7752
7737
snprintf (err , errlen ,
@@ -11718,18 +11703,18 @@ mlfi_header(SMFICTX *ctx, char *headerf, char *headerv)
11718
11703
{
11719
11704
* slash = '\0' ;
11720
11705
11721
- c = dkimf_lookup_strtoint ( headerv , dkimf_canon );
11706
+ c = dkim_name_to_code ( dkim_table_canonicalizations , headerv );
11722
11707
if (c != -1 )
11723
11708
dfc -> mctx_hdrcanon = (dkim_canon_t ) c ;
11724
- c = dkimf_lookup_strtoint ( slash + 1 , dkimf_canon );
11709
+ c = dkim_name_to_code ( dkim_table_canonicalizations , slash + 1 );
11725
11710
if (c != -1 )
11726
11711
dfc -> mctx_bodycanon = (dkim_canon_t ) c ;
11727
11712
11728
11713
* slash = '/' ;
11729
11714
}
11730
11715
else
11731
11716
{
11732
- c = dkimf_lookup_strtoint ( headerv , dkimf_canon );
11717
+ c = dkim_name_to_code ( dkim_table_canonicalizations , headerv );
11733
11718
if (c != -1 )
11734
11719
dfc -> mctx_hdrcanon = (dkim_canon_t ) c ;
11735
11720
}
@@ -15544,6 +15529,10 @@ main(int argc, char **argv)
15544
15529
char * end ;
15545
15530
char argstr [MAXARGV ];
15546
15531
char err [BUFRSZ + 1 ];
15532
+ DKIM_STAT dkim_stat ;
15533
+ DKIM_ITER_CTX * iter_ctx ;
15534
+ int entry_code ;
15535
+ char * entry_name ;
15547
15536
15548
15537
/* initialize */
15549
15538
reload = FALSE;
@@ -15771,17 +15760,55 @@ main(int argc, char **argv)
15771
15760
printf ("\tlibmilter version %d.%d.%d\n" ,
15772
15761
mvmajor , mvminor , mvrelease );
15773
15762
#endif /* HAVE_SMFI_VERSION */
15763
+ dkim_stat = dkim_nametable_first (dkim_table_algorithms ,
15764
+ & iter_ctx , & entry_name ,
15765
+ & entry_code );
15774
15766
printf ("\tSupported signing algorithms:\n" );
15775
- for (c = 0 ; dkimf_sign [c ].str != NULL ; c ++ )
15767
+ if (dkim_stat == DKIM_STAT_NORESOURCE )
15768
+ {
15769
+ printf ("\twarn: list of algorithms is not "
15770
+ "available\n" );
15771
+ }
15772
+ else
15776
15773
{
15777
- if (dkimf_sign [c ].code != DKIM_SIGN_RSASHA256 ||
15778
- dkim_libfeature (curconf -> conf_libopendkim ,
15779
- DKIM_FEATURE_SHA256 ))
15780
- printf ("\t\t%s\n" , dkimf_sign [c ].str );
15774
+ while (dkim_stat == DKIM_STAT_OK )
15775
+ {
15776
+ if (entry_code != DKIM_SIGN_RSASHA256 ||
15777
+ dkim_libfeature (curconf -> conf_libopendkim ,
15778
+ DKIM_FEATURE_SHA256 ))
15779
+ {
15780
+ printf ("\t\t%s\n" , entry_name );
15781
+ }
15782
+ dkim_stat = dkim_nametable_next (iter_ctx ,
15783
+ & entry_name ,
15784
+ & entry_code );
15785
+ }
15786
+ dkim_stat = dkim_iter_ctx_free (iter_ctx );
15787
+ /* we can do nothing eveif dkim_stat is not
15788
+ DKIM_STAT_OK ... */
15781
15789
}
15782
15790
printf ("\tSupported canonicalization algorithms:\n" );
15783
- for (c = 0 ; dkimf_canon [c ].str != NULL ; c ++ )
15784
- printf ("\t\t%s\n" , dkimf_canon [c ].str );
15791
+ dkim_stat = dkim_nametable_first (dkim_table_canonicalizations ,
15792
+ & iter_ctx , & entry_name ,
15793
+ & entry_code );
15794
+ if (dkim_stat == DKIM_STAT_NORESOURCE )
15795
+ {
15796
+ printf ("\twarn: list of canonicalizations "
15797
+ "is not available\n" );
15798
+ }
15799
+ else
15800
+ {
15801
+ while (dkim_stat == DKIM_STAT_OK )
15802
+ {
15803
+ printf ("\t\t%s\n" , entry_name );
15804
+ dkim_stat = dkim_nametable_next (iter_ctx ,
15805
+ & entry_name ,
15806
+ & entry_code );
15807
+ }
15808
+ dkim_stat = dkim_iter_ctx_free (iter_ctx );
15809
+ /* we can do nothing eveif dkim_stat is not
15810
+ DKIM_STAT_OK ... */
15811
+ }
15785
15812
dkimf_optlist (stdout );
15786
15813
return EX_OK ;
15787
15814
0 commit comments