aboutsummaryrefslogtreecommitdiffstats
path: root/src/cert
diff options
context:
space:
mode:
Diffstat (limited to 'src/cert')
-rw-r--r--src/cert/cvc/asn1_eac_tm.cpp4
-rw-r--r--src/cert/cvc/cvc_ado.cpp43
-rw-r--r--src/cert/cvc/cvc_ado.h4
-rw-r--r--src/cert/cvc/cvc_ca.cpp3
-rw-r--r--src/cert/cvc/cvc_cert.cpp6
-rw-r--r--src/cert/cvc/cvc_cert.h2
-rw-r--r--src/cert/cvc/cvc_gen_cert.h9
-rw-r--r--src/cert/cvc/cvc_req.cpp15
-rw-r--r--src/cert/cvc/cvc_req.h2
-rw-r--r--src/cert/cvc/cvc_self.cpp18
-rw-r--r--src/cert/cvc/eac_obj.h10
-rw-r--r--src/cert/cvc/freestore.h84
-rw-r--r--src/cert/cvc/info.txt3
-rw-r--r--src/cert/x509/x509_ext.cpp2
14 files changed, 57 insertions, 148 deletions
diff --git a/src/cert/cvc/asn1_eac_tm.cpp b/src/cert/cvc/asn1_eac_tm.cpp
index dc38e3296..73a2843f7 100644
--- a/src/cert/cvc/asn1_eac_tm.cpp
+++ b/src/cert/cvc/asn1_eac_tm.cpp
@@ -182,9 +182,9 @@ bool EAC_Time::passes_sanity_check() const
return true;
}
-/******************************************
+/*
* modification functions
-******************************************/
+*/
void EAC_Time::add_years(u32bit years)
{
diff --git a/src/cert/cvc/cvc_ado.cpp b/src/cert/cvc/cvc_ado.cpp
index 6e1484e90..fcce0ff82 100644
--- a/src/cert/cvc/cvc_ado.cpp
+++ b/src/cert/cvc/cvc_ado.cpp
@@ -8,11 +8,10 @@
#include <botan/cvc_ado.h>
#include <fstream>
-#include <assert.h>
namespace Botan {
-EAC1_1_ADO::EAC1_1_ADO(std::tr1::shared_ptr<DataSource> in)
+EAC1_1_ADO::EAC1_1_ADO(DataSource& in)
{
init(in);
do_decode();
@@ -20,7 +19,7 @@ EAC1_1_ADO::EAC1_1_ADO(std::tr1::shared_ptr<DataSource> in)
EAC1_1_ADO::EAC1_1_ADO(const std::string& in)
{
- std::tr1::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
+ DataSource_Stream stream(in, true);
init(stream);
do_decode();
}
@@ -41,7 +40,7 @@ void EAC1_1_ADO::force_decode()
.end_cons()
.get_contents();
- std::tr1::shared_ptr<DataSource> req_source(new DataSource_Memory(req_bits));
+ DataSource_Memory req_source(req_bits);
m_req = EAC1_1_Req(req_source);
sig_algo = m_req.sig_algo;
}
@@ -53,14 +52,13 @@ MemoryVector<byte> EAC1_1_ADO::make_signed(
{
SecureVector<byte> concat_sig =
EAC1_1_obj<EAC1_1_ADO>::make_signature(signer.get(), tbs_bits, rng);
- assert(concat_sig.size() % 2 == 0);
- MemoryVector<byte> result = DER_Encoder()
+
+ return DER_Encoder()
.start_cons(ASN1_Tag(7), APPLICATION)
.raw_bytes(tbs_bits)
.encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
.end_cons()
.get_contents();
- return result;
}
ASN1_Car EAC1_1_ADO::get_car() const
@@ -68,14 +66,15 @@ ASN1_Car EAC1_1_ADO::get_car() const
return m_car;
}
-void EAC1_1_ADO::decode_info(SharedPtrConverter<DataSource> source,
+void EAC1_1_ADO::decode_info(DataSource& source,
SecureVector<byte> & res_tbs_bits,
ECDSA_Signature & res_sig)
{
SecureVector<byte> concat_sig;
SecureVector<byte> cert_inner_bits;
ASN1_Car car;
- BER_Decoder(*source.get_ptr().get())
+
+ BER_Decoder(source)
.start_cons(ASN1_Tag(7))
.start_cons(ASN1_Tag(33))
.raw_bytes(cert_inner_bits)
@@ -89,28 +88,30 @@ void EAC1_1_ADO::decode_info(SharedPtrConverter<DataSource> source,
.raw_bytes(cert_inner_bits)
.end_cons()
.get_contents();
+
SecureVector<byte> enc_car = DER_Encoder()
.encode(car)
.get_contents();
+
res_tbs_bits = enc_cert;
res_tbs_bits.append(enc_car);
res_sig = decode_concatenation(concat_sig);
-
-
}
+
void EAC1_1_ADO::encode(Pipe& out, X509_Encoding encoding) const
{
- SecureVector<byte> concat_sig(EAC1_1_obj<EAC1_1_ADO>::m_sig.get_concatenation());
- SecureVector<byte> der = DER_Encoder()
- .start_cons(ASN1_Tag(7), APPLICATION)
- .raw_bytes(tbs_bits)
- .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
- .end_cons()
- .get_contents();
if(encoding == PEM)
throw Invalid_Argument("EAC1_1_ADO::encode() cannot PEM encode an EAC object");
- else
- out.write(der);
+
+ SecureVector<byte> concat_sig(
+ EAC1_1_obj<EAC1_1_ADO>::m_sig.get_concatenation());
+
+ out.write(DER_Encoder()
+ .start_cons(ASN1_Tag(7), APPLICATION)
+ .raw_bytes(tbs_bits)
+ .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
+ .end_cons()
+ .get_contents());
}
SecureVector<byte> EAC1_1_ADO::tbs_data() const
@@ -120,8 +121,6 @@ SecureVector<byte> EAC1_1_ADO::tbs_data() const
bool EAC1_1_ADO::operator==(EAC1_1_ADO const& rhs) const
{
- assert(((this->m_req == rhs.m_req) && (this->tbs_data() == rhs.tbs_data())) ||
- ((this->m_req != rhs.m_req) && (this->tbs_data() != rhs.tbs_data())));
return (this->get_concat_sig() == rhs.get_concat_sig()
&& this->tbs_data() == rhs.tbs_data()
&& this->get_car() == rhs.get_car());
diff --git a/src/cert/cvc/cvc_ado.h b/src/cert/cvc/cvc_ado.h
index a0dbec2a6..80e6a82b7 100644
--- a/src/cert/cvc/cvc_ado.h
+++ b/src/cert/cvc/cvc_ado.h
@@ -38,7 +38,7 @@ class BOTAN_DLL EAC1_1_ADO : public EAC1_1_obj<EAC1_1_ADO>
* Construct a CVC ADO request from a data source
* @param source the data source
*/
- EAC1_1_ADO(std::tr1::shared_ptr<DataSource> source);
+ EAC1_1_ADO(DataSource& source);
/**
* Create a signed CVC ADO request from to be signed (TBS) data
@@ -83,7 +83,7 @@ class BOTAN_DLL EAC1_1_ADO : public EAC1_1_obj<EAC1_1_ADO>
EAC1_1_Req m_req;
void force_decode();
- static void decode_info(SharedPtrConverter<DataSource> source,
+ static void decode_info(DataSource& source,
SecureVector<byte> & res_tbs_bits,
ECDSA_Signature & res_sig);
};
diff --git a/src/cert/cvc/cvc_ca.cpp b/src/cert/cvc/cvc_ca.cpp
index 8ca8db0c2..814df216b 100644
--- a/src/cert/cvc/cvc_ca.cpp
+++ b/src/cert/cvc/cvc_ca.cpp
@@ -37,8 +37,7 @@ EAC1_1_CVC EAC1_1_CVC_CA::make_cert(std::auto_ptr<PK_Signer> signer,
EAC1_1_CVC::build_cert_body(tbs),
rng);
- std::tr1::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
-
+ DataSource_Memory source(signed_cert);
return EAC1_1_CVC(source);
}
diff --git a/src/cert/cvc/cvc_cert.cpp b/src/cert/cvc/cvc_cert.cpp
index d2be12df8..94d80af21 100644
--- a/src/cert/cvc/cvc_cert.cpp
+++ b/src/cert/cvc/cvc_cert.cpp
@@ -56,7 +56,7 @@ void EAC1_1_CVC::force_decode()
throw Decoding_Error("CertificateHolderAuthorizationValue was not of length 1");
if(cpi != 0)
- throw Decoding_Error("EAC1_1 certificate´s cpi was not 0");
+ throw Decoding_Error("EAC1_1 certificate's cpi was not 0");
// FIXME: PK algos have no notion of EAC encoder/decoder currently
#if 0
@@ -78,7 +78,7 @@ void EAC1_1_CVC::force_decode()
/*
* CVC Certificate Constructor
*/
-EAC1_1_CVC::EAC1_1_CVC(std::tr1::shared_ptr<DataSource>& in)
+EAC1_1_CVC::EAC1_1_CVC(DataSource& in)
{
init(in);
self_signed = false;
@@ -87,7 +87,7 @@ EAC1_1_CVC::EAC1_1_CVC(std::tr1::shared_ptr<DataSource>& in)
EAC1_1_CVC::EAC1_1_CVC(const std::string& in)
{
- std::tr1::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
+ DataSource_Stream stream(in, true);
init(stream);
self_signed = false;
do_decode();
diff --git a/src/cert/cvc/cvc_cert.h b/src/cert/cvc/cvc_cert.h
index 17671d332..ae0c21d7b 100644
--- a/src/cert/cvc/cvc_cert.h
+++ b/src/cert/cvc/cvc_cert.h
@@ -59,7 +59,7 @@ class BOTAN_DLL EAC1_1_CVC : public EAC1_1_gen_CVC<EAC1_1_CVC>//Signed_Object
* Construct a CVC from a data source
* @param source the data source
*/
- EAC1_1_CVC(std::tr1::shared_ptr<DataSource>& source);
+ EAC1_1_CVC(DataSource& source);
/**
* Construct a CVC from a file
diff --git a/src/cert/cvc/cvc_gen_cert.h b/src/cert/cvc/cvc_gen_cert.h
index 797970e29..096f7898c 100644
--- a/src/cert/cvc/cvc_gen_cert.h
+++ b/src/cert/cvc/cvc_gen_cert.h
@@ -16,7 +16,6 @@
#include <botan/ecdsa.h>
#include <botan/ecdsa_sig.h>
#include <string>
-#include <assert.h>
namespace Botan {
@@ -87,7 +86,7 @@ class BOTAN_DLL EAC1_1_gen_CVC : public EAC1_1_obj<Derived> // CRTP continuation
ASN1_Chr m_chr;
bool self_signed;
- static void decode_info(SharedPtrConverter<DataSource> source,
+ static void decode_info(DataSource& source,
SecureVector<byte> & res_tbs_bits,
ECDSA_Signature & res_sig);
@@ -109,7 +108,7 @@ template<typename Derived> MemoryVector<byte> EAC1_1_gen_CVC<Derived>::make_sign
RandomNumberGenerator& rng) // static
{
SecureVector<byte> concat_sig = EAC1_1_obj<Derived>::make_signature(signer.get(), tbs_bits, rng);
- assert(concat_sig.size() % 2 == 0);
+
return DER_Encoder()
.start_cons(ASN1_Tag(33), APPLICATION)
.raw_bytes(tbs_bits)
@@ -156,12 +155,12 @@ template<typename Derived> void EAC1_1_gen_CVC<Derived>::encode(Pipe& out, X509_
template<typename Derived>
void EAC1_1_gen_CVC<Derived>::decode_info(
- SharedPtrConverter<DataSource> source,
+ DataSource& source,
SecureVector<byte> & res_tbs_bits,
ECDSA_Signature & res_sig)
{
SecureVector<byte> concat_sig;
- BER_Decoder(*source.get_shared().get())
+ BER_Decoder(source)
.start_cons(ASN1_Tag(33))
.start_cons(ASN1_Tag(78))
.raw_bytes(res_tbs_bits)
diff --git a/src/cert/cvc/cvc_req.cpp b/src/cert/cvc/cvc_req.cpp
index 70a44bacd..78dbdea52 100644
--- a/src/cert/cvc/cvc_req.cpp
+++ b/src/cert/cvc/cvc_req.cpp
@@ -10,19 +10,17 @@
#include <botan/ber_dec.h>
#include <botan/pem.h>
#include <botan/parsing.h>
-#include <assert.h>
#include <botan/cvc_key.h>
#include <botan/oids.h>
#include <botan/look_pk.h>
#include <botan/cvc_req.h>
-#include <botan/freestore.h>
namespace Botan {
bool EAC1_1_Req::operator==(EAC1_1_Req const& rhs) const
{
- return (this->tbs_data() == rhs.tbs_data()
- && this->get_concat_sig() == rhs.get_concat_sig());
+ return (this->tbs_data() == rhs.tbs_data() &&
+ this->get_concat_sig() == rhs.get_concat_sig());
}
void EAC1_1_Req::force_decode()
@@ -36,10 +34,9 @@ void EAC1_1_Req::force_decode()
.end_cons()
.decode(m_chr)
.verify_end();
+
if(cpi != 0)
- {
- throw Decoding_Error("EAC1_1 request´s cpi was not 0");
- }
+ throw Decoding_Error("EAC1_1 requests cpi was not 0");
// FIXME: No EAC support in ECDSA
#if 0
@@ -50,7 +47,7 @@ void EAC1_1_Req::force_decode()
#endif
}
-EAC1_1_Req::EAC1_1_Req(std::tr1::shared_ptr<DataSource> in)
+EAC1_1_Req::EAC1_1_Req(DataSource& in)
{
init(in);
self_signed = true;
@@ -59,7 +56,7 @@ EAC1_1_Req::EAC1_1_Req(std::tr1::shared_ptr<DataSource> in)
EAC1_1_Req::EAC1_1_Req(const std::string& in)
{
- std::tr1::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
+ DataSource_Stream stream(in, true);
init(stream);
self_signed = true;
do_decode();
diff --git a/src/cert/cvc/cvc_req.h b/src/cert/cvc/cvc_req.h
index 28f03db80..2abc72c9a 100644
--- a/src/cert/cvc/cvc_req.h
+++ b/src/cert/cvc/cvc_req.h
@@ -35,7 +35,7 @@ class BOTAN_DLL EAC1_1_Req : public EAC1_1_gen_CVC<EAC1_1_Req>
* Construct a CVC request from a data source.
* @param source the data source
*/
- EAC1_1_Req(std::tr1::shared_ptr<DataSource> source);
+ EAC1_1_Req(DataSource& source);
/**
* Construct a CVC request from a DER encoded CVC reqeust file.
diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp
index 227ff4136..deef351b9 100644
--- a/src/cert/cvc/cvc_self.cpp
+++ b/src/cert/cvc/cvc_self.cpp
@@ -16,14 +16,15 @@
#include <botan/cvc_ado.h>
#include <botan/time.h>
#include <sstream>
+#include <assert.h>
namespace Botan {
namespace {
-/*******************************
+/*
* cvc CHAT values
-*******************************/
+*/
enum CHAT_values{
CVCA = 0xC0,
DVCA_domestic = 0x80,
@@ -42,6 +43,7 @@ std::string padding_and_hash_from_oid(OID const& oid)
padding_and_hash.erase(0, padding_and_hash.find("/",0) + 1);
return padding_and_hash;
}
+
std::string fixed_len_seqnr(u32bit seqnr, u32bit len)
{
std::stringstream ss;
@@ -80,7 +82,7 @@ EAC1_1_CVC create_self_signed_cert(Private_Key const& key,
ASN1_Chr chr(opt.car.value());
AlgorithmIdentifier sig_algo;
- std::string padding_and_hash(eac_cvc_emsa + "(" + opt.hash_alg + ")");
+ std::string padding_and_hash("EMSA1_BSI(" + opt.hash_alg + ")");
sig_algo.oid = OIDS::lookup(priv_key->algo_name() + "/" + padding_and_hash);
sig_algo = AlgorithmIdentifier(sig_algo.oid, AlgorithmIdentifier::USE_NULL_PARAM);
@@ -109,7 +111,7 @@ EAC1_1_Req create_cvc_req(Private_Key const& key,
throw Invalid_Argument("CVC_EAC::create_self_signed_cert(): unsupported key type");
}
AlgorithmIdentifier sig_algo;
- std::string padding_and_hash(eac_cvc_emsa + "(" + hash_alg + ")");
+ std::string padding_and_hash("EMSA1_BSI(" + hash_alg + ")");
sig_algo.oid = OIDS::lookup(priv_key->algo_name() + "/" + padding_and_hash);
sig_algo = AlgorithmIdentifier(sig_algo.oid, AlgorithmIdentifier::USE_NULL_PARAM);
@@ -131,7 +133,8 @@ EAC1_1_Req create_cvc_req(Private_Key const& key,
.get_contents();
MemoryVector<byte> signed_cert = EAC1_1_gen_CVC<EAC1_1_Req>::make_signed(signer, EAC1_1_gen_CVC<EAC1_1_Req>::build_cert_body(tbs), rng);
- std::tr1::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
+
+ DataSource_Memory source(signed_cert);
return EAC1_1_Req(source);
}
@@ -151,7 +154,8 @@ EAC1_1_ADO create_ado_req(Private_Key const& key,
SecureVector<byte> tbs_bits = req.BER_encode();
tbs_bits.append(DER_Encoder().encode(car).get_contents());
MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(signer, tbs_bits, rng);
- std::tr1::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
+
+ DataSource_Memory source(signed_cert);
return EAC1_1_ADO(source);
}
@@ -206,7 +210,7 @@ EAC1_1_CVC link_cvca(EAC1_1_CVC const& signer,
}
if (signer.signature_algorithm() != signee.signature_algorithm())
{
- throw Invalid_Argument("link_cvca(): signature algorithms of signer and signee don´t match");
+ throw Invalid_Argument("link_cvca(): signature algorithms of signer and signee don't match");
}
AlgorithmIdentifier sig_algo = signer.signature_algorithm();
std::string padding_and_hash = padding_and_hash_from_oid(sig_algo.oid);
diff --git a/src/cert/cvc/eac_obj.h b/src/cert/cvc/eac_obj.h
index d357adb7d..e4eb895c1 100644
--- a/src/cert/cvc/eac_obj.h
+++ b/src/cert/cvc/eac_obj.h
@@ -18,13 +18,10 @@
#include <botan/oids.h>
#include <botan/look_pk.h>
#include <botan/ecdsa_sig.h>
-#include <botan/freestore.h>
#include <string>
namespace Botan {
-const std::string eac_cvc_emsa("EMSA1_BSI");
-
/*
* TR03110 v1.1 EAC CV Certificate
*/
@@ -52,7 +49,7 @@ class BOTAN_DLL EAC1_1_obj : public EAC_Signed_Object
virtual bool check_signature(Public_Key& pub_key) const;
protected:
- void init(SharedPtrConverter<DataSource> in);
+ void init(DataSource& in);
static SecureVector<byte> make_signature(PK_Signer* signer,
const MemoryRegion<byte>& tbs_bits,
@@ -80,11 +77,12 @@ EAC1_1_obj<Derived>::make_signature(PK_Signer* signer,
return concat_sig;
}
-template<typename Derived> void EAC1_1_obj<Derived>::init(SharedPtrConverter<DataSource> in)
+template<typename Derived>
+void EAC1_1_obj<Derived>::init(DataSource& in)
{
try
{
- Derived::decode_info(in.get_shared(), tbs_bits, m_sig);
+ Derived::decode_info(in, tbs_bits, m_sig);
}
catch(Decoding_Error)
{
diff --git a/src/cert/cvc/freestore.h b/src/cert/cvc/freestore.h
deleted file mode 100644
index 7f8b85388..000000000
--- a/src/cert/cvc/freestore.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-* (C) 2007 Christoph Ludwig
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_FREESTORE_H__
-#define BOTAN_FREESTORE_H__
-
-#include <botan/build.h>
-
-#if defined(BOTAN_USE_STD_TR1)
- #include <tr1/memory>
-#elif defined(BOTAN_USE_BOOST_TR1)
- #include <boost/tr1/memory.hpp>
-#else
- #error "Please choose a TR1 implementation in build.h"
-#endif
-
-namespace Botan {
-
-/**
-* This class is intended as an function call parameter type and
-* enables convenient automatic conversions between plain and smart
-* pointer types. It internally stores a SharedPointer which can be
-* accessed.
-*/
-template<typename T>
-class BOTAN_DLL SharedPtrConverter
- {
- public:
- typedef std::tr1::shared_ptr<T> SharedPtr;
-
- /**
- * Construct a null pointer equivalent object.
- */
- SharedPtrConverter() : ptr() {}
-
- /**
- * Copy constructor.
- */
- SharedPtrConverter(SharedPtrConverter const& other) :
- ptr(other.ptr) {}
-
- /**
- * Construct a converter object from another pointer type.
- * @param p the pointer which shall be set as the internally stored
- * pointer value of this converter.
- */
- template<typename Ptr>
- SharedPtrConverter(Ptr p)
- : ptr(p) {}
-
- /**
- * Get the internally stored shared pointer.
- * @return the internally stored shared pointer
- */
- SharedPtr const& get_ptr() const { return this->ptr; }
-
- /**
- * Get the internally stored shared pointer.
- * @return the internally stored shared pointer
- */
- SharedPtr get_ptr() { return this->ptr; }
-
- /**
- * Get the internally stored shared pointer.
- * @return the internally stored shared pointer
- */
- SharedPtr const& get_shared() const { return this->ptr; }
-
- /**
- * Get the internally stored shared pointer.
- * @return the internally stored shared pointer
- */
- SharedPtr get_shared() { return this->ptr; }
-
- private:
- SharedPtr ptr;
- };
-
-}
-
-#endif
diff --git a/src/cert/cvc/info.txt b/src/cert/cvc/info.txt
index 2033b9576..f3cf42a0e 100644
--- a/src/cert/cvc/info.txt
+++ b/src/cert/cvc/info.txt
@@ -1,7 +1,5 @@
define CARD_VERIFIABLE_CERTIFICATES
-uses_tr1 yes
-
load_on auto
<header:public>
@@ -15,7 +13,6 @@ cvc_self.h
eac_asn_obj.h
eac_obj.h
ecdsa_sig.h
-freestore.h
signed_obj.h
</header:public>
diff --git a/src/cert/x509/x509_ext.cpp b/src/cert/x509/x509_ext.cpp
index 9a03c9d23..69b21d8b3 100644
--- a/src/cert/x509/x509_ext.cpp
+++ b/src/cert/x509/x509_ext.cpp
@@ -473,7 +473,7 @@ MemoryVector<byte> Certificate_Policies::encode_inner() const
{
// FIXME
#if 1
- throw Exception("Certificate_Policies::encode_inner: Bugged");
+ throw Internal_Error("Certificate_Policies::encode_inner: Bugged");
#else
std::vector<Policy_Information> policies;