diff options
| author | Harald Welte <laforge@gnumonks.org> | 2012-06-27 15:06:19 +0200 | 
|---|---|---|
| committer | Harald Welte <laforge@gnumonks.org> | 2012-06-27 15:06:19 +0200 | 
| commit | 57799ed87f9473f6cee48fd48d26809aff2bc7ec (patch) | |
| tree | 80f7beedaaa64e5b5ef5f1435de9bbd6b5e6480f /utils | |
| parent | c17f57053802c8b151df38169b73eef804ce2b3e (diff) | |
osmo-auc-gen: Add "-I" mode for generating triplets.dat for strongswan
If you want to use eap-sim-file with strongswan, you need a triplets.dat
file in a specific format.  osmo-auc-gen can now generate the respective
format automatically.
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/osmo-auc-gen.c | 26 | 
1 files changed, 23 insertions, 3 deletions
| diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index e3502b2c..266d0d6a 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -30,6 +30,18 @@  #include <osmocom/crypt/auth.h>  #include <osmocom/core/utils.h> +static void dump_triplets_dat(struct osmo_auth_vector *vec) +{ +	if (vec->auth_types & OSMO_AUTH_TYPE_UMTS) { +		fprintf(stderr, "triplets.dat doesn't support UMTS!\n"); +		return; +	} +	printf("imsi,"); +	printf("%s,", osmo_hexdump_nospc(vec->rand, sizeof(vec->rand))); +	printf("%s,", osmo_hexdump_nospc(vec->sres, sizeof(vec->sres))); +	printf("%s\n", osmo_hexdump_nospc(vec->kc, sizeof(vec->kc))); +} +  static void dump_auth_vec(struct osmo_auth_vector *vec)  {  	printf("RAND:\t%s\n", osmo_hexdump(vec->rand, sizeof(vec->rand))); @@ -63,7 +75,8 @@ static void help()  		"-a  --amf\tSpecify AMF (only for 3G)\n"  		"-s  --sqn\tSpecify SQN (only for 3G)\n"  		"-A  --auts\tSpecify AUTS (only for 3G)\n" -		"-r  --rand\tSpecify random value\n"); +		"-r  --rand\tSpecify random value\n" +		"-I  --ipsec\tOutput in triplets.dat format for strongswan\n");  }  int main(int argc, char **argv) @@ -74,6 +87,7 @@ int main(int argc, char **argv)  	int rc, option_index;  	int rand_is_set = 0;  	int auts_is_set = 0; +	int fmt_triplets_dat = 0;  	printf("osmo-auc-gen (C) 2011-2012 by Harald Welte\n");  	printf("This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n"); @@ -100,7 +114,7 @@ int main(int argc, char **argv)  		rc = 0; -		c = getopt_long(argc, argv, "23a:k:o:f:s:r:hO:A:", long_options, +		c = getopt_long(argc, argv, "23a:k:o:f:s:r:hO:A:I", long_options,  				&option_index);  		if (c == -1) @@ -179,6 +193,9 @@ int main(int argc, char **argv)  			rc = osmo_hexparse(optarg, _rand, sizeof(_rand));  			rand_is_set = 1;  			break; +		case 'I': +			fmt_triplets_dat = 1; +			break;  		case 'h':  			help();  			exit(0); @@ -222,7 +239,10 @@ int main(int argc, char **argv)  		exit(1);  	} -	dump_auth_vec(vec); +	if (fmt_triplets_dat) +		dump_triplets_dat(vec); +	else +		dump_auth_vec(vec);  	if (auts_is_set)  		printf("AUTS success: SEQ.MS = %lu\n", test_aud.u.umts.sqn); | 
