From 631a004b22b6c3e5a1306592803e952ede664576 Mon Sep 17 00:00:00 2001 From: anwleung Date: Fri, 9 Mar 2007 18:23:49 +0000 Subject: [PATCH] Oops, forgot to check in reply message git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1188 29311d96-e01e-0410-9327-a35deaab8ce9 --- .../ceph/messages/MClientUpdateReply.h | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 branches/aleung/security1/ceph/messages/MClientUpdateReply.h diff --git a/branches/aleung/security1/ceph/messages/MClientUpdateReply.h b/branches/aleung/security1/ceph/messages/MClientUpdateReply.h new file mode 100644 index 0000000000000..b24f321c64d1e --- /dev/null +++ b/branches/aleung/security1/ceph/messages/MClientUpdateReply.h @@ -0,0 +1,73 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2006 Sage Weil + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef __MCLIENTUPDATEREPLY_H +#define __MCLIENTUPDATEREPLY_H + +#include "msg/Message.h" +#include "osd/osd_types.h" +#include "crypto/CryptoLib.h" +using namespace CryptoLib; +#include "crypto/MerkleTree.h" + +class MClientUpdateReply : public Message { + private: + hash_t user_hash; + byte signature[ESIGNSIGSIZE]; + list updated_users; + + public: + MClientUpdateReply() : Message(MSG_CLIENT_UPDATE_REPLY) { } + MClientUpdateReply(hash_t uhash, list ulist) : + Message(MSG_CLIENT_UPDATE_REPLY), + user_hash(uhash), updated_users(ulist) { } + + hash_t get_user_hash() { return user_hash; } + list& get_user_list() { return updated_users; } + + void set_sig(byte *sig) { memcpy(signature, sig, ESIGNSIGSIZE); } + byte *get_sig() { return signature; } + + void sign_list(esignPriv privKey) { + SigBuf sig; + sig = esignSig((byte*)&user_hash, sizeof(user_hash), privKey); + memcpy(signature, sig.data(), sig.size()); + } + + bool verify_list(esignPub pubKey) { + SigBuf sig; + sig.Assign(signature, sizeof(signature)); + return esignVer((byte*)&user_hash, sizeof(user_hash), sig, pubKey); + } + + virtual void encode_payload() { + payload.append((char*)&user_hash, sizeof(user_hash)); + payload.append((char*)signature, sizeof(signature)); + _encode(updated_users, payload); + } + virtual void decode_payload() { + int off = 0; + payload.copy(off, sizeof(user_hash), (char*)&user_hash); + off += sizeof(user_hash); + payload.copy(off, sizeof(signature), (char*)signature); + off += sizeof(signature); + _decode(updated_users, payload, off); + } + virtual char *get_type_name() { return "client_update_reply"; } + void print(ostream& out) { + out << "client_update_reply(" << user_hash + << ")"; + } +}; + +#endif -- 2.39.5