mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Renaming Base64Decoder to Base64Converter.
It nows encodes and decodes.
This commit is contained in:
parent
f412a00ada
commit
6865f0438a
6 changed files with 21 additions and 17 deletions
6
CHANGES
6
CHANGES
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
2.1-373 | 2013-03-17 12:58:39 -0700
|
2.1-375 | 2013-03-17 13:14:26 -0700
|
||||||
|
|
||||||
* Add base64 encoding functionality, including new BiFs
|
* Add base64 encoding functionality, including new BiFs
|
||||||
encode_base64() and encode_base64_custom(). (Bernhard Amann)
|
encode_base64() and encode_base64_custom(). (Bernhard Amann)
|
||||||
|
@ -7,6 +7,10 @@
|
||||||
* Replace call to external "openssl" in extract-certs-pem.bro with
|
* Replace call to external "openssl" in extract-certs-pem.bro with
|
||||||
that encode_base64(). (Bernhard Amann)
|
that encode_base64(). (Bernhard Amann)
|
||||||
|
|
||||||
|
* Adding a test for extract-certs-pem.pem. (Robin Sommer)
|
||||||
|
|
||||||
|
* Renaming Base64Decoder to Base64Converter. (Robin Sommer)
|
||||||
|
|
||||||
2.1-366 | 2013-03-17 12:35:59 -0700
|
2.1-366 | 2013-03-17 12:35:59 -0700
|
||||||
|
|
||||||
* Correctly handle DNS lookups for software version ranges. (Seth
|
* Correctly handle DNS lookups for software version ranges. (Seth
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.1-373
|
2.1-375
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#include "Base64.h"
|
#include "Base64.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
int Base64Decoder::default_base64_table[256];
|
int Base64Converter::default_base64_table[256];
|
||||||
const string Base64Decoder::default_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
const string Base64Converter::default_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
void Base64Decoder::Encode(int len, const unsigned char* data, int* pblen, char** pbuf)
|
void Base64Converter::Encode(int len, const unsigned char* data, int* pblen, char** pbuf)
|
||||||
{
|
{
|
||||||
int blen;
|
int blen;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -42,7 +42,7 @@ void Base64Decoder::Encode(int len, const unsigned char* data, int* pblen, char*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int* Base64Decoder::InitBase64Table(const string& alphabet)
|
int* Base64Converter::InitBase64Table(const string& alphabet)
|
||||||
{
|
{
|
||||||
assert(alphabet.size() == 64);
|
assert(alphabet.size() == 64);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ int* Base64Decoder::InitBase64Table(const string& alphabet)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Base64Decoder::Base64Decoder(Analyzer* arg_analyzer, const string& arg_alphabet)
|
Base64Converter::Base64Converter(Analyzer* arg_analyzer, const string& arg_alphabet)
|
||||||
{
|
{
|
||||||
if ( arg_alphabet.size() > 0 )
|
if ( arg_alphabet.size() > 0 )
|
||||||
{
|
{
|
||||||
|
@ -103,13 +103,13 @@ Base64Decoder::Base64Decoder(Analyzer* arg_analyzer, const string& arg_alphabet)
|
||||||
analyzer = arg_analyzer;
|
analyzer = arg_analyzer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Base64Decoder::~Base64Decoder()
|
Base64Converter::~Base64Converter()
|
||||||
{
|
{
|
||||||
if ( base64_table != default_base64_table )
|
if ( base64_table != default_base64_table )
|
||||||
delete base64_table;
|
delete base64_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Base64Decoder::Decode(int len, const char* data, int* pblen, char** pbuf)
|
int Base64Converter::Decode(int len, const char* data, int* pblen, char** pbuf)
|
||||||
{
|
{
|
||||||
int blen;
|
int blen;
|
||||||
char* buf;
|
char* buf;
|
||||||
|
@ -199,7 +199,7 @@ int Base64Decoder::Decode(int len, const char* data, int* pblen, char** pbuf)
|
||||||
return dlen;
|
return dlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Base64Decoder::Done(int* pblen, char** pbuf)
|
int Base64Converter::Done(int* pblen, char** pbuf)
|
||||||
{
|
{
|
||||||
const char* padding = "===";
|
const char* padding = "===";
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ BroString* decode_base64(const BroString* s, const BroString* a)
|
||||||
int rlen2, rlen = buf_len;
|
int rlen2, rlen = buf_len;
|
||||||
char* rbuf2, *rbuf = new char[rlen];
|
char* rbuf2, *rbuf = new char[rlen];
|
||||||
|
|
||||||
Base64Decoder dec(0, a ? a->CheckString() : "");
|
Base64Converter dec(0, a ? a->CheckString() : "");
|
||||||
if ( dec.Decode(s->Len(), (const char*) s->Bytes(), &rlen, &rbuf) == -1 )
|
if ( dec.Decode(s->Len(), (const char*) s->Bytes(), &rlen, &rbuf) == -1 )
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ BroString* encode_base64(const BroString* s, const BroString* a)
|
||||||
|
|
||||||
char* outbuf = 0;
|
char* outbuf = 0;
|
||||||
int outlen = 0;
|
int outlen = 0;
|
||||||
Base64Decoder enc(0, a ? a->CheckString() : "");
|
Base64Converter enc(0, a ? a->CheckString() : "");
|
||||||
enc.Encode(s->Len(), (const unsigned char*) s->Bytes(), &outlen, &outbuf);
|
enc.Encode(s->Len(), (const unsigned char*) s->Bytes(), &outlen, &outbuf);
|
||||||
|
|
||||||
return new BroString(1, (u_char*)outbuf, outlen);
|
return new BroString(1, (u_char*)outbuf, outlen);
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
#include "Analyzer.h"
|
#include "Analyzer.h"
|
||||||
|
|
||||||
// Maybe we should have a base class for generic decoders?
|
// Maybe we should have a base class for generic decoders?
|
||||||
class Base64Decoder {
|
class Base64Converter {
|
||||||
public:
|
public:
|
||||||
// <analyzer> is used for error reporting, and it should be zero when
|
// <analyzer> is used for error reporting, and it should be zero when
|
||||||
// the decoder is called by the built-in function decode_base64() or encode_base64().
|
// the decoder is called by the built-in function decode_base64() or encode_base64().
|
||||||
// Empty alphabet indicates the default base64 alphabet.
|
// Empty alphabet indicates the default base64 alphabet.
|
||||||
Base64Decoder(Analyzer* analyzer, const string& alphabet = "");
|
Base64Converter(Analyzer* analyzer, const string& alphabet = "");
|
||||||
~Base64Decoder();
|
~Base64Converter();
|
||||||
|
|
||||||
// A note on Decode():
|
// A note on Decode():
|
||||||
//
|
//
|
||||||
|
|
|
@ -810,7 +810,7 @@ void MIME_Entity::StartDecodeBase64()
|
||||||
if ( base64_decoder )
|
if ( base64_decoder )
|
||||||
reporter->InternalError("previous Base64 decoder not released!");
|
reporter->InternalError("previous Base64 decoder not released!");
|
||||||
|
|
||||||
base64_decoder = new Base64Decoder(message->GetAnalyzer());
|
base64_decoder = new Base64Converter(message->GetAnalyzer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MIME_Entity::FinishDecodeBase64()
|
void MIME_Entity::FinishDecodeBase64()
|
||||||
|
|
|
@ -163,7 +163,7 @@ protected:
|
||||||
MIME_Entity* parent;
|
MIME_Entity* parent;
|
||||||
MIME_Entity* current_child_entity;
|
MIME_Entity* current_child_entity;
|
||||||
|
|
||||||
Base64Decoder* base64_decoder;
|
Base64Converter* base64_decoder;
|
||||||
|
|
||||||
int data_buf_length;
|
int data_buf_length;
|
||||||
char* data_buf_data;
|
char* data_buf_data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue