libceph: message signature support
Signed-off-by: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
struct ceph_auth_client;
|
||||
struct ceph_authorizer;
|
||||
struct ceph_msg;
|
||||
|
||||
struct ceph_auth_handshake {
|
||||
struct ceph_authorizer *authorizer;
|
||||
@@ -20,6 +21,10 @@ struct ceph_auth_handshake {
|
||||
size_t authorizer_buf_len;
|
||||
void *authorizer_reply_buf;
|
||||
size_t authorizer_reply_buf_len;
|
||||
int (*sign_message)(struct ceph_auth_handshake *auth,
|
||||
struct ceph_msg *msg);
|
||||
int (*check_message_signature)(struct ceph_auth_handshake *auth,
|
||||
struct ceph_msg *msg);
|
||||
};
|
||||
|
||||
struct ceph_auth_client_ops {
|
||||
@@ -66,6 +71,11 @@ struct ceph_auth_client_ops {
|
||||
void (*reset)(struct ceph_auth_client *ac);
|
||||
|
||||
void (*destroy)(struct ceph_auth_client *ac);
|
||||
|
||||
int (*sign_message)(struct ceph_auth_handshake *auth,
|
||||
struct ceph_msg *msg);
|
||||
int (*check_message_signature)(struct ceph_auth_handshake *auth,
|
||||
struct ceph_msg *msg);
|
||||
};
|
||||
|
||||
struct ceph_auth_client {
|
||||
@@ -113,4 +123,20 @@ extern int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac,
|
||||
extern void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac,
|
||||
int peer_type);
|
||||
|
||||
static inline int ceph_auth_sign_message(struct ceph_auth_handshake *auth,
|
||||
struct ceph_msg *msg)
|
||||
{
|
||||
if (auth->sign_message)
|
||||
return auth->sign_message(auth, msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline
|
||||
int ceph_auth_check_message_signature(struct ceph_auth_handshake *auth,
|
||||
struct ceph_msg *msg)
|
||||
{
|
||||
if (auth->check_message_signature)
|
||||
return auth->check_message_signature(auth, msg);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@@ -84,6 +84,7 @@ static inline u64 ceph_sanitize_features(u64 features)
|
||||
CEPH_FEATURE_PGPOOL3 | \
|
||||
CEPH_FEATURE_OSDENC | \
|
||||
CEPH_FEATURE_CRUSH_TUNABLES | \
|
||||
CEPH_FEATURE_MSG_AUTH | \
|
||||
CEPH_FEATURE_CRUSH_TUNABLES2 | \
|
||||
CEPH_FEATURE_REPLY_CREATE_INODE | \
|
||||
CEPH_FEATURE_OSDHASHPSPOOL | \
|
||||
|
@@ -42,6 +42,10 @@ struct ceph_connection_operations {
|
||||
struct ceph_msg * (*alloc_msg) (struct ceph_connection *con,
|
||||
struct ceph_msg_header *hdr,
|
||||
int *skip);
|
||||
int (*sign_message) (struct ceph_connection *con, struct ceph_msg *msg);
|
||||
|
||||
int (*check_message_signature) (struct ceph_connection *con,
|
||||
struct ceph_msg *msg);
|
||||
};
|
||||
|
||||
/* use format string %s%d */
|
||||
@@ -142,7 +146,10 @@ struct ceph_msg_data_cursor {
|
||||
*/
|
||||
struct ceph_msg {
|
||||
struct ceph_msg_header hdr; /* header */
|
||||
struct ceph_msg_footer footer; /* footer */
|
||||
union {
|
||||
struct ceph_msg_footer footer; /* footer */
|
||||
struct ceph_msg_footer_old old_footer; /* old format footer */
|
||||
};
|
||||
struct kvec front; /* unaligned blobs of message */
|
||||
struct ceph_buffer *middle;
|
||||
|
||||
|
@@ -164,13 +164,21 @@ struct ceph_msg_header {
|
||||
/*
|
||||
* follows data payload
|
||||
*/
|
||||
struct ceph_msg_footer_old {
|
||||
__le32 front_crc, middle_crc, data_crc;
|
||||
__u8 flags;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ceph_msg_footer {
|
||||
__le32 front_crc, middle_crc, data_crc;
|
||||
// sig holds the 64 bits of the digital signature for the message PLR
|
||||
__le64 sig;
|
||||
__u8 flags;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
|
||||
#define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */
|
||||
#define CEPH_MSG_FOOTER_SIGNED (1<<2) /* msg was signed */
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user