00001 #ifndef ENCRYPTION_WRAPPER_IMPLEMENTATION_FILE
00002 #define ENCRYPTION_WRAPPER_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef OMIT_CRYPTO_SUPPORT
00019
00020 #include "encryption_wrapper.h"
00021
00022 #include <basis/byte_array.h>
00023 #include <basis/log_base.h>
00024 #include <basis/mutex.h>
00025 #include <data_struct/static_memory_gremlin.h>
00026
00027 #undef LOG
00028 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger(), s)
00029
00030 encryption_wrapper::encryption_wrapper(const byte_array &wrapped)
00031 : infoton(encryption_classifier()),
00032 _wrapped(wrapped)
00033 {}
00034
00035 encryption_wrapper::encryption_wrapper(const encryption_wrapper &to_copy)
00036 : object_base(),
00037 infoton(to_copy),
00038 _wrapped(to_copy._wrapped)
00039 {}
00040
00041 encryption_wrapper::~encryption_wrapper() {}
00042
00043 clonable *encryption_wrapper::clone() const
00044 { return cloner<encryption_wrapper>(*this); }
00045
00046 encryption_wrapper &encryption_wrapper::operator =
00047 (const encryption_wrapper &to_copy)
00048 {
00049 if (this == &to_copy) return *this;
00050 _wrapped = to_copy._wrapped;
00051 return *this;
00052 }
00053
00054 const char *wrap_encryption_classifier[] = { "#octrap" };
00055
00056 SAFE_STATIC_CONST(string_array, encryption_wrapper::encryption_classifier,
00057 (1, wrap_encryption_classifier))
00058
00059 int encryption_wrapper::packed_size() const
00060 {
00061 return _wrapped.length() + sizeof(int);
00062 }
00063
00064 void encryption_wrapper::pack(byte_array &packed_form) const
00065 {
00066 basis::attach(packed_form, _wrapped);
00067 }
00068
00069 bool encryption_wrapper::unpack(byte_array &packed_form)
00070 {
00071 if (!basis::detach(packed_form, _wrapped)) return false;
00072 return true;
00073 }
00074
00076
00077 unwrapping_tentacle::unwrapping_tentacle()
00078 : tentacle_helper<encryption_wrapper>
00079 (encryption_wrapper::encryption_classifier(), false)
00080 {}
00081
00082 unwrapping_tentacle::~unwrapping_tentacle()
00083 {}
00084
00085 outcome unwrapping_tentacle::reconstitute(const string_array &classifier,
00086 byte_array &packed_form, infoton * &reformed)
00087 {
00088 if (classifier != encryption_wrapper::encryption_classifier())
00089 return NO_HANDLER;
00090
00091 return reconstituter(classifier, packed_form, reformed,
00092 (encryption_wrapper *)NIL);
00093 }
00094
00095 outcome unwrapping_tentacle::consume(infoton &formal(to_chow),
00096 const octopus_request_id &formal(item_id), byte_array &transformed)
00097 {
00098 FUNCDEF("consume");
00099 transformed.reset();
00100 LOG("should never enter this method.");
00101 return common::NOT_IMPLEMENTED;
00102 }
00103
00104 #endif // crypto support.
00105
00106
00107 #endif //ENCRYPTION_WRAPPER_IMPLEMENTATION_FILE
00108