aboutsummaryrefslogtreecommitdiffstats
path: root/src/asn1
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-03-30 18:27:18 +0000
committerlloyd <[email protected]>2009-03-30 18:27:18 +0000
commit96d6eb6f29c55e16a37cf11899547886f735b065 (patch)
tree9f13901e9b44c98d58b2589c9b09c6a7443eb7cd /src/asn1
parent3cc3dd72c5f87b76852a55c1f2d1821dba967d8c (diff)
Thomas Moschny passed along a request from the Fedora packagers which came
up during the Fedora submission review, that each source file include some text about the license. One handy Perl script later and each file now has the line Distributed under the terms of the Botan license after the copyright notices. While I was in there modifying every file anyway, I also stripped out the remainder of the block comments (lots of astericks before and after the text); this is stylistic thing I picked up when I was first learning C++ but in retrospect it is not a good style as the structure makes it harder to modify comments (with the result that comments become fewer, shorter and are less likely to be updated, which are not good things).
Diffstat (limited to 'src/asn1')
-rw-r--r--src/asn1/alg_id.cpp58
-rw-r--r--src/asn1/alg_id.h22
-rw-r--r--src/asn1/asn1_alt.cpp72
-rw-r--r--src/asn1/asn1_att.cpp34
-rw-r--r--src/asn1/asn1_dn.cpp112
-rw-r--r--src/asn1/asn1_int.cpp34
-rw-r--r--src/asn1/asn1_int.h46
-rw-r--r--src/asn1/asn1_obj.h54
-rw-r--r--src/asn1/asn1_oid.cpp70
-rw-r--r--src/asn1/asn1_oid.h10
-rw-r--r--src/asn1/asn1_str.cpp64
-rw-r--r--src/asn1/asn1_tm.cpp94
-rw-r--r--src/asn1/ber_dec.cpp190
-rw-r--r--src/asn1/ber_dec.h28
-rw-r--r--src/asn1/der_enc.cpp190
-rw-r--r--src/asn1/der_enc.h16
16 files changed, 563 insertions, 531 deletions
diff --git a/src/asn1/alg_id.cpp b/src/asn1/alg_id.cpp
index 5e5db73b3..94709ba16 100644
--- a/src/asn1/alg_id.cpp
+++ b/src/asn1/alg_id.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Algorithm Identifier Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Algorithm Identifier
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/alg_id.h>
#include <botan/der_enc.h>
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* Create an AlgorithmIdentifier *
-*************************************************/
+/*
+* Create an AlgorithmIdentifier
+*/
AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
const MemoryRegion<byte>& param)
{
@@ -20,9 +22,9 @@ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
parameters = param;
}
-/*************************************************
-* Create an AlgorithmIdentifier *
-*************************************************/
+/*
+* Create an AlgorithmIdentifier
+*/
AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
const MemoryRegion<byte>& param)
{
@@ -30,9 +32,9 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
parameters = param;
}
-/*************************************************
-* Create an AlgorithmIdentifier *
-*************************************************/
+/*
+* Create an AlgorithmIdentifier
+*/
AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
Encoding_Option option)
{
@@ -43,9 +45,9 @@ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
parameters.append(DER_NULL, sizeof(DER_NULL));
}
-/*************************************************
-* Create an AlgorithmIdentifier *
-*************************************************/
+/*
+* Create an AlgorithmIdentifier
+*/
AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
Encoding_Option option)
{
@@ -56,9 +58,9 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
parameters.append(DER_NULL, sizeof(DER_NULL));
}
-/*************************************************
-* Compare two AlgorithmIdentifiers *
-*************************************************/
+/*
+* Compare two AlgorithmIdentifiers
+*/
bool operator==(const AlgorithmIdentifier& a1, const AlgorithmIdentifier& a2)
{
if(a1.oid != a2.oid)
@@ -68,17 +70,17 @@ bool operator==(const AlgorithmIdentifier& a1, const AlgorithmIdentifier& a2)
return true;
}
-/*************************************************
-* Compare two AlgorithmIdentifiers *
-*************************************************/
+/*
+* Compare two AlgorithmIdentifiers
+*/
bool operator!=(const AlgorithmIdentifier& a1, const AlgorithmIdentifier& a2)
{
return !(a1 == a2);
}
-/*************************************************
-* DER encode an AlgorithmIdentifier *
-*************************************************/
+/*
+* DER encode an AlgorithmIdentifier
+*/
void AlgorithmIdentifier::encode_into(DER_Encoder& codec) const
{
codec.start_cons(SEQUENCE)
@@ -87,9 +89,9 @@ void AlgorithmIdentifier::encode_into(DER_Encoder& codec) const
.end_cons();
}
-/*************************************************
-* Decode a BER encoded AlgorithmIdentifier *
-*************************************************/
+/*
+* Decode a BER encoded AlgorithmIdentifier
+*/
void AlgorithmIdentifier::decode_from(BER_Decoder& codec)
{
codec.start_cons(SEQUENCE)
diff --git a/src/asn1/alg_id.h b/src/asn1/alg_id.h
index 8187fc070..4a1ad2f30 100644
--- a/src/asn1/alg_id.h
+++ b/src/asn1/alg_id.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Algorithm Identifier Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Algorithm Identifier
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_ALGORITHM_IDENTIFIER_H__
#define BOTAN_ALGORITHM_IDENTIFIER_H__
@@ -12,9 +14,9 @@
namespace Botan {
-/*************************************************
-* Algorithm Identifier *
-*************************************************/
+/*
+* Algorithm Identifier
+*/
class BOTAN_DLL AlgorithmIdentifier : public ASN1_Object
{
public:
@@ -34,9 +36,9 @@ class BOTAN_DLL AlgorithmIdentifier : public ASN1_Object
SecureVector<byte> parameters;
};
-/*************************************************
-* Comparison Operations *
-*************************************************/
+/*
+* Comparison Operations
+*/
bool BOTAN_DLL operator==(const AlgorithmIdentifier&,
const AlgorithmIdentifier&);
bool BOTAN_DLL operator!=(const AlgorithmIdentifier&,
diff --git a/src/asn1/asn1_alt.cpp b/src/asn1/asn1_alt.cpp
index 035f918cb..41974eef6 100644
--- a/src/asn1/asn1_alt.cpp
+++ b/src/asn1/asn1_alt.cpp
@@ -1,8 +1,10 @@
-/*************************************************
-* AlternativeName Source File *
-* (C) 1999-2007 Jack Lloyd *
-* 2007 Yves Jerschow *
-*************************************************/
+/*
+* AlternativeName
+* (C) 1999-2007 Jack Lloyd
+* 2007 Yves Jerschow
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/asn1_obj.h>
#include <botan/der_enc.h>
@@ -15,9 +17,9 @@
namespace Botan {
-/*************************************************
-* Create an AlternativeName *
-*************************************************/
+/*
+* Create an AlternativeName
+*/
AlternativeName::AlternativeName(const std::string& email_addr,
const std::string& uri,
const std::string& dns,
@@ -29,9 +31,9 @@ AlternativeName::AlternativeName(const std::string& email_addr,
add_attribute("IP", ip);
}
-/*************************************************
-* Add an attribute to an alternative name *
-*************************************************/
+/*
+* Add an attribute to an alternative name
+*/
void AlternativeName::add_attribute(const std::string& type,
const std::string& str)
{
@@ -47,9 +49,9 @@ void AlternativeName::add_attribute(const std::string& type,
multimap_insert(alt_info, type, str);
}
-/*************************************************
-* Add an OtherName field *
-*************************************************/
+/*
+* Add an OtherName field
+*/
void AlternativeName::add_othername(const OID& oid, const std::string& value,
ASN1_Tag type)
{
@@ -58,25 +60,25 @@ void AlternativeName::add_othername(const OID& oid, const std::string& value,
multimap_insert(othernames, oid, ASN1_String(value, type));
}
-/*************************************************
-* Get the attributes of this alternative name *
-*************************************************/
+/*
+* Get the attributes of this alternative name
+*/
std::multimap<std::string, std::string> AlternativeName::get_attributes() const
{
return alt_info;
}
-/*************************************************
-* Get the otherNames *
-*************************************************/
+/*
+* Get the otherNames
+*/
std::multimap<OID, ASN1_String> AlternativeName::get_othernames() const
{
return othernames;
}
-/*************************************************
-* Return all of the alternative names *
-*************************************************/
+/*
+* Return all of the alternative names
+*/
std::multimap<std::string, std::string> AlternativeName::contents() const
{
std::multimap<std::string, std::string> names;
@@ -92,9 +94,9 @@ std::multimap<std::string, std::string> AlternativeName::contents() const
return names;
}
-/*************************************************
-* Return if this object has anything useful *
-*************************************************/
+/*
+* Return if this object has anything useful
+*/
bool AlternativeName::has_items() const
{
return (alt_info.size() > 0 || othernames.size() > 0);
@@ -102,9 +104,9 @@ bool AlternativeName::has_items() const
namespace {
-/*************************************************
-* DER encode an AlternativeName entry *
-*************************************************/
+/*
+* DER encode an AlternativeName entry
+*/
void encode_entries(DER_Encoder& encoder,
const std::multimap<std::string, std::string>& attr,
const std::string& type, ASN1_Tag tagging)
@@ -131,9 +133,9 @@ void encode_entries(DER_Encoder& encoder,
}
-/*************************************************
-* DER encode an AlternativeName extension *
-*************************************************/
+/*
+* DER encode an AlternativeName extension
+*/
void AlternativeName::encode_into(DER_Encoder& der) const
{
der.start_cons(SEQUENCE);
@@ -157,9 +159,9 @@ void AlternativeName::encode_into(DER_Encoder& der) const
der.end_cons();
}
-/*************************************************
-* Decode a BER encoded AlternativeName *
-*************************************************/
+/*
+* Decode a BER encoded AlternativeName
+*/
void AlternativeName::decode_from(BER_Decoder& source)
{
BER_Decoder names = source.start_cons(SEQUENCE);
diff --git a/src/asn1/asn1_att.cpp b/src/asn1/asn1_att.cpp
index 7c16ff3a5..c8d771e25 100644
--- a/src/asn1/asn1_att.cpp
+++ b/src/asn1/asn1_att.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Attribute Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Attribute
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/asn1_obj.h>
#include <botan/der_enc.h>
@@ -10,18 +12,18 @@
namespace Botan {
-/*************************************************
-* Create an Attribute *
-*************************************************/
+/*
+* Create an Attribute
+*/
Attribute::Attribute(const OID& attr_oid, const MemoryRegion<byte>& attr_value)
{
oid = attr_oid;
parameters = attr_value;
}
-/*************************************************
-* Create an Attribute *
-*************************************************/
+/*
+* Create an Attribute
+*/
Attribute::Attribute(const std::string& attr_oid,
const MemoryRegion<byte>& attr_value)
{
@@ -29,9 +31,9 @@ Attribute::Attribute(const std::string& attr_oid,
parameters = attr_value;
}
-/*************************************************
-* DER encode a Attribute *
-*************************************************/
+/*
+* DER encode a Attribute
+*/
void Attribute::encode_into(DER_Encoder& codec) const
{
codec.start_cons(SEQUENCE)
@@ -42,9 +44,9 @@ void Attribute::encode_into(DER_Encoder& codec) const
.end_cons();
}
-/*************************************************
-* Decode a BER encoded Attribute *
-*************************************************/
+/*
+* Decode a BER encoded Attribute
+*/
void Attribute::decode_from(BER_Decoder& codec)
{
codec.start_cons(SEQUENCE)
diff --git a/src/asn1/asn1_dn.cpp b/src/asn1/asn1_dn.cpp
index 3fd0c09b0..c5a132d85 100644
--- a/src/asn1/asn1_dn.cpp
+++ b/src/asn1/asn1_dn.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* X509_DN Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* X509_DN
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/asn1_obj.h>
#include <botan/der_enc.h>
@@ -12,16 +14,16 @@
namespace Botan {
-/*************************************************
-* Create an empty X509_DN *
-*************************************************/
+/*
+* Create an empty X509_DN
+*/
X509_DN::X509_DN()
{
}
-/*************************************************
-* Create an X509_DN *
-*************************************************/
+/*
+* Create an X509_DN
+*/
X509_DN::X509_DN(const std::multimap<OID, std::string>& args)
{
std::multimap<OID, std::string>::const_iterator j;
@@ -29,9 +31,9 @@ X509_DN::X509_DN(const std::multimap<OID, std::string>& args)
add_attribute(j->first, j->second);
}
-/*************************************************
-* Create an X509_DN *
-*************************************************/
+/*
+* Create an X509_DN
+*/
X509_DN::X509_DN(const std::multimap<std::string, std::string>& args)
{
std::multimap<std::string, std::string>::const_iterator j;
@@ -39,9 +41,9 @@ X509_DN::X509_DN(const std::multimap<std::string, std::string>& args)
add_attribute(OIDS::lookup(j->first), j->second);
}
-/*************************************************
-* Add an attribute to a X509_DN *
-*************************************************/
+/*
+* Add an attribute to a X509_DN
+*/
void X509_DN::add_attribute(const std::string& type,
const std::string& str)
{
@@ -49,9 +51,9 @@ void X509_DN::add_attribute(const std::string& type,
add_attribute(oid, str);
}
-/*************************************************
-* Add an attribute to a X509_DN *
-*************************************************/
+/*
+* Add an attribute to a X509_DN
+*/
void X509_DN::add_attribute(const OID& oid, const std::string& str)
{
if(str == "")
@@ -68,9 +70,9 @@ void X509_DN::add_attribute(const OID& oid, const std::string& str)
dn_bits.destroy();
}
-/*************************************************
-* Get the attributes of this X509_DN *
-*************************************************/
+/*
+* Get the attributes of this X509_DN
+*/
std::multimap<OID, std::string> X509_DN::get_attributes() const
{
typedef std::multimap<OID, ASN1_String>::const_iterator rdn_iter;
@@ -81,9 +83,9 @@ std::multimap<OID, std::string> X509_DN::get_attributes() const
return retval;
}
-/*************************************************
-* Get the contents of this X.500 Name *
-*************************************************/
+/*
+* Get the contents of this X.500 Name
+*/
std::multimap<std::string, std::string> X509_DN::contents() const
{
typedef std::multimap<OID, ASN1_String>::const_iterator rdn_iter;
@@ -94,9 +96,9 @@ std::multimap<std::string, std::string> X509_DN::contents() const
return retval;
}
-/*************************************************
-* Get a single attribute type *
-*************************************************/
+/*
+* Get a single attribute type
+*/
std::vector<std::string> X509_DN::get_attribute(const std::string& attr) const
{
typedef std::multimap<OID, ASN1_String>::const_iterator rdn_iter;
@@ -110,9 +112,9 @@ std::vector<std::string> X509_DN::get_attribute(const std::string& attr) const
return values;
}
-/*************************************************
-* Handle the decoding operation of a DN *
-*************************************************/
+/*
+* Handle the decoding operation of a DN
+*/
void X509_DN::do_decode(const MemoryRegion<byte>& bits)
{
BER_Decoder sequence(bits);
@@ -139,17 +141,17 @@ void X509_DN::do_decode(const MemoryRegion<byte>& bits)
dn_bits = bits;
}
-/*************************************************
-* Return the BER encoded data, if any *
-*************************************************/
+/*
+* Return the BER encoded data, if any
+*/
MemoryVector<byte> X509_DN::get_bits() const
{
return dn_bits;
}
-/*************************************************
-* Deref aliases in a subject/issuer info request *
-*************************************************/
+/*
+* Deref aliases in a subject/issuer info request
+*/
std::string X509_DN::deref_info_field(const std::string& info)
{
if(info == "Name" || info == "CommonName") return "X520.CommonName";
@@ -164,9 +166,9 @@ std::string X509_DN::deref_info_field(const std::string& info)
return info;
}
-/*************************************************
-* Compare two X509_DNs for equality *
-*************************************************/
+/*
+* Compare two X509_DNs for equality
+*/
bool operator==(const X509_DN& dn1, const X509_DN& dn2)
{
typedef std::multimap<OID, std::string>::const_iterator rdn_iter;
@@ -194,17 +196,17 @@ bool operator==(const X509_DN& dn1, const X509_DN& dn2)
return true;
}
-/*************************************************
-* Compare two X509_DNs for inequality *
-*************************************************/
+/*
+* Compare two X509_DNs for inequality
+*/
bool operator!=(const X509_DN& dn1, const X509_DN& dn2)
{
return !(dn1 == dn2);
}
-/*************************************************
-* Compare two X509_DNs *
-*************************************************/
+/*
+* Compare two X509_DNs
+*/
bool operator<(const X509_DN& dn1, const X509_DN& dn2)
{
typedef std::multimap<OID, std::string>::const_iterator rdn_iter;
@@ -228,9 +230,9 @@ bool operator<(const X509_DN& dn1, const X509_DN& dn2)
namespace {
-/*************************************************
-* DER encode a RelativeDistinguishedName *
-*************************************************/
+/*
+* DER encode a RelativeDistinguishedName
+*/
void do_ava(DER_Encoder& encoder,
const std::multimap<OID, std::string>& dn_info,
ASN1_Tag string_type, const std::string& oid_str,
@@ -260,9 +262,9 @@ void do_ava(DER_Encoder& encoder,
}
-/*************************************************
-* DER encode a DistinguishedName *
-*************************************************/
+/*
+* DER encode a DistinguishedName
+*/
void X509_DN::encode_into(DER_Encoder& der) const
{
std::multimap<OID, std::string> dn_info = get_attributes();
@@ -285,9 +287,9 @@ void X509_DN::encode_into(DER_Encoder& der) const
der.end_cons();
}
-/*************************************************
-* Decode a BER encoded DistinguishedName *
-*************************************************/
+/*
+* Decode a BER encoded DistinguishedName
+*/
void X509_DN::decode_from(BER_Decoder& source)
{
dn_info.clear();
diff --git a/src/asn1/asn1_int.cpp b/src/asn1/asn1_int.cpp
index e837dedf0..5e18f3961 100644
--- a/src/asn1/asn1_int.cpp
+++ b/src/asn1/asn1_int.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* ASN.1 Internals Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* ASN.1 Internals
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/asn1_int.h>
#include <botan/der_enc.h>
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* BER Decoding Exceptions *
-*************************************************/
+/*
+* BER Decoding Exceptions
+*/
BER_Decoding_Error::BER_Decoding_Error(const std::string& str) :
Decoding_Error("BER: " + str) {}
@@ -26,9 +28,9 @@ BER_Bad_Tag::BER_Bad_Tag(const std::string& str,
namespace ASN1 {
-/*************************************************
-* Put some arbitrary bytes into a SEQUENCE *
-*************************************************/
+/*
+* Put some arbitrary bytes into a SEQUENCE
+*/
SecureVector<byte> put_in_sequence(const MemoryRegion<byte>& contents)
{
return DER_Encoder()
@@ -38,18 +40,18 @@ SecureVector<byte> put_in_sequence(const MemoryRegion<byte>& contents)
.get_contents();
}
-/*************************************************
-* Convert a BER object into a string object *
-*************************************************/
+/*
+* Convert a BER object into a string object
+*/
std::string to_string(const BER_Object& obj)
{
return std::string(reinterpret_cast<const char*>(obj.value.begin()),
obj.value.size());
}
-/*************************************************
-* Do heuristic tests for BER data *
-*************************************************/
+/*
+* Do heuristic tests for BER data
+*/
bool maybe_BER(DataSource& source)
{
byte first_byte;
diff --git a/src/asn1/asn1_int.h b/src/asn1/asn1_int.h
index 3e0562b9c..619f45b53 100644
--- a/src/asn1/asn1_int.h
+++ b/src/asn1/asn1_int.h
@@ -1,7 +1,9 @@
-/*************************************************
-* ASN.1 Internals Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* ASN.1 Internals
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_ASN1_H__
#define BOTAN_ASN1_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* ASN.1 Type and Class Tags *
-*************************************************/
+/*
+* ASN.1 Type and Class Tags
+*/
enum ASN1_Tag {
UNIVERSAL = 0x00,
APPLICATION = 0x40,
@@ -48,9 +50,9 @@ enum ASN1_Tag {
DIRECTORY_STRING = 0xFF01
};
-/*************************************************
-* Basic ASN.1 Object Interface *
-*************************************************/
+/*
+* Basic ASN.1 Object Interface
+*/
class BOTAN_DLL ASN1_Object
{
public:
@@ -59,9 +61,9 @@ class BOTAN_DLL ASN1_Object
virtual ~ASN1_Object() {}
};
-/*************************************************
-* BER Encoded Object *
-*************************************************/
+/*
+* BER Encoded Object
+*/
class BOTAN_DLL BER_Object
{
public:
@@ -71,9 +73,9 @@ class BOTAN_DLL BER_Object
SecureVector<byte> value;
};
-/*************************************************
-* ASN.1 Utility Functions *
-*************************************************/
+/*
+* ASN.1 Utility Functions
+*/
class DataSource;
namespace ASN1 {
@@ -84,17 +86,17 @@ bool maybe_BER(DataSource&);
}
-/*************************************************
-* General BER Decoding Error Exception *
-*************************************************/
+/*
+* General BER Decoding Error Exception
+*/
struct BER_Decoding_Error : public Decoding_Error
{
BER_Decoding_Error(const std::string&);
};
-/*************************************************
-* Exception For Incorrect BER Taggings *
-*************************************************/
+/*
+* Exception For Incorrect BER Taggings
+*/
struct BER_Bad_Tag : public BER_Decoding_Error
{
BER_Bad_Tag(const std::string&, ASN1_Tag);
diff --git a/src/asn1/asn1_obj.h b/src/asn1/asn1_obj.h
index 67645ca08..ea21c475f 100644
--- a/src/asn1/asn1_obj.h
+++ b/src/asn1/asn1_obj.h
@@ -1,8 +1,10 @@
-/*************************************************
-* Common ASN.1 Objects Header File *
-* (C) 1999-2007 Jack Lloyd *
-* 2007 Yves Jerschow *
-*************************************************/
+/*
+* Common ASN.1 Objects
+* (C) 1999-2007 Jack Lloyd
+* 2007 Yves Jerschow
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_ASN1_OBJ_H__
#define BOTAN_ASN1_OBJ_H__
@@ -15,9 +17,9 @@
namespace Botan {
-/*************************************************
-* Attribute *
-*************************************************/
+/*
+* Attribute
+*/
class BOTAN_DLL Attribute : public ASN1_Object
{
public:
@@ -32,9 +34,9 @@ class BOTAN_DLL Attribute : public ASN1_Object
Attribute(const std::string&, const MemoryRegion<byte>&);
};
-/*************************************************
-* X.509 Time *
-*************************************************/
+/*
+* X.509 Time
+*/
class BOTAN_DLL X509_Time : public ASN1_Object
{
public:
@@ -59,9 +61,9 @@ class BOTAN_DLL X509_Time : public ASN1_Object
ASN1_Tag tag;
};
-/*************************************************
-* Simple String *
-*************************************************/
+/*
+* Simple String
+*/
class BOTAN_DLL ASN1_String : public ASN1_Object
{
public:
@@ -80,9 +82,9 @@ class BOTAN_DLL ASN1_String : public ASN1_Object
ASN1_Tag tag;
};
-/*************************************************
-* Distinguished Name *
-*************************************************/
+/*
+* Distinguished Name
+*/
class BOTAN_DLL X509_DN : public ASN1_Object
{
public:
@@ -110,9 +112,9 @@ class BOTAN_DLL X509_DN : public ASN1_Object
MemoryVector<byte> dn_bits;
};
-/*************************************************
-* Alternative Name *
-*************************************************/
+/*
+* Alternative Name
+*/
class BOTAN_DLL AlternativeName : public ASN1_Object
{
public:
@@ -136,9 +138,9 @@ class BOTAN_DLL AlternativeName : public ASN1_Object
std::multimap<OID, ASN1_String> othernames;
};
-/*************************************************
-* Comparison Operations *
-*************************************************/
+/*
+* Comparison Operations
+*/
bool BOTAN_DLL operator==(const X509_Time&, const X509_Time&);
bool BOTAN_DLL operator!=(const X509_Time&, const X509_Time&);
bool BOTAN_DLL operator<=(const X509_Time&, const X509_Time&);
@@ -148,9 +150,9 @@ bool BOTAN_DLL operator==(const X509_DN&, const X509_DN&);
bool BOTAN_DLL operator!=(const X509_DN&, const X509_DN&);
bool BOTAN_DLL operator<(const X509_DN&, const X509_DN&);
-/*************************************************
-* Helper Functions *
-*************************************************/
+/*
+* Helper Functions
+*/
bool BOTAN_DLL is_string_type(ASN1_Tag);
}
diff --git a/src/asn1/asn1_oid.cpp b/src/asn1/asn1_oid.cpp
index 80968ed8f..531ceb9b2 100644
--- a/src/asn1/asn1_oid.cpp
+++ b/src/asn1/asn1_oid.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* ASN.1 OID Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* ASN.1 OID
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/asn1_oid.h>
#include <botan/der_enc.h>
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* ASN.1 OID Constructor *
-*************************************************/
+/*
+* ASN.1 OID Constructor
+*/
OID::OID(const std::string& oid_str)
{
if(oid_str != "")
@@ -26,17 +28,17 @@ OID::OID(const std::string& oid_str)
}
}
-/*************************************************
-* Clear the current OID *
-*************************************************/
+/*
+* Clear the current OID
+*/
void OID::clear()
{
id.clear();
}
-/*************************************************
-* Return this OID as a string *
-*************************************************/
+/*
+* Return this OID as a string
+*/
std::string OID::as_string() const
{
std::string oid_str;
@@ -49,9 +51,9 @@ std::string OID::as_string() const
return oid_str;
}
-/*************************************************
-* OID equality comparison *
-*************************************************/
+/*
+* OID equality comparison
+*/
bool OID::operator==(const OID& oid) const
{
if(id.size() != oid.id.size())
@@ -62,18 +64,18 @@ bool OID::operator==(const OID& oid) const
return true;
}
-/*************************************************
-* Append another component to the OID *
-*************************************************/
+/*
+* Append another component to the OID
+*/
OID& OID::operator+=(u32bit component)
{
id.push_back(component);
return (*this);
}
-/*************************************************
-* Append another component to the OID *
-*************************************************/
+/*
+* Append another component to the OID
+*/
OID operator+(const OID& oid, u32bit component)
{
OID new_oid(oid);
@@ -81,17 +83,17 @@ OID operator+(const OID& oid, u32bit component)
return new_oid;
}
-/*************************************************
-* OID inequality comparison *
-*************************************************/
+/*
+* OID inequality comparison
+*/
bool operator!=(const OID& a, const OID& b)
{
return !(a == b);
}
-/*************************************************
-* Compare two OIDs *
-*************************************************/
+/*
+* Compare two OIDs
+*/
bool operator<(const OID& a, const OID& b)
{
std::vector<u32bit> oid1 = a.get_id();
@@ -111,9 +113,9 @@ bool operator<(const OID& a, const OID& b)
return false;
}
-/*************************************************
-* DER encode an OBJECT IDENTIFIER *
-*************************************************/
+/*
+* DER encode an OBJECT IDENTIFIER
+*/
void OID::encode_into(DER_Encoder& der) const
{
if(id.size() < 2)
@@ -139,9 +141,9 @@ void OID::encode_into(DER_Encoder& der) const
der.add_object(OBJECT_ID, UNIVERSAL, encoding);
}
-/*************************************************
-* Decode a BER encoded OBJECT IDENTIFIER *
-*************************************************/
+/*
+* Decode a BER encoded OBJECT IDENTIFIER
+*/
void OID::decode_from(BER_Decoder& decoder)
{
BER_Object obj = decoder.get_next_object();
diff --git a/src/asn1/asn1_oid.h b/src/asn1/asn1_oid.h
index 3802c69b6..e6d077bee 100644
--- a/src/asn1/asn1_oid.h
+++ b/src/asn1/asn1_oid.h
@@ -1,7 +1,9 @@
-/*************************************************
-* ASN.1 OID Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* ASN.1 OID
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_ASN1_OID_H__
#define BOTAN_ASN1_OID_H__
diff --git a/src/asn1/asn1_str.cpp b/src/asn1/asn1_str.cpp
index bca1bf3c3..25782e239 100644
--- a/src/asn1/asn1_str.cpp
+++ b/src/asn1/asn1_str.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Simple ASN.1 String Types Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Simple ASN.1 String Types
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/asn1_obj.h>
#include <botan/der_enc.h>
@@ -13,9 +15,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Choose an encoding for the string *
-*************************************************/
+/*
+* Choose an encoding for the string
+*/
ASN1_Tag choose_encoding(const std::string& str,
const std::string& type)
{
@@ -57,9 +59,9 @@ ASN1_Tag choose_encoding(const std::string& str,
}
-/*************************************************
-* Check if type is a known ASN.1 string type *
-*************************************************/
+/*
+* Check if type is a known ASN.1 string type
+*/
bool is_string_type(ASN1_Tag tag)
{
if(tag == NUMERIC_STRING || tag == PRINTABLE_STRING ||
@@ -69,9 +71,9 @@ bool is_string_type(ASN1_Tag tag)
return false;
}
-/*************************************************
-* Create an ASN1_String *
-*************************************************/
+/*
+* Create an ASN1_String
+*/
ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : tag(t)
{
iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
@@ -90,42 +92,42 @@ ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : tag(t)
to_string(tag));
}
-/*************************************************
-* Create an ASN1_String *
-*************************************************/
+/*
+* Create an ASN1_String
+*/
ASN1_String::ASN1_String(const std::string& str)
{
iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
tag = choose_encoding(iso_8859_str, "latin1");
}
-/*************************************************
-* Return this string in ISO 8859-1 encoding *
-*************************************************/
+/*
+* Return this string in ISO 8859-1 encoding
+*/
std::string ASN1_String::iso_8859() const
{
return iso_8859_str;
}
-/*************************************************
-* Return this string in local encoding *
-*************************************************/
+/*
+* Return this string in local encoding
+*/
std::string ASN1_String::value() const
{
return Charset::transcode(iso_8859_str, LATIN1_CHARSET, LOCAL_CHARSET);
}
-/*************************************************
-* Return the type of this string object *
-*************************************************/
+/*
+* Return the type of this string object
+*/
ASN1_Tag ASN1_String::tagging() const
{
return tag;
}
-/*************************************************
-* DER encode an ASN1_String *
-*************************************************/
+/*
+* DER encode an ASN1_String
+*/
void ASN1_String::encode_into(DER_Encoder& encoder) const
{
std::string value = iso_8859();
@@ -134,9 +136,9 @@ void ASN1_String::encode_into(DER_Encoder& encoder) const
encoder.add_object(tagging(), UNIVERSAL, value);
}
-/*************************************************
-* Decode a BER encoded ASN1_String *
-*************************************************/
+/*
+* Decode a BER encoded ASN1_String
+*/
void ASN1_String::decode_from(BER_Decoder& source)
{
BER_Object obj = source.get_next_object();
diff --git a/src/asn1/asn1_tm.cpp b/src/asn1/asn1_tm.cpp
index 7cd051af7..f85ea128b 100644
--- a/src/asn1/asn1_tm.cpp
+++ b/src/asn1/asn1_tm.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* X.509 Time Types Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* X.509 Time Types
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/asn1_obj.h>
#include <botan/der_enc.h>
@@ -14,9 +16,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Convert a time_t to a struct tm *
-*************************************************/
+/*
+* Convert a time_t to a struct tm
+*/
std::tm get_tm(u64bit timer)
{
std::time_t time_val = static_cast<std::time_t>(timer);
@@ -30,17 +32,17 @@ std::tm get_tm(u64bit timer)
}
-/*************************************************
-* Create an X509_Time *
-*************************************************/
+/*
+* Create an X509_Time
+*/
X509_Time::X509_Time(const std::string& time_str)
{
set_to(time_str);
}
-/*************************************************
-* Create an X509_Time *
-*************************************************/
+/*
+* Create an X509_Time
+*/
X509_Time::X509_Time(u64bit timer)
{
std::tm time_info = get_tm(timer);
@@ -58,17 +60,17 @@ X509_Time::X509_Time(u64bit timer)
tag = UTC_TIME;
}
-/*************************************************
-* Create an X509_Time *
-*************************************************/
+/*
+* Create an X509_Time
+*/
X509_Time::X509_Time(const std::string& t_spec, ASN1_Tag t) : tag(t)
{
set_to(t_spec, tag);
}
-/*************************************************
-* Set the time with a human readable string *
-*************************************************/
+/*
+* Set the time with a human readable string
+*/
void X509_Time::set_to(const std::string& time_str)
{
if(time_str == "")
@@ -113,9 +115,9 @@ void X509_Time::set_to(const std::string& time_str)
throw Invalid_Argument("Invalid time specification " + time_str);
}
-/*************************************************
-* Set the time with an ISO time format string *
-*************************************************/
+/*
+* Set the time with an ISO time format string
+*/
void X509_Time::set_to(const std::string& t_spec, ASN1_Tag tag)
{
if(tag != GENERALIZED_TIME && tag != UTC_TIME)
@@ -164,9 +166,9 @@ void X509_Time::set_to(const std::string& t_spec, ASN1_Tag tag)
throw Invalid_Argument("Invalid time specification " + t_spec);
}
-/*************************************************
-* DER encode a X509_Time *
-*************************************************/
+/*
+* DER encode a X509_Time
+*/
void X509_Time::encode_into(DER_Encoder& der) const
{
if(tag != GENERALIZED_TIME && tag != UTC_TIME)
@@ -176,9 +178,9 @@ void X509_Time::encode_into(DER_Encoder& der) const
LOCAL_CHARSET, LATIN1_CHARSET));
}
-/*************************************************
-* Decode a BER encoded X509_Time *
-*************************************************/
+/*
+* Decode a BER encoded X509_Time
+*/
void X509_Time::decode_from(BER_Decoder& source)
{
BER_Object ber_time = source.get_next_object();
@@ -187,9 +189,9 @@ void X509_Time::decode_from(BER_Decoder& source)
ber_time.type_tag);
}
-/*************************************************
-* Return a string representation of the time *
-*************************************************/
+/*
+* Return a string representation of the time
+*/
std::string X509_Time::as_string() const
{
if(time_is_set() == false)
@@ -212,17 +214,17 @@ std::string X509_Time::as_string() const
return asn1rep;
}
-/*************************************************
-* Return if the time has been set somehow *
-*************************************************/
+/*
+* Return if the time has been set somehow
+*/
bool X509_Time::time_is_set() const
{
return (year != 0);
}
-/*************************************************
-* Return a human readable string representation *
-*************************************************/
+/*
+* Return a human readable string representation
+*/
std::string X509_Time::readable_string() const
{
if(time_is_set() == false)
@@ -238,9 +240,9 @@ std::string X509_Time::readable_string() const
return readable;
}
-/*************************************************
-* Do a general sanity check on the time *
-*************************************************/
+/*
+* Do a general sanity check on the time
+*/
bool X509_Time::passes_sanity_check() const
{
if(year < 1950 || year > 2100)
@@ -254,9 +256,9 @@ bool X509_Time::passes_sanity_check() const
return true;
}
-/*************************************************
-* Compare this time against another *
-*************************************************/
+/*
+* Compare this time against another
+*/
s32bit X509_Time::cmp(const X509_Time& other) const
{
if(time_is_set() == false)
@@ -280,9 +282,9 @@ s32bit X509_Time::cmp(const X509_Time& other) const
return SAME_TIME;
}
-/*************************************************
-* Compare two X509_Times for in various ways *
-*************************************************/
+/*
+* Compare two X509_Times for in various ways
+*/
bool operator==(const X509_Time& t1, const X509_Time& t2)
{ return (t1.cmp(t2) == 0); }
bool operator!=(const X509_Time& t1, const X509_Time& t2)
diff --git a/src/asn1/ber_dec.cpp b/src/asn1/ber_dec.cpp
index c725a5af9..ce6046652 100644
--- a/src/asn1/ber_dec.cpp
+++ b/src/asn1/ber_dec.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* BER Decoder Source File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* BER Decoder
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/ber_dec.h>
#include <botan/bigint.h>
@@ -11,9 +13,9 @@ namespace Botan {
namespace {
-/*************************************************
-* BER decode an ASN.1 type tag *
-*************************************************/
+/*
+* BER decode an ASN.1 type tag
+*/
u32bit decode_tag(DataSource* ber, ASN1_Tag& type_tag, ASN1_Tag& class_tag)
{
byte b;
@@ -48,14 +50,14 @@ u32bit decode_tag(DataSource* ber, ASN1_Tag& type_tag, ASN1_Tag& class_tag)
return tag_bytes;
}
-/*************************************************
-* Find the EOC marker *
-*************************************************/
+/*
+* Find the EOC marker
+*/
u32bit find_eoc(DataSource*);
-/*************************************************
-* BER decode an ASN.1 length field *
-*************************************************/
+/*
+* BER decode an ASN.1 length field
+*/
u32bit decode_length(DataSource* ber, u32bit& field_size)
{
byte b;
@@ -83,18 +85,18 @@ u32bit decode_length(DataSource* ber, u32bit& field_size)
return length;
}
-/*************************************************
-* BER decode an ASN.1 length field *
-*************************************************/
+/*
+* BER decode an ASN.1 length field
+*/
u32bit decode_length(DataSource* ber)
{
u32bit dummy;
return decode_length(ber, dummy);
}
-/*************************************************
-* Find the EOC marker *
-*************************************************/
+/*
+* Find the EOC marker
+*/
u32bit find_eoc(DataSource* ber)
{
SecureVector<byte> buffer(DEFAULT_BUFFERSIZE), data;
@@ -132,18 +134,18 @@ u32bit find_eoc(DataSource* ber)
}
-/*************************************************
-* Check a type invariant on BER data *
-*************************************************/
+/*
+* Check a type invariant on BER data
+*/
void BER_Object::assert_is_a(ASN1_Tag type_tag, ASN1_Tag class_tag)
{
if(this->type_tag != type_tag || this->class_tag != class_tag)
throw BER_Decoding_Error("Tag mismatch when decoding");
}
-/*************************************************
-* Check if more objects are there *
-*************************************************/
+/*
+* Check if more objects are there
+*/
bool BER_Decoder::more_items() const
{
if(source->end_of_data() && (pushed.type_tag == NO_OBJECT))
@@ -151,9 +153,9 @@ bool BER_Decoder::more_items() const
return true;
}
-/*************************************************
-* Verify that no bytes remain in the source *
-*************************************************/
+/*
+* Verify that no bytes remain in the source
+*/
BER_Decoder& BER_Decoder::verify_end()
{
if(!source->end_of_data() || (pushed.type_tag != NO_OBJECT))
@@ -161,9 +163,9 @@ BER_Decoder& BER_Decoder::verify_end()
return (*this);
}
-/*************************************************
-* Save all the bytes remaining in the source *
-*************************************************/
+/*
+* Save all the bytes remaining in the source
+*/
BER_Decoder& BER_Decoder::raw_bytes(MemoryRegion<byte>& out)
{
out.destroy();
@@ -173,9 +175,9 @@ BER_Decoder& BER_Decoder::raw_bytes(MemoryRegion<byte>& out)
return (*this);
}
-/*************************************************
-* Discard all the bytes remaining in the source *
-*************************************************/
+/*
+* Discard all the bytes remaining in the source
+*/
BER_Decoder& BER_Decoder::discard_remaining()
{
byte buf;
@@ -184,9 +186,9 @@ BER_Decoder& BER_Decoder::discard_remaining()
return (*this);
}
-/*************************************************
-* Return the BER encoding of the next object *
-*************************************************/
+/*
+* Return the BER encoding of the next object
+*/
BER_Object BER_Decoder::get_next_object()
{
BER_Object next;
@@ -213,9 +215,9 @@ BER_Object BER_Decoder::get_next_object()
return next;
}
-/*************************************************
-* Push a object back into the stream *
-*************************************************/
+/*
+* Push a object back into the stream
+*/
void BER_Decoder::push_back(const BER_Object& obj)
{
if(pushed.type_tag != NO_OBJECT)
@@ -223,9 +225,9 @@ void BER_Decoder::push_back(const BER_Object& obj)
pushed = obj;
}
-/*************************************************
-* Begin decoding a CONSTRUCTED type *
-*************************************************/
+/*
+* Begin decoding a CONSTRUCTED type
+*/
BER_Decoder BER_Decoder::start_cons(ASN1_Tag type_tag,
ASN1_Tag class_tag)
{
@@ -237,9 +239,9 @@ BER_Decoder BER_Decoder::start_cons(ASN1_Tag type_tag,
return result;
}
-/*************************************************
-* Finish decoding a CONSTRUCTED type *
-*************************************************/
+/*
+* Finish decoding a CONSTRUCTED type
+*/
BER_Decoder& BER_Decoder::end_cons()
{
if(!parent)
@@ -249,9 +251,9 @@ BER_Decoder& BER_Decoder::end_cons()
return (*parent);
}
-/*************************************************
-* BER_Decoder Constructor *
-*************************************************/
+/*
+* BER_Decoder Constructor
+*/
BER_Decoder::BER_Decoder(DataSource& src)
{
source = &src;
@@ -260,9 +262,9 @@ BER_Decoder::BER_Decoder(DataSource& src)
parent = 0;
}
-/*************************************************
-* BER_Decoder Constructor *
- *************************************************/
+/*
+* BER_Decoder Constructor
+ */
BER_Decoder::BER_Decoder(const byte data[], u32bit length)
{
source = new DataSource_Memory(data, length);
@@ -271,9 +273,9 @@ BER_Decoder::BER_Decoder(const byte data[], u32bit length)
parent = 0;
}
-/*************************************************
-* BER_Decoder Constructor *
-*************************************************/
+/*
+* BER_Decoder Constructor
+*/
BER_Decoder::BER_Decoder(const MemoryRegion<byte>& data)
{
source = new DataSource_Memory(data);
@@ -282,9 +284,9 @@ BER_Decoder::BER_Decoder(const MemoryRegion<byte>& data)
parent = 0;
}
-/*************************************************
-* BER_Decoder Copy Constructor *
-*************************************************/
+/*
+* BER_Decoder Copy Constructor
+*/
BER_Decoder::BER_Decoder(const BER_Decoder& other)
{
source = other.source;
@@ -298,9 +300,9 @@ BER_Decoder::BER_Decoder(const BER_Decoder& other)
parent = other.parent;
}
-/*************************************************
-* BER_Decoder Destructor *
-*************************************************/
+/*
+* BER_Decoder Destructor
+*/
BER_Decoder::~BER_Decoder()
{
if(owns)
@@ -308,18 +310,18 @@ BER_Decoder::~BER_Decoder()
source = 0;
}
-/*************************************************
-* Request for an object to decode itself *
-*************************************************/
+/*
+* Request for an object to decode itself
+*/
BER_Decoder& BER_Decoder::decode(ASN1_Object& obj)
{
obj.decode_from(*this);
return (*this);
}
-/*************************************************
-* Decode a BER encoded NULL *
-*************************************************/
+/*
+* Decode a BER encoded NULL
+*/
BER_Decoder& BER_Decoder::decode_null()
{
BER_Object obj = get_next_object();
@@ -329,33 +331,33 @@ BER_Decoder& BER_Decoder::decode_null()
return (*this);
}
-/*************************************************
-* Decode a BER encoded BOOLEAN *
-*************************************************/
+/*
+* Decode a BER encoded BOOLEAN
+*/
BER_Decoder& BER_Decoder::decode(bool& out)
{
return decode(out, BOOLEAN, UNIVERSAL);
}
-/*************************************************
-* Decode a small BER encoded INTEGER *
-*************************************************/
+/*
+* Decode a small BER encoded INTEGER
+*/
BER_Decoder& BER_Decoder::decode(u32bit& out)
{
return decode(out, INTEGER, UNIVERSAL);
}
-/*************************************************
-* Decode a BER encoded INTEGER *
-*************************************************/
+/*
+* Decode a BER encoded INTEGER
+*/
BER_Decoder& BER_Decoder::decode(BigInt& out)
{
return decode(out, INTEGER, UNIVERSAL);
}
-/*************************************************
-* Decode a BER encoded BOOLEAN *
-*************************************************/
+/*
+* Decode a BER encoded BOOLEAN
+*/
BER_Decoder& BER_Decoder::decode(bool& out,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -369,9 +371,9 @@ BER_Decoder& BER_Decoder::decode(bool& out,
return (*this);
}
-/*************************************************
-* Decode a small BER encoded INTEGER *
-*************************************************/
+/*
+* Decode a small BER encoded INTEGER
+*/
BER_Decoder& BER_Decoder::decode(u32bit& out,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -381,9 +383,9 @@ BER_Decoder& BER_Decoder::decode(u32bit& out,
return (*this);
}
-/*************************************************
-* Decode a BER encoded INTEGER *
-*************************************************/
+/*
+* Decode a BER encoded INTEGER
+*/
BER_Decoder& BER_Decoder::decode(BigInt& out,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -414,17 +416,17 @@ BER_Decoder& BER_Decoder::decode(BigInt& out,
return (*this);
}
-/*************************************************
-* BER decode a BIT STRING or OCTET STRING *
-*************************************************/
+/*
+* BER decode a BIT STRING or OCTET STRING
+*/
BER_Decoder& BER_Decoder::decode(MemoryRegion<byte>& out, ASN1_Tag real_type)
{
return decode(out, real_type, real_type, UNIVERSAL);
}
-/*************************************************
-* BER decode a BIT STRING or OCTET STRING *
-*************************************************/
+/*
+* BER decode a BIT STRING or OCTET STRING
+*/
BER_Decoder& BER_Decoder::decode(MemoryRegion<byte>& buffer,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
@@ -446,9 +448,9 @@ BER_Decoder& BER_Decoder::decode(MemoryRegion<byte>& buffer,
return (*this);
}
-/*************************************************
-* Decode an OPTIONAL string type *
-*************************************************/
+/*
+* Decode an OPTIONAL string type
+*/
BER_Decoder& BER_Decoder::decode_optional_string(MemoryRegion<byte>& out,
ASN1_Tag real_type,
u16bit type_no)
diff --git a/src/asn1/ber_dec.h b/src/asn1/ber_dec.h
index 1888953d1..2e38af301 100644
--- a/src/asn1/ber_dec.h
+++ b/src/asn1/ber_dec.h
@@ -1,7 +1,9 @@
-/*************************************************
-* BER Decoder Header File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* BER Decoder
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_BER_DECODER_H__
#define BOTAN_BER_DECODER_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* BER Decoding Object *
-*************************************************/
+/*
+* BER Decoding Object
+*/
class BOTAN_DLL BER_Decoder
{
public:
@@ -67,9 +69,9 @@ class BOTAN_DLL BER_Decoder
mutable bool owns;
};
-/*************************************************
-* Decode an OPTIONAL or DEFAULT element *
-*************************************************/
+/*
+* Decode an OPTIONAL or DEFAULT element
+*/
template<typename T>
BER_Decoder& BER_Decoder::decode_optional(T& out,
ASN1_Tag type_tag,
@@ -97,9 +99,9 @@ BER_Decoder& BER_Decoder::decode_optional(T& out,
return (*this);
}
-/*************************************************
-* Decode a list of homogenously typed values *
-*************************************************/
+/*
+* Decode a list of homogenously typed values
+*/
template<typename T>
BER_Decoder& BER_Decoder::decode_list(std::vector<T>& vec, bool clear_it)
{
diff --git a/src/asn1/der_enc.cpp b/src/asn1/der_enc.cpp
index 1ab5ddd4e..bee269431 100644
--- a/src/asn1/der_enc.cpp
+++ b/src/asn1/der_enc.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* DER Encoder Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* DER Encoder
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/der_enc.h>
#include <botan/asn1_int.h>
@@ -15,9 +17,9 @@ namespace Botan {
namespace {
-/*************************************************
-* DER encode an ASN.1 type tag *
-*************************************************/
+/*
+* DER encode an ASN.1 type tag
+*/
SecureVector<byte> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag)
{
if((class_tag | 0xE0) != 0xE0)
@@ -41,9 +43,9 @@ SecureVector<byte> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag)
return encoded_tag;
}
-/*************************************************
-* DER encode an ASN.1 length field *
-*************************************************/
+/*
+* DER encode an ASN.1 length field
+*/
SecureVector<byte> encode_length(u32bit length)
{
SecureVector<byte> encoded_length;
@@ -61,9 +63,9 @@ SecureVector<byte> encode_length(u32bit length)
}
-/*************************************************
-* Return the encoded SEQUENCE/SET *
-*************************************************/
+/*
+* Return the encoded SEQUENCE/SET
+*/
SecureVector<byte> DER_Encoder::DER_Sequence::get_contents()
{
const ASN1_Tag real_class_tag = ASN1_Tag(class_tag | CONSTRUCTED);
@@ -88,9 +90,9 @@ SecureVector<byte> DER_Encoder::DER_Sequence::get_contents()
return retval;
}
-/*************************************************
-* Add an encoded value to the SEQUENCE/SET *
-*************************************************/
+/*
+* Add an encoded value to the SEQUENCE/SET
+*/
void DER_Encoder::DER_Sequence::add_bytes(const byte data[], u32bit length)
{
if(type_tag == SET)
@@ -99,25 +101,25 @@ void DER_Encoder::DER_Sequence::add_bytes(const byte data[], u32bit length)
contents.append(data, length);
}
-/*************************************************
-* Return the type and class taggings *
-*************************************************/
+/*
+* Return the type and class taggings
+*/
ASN1_Tag DER_Encoder::DER_Sequence::tag_of() const
{
return ASN1_Tag(type_tag | class_tag);
}
-/*************************************************
-* DER_Sequence Constructor *
-*************************************************/
+/*
+* DER_Sequence Constructor
+*/
DER_Encoder::DER_Sequence::DER_Sequence(ASN1_Tag t1, ASN1_Tag t2) :
type_tag(t1), class_tag(t2)
{
}
-/*************************************************
-* Return the encoded contents *
-*************************************************/
+/*
+* Return the encoded contents
+*/
SecureVector<byte> DER_Encoder::get_contents()
{
if(subsequences.size() != 0)
@@ -129,9 +131,9 @@ SecureVector<byte> DER_Encoder::get_contents()
return retval;
}
-/*************************************************
-* Start a new ASN.1 SEQUENCE/SET/EXPLICIT *
-*************************************************/
+/*
+* Start a new ASN.1 SEQUENCE/SET/EXPLICIT
+*/
DER_Encoder& DER_Encoder::start_cons(ASN1_Tag type_tag,
ASN1_Tag class_tag)
{
@@ -139,9 +141,9 @@ DER_Encoder& DER_Encoder::start_cons(ASN1_Tag type_tag,
return (*this);
}
-/*************************************************
-* Finish the current ASN.1 SEQUENCE/SET/EXPLICIT *
-*************************************************/
+/*
+* Finish the current ASN.1 SEQUENCE/SET/EXPLICIT
+*/
DER_Encoder& DER_Encoder::end_cons()
{
if(subsequences.empty())
@@ -153,9 +155,9 @@ DER_Encoder& DER_Encoder::end_cons()
return (*this);
}
-/*************************************************
-* Start a new ASN.1 EXPLICIT encoding *
-*************************************************/
+/*
+* Start a new ASN.1 EXPLICIT encoding
+*/
DER_Encoder& DER_Encoder::start_explicit(u16bit type_no)
{
ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
@@ -166,25 +168,25 @@ DER_Encoder& DER_Encoder::start_explicit(u16bit type_no)
return start_cons(type_tag, CONTEXT_SPECIFIC);
}
-/*************************************************
-* Finish the current ASN.1 EXPLICIT encoding *
-*************************************************/
+/*
+* Finish the current ASN.1 EXPLICIT encoding
+*/
DER_Encoder& DER_Encoder::end_explicit()
{
return end_cons();
}
-/*************************************************
-* Write raw bytes into the stream *
-*************************************************/
+/*
+* Write raw bytes into the stream
+*/
DER_Encoder& DER_Encoder::raw_bytes(const MemoryRegion<byte>& val)
{
return raw_bytes(val.begin(), val.size());
}
-/*************************************************
-* Write raw bytes into the stream *
-*************************************************/
+/*
+* Write raw bytes into the stream
+*/
DER_Encoder& DER_Encoder::raw_bytes(const byte bytes[], u32bit length)
{
if(subsequences.size())
@@ -195,41 +197,41 @@ DER_Encoder& DER_Encoder::raw_bytes(const byte bytes[], u32bit length)
return (*this);
}
-/*************************************************
-* Encode a NULL object *
-*************************************************/
+/*
+* Encode a NULL object
+*/
DER_Encoder& DER_Encoder::encode_null()
{
return add_object(NULL_TAG, UNIVERSAL, 0, 0);
}
-/*************************************************
-* DER encode a BOOLEAN *
-*************************************************/
+/*
+* DER encode a BOOLEAN
+*/
DER_Encoder& DER_Encoder::encode(bool is_true)
{
return encode(is_true, BOOLEAN, UNIVERSAL);
}
-/*************************************************
-* DER encode a small INTEGER *
-*************************************************/
+/*
+* DER encode a small INTEGER
+*/
DER_Encoder& DER_Encoder::encode(u32bit n)
{
return encode(BigInt(n), INTEGER, UNIVERSAL);
}
-/*************************************************
-* DER encode a small INTEGER *
-*************************************************/
+/*
+* DER encode a small INTEGER
+*/
DER_Encoder& DER_Encoder::encode(const BigInt& n)
{
return encode(n, INTEGER, UNIVERSAL);
}
-/*************************************************
-* DER encode an OCTET STRING or BIT STRING *
-*************************************************/
+/*
+* DER encode an OCTET STRING or BIT STRING
+*/
DER_Encoder& DER_Encoder::encode(const MemoryRegion<byte>& bytes,
ASN1_Tag real_type)
{
@@ -237,18 +239,18 @@ DER_Encoder& DER_Encoder::encode(const MemoryRegion<byte>& bytes,
real_type, real_type, UNIVERSAL);
}
-/*************************************************
-* Encode this object *
-*************************************************/
+/*
+* Encode this object
+*/
DER_Encoder& DER_Encoder::encode(const byte bytes[], u32bit length,
ASN1_Tag real_type)
{
return encode(bytes, length, real_type, real_type, UNIVERSAL);
}
-/*************************************************
-* DER encode a BOOLEAN *
-*************************************************/
+/*
+* DER encode a BOOLEAN
+*/
DER_Encoder& DER_Encoder::encode(bool is_true,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -256,18 +258,18 @@ DER_Encoder& DER_Encoder::encode(bool is_true,
return add_object(type_tag, class_tag, &val, 1);
}
-/*************************************************
-* DER encode a small INTEGER *
-*************************************************/
+/*
+* DER encode a small INTEGER
+*/
DER_Encoder& DER_Encoder::encode(u32bit n,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
return encode(BigInt(n), type_tag, class_tag);
}
-/*************************************************
-* DER encode an INTEGER *
-*************************************************/
+/*
+* DER encode an INTEGER
+*/
DER_Encoder& DER_Encoder::encode(const BigInt& n,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -289,9 +291,9 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n,
return add_object(type_tag, class_tag, contents);
}
-/*************************************************
-* DER encode an OCTET STRING or BIT STRING *
-*************************************************/
+/*
+* DER encode an OCTET STRING or BIT STRING
+*/
DER_Encoder& DER_Encoder::encode(const MemoryRegion<byte>& bytes,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
@@ -300,9 +302,9 @@ DER_Encoder& DER_Encoder::encode(const MemoryRegion<byte>& bytes,
real_type, type_tag, class_tag);
}
-/*************************************************
-* DER encode an OCTET STRING or BIT STRING *
-*************************************************/
+/*
+* DER encode an OCTET STRING or BIT STRING
+*/
DER_Encoder& DER_Encoder::encode(const byte bytes[], u32bit length,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
@@ -321,9 +323,9 @@ DER_Encoder& DER_Encoder::encode(const byte bytes[], u32bit length,
return add_object(type_tag, class_tag, bytes, length);
}
-/*************************************************
-* Conditionally write some values to the stream *
-*************************************************/
+/*
+* Conditionally write some values to the stream
+*/
DER_Encoder& DER_Encoder::encode_if(bool cond, DER_Encoder& codec)
{
if(cond)
@@ -331,18 +333,18 @@ DER_Encoder& DER_Encoder::encode_if(bool cond, DER_Encoder& codec)
return (*this);
}
-/*************************************************
-* Request for an object to encode itself *
-*************************************************/
+/*
+* Request for an object to encode itself
+*/
DER_Encoder& DER_Encoder::encode(const ASN1_Object& obj)
{
obj.encode_into(*this);
return (*this);
}
-/*************************************************
-* Write the encoding of the byte(s) *
-*************************************************/
+/*
+* Write the encoding of the byte(s)
+*/
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
const byte rep[], u32bit length)
{
@@ -357,9 +359,9 @@ DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
return raw_bytes(buffer);
}
-/*************************************************
-* Write the encoding of the byte(s) *
-*************************************************/
+/*
+* Write the encoding of the byte(s)
+*/
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
const MemoryRegion<byte>& rep_buf)
{
@@ -368,9 +370,9 @@ DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
return add_object(type_tag, class_tag, rep, rep_len);
}
-/*************************************************
-* Write the encoding of the byte(s) *
-*************************************************/
+/*
+* Write the encoding of the byte(s)
+*/
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
const std::string& rep_str)
{
@@ -379,9 +381,9 @@ DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
return add_object(type_tag, class_tag, rep, rep_len);
}
-/*************************************************
-* Write the encoding of the byte *
-*************************************************/
+/*
+* Write the encoding of the byte
+*/
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag,
ASN1_Tag class_tag, byte rep)
{
diff --git a/src/asn1/der_enc.h b/src/asn1/der_enc.h
index 5b3c11489..23b5297e5 100644
--- a/src/asn1/der_enc.h
+++ b/src/asn1/der_enc.h
@@ -1,7 +1,9 @@
-/*************************************************
-* DER Encoder Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* DER Encoder
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_DER_ENCODER_H__
#define BOTAN_DER_ENCODER_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* General DER Encoding Object *
-*************************************************/
+/*
+* General DER Encoding Object
+*/
class BOTAN_DLL DER_Encoder
{
public: