提交 f8d3a644 编写于 作者: B Boaz Harrosh 提交者: James Bottomley

[SCSI] libosd: OSD2r05: OSD_CRYPTO_KEYID_SIZE will grow 20 => 32 bytes

In OSD2r04 draft, cryptographic key size changed to 32 bytes from
OSD1's 20 bytes. This causes a couple of on-the-wire structures
to change, including the CDB.

In this patch the OSD1/OSD2 handling is separated out in regard
to affected structures, but on-the-wire is still the same. All
on the wire changes will be submitted in one patch for bisect-ability.
Signed-off-by: NBoaz Harrosh <bharrosh@panasas.com>
Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
上级 71f32e31
...@@ -345,9 +345,9 @@ _osd_req_sec_params(struct osd_request *or) ...@@ -345,9 +345,9 @@ _osd_req_sec_params(struct osd_request *or)
struct osd_cdb *ocdb = &or->cdb; struct osd_cdb *ocdb = &or->cdb;
if (osd_req_is_ver1(or)) if (osd_req_is_ver1(or))
return &ocdb->v1.sec_params; return (struct osd_security_parameters *)&ocdb->v1.sec_params;
else else
return &ocdb->v2.sec_params; return (struct osd_security_parameters *)&ocdb->v2.sec_params;
} }
void osd_dev_init(struct osd_dev *osdd, struct scsi_device *scsi_device) void osd_dev_init(struct osd_dev *osdd, struct scsi_device *scsi_device)
...@@ -1209,6 +1209,24 @@ static int _osd_req_finalize_attr_page(struct osd_request *or) ...@@ -1209,6 +1209,24 @@ static int _osd_req_finalize_attr_page(struct osd_request *or)
return ret; return ret;
} }
static inline void osd_sec_parms_set_out_offset(bool is_v1,
struct osd_security_parameters *sec_parms, osd_cdb_offset offset)
{
if (is_v1)
sec_parms->v1.data_out_integrity_check_offset = offset;
else
sec_parms->v2.data_out_integrity_check_offset = offset;
}
static inline void osd_sec_parms_set_in_offset(bool is_v1,
struct osd_security_parameters *sec_parms, osd_cdb_offset offset)
{
if (is_v1)
sec_parms->v1.data_in_integrity_check_offset = offset;
else
sec_parms->v2.data_in_integrity_check_offset = offset;
}
static int _osd_req_finalize_data_integrity(struct osd_request *or, static int _osd_req_finalize_data_integrity(struct osd_request *or,
bool has_in, bool has_out, const u8 *cap_key) bool has_in, bool has_out, const u8 *cap_key)
{ {
...@@ -1232,8 +1250,8 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or, ...@@ -1232,8 +1250,8 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or,
or->out_data_integ.get_attributes_bytes = cpu_to_be64( or->out_data_integ.get_attributes_bytes = cpu_to_be64(
or->enc_get_attr.total_bytes); or->enc_get_attr.total_bytes);
sec_parms->data_out_integrity_check_offset = osd_sec_parms_set_out_offset(osd_req_is_ver1(or), sec_parms,
osd_req_encode_offset(or, or->out.total_bytes, &pad); osd_req_encode_offset(or, or->out.total_bytes, &pad));
ret = _req_append_segment(or, pad, &seg, or->out.last_seg, ret = _req_append_segment(or, pad, &seg, or->out.last_seg,
&or->out); &or->out);
...@@ -1253,8 +1271,8 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or, ...@@ -1253,8 +1271,8 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or,
}; };
unsigned pad; unsigned pad;
sec_parms->data_in_integrity_check_offset = osd_sec_parms_set_in_offset(osd_req_is_ver1(or), sec_parms,
osd_req_encode_offset(or, or->in.total_bytes, &pad); osd_req_encode_offset(or, or->in.total_bytes, &pad));
ret = _req_append_segment(or, pad, &seg, or->in.last_seg, ret = _req_append_segment(or, pad, &seg, or->in.last_seg,
&or->in); &or->in);
......
...@@ -33,8 +33,10 @@ enum { ...@@ -33,8 +33,10 @@ enum {
OSD_CAP_LEN = OSDv1_CAP_LEN,/* FIXME: Pete rev-001 sup */ OSD_CAP_LEN = OSDv1_CAP_LEN,/* FIXME: Pete rev-001 sup */
OSD_SYSTEMID_LEN = 20, OSD_SYSTEMID_LEN = 20,
OSD_CRYPTO_KEYID_SIZE = 20, OSDv1_CRYPTO_KEYID_SIZE = 20,
/*FIXME: OSDv2_CRYPTO_KEYID_SIZE = 32,*/ /*FIXME: OSDv2_CRYPTO_KEYID_SIZE = 32,*/
OSDv2_CRYPTO_KEYID_SIZE = 20,
OSD_CRYPTO_KEYID_SIZE = OSDv2_CRYPTO_KEYID_SIZE,
OSD_CRYPTO_SEED_SIZE = 4, OSD_CRYPTO_SEED_SIZE = 4,
OSD_CRYPTO_NONCE_SIZE = 12, OSD_CRYPTO_NONCE_SIZE = 12,
OSD_MAX_SENSE_LEN = 252, /* from SPC-3 */ OSD_MAX_SENSE_LEN = 252, /* from SPC-3 */
...@@ -204,29 +206,40 @@ struct osd_cdb_head { ...@@ -204,29 +206,40 @@ struct osd_cdb_head {
/*80*/ /*80*/
/*160 v1*/ /*160 v1*/
/*184 v2*/ struct osdv1_security_parameters {
struct osd_security_parameters { /*160*/u8 integrity_check_value[OSDv1_CRYPTO_KEYID_SIZE];
/*160*/u8 integrity_check_value[OSD_CRYPTO_KEYID_SIZE];
/*180*/u8 request_nonce[OSD_CRYPTO_NONCE_SIZE]; /*180*/u8 request_nonce[OSD_CRYPTO_NONCE_SIZE];
/*192*/osd_cdb_offset data_in_integrity_check_offset; /*192*/osd_cdb_offset data_in_integrity_check_offset;
/*196*/osd_cdb_offset data_out_integrity_check_offset; /*196*/osd_cdb_offset data_out_integrity_check_offset;
} __packed; } __packed;
/*200 v1*/ /*200 v1*/
/*224 v2*/
/* FIXME: osdv2_security_parameters */ /*184 v2*/
struct osdv2_security_parameters {
/*184*/u8 integrity_check_value[OSDv2_CRYPTO_KEYID_SIZE];
/*216*/u8 request_nonce[OSD_CRYPTO_NONCE_SIZE];
/*228*/osd_cdb_offset data_in_integrity_check_offset;
/*232*/osd_cdb_offset data_out_integrity_check_offset;
} __packed;
/*236 v2*/
struct osd_security_parameters {
union {
struct osdv1_security_parameters v1;
struct osdv2_security_parameters v2;
};
};
struct osdv1_cdb { struct osdv1_cdb {
struct osd_cdb_head h; struct osd_cdb_head h;
u8 caps[OSDv1_CAP_LEN]; u8 caps[OSDv1_CAP_LEN];
struct osd_security_parameters sec_params; struct osdv1_security_parameters sec_params;
} __packed; } __packed;
struct osdv2_cdb { struct osdv2_cdb {
struct osd_cdb_head h; struct osd_cdb_head h;
u8 caps[OSD_CAP_LEN]; u8 caps[OSD_CAP_LEN];
struct osd_security_parameters sec_params; struct osdv2_security_parameters sec_params;
/* FIXME: osdv2_security_parameters */
} __packed; } __packed;
struct osd_cdb { struct osd_cdb {
...@@ -429,15 +442,35 @@ struct osd_data_out_integrity_info { ...@@ -429,15 +442,35 @@ struct osd_data_out_integrity_info {
__be64 data_bytes; __be64 data_bytes;
__be64 set_attributes_bytes; __be64 set_attributes_bytes;
__be64 get_attributes_bytes; __be64 get_attributes_bytes;
__be64 integrity_check_value; __u8 integrity_check_value[OSD_CRYPTO_KEYID_SIZE];
} __packed; } __packed;
/* Same osd_data_out_integrity_info is used for OSD2/OSD1. The only difference
* Is the sizeof the structure since in OSD1 the last array is smaller. Use
* below for version independent handling of this structure
*/
static inline int osd_data_out_integrity_info_sizeof(bool is_ver1)
{
return sizeof(struct osd_data_out_integrity_info) -
(is_ver1 * (OSDv2_CRYPTO_KEYID_SIZE - OSDv1_CRYPTO_KEYID_SIZE));
}
struct osd_data_in_integrity_info { struct osd_data_in_integrity_info {
__be64 data_bytes; __be64 data_bytes;
__be64 retrieved_attributes_bytes; __be64 retrieved_attributes_bytes;
__be64 integrity_check_value; __u8 integrity_check_value[OSD_CRYPTO_KEYID_SIZE];
} __packed; } __packed;
/* Same osd_data_in_integrity_info is used for OSD2/OSD1. The only difference
* Is the sizeof the structure since in OSD1 the last array is smaller. Use
* below for version independent handling of this structure
*/
static inline int osd_data_in_integrity_info_sizeof(bool is_ver1)
{
return sizeof(struct osd_data_in_integrity_info) -
(is_ver1 * (OSDv2_CRYPTO_KEYID_SIZE - OSDv1_CRYPTO_KEYID_SIZE));
}
struct osd_timestamp { struct osd_timestamp {
u8 time[6]; /* number of milliseconds since 1/1/1970 UT (big endian) */ u8 time[6]; /* number of milliseconds since 1/1/1970 UT (big endian) */
} __packed; } __packed;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册