The unified diff between revisions [853c4385..] and [4e40e885..] is displayed below. It can also be downloaded as a raw diff.

This diff has been restricted to the following files: 'src/x509_ext.cpp'

#
#
# patch "src/x509_ext.cpp"
#  from [ece40e7de263fe3eee1cd2f0b1d2efcf7a38493c]
#    to [5724ac53f27fc3f50ab9df3d44a1ed2f52b34517]
#
============================================================
--- src/x509_ext.cpp	ece40e7de263fe3eee1cd2f0b1d2efcf7a38493c
+++ src/x509_ext.cpp	5724ac53f27fc3f50ab9df3d44a1ed2f52b34517
@@ -1,11 +1,9 @@
 /*************************************************
 * X.509 Certificate Extensions Source File       *
-* (C) 1999-2007 The Botan Project                *
+* (C) 1999-2007 Jack Lloyd                       *
 *************************************************/

 #include <botan/x509_ext.h>
-#include <botan/x509stat.h>
-#include <botan/libstate.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
 #include <botan/lookup.h>
@@ -18,6 +16,51 @@ namespace Botan {
 namespace Botan {

 /*************************************************
+* List of X.509 Certificate Extensions           *
+*************************************************/
+Certificate_Extension* Extensions::get_extension(const OID& oid)
+   {
+#define X509_EXTENSION(NAME, TYPE) \
+   if(OIDS::name_of(oid, NAME))    \
+      return new Cert_Extension::TYPE();
+
+   X509_EXTENSION("X509v3.KeyUsage", Key_Usage);
+   X509_EXTENSION("X509v3.BasicConstraints", Basic_Constraints);
+   X509_EXTENSION("X509v3.SubjectKeyIdentifier", Subject_Key_ID);
+   X509_EXTENSION("X509v3.AuthorityKeyIdentifier", Authority_Key_ID);
+   X509_EXTENSION("X509v3.ExtendedKeyUsage", Extended_Key_Usage);
+   X509_EXTENSION("X509v3.IssuerAlternativeName", Issuer_Alternative_Name);
+   X509_EXTENSION("X509v3.SubjectAlternativeName", Subject_Alternative_Name);
+   X509_EXTENSION("X509v3.CRLNumber", CRL_Number);
+   X509_EXTENSION("X509v3.CertificatePolicies", Certificate_Policies);
+
+   return 0;
+   }
+
+/*************************************************
+* Extensions Copy Constructor                    *
+*************************************************/
+Extensions::Extensions(const Extensions& extensions) : ASN1_Object()
+   {
+   *this = extensions;
+   }
+
+/*************************************************
+* Extensions Assignment Operator                 *
+*************************************************/
+Extensions& Extensions::operator=(const Extensions& other)
+   {
+   for(u32bit j = 0; j != extensions.size(); ++j)
+      delete extensions[j];
+   extensions.clear();
+
+   for(u32bit j = 0; j != other.extensions.size(); ++j)
+      extensions.push_back(other.extensions[j]->copy());
+
+   return (*this);
+   }
+
+/*************************************************
 * Return the OID of this extension               *
 *************************************************/
 OID Certificate_Extension::oid_of() const
@@ -84,8 +127,7 @@ void Extensions::decode_from(BER_Decoder
             .verify_end()
          .end_cons();

-      Certificate_Extension* ext =
-         global_state().x509_state().get_extension(oid);
+      Certificate_Extension* ext = get_extension(oid);

       if(!ext)
          {
@@ -114,21 +156,6 @@ void Extensions::contents_to(Data_Store&
    }

 /*************************************************
-* Copy another extensions list                   *
-*************************************************/
-Extensions& Extensions::copy_this(const Extensions& other)
-   {
-   for(u32bit j = 0; j != extensions.size(); ++j)
-      delete extensions[j];
-   extensions.clear();
-
-   for(u32bit j = 0; j != other.extensions.size(); ++j)
-      extensions.push_back(other.extensions[j]->copy());
-
-   return (*this);
-   }
-
-/*************************************************
 * Delete an Extensions list                      *
 *************************************************/
 Extensions::~Extensions()
@@ -201,12 +228,12 @@ MemoryVector<byte> Key_Usage::encode_inn
    const u32bit unused_bits = low_bit(constraints) - 1;

    SecureVector<byte> der;
-   der.push_back(BIT_STRING);
-   der.push_back(2 + ((unused_bits < 8) ? 1 : 0));
-   der.push_back(unused_bits % 8);
-   der.push_back((constraints >> 8) & 0xFF);
+   der.append(BIT_STRING);
+   der.append(2 + ((unused_bits < 8) ? 1 : 0));
+   der.append(unused_bits % 8);
+   der.append((constraints >> 8) & 0xFF);
    if(constraints & 0xFF)
-      der.push_back(constraints & 0xFF);
+      der.append(constraints & 0xFF);

    return der;
    }