first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / octopi / library / tentacles / encryption_wrapper.h
1 #ifndef ENCRYPTION_WRAPPER_CLASS
2 #define ENCRYPTION_WRAPPER_CLASS
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : encryption_wrapper                                                *
7 *  Author : Chris Koeritz                                                     *
8 *                                                                             *
9 *******************************************************************************
10 * Copyright (c) 2004-$now By Author.  This program is free software; you can  *
11 * redistribute it and/or modify it under the terms of the GNU General Public  *
12 * License as published by the Free Software Foundation; either version 2 of   *
13 * the License or (at your option) any later version.  This is online at:      *
14 *     http://www.fsf.org/copyleft/gpl.html                                    *
15 * Please send any updates to: fred@gruntose.com                               *
16 \*****************************************************************************/
17
18 #include <octopus/entity_defs.h>
19 #include <octopus/infoton.h>
20 #include <octopus/tentacle_helper.h>
21
22 namespace octopi {
23
24 //! Wraps an encrypted infoton when the octopus is in an encrypted mode.
25 /*!
26   The enclosed package will be unwrapped by the encryption tentacle.
27 */
28
29 class encryption_wrapper : public infoton
30 {
31 public:
32   basis::byte_array _wrapped;
33     //!< the encrypted data that's held here.
34     /*!< this must be a packed classifier string array followed by
35     the packed infoton. */
36
37   encryption_wrapper(const basis::byte_array &wrapped = basis::byte_array::empty_array());
38
39   encryption_wrapper(const encryption_wrapper &to_copy);
40
41   virtual ~encryption_wrapper();
42
43   DEFINE_CLASS_NAME("encryption_wrapper");
44
45   encryption_wrapper &operator =(const encryption_wrapper &to_copy);
46
47   void text_form(basis::base_string &fill) const {
48     fill.assign(basis::astring(class_name()));  // low exposure for vital held info.
49   }
50
51   static const structures::string_array &encryption_classifier();
52     //!< returns the classifier for this type of infoton.
53
54   virtual void pack(basis::byte_array &packed_form) const;
55   virtual bool unpack(basis::byte_array &packed_form);
56
57   virtual clonable *clone() const;
58
59   virtual int packed_size() const;
60 };
61
62 //////////////
63
64 //! this simple tentacle just unpacks the encryption_wrapper infoton.
65 /*!
66   this object should never be doing more than that.
67 */
68
69 class unwrapping_tentacle
70 : public tentacle_helper<encryption_wrapper>
71 {
72 public:
73   unwrapping_tentacle();
74   virtual ~unwrapping_tentacle();
75
76   DEFINE_CLASS_NAME("unwrapping_tentacle");
77
78   virtual basis::outcome reconstitute(const structures::string_array &classifier,
79           basis::byte_array &packed_form, infoton * &reformed);
80
81   virtual basis::outcome consume(infoton &to_chow, const octopus_request_id &item_id,
82           basis::byte_array &transformed);
83     //!< this should never be called.
84 };
85
86 } //namespace.
87
88 #endif  // outer guard.
89