Finish implementation of copy method.

All types (besides EntropyVal) now support a native copy operation,
which uses primitives of the underlying datatypes to perform a quick
copy, without serialization.

EntropyVal is the one exception - since that type is rather complex
(many members) and will probably not be copied a lot, if at all, it
makes sense to just use the serialization function.

This will have to be slightly re-written in the near-term-future to use
the new serialization function for that opaque type.

This change also introduces a new x509_from_der bif, which allows to
parse a der into an opaque of x509.

This change removes the d2i_X509_ wrapper function; this was a remnant
when d2i_X509 took non-const arguments. We directly use d2i_X509 at
several places assuming const-ness, so there does not seem to ba a
reason to keep the wrapper.

This change also exposed a problem in the File cache - cases in which an
object was brought back into the cache, and writing occurred in the
file_open event were never correctly handeled as far as I can tell.
This commit is contained in:
Johanna Amann 2019-05-22 11:36:52 -07:00
parent 2efbe76920
commit 74bb7716f6
22 changed files with 280 additions and 33 deletions

View file

@ -47,6 +47,8 @@ public:
MD5Val();
~MD5Val();
Val* DoClone(CloneState* state) override;
protected:
friend class Val;
@ -67,6 +69,8 @@ public:
SHA1Val();
~SHA1Val();
Val* DoClone(CloneState* state) override;
protected:
friend class Val;
@ -87,6 +91,8 @@ public:
SHA256Val();
~SHA256Val();
Val* DoClone(CloneState* state) override;
protected:
friend class Val;
@ -104,6 +110,8 @@ class EntropyVal : public OpaqueVal {
public:
EntropyVal();
Val* DoClone(CloneState* state) override;
bool Feed(const void* data, size_t size);
bool Get(double *r_ent, double *r_chisq, double *r_mean,
double *r_montepicalc, double *r_scc);
@ -122,6 +130,8 @@ public:
explicit BloomFilterVal(probabilistic::BloomFilter* bf);
~BloomFilterVal() override;
Val* DoClone(CloneState* state) override;
BroType* Type() const;
bool Typify(BroType* type);
@ -149,7 +159,7 @@ private:
BroType* type;
CompositeHash* hash;
probabilistic::BloomFilter* bloom_filter;
};
};
class CardinalityVal: public OpaqueVal {
@ -157,11 +167,14 @@ public:
explicit CardinalityVal(probabilistic::CardinalityCounter*);
~CardinalityVal() override;
Val* DoClone(CloneState* state) override;
void Add(const Val* val);
BroType* Type() const;
bool Typify(BroType* type);
probabilistic::CardinalityCounter* Get() { return c; };
protected: