@@ -9757,6 +9757,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
97579757 const char * keytype = "Key type of the retained key." ;
97589758 const char * insert = "Insert retained key into the keyring." ;
97599759 const char * keyfile = "Update key file with the derive TLS PSK." ;
9760+ const char * compat = "Use compatibility algorithm for HKDF-Expand-Label." ;
97609761
97619762 _cleanup_free_ unsigned char * raw_secret = NULL ;
97629763 _cleanup_free_ char * encoded_key = NULL ;
@@ -9775,6 +9776,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
97759776 unsigned char hmac ;
97769777 unsigned char version ;
97779778 bool insert ;
9779+ bool compat ;
97789780 };
97799781
97809782 struct config cfg = {
@@ -9787,6 +9789,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
97879789 .hmac = 1 ,
97889790 .version = 0 ,
97899791 .insert = false,
9792+ .compat = false,
97909793 };
97919794
97929795 NVME_ARGS (opts ,
@@ -9798,7 +9801,8 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
97989801 OPT_STR ("keyfile" , 'f' , & cfg .keyfile , keyfile ),
97999802 OPT_BYTE ("hmac" , 'm' , & cfg .hmac , hmac ),
98009803 OPT_BYTE ("identity" , 'I' , & cfg .version , version ),
9801- OPT_FLAG ("insert" , 'i' , & cfg .insert , insert ));
9804+ OPT_FLAG ("insert" , 'i' , & cfg .insert , insert ),
9805+ OPT_FLAG ("compat" , 'C' , & cfg .compat , compat ));
98029806
98039807 err = parse_args (argc , argv , desc , opts );
98049808 if (err )
@@ -9859,7 +9863,13 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
98599863 printf ("%s\n" , encoded_key );
98609864
98619865 if (cfg .insert ) {
9862- tls_key = nvme_insert_tls_key_versioned (cfg .keyring ,
9866+ if (cfg .compat )
9867+ tls_key = nvme_insert_tls_key_compat (cfg .keyring ,
9868+ cfg .keytype , cfg .hostnqn ,
9869+ cfg .subsysnqn , cfg .version ,
9870+ cfg .hmac , raw_secret , key_len );
9871+ else
9872+ tls_key = nvme_insert_tls_key_versioned (cfg .keyring ,
98639873 cfg .keytype , cfg .hostnqn ,
98649874 cfg .subsysnqn , cfg .version ,
98659875 cfg .hmac , raw_secret , key_len );
@@ -9891,6 +9901,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
98919901 const char * keytype = "Key type of the retained key." ;
98929902 const char * insert = "Insert retained key into the keyring." ;
98939903 const char * keyfile = "Update key file with the derive TLS PSK." ;
9904+ const char * compat = "Use compatibility algorithm for HKDF-Expand-Label." ;
98949905
98959906 _cleanup_free_ unsigned char * decoded_key = NULL ;
98969907 _cleanup_free_ char * hnqn = NULL ;
@@ -9906,6 +9917,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
99069917 char * keyfile ;
99079918 unsigned char identity ;
99089919 bool insert ;
9920+ bool compat ;
99099921 };
99109922
99119923 struct config cfg = {
@@ -9917,6 +9929,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
99179929 .keyfile = NULL ,
99189930 .identity = 0 ,
99199931 .insert = false,
9932+ .compat = false,
99209933 };
99219934
99229935 NVME_ARGS (opts ,
@@ -9927,7 +9940,8 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
99279940 OPT_STR ("keydata" , 'd' , & cfg .keydata , keydata ),
99289941 OPT_STR ("keyfile" , 'f' , & cfg .keyfile , keyfile ),
99299942 OPT_BYTE ("identity" , 'I' , & cfg .identity , identity ),
9930- OPT_FLAG ("insert" , 'i' , & cfg .insert , insert ));
9943+ OPT_FLAG ("insert" , 'i' , & cfg .insert , insert ),
9944+ OPT_FLAG ("compat" , 'C' , & cfg .compat , compat ));
99319945
99329946 err = parse_args (argc , argv , desc , opts );
99339947 if (err )
@@ -9963,7 +9977,13 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
99639977 }
99649978
99659979 if (cfg .insert ) {
9966- tls_key = nvme_insert_tls_key_versioned (cfg .keyring ,
9980+ if (cfg .compat )
9981+ tls_key = nvme_insert_tls_key_compat (cfg .keyring ,
9982+ cfg .keytype , cfg .hostnqn ,
9983+ cfg .subsysnqn , cfg .identity ,
9984+ hmac , decoded_key , decoded_len );
9985+ else
9986+ tls_key = nvme_insert_tls_key_versioned (cfg .keyring ,
99679987 cfg .keytype , cfg .hostnqn ,
99689988 cfg .subsysnqn , cfg .identity ,
99699989 hmac , decoded_key , decoded_len );
@@ -9981,7 +10001,12 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
998110001 } else {
998210002 _cleanup_free_ char * tls_id = NULL ;
998310003
9984- tls_id = nvme_generate_tls_key_identity (cfg .hostnqn ,
10004+ if (cfg .compat )
10005+ tls_id = nvme_generate_tls_key_identity_compat (cfg .hostnqn ,
10006+ cfg .subsysnqn , cfg .identity ,
10007+ hmac , decoded_key , decoded_len );
10008+ else
10009+ tls_id = nvme_generate_tls_key_identity (cfg .hostnqn ,
998510010 cfg .subsysnqn , cfg .identity ,
998610011 hmac , decoded_key , decoded_len );
998710012 if (!tls_id ) {
0 commit comments