@@ -9729,6 +9729,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
97299729 const char * keytype = "Key type of the retained key." ;
97309730 const char * insert = "Insert retained key into the keyring." ;
97319731 const char * keyfile = "Update key file with the derive TLS PSK." ;
9732+ const char * compat = "Use compatibility algorithm for HKDF-Expand-Label." ;
97329733
97339734 _cleanup_free_ unsigned char * raw_secret = NULL ;
97349735 _cleanup_free_ char * encoded_key = NULL ;
@@ -9747,6 +9748,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
97479748 unsigned char hmac ;
97489749 unsigned char version ;
97499750 bool insert ;
9751+ bool compat ;
97509752 };
97519753
97529754 struct config cfg = {
@@ -9759,6 +9761,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
97599761 .hmac = 1 ,
97609762 .version = 0 ,
97619763 .insert = false,
9764+ .compat = false,
97629765 };
97639766
97649767 NVME_ARGS (opts ,
@@ -9770,7 +9773,8 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
97709773 OPT_STR ("keyfile" , 'f' , & cfg .keyfile , keyfile ),
97719774 OPT_BYTE ("hmac" , 'm' , & cfg .hmac , hmac ),
97729775 OPT_BYTE ("identity" , 'I' , & cfg .version , version ),
9773- OPT_FLAG ("insert" , 'i' , & cfg .insert , insert ));
9776+ OPT_FLAG ("insert" , 'i' , & cfg .insert , insert ),
9777+ OPT_FLAG ("compat" , 'C' , & cfg .compat , compat ));
97749778
97759779 err = parse_args (argc , argv , desc , opts );
97769780 if (err )
@@ -9831,7 +9835,13 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
98319835 printf ("%s\n" , encoded_key );
98329836
98339837 if (cfg .insert ) {
9834- tls_key = nvme_insert_tls_key_versioned (cfg .keyring ,
9838+ if (cfg .compat )
9839+ tls_key = nvme_insert_tls_key_compat (cfg .keyring ,
9840+ cfg .keytype , cfg .hostnqn ,
9841+ cfg .subsysnqn , cfg .version ,
9842+ cfg .hmac , raw_secret , key_len );
9843+ else
9844+ tls_key = nvme_insert_tls_key_versioned (cfg .keyring ,
98359845 cfg .keytype , cfg .hostnqn ,
98369846 cfg .subsysnqn , cfg .version ,
98379847 cfg .hmac , raw_secret , key_len );
@@ -9863,6 +9873,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
98639873 const char * keytype = "Key type of the retained key." ;
98649874 const char * insert = "Insert retained key into the keyring." ;
98659875 const char * keyfile = "Update key file with the derive TLS PSK." ;
9876+ const char * compat = "Use compatibility algorithm for HKDF-Expand-Label." ;
98669877
98679878 _cleanup_free_ unsigned char * decoded_key = NULL ;
98689879 _cleanup_free_ char * hnqn = NULL ;
@@ -9878,6 +9889,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
98789889 char * keyfile ;
98799890 unsigned char identity ;
98809891 bool insert ;
9892+ bool compat ;
98819893 };
98829894
98839895 struct config cfg = {
@@ -9889,6 +9901,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
98899901 .keyfile = NULL ,
98909902 .identity = 0 ,
98919903 .insert = false,
9904+ .compat = false,
98929905 };
98939906
98949907 NVME_ARGS (opts ,
@@ -9899,7 +9912,8 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
98999912 OPT_STR ("keydata" , 'd' , & cfg .keydata , keydata ),
99009913 OPT_STR ("keyfile" , 'f' , & cfg .keyfile , keyfile ),
99019914 OPT_BYTE ("identity" , 'I' , & cfg .identity , identity ),
9902- OPT_FLAG ("insert" , 'i' , & cfg .insert , insert ));
9915+ OPT_FLAG ("insert" , 'i' , & cfg .insert , insert ),
9916+ OPT_FLAG ("compat" , 'C' , & cfg .compat , compat ));
99039917
99049918 err = parse_args (argc , argv , desc , opts );
99059919 if (err )
@@ -9935,7 +9949,13 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
99359949 }
99369950
99379951 if (cfg .insert ) {
9938- tls_key = nvme_insert_tls_key_versioned (cfg .keyring ,
9952+ if (cfg .compat )
9953+ tls_key = nvme_insert_tls_key_compat (cfg .keyring ,
9954+ cfg .keytype , cfg .hos `tnqn ,
9955+ cfg .subsysnqn , cfg .identity ,
9956+ hmac , decoded_key , decoded_len );
9957+ else
9958+ tls_key = nvme_insert_tls_key_versioned (cfg .keyring ,
99399959 cfg .keytype , cfg .hostnqn ,
99409960 cfg .subsysnqn , cfg .identity ,
99419961 hmac , decoded_key , decoded_len );
@@ -9953,7 +9973,12 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
99539973 } else {
99549974 _cleanup_free_ char * tls_id = NULL ;
99559975
9956- tls_id = nvme_generate_tls_key_identity (cfg .hostnqn ,
9976+ if (cfg .compat )
9977+ tls_id = nvme_generate_tls_key_identity_compat (cfg .hostnqn ,
9978+ cfg .subsysnqn , cfg .identity ,
9979+ hmac , decoded_key , decoded_len );
9980+ else
9981+ tls_id = nvme_generate_tls_key_identity (cfg .hostnqn ,
99579982 cfg .subsysnqn , cfg .identity ,
99589983 hmac , decoded_key , decoded_len );
99599984 if (!tls_id ) {
0 commit comments