]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: move hexdump into a header
authorSage Weil <sage@newdream.net>
Fri, 25 Sep 2009 21:12:50 +0000 (14:12 -0700)
committerSage Weil <sage@newdream.net>
Fri, 25 Sep 2009 21:12:50 +0000 (14:12 -0700)
src/auth/Auth.cc
src/auth/AuthServiceManager.cc
src/auth/KeyRing.cc
src/auth/KeysServer.cc
src/common/debug.h

index 29d84eff66c1b257e29539f013524ed0e210b313..29c372388270fc2dd43dd03e88299cd61e8c37c8 100644 (file)
@@ -4,22 +4,6 @@
 
 #include "config.h"
 
-static void hexdump(string msg, const char *s, int len)
-{
-  int buf_len = len*4;
-  char buf[buf_len];
-  int pos = 0;
-  for (int i=0; i<len && pos<buf_len - 8; i++) {
-    if (i && !(i%8))
-      pos += snprintf(&buf[pos], buf_len-pos, " ");
-    if (i && !(i%16))
-      pos += snprintf(&buf[pos], buf_len-pos, "\n");
-    pos += snprintf(&buf[pos], buf_len-pos, "%.2x ", (int)(unsigned char)s[i]);
-  }
-  dout(0) << msg << ":\n" << buf << dendl;
-}
-
-
 
 
 /*
index c38a21e67af6922d1c9d27a7fa9f6f54d3e4c65d..1fe539b5ccdf816ca1214468969665551588041c 100644 (file)
 #define PRINCIPAL_CLIENT_SECRET "123456789ABCDEF0"
 #define PRINCIPAL_OSD_SECRET "3456789ABCDEF012"
 
-static inline void hexdump(string msg, const char *s, int len)
-{
-  int buf_len = len*4;
-  char buf[buf_len];
-  int pos = 0;
-  for (int i=0; i<len && pos<buf_len - 8; i++) {
-    if (i && !(i%8))
-      pos += snprintf(&buf[pos], buf_len-pos, " ");
-    if (i && !(i%16))
-      pos += snprintf(&buf[pos], buf_len-pos, "\n");
-    pos += snprintf(&buf[pos], buf_len-pos, "%.2x ", (int)(unsigned char)s[i]);
+
+class CephAuthServer {
+  /* FIXME: this is all temporary */
+  AuthTicket ticket;
+  CryptoKey client_secret;
+  CryptoKey auth_session_key;
+  CryptoKey service_secret;
+  
+public:
+  CephAuthServer() {
+    bufferptr ptr1(SERVICE_SECRET, sizeof(SERVICE_SECRET) - 1);
+    service_secret.set_secret(CEPH_SECRET_AES, ptr1);
+
+    bufferptr ptr2(PRINCIPAL_CLIENT_SECRET, sizeof(PRINCIPAL_CLIENT_SECRET) - 1);
+    client_secret.set_secret(CEPH_SECRET_AES, ptr2);
+
+    bufferptr ptr4(AUTH_SESSION_KEY, sizeof(AUTH_SESSION_KEY) - 1);
+    auth_session_key.set_secret(CEPH_SECRET_AES, ptr4);
+   }
+
+/* FIXME: temporary stabs */
+  int lookup_entity(const EntityName& name, CryptoKey& secret, map<string,bufferlist>& caps) {
+     secret = client_secret;
+     return 0;
   }
-  dout(0) << msg << ":\n" << buf << dendl;
-}
+
+  int get_service_secret(CryptoKey& secret, uint32_t service_id) {
+    char buf[16];
+    memcpy(buf, SERVICE_SECRET, 16);
+    buf[0] = service_id & 0xFF;
+    bufferptr ptr(buf, 16);
+    secret.set_secret(CEPH_SECRET_AES, ptr);
+
+    return 0;
+  }
+
+  int get_service_session_key(CryptoKey& secret, uint32_t service_id) {
+    char buf[16];
+    memcpy(buf, SERVICE_SECRET, 16);
+    buf[0] = service_id & 0xFF;
+    bufferptr ptr(buf, 16);
+    secret.set_secret(CEPH_SECRET_AES, ptr);
+
+    return 0;
+  }
+
+  int create_session_key(CryptoKey& key) {
+    return key.create(CEPH_SECRET_AES);
+  }
+
+};
+
+static CephAuthServer auth_server;
+
+
 
 /*
    the first X request is empty, we then send a response and get another request which
index aa40cf3ea3809e071a81feb6a64d7c7704b2a5ee..fba836157a1ac74fd43c4875f9139c9d13434a9c 100644 (file)
 
 using namespace std;
 
-static void hexdump(string msg, const char *s, int len)
-{
-  int buf_len = len*4;
-  char buf[buf_len];
-  int pos = 0;
-  for (int i=0; i<len && pos<buf_len - 8; i++) {
-    if (i && !(i%8))
-      pos += snprintf(&buf[pos], buf_len-pos, " ");
-    if (i && !(i%16))
-      pos += snprintf(&buf[pos], buf_len-pos, "\n");
-    pos += snprintf(&buf[pos], buf_len-pos, "%.2x ", (int)(unsigned char)s[i]);
-  }
-  dout(0) << msg << ":\n" << buf << dendl;
-}
-
 
 
 bool KeyRing::load_master(const char *filename)
index 6d7cba3be8d596a596d5ce6b6651dafee0121074..2b53f7143c061596174b87e8ade501894cc10105 100644 (file)
 
 #include <sstream>
 
-static void hexdump(string msg, const char *s, int len)
-{
-  int buf_len = len*4;
-  char buf[buf_len];
-  int pos = 0;
-  for (int i=0; i<len && pos<buf_len - 8; i++) {
-    if (i && !(i%8))
-      pos += snprintf(&buf[pos], buf_len-pos, " ");
-    if (i && !(i%16))
-      pos += snprintf(&buf[pos], buf_len-pos, "\n");
-    pos += snprintf(&buf[pos], buf_len-pos, "%.2x ", (int)(unsigned char)s[i]);
-  }
-  dout(0) << msg << ":\n" << buf << dendl;
-}
 
 void RotatingSecrets::add(ExpiringCryptoKey& key)
 {
index 121340e677407a8cf5fb09312f379616a68319d9..26d3c9f9100c0cfa1f073198e5e0ab205e8d1d24 100644 (file)
@@ -86,4 +86,21 @@ inline ostream& operator<<(ostream& out, _bad_endl_use_dendl_t) {
 #define dendl std::endl; _dout_end_line(); } } while (0)
 
 
+inline static void hexdump(string msg, const char *s, int len)
+{
+  int buf_len = len*4;
+  char buf[buf_len];
+  int pos = 0;
+  for (int i=0; i<len && pos<buf_len - 8; i++) {
+    if (i && !(i%8))
+      pos += snprintf(&buf[pos], buf_len-pos, " ");
+    if (i && !(i%16))
+      pos += snprintf(&buf[pos], buf_len-pos, "\n");
+    pos += snprintf(&buf[pos], buf_len-pos, "%.2x ", (int)(unsigned char)s[i]);
+  }
+  generic_dout(0) << msg << ":\n" << buf << dendl;
+}
+
+
+
 #endif