History

libceph: store session key in cephx authorizer

Session key is required when calculating message signature. Save the session key in authorizer, this avoid lookup ticket handler for each message

Yan, Zheng committed 12 years ago

Commit ae385ea1 parent e96a6502 files · +12 −7Browse files

Unified · Split

2 files
  1. net/ceph/auth_x.c +11 −7
  2. net/ceph/auth_x.h +1 −0
net/ceph/auth_x.c+11−7
@@ -293,6 +293,11 @@ static int ceph_x_build_authorizer(struct ceph_auth_client *ac, · 292 unmodified lines
293293 dout("build_authorizer for %s %p\n",
294294 ceph_entity_type_name(th->service), au);
295295
296+ ceph_crypto_key_destroy(&au->session_key);
297+ ret = ceph_crypto_key_clone(&au->session_key, &th->session_key);
298+ if (ret)
299+ return ret;
300+
296301 maxlen = sizeof(*msg_a) + sizeof(msg_b) +
297302 ceph_x_encrypt_buflen(ticket_blob_len);
298303 dout(" need len %d\n", maxlen);
@@ -302,8 +307,10 @@ static int ceph_x_build_authorizer(struct ceph_auth_client *ac, · 3 unmodified lines
302307 }
303308 if (!au->buf) {
304309 au->buf = ceph_buffer_new(maxlen, GFP_NOFS);
305− if (!au->buf)
310+ if (!au->buf) {
311+ ceph_crypto_key_destroy(&au->session_key);
306312 return -ENOMEM;
313+ }
307314 }
308315 au->service = th->service;
309316 au->secret_id = th->secret_id;
@@ -329,7 +336,7 @@ static int ceph_x_build_authorizer(struct ceph_auth_client *ac, · 19 unmodified lines
329336 get_random_bytes(&au->nonce, sizeof(au->nonce));
330337 msg_b.struct_v = 1;
331338 msg_b.nonce = cpu_to_le64(au->nonce);
332− ret = ceph_x_encrypt(&th->session_key, &msg_b, sizeof(msg_b),
339+ ret = ceph_x_encrypt(&au->session_key, &msg_b, sizeof(msg_b),
333340 p, end - p);
334341 if (ret < 0)
335342 goto out_buf;
@@ -588,17 +595,13 @@ static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac, · 252 unmodified lines
588595 struct ceph_authorizer *a, size_t len)
589596 {
590597 struct ceph_x_authorizer *au = (void *)a;
591− struct ceph_x_ticket_handler *th;
592598 int ret = 0;
593599 struct ceph_x_authorize_reply reply;
594600 void *preply = &reply;
595601 void *p = au->reply_buf;
596602 void *end = p + sizeof(au->reply_buf);
597603
598− th = get_ticket_handler(ac, au->service);
599− if (IS_ERR(th))
600− return PTR_ERR(th);
601− ret = ceph_x_decrypt(&th->session_key, &p, end, &preply, sizeof(reply));
604+ ret = ceph_x_decrypt(&au->session_key, &p, end, &preply, sizeof(reply));
602605 if (ret < 0)
603606 return ret;
604607 if (ret != sizeof(reply))
@@ -618,6 +621,7 @@ static void ceph_x_destroy_authorizer(struct ceph_auth_client *ac, · 13 unmodified lines
618621 {
619622 struct ceph_x_authorizer *au = (void *)a;
620623
624+ ceph_crypto_key_destroy(&au->session_key);
621625 ceph_buffer_put(au->buf);
622626 kfree(au);
623627 }
net/ceph/auth_x.h+1−0
@@ -26,6 +26,7 @@ struct ceph_x_ticket_handler { · 25 unmodified lines
2626
2727
2828 struct ceph_x_authorizer {
29+ struct ceph_crypto_key session_key;
2930 struct ceph_buffer *buf;
3031 unsigned int service;
3132 u64 nonce;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t