@@ -9757,6 +9757,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
9757
9757
const char * keytype = "Key type of the retained key." ;
9758
9758
const char * insert = "Insert retained key into the keyring." ;
9759
9759
const char * keyfile = "Update key file with the derive TLS PSK." ;
9760
+ const char * compat = "Use compatibility algorithm for HKDF-Expand-Label." ;
9760
9761
9761
9762
_cleanup_free_ unsigned char * raw_secret = NULL ;
9762
9763
_cleanup_free_ char * encoded_key = NULL ;
@@ -9775,6 +9776,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
9775
9776
unsigned char hmac ;
9776
9777
unsigned char version ;
9777
9778
bool insert ;
9779
+ bool compat ;
9778
9780
};
9779
9781
9780
9782
struct config cfg = {
@@ -9787,6 +9789,7 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
9787
9789
.hmac = 1 ,
9788
9790
.version = 0 ,
9789
9791
.insert = false,
9792
+ .compat = false,
9790
9793
};
9791
9794
9792
9795
NVME_ARGS (opts ,
@@ -9798,7 +9801,8 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
9798
9801
OPT_STR ("keyfile" , 'f' , & cfg .keyfile , keyfile ),
9799
9802
OPT_BYTE ("hmac" , 'm' , & cfg .hmac , hmac ),
9800
9803
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 ));
9802
9806
9803
9807
err = parse_args (argc , argv , desc , opts );
9804
9808
if (err )
@@ -9859,7 +9863,13 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
9859
9863
printf ("%s\n" , encoded_key );
9860
9864
9861
9865
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 ,
9863
9873
cfg .keytype , cfg .hostnqn ,
9864
9874
cfg .subsysnqn , cfg .version ,
9865
9875
cfg .hmac , raw_secret , key_len );
@@ -9891,6 +9901,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
9891
9901
const char * keytype = "Key type of the retained key." ;
9892
9902
const char * insert = "Insert retained key into the keyring." ;
9893
9903
const char * keyfile = "Update key file with the derive TLS PSK." ;
9904
+ const char * compat = "Use compatibility algorithm for HKDF-Expand-Label." ;
9894
9905
9895
9906
_cleanup_free_ unsigned char * decoded_key = NULL ;
9896
9907
_cleanup_free_ char * hnqn = NULL ;
@@ -9906,6 +9917,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
9906
9917
char * keyfile ;
9907
9918
unsigned char identity ;
9908
9919
bool insert ;
9920
+ bool compat ;
9909
9921
};
9910
9922
9911
9923
struct config cfg = {
@@ -9917,6 +9929,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
9917
9929
.keyfile = NULL ,
9918
9930
.identity = 0 ,
9919
9931
.insert = false,
9932
+ .compat = false,
9920
9933
};
9921
9934
9922
9935
NVME_ARGS (opts ,
@@ -9927,7 +9940,8 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
9927
9940
OPT_STR ("keydata" , 'd' , & cfg .keydata , keydata ),
9928
9941
OPT_STR ("keyfile" , 'f' , & cfg .keyfile , keyfile ),
9929
9942
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 ));
9931
9945
9932
9946
err = parse_args (argc , argv , desc , opts );
9933
9947
if (err )
@@ -9963,7 +9977,13 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
9963
9977
}
9964
9978
9965
9979
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 ,
9967
9987
cfg .keytype , cfg .hostnqn ,
9968
9988
cfg .subsysnqn , cfg .identity ,
9969
9989
hmac , decoded_key , decoded_len );
@@ -9981,7 +10001,12 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
9981
10001
} else {
9982
10002
_cleanup_free_ char * tls_id = NULL ;
9983
10003
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 ,
9985
10010
cfg .subsysnqn , cfg .identity ,
9986
10011
hmac , decoded_key , decoded_len );
9987
10012
if (!tls_id ) {
0 commit comments