diff options
Diffstat (limited to 'src/cert')
42 files changed, 933 insertions, 849 deletions
diff --git a/src/cert/cvc/asn1_eac_str.cpp b/src/cert/cvc/asn1_eac_str.cpp index b367df394..a306ffb01 100644 --- a/src/cert/cvc/asn1_eac_str.cpp +++ b/src/cert/cvc/asn1_eac_str.cpp @@ -1,8 +1,10 @@ -/************************************************* -* Simple ASN.1 String Types Source File * -* (C) 2007 FlexSecure GmbH * -* 2008 Jack Lloyd * -*************************************************/ +/* +* Simple ASN.1 String Types +* (C) 2007 FlexSecure GmbH +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/eac_asn_obj.h> #include <botan/der_enc.h> @@ -13,9 +15,9 @@ namespace Botan { -/************************************************* -* Create an ASN1_EAC_String * -*************************************************/ +/* +* Create an ASN1_EAC_String +*/ ASN1_EAC_String::ASN1_EAC_String(const std::string& str, ASN1_Tag t) : tag(t) { iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET); @@ -25,42 +27,42 @@ ASN1_EAC_String::ASN1_EAC_String(const std::string& str, ASN1_Tag t) : tag(t) } } -/************************************************* -* Return this string in ISO 8859-1 encoding * -*************************************************/ +/* +* Return this string in ISO 8859-1 encoding +*/ std::string ASN1_EAC_String::iso_8859() const { return iso_8859_str; } -/************************************************* -* Return this string in local encoding * -*************************************************/ +/* +* Return this string in local encoding +*/ std::string ASN1_EAC_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_EAC_String::tagging() const { return tag; } -/************************************************* -* DER encode an ASN1_EAC_String * -*************************************************/ +/* +* DER encode an ASN1_EAC_String +*/ void ASN1_EAC_String::encode_into(DER_Encoder& encoder) const { std::string value = iso_8859(); encoder.add_object(tagging(), APPLICATION, value); } -/************************************************* -* Decode a BER encoded ASN1_EAC_String * -*************************************************/ +/* +* Decode a BER encoded ASN1_EAC_String +*/ void ASN1_EAC_String::decode_from(BER_Decoder& source) { BER_Object obj = source.get_next_object(); diff --git a/src/cert/cvc/asn1_eac_tm.cpp b/src/cert/cvc/asn1_eac_tm.cpp index 91688879c..05533b520 100644 --- a/src/cert/cvc/asn1_eac_tm.cpp +++ b/src/cert/cvc/asn1_eac_tm.cpp @@ -1,8 +1,10 @@ -/************************************************* -* EAC Time Types Source File * -* (C) 2007 FlexSecure GmbH * -* 2008 Jack Lloyd * -*************************************************/ +/* +* EAC Time Types +* (C) 2007 FlexSecure GmbH +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/eac_asn_obj.h> #include <botan/der_enc.h> @@ -16,9 +18,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); @@ -59,9 +61,9 @@ u32bit dec_two_digit(byte b1, byte b2) } } -/************************************************* -* Create an EAC_Time * -*************************************************/ +/* +* Create an EAC_Time +*/ EAC_Time::EAC_Time(u64bit timer, ASN1_Tag t) :tag(t) { @@ -73,17 +75,17 @@ EAC_Time::EAC_Time(u64bit timer, ASN1_Tag t) } -/************************************************* -* Create an EAC_Time * -*************************************************/ +/* +* Create an EAC_Time +*/ EAC_Time::EAC_Time(const std::string& t_spec, ASN1_Tag t) :tag(t) { set_to(t_spec); } -/************************************************* -* Create an EAC_Time * -*************************************************/ +/* +* Create an EAC_Time +*/ EAC_Time::EAC_Time(u32bit y, u32bit m, u32bit d, ASN1_Tag t) : year(y), month(m), @@ -92,9 +94,9 @@ EAC_Time::EAC_Time(u32bit y, u32bit m, u32bit d, ASN1_Tag t) { } -/************************************************* -* Set the time with a human readable string * -*************************************************/ +/* +* Set the time with a human readable string +*/ void EAC_Time::set_to(const std::string& time_str) { if (time_str == "") @@ -132,18 +134,18 @@ void EAC_Time::set_to(const std::string& time_str) } -/************************************************* -* DER encode a EAC_Time * -*************************************************/ +/* +* DER encode a EAC_Time +*/ void EAC_Time::encode_into(DER_Encoder& der) const { der.add_object(tag, APPLICATION, encoded_eac_time()); } -/************************************************* -* Return a string representation of the time * -*************************************************/ +/* +* Return a string representation of the time +*/ std::string EAC_Time::as_string() const { if (time_is_set() == false) @@ -157,17 +159,17 @@ std::string EAC_Time::as_string() const return asn1rep; } -/************************************************* -* Return if the time has been set somehow * -*************************************************/ +/* +* Return if the time has been set somehow +*/ bool EAC_Time::time_is_set() const { return (year != 0); } -/************************************************* -* Return a human readable string representation * -*************************************************/ +/* +* Return a human readable string representation +*/ std::string EAC_Time::readable_string() const { if (time_is_set() == false) @@ -181,9 +183,9 @@ std::string EAC_Time::readable_string() const return readable; } -/************************************************* -* Do a general sanity check on the time * -*************************************************/ +/* +* Do a general sanity check on the time +*/ bool EAC_Time::passes_sanity_check() const { if (year < 2000 || year > 2099) @@ -197,7 +199,7 @@ bool EAC_Time::passes_sanity_check() const } /****************************************** -* modification functions * +* modification functions ******************************************/ void EAC_Time::add_years(u32bit years) @@ -216,9 +218,9 @@ void EAC_Time::add_months(u32bit months) } -/************************************************* -* Compare this time against another * -*************************************************/ +/* +* Compare this time against another +*/ s32bit EAC_Time::cmp(const EAC_Time& other) const { if (time_is_set() == false) @@ -236,9 +238,9 @@ s32bit EAC_Time::cmp(const EAC_Time& other) const return SAME_TIME; } -/************************************************* -* Compare two EAC_Times for in various ways * -*************************************************/ +/* +* Compare two EAC_Times for in various ways +*/ bool operator==(const EAC_Time& t1, const EAC_Time& t2) { return (t1.cmp(t2) == 0); @@ -264,9 +266,9 @@ bool operator<(const EAC_Time& t1, const EAC_Time& t2) return (t1.cmp(t2) < 0); } -/************************************************* -* Decode a BER encoded EAC_Time * -*************************************************/ +/* +* Decode a BER encoded EAC_Time +*/ void EAC_Time::decode_from(BER_Decoder& source) { BER_Object obj = source.get_next_object(); @@ -320,9 +322,9 @@ u32bit EAC_Time::get_day() const return day; } -/************************************************* -* make the value an octet string for encoding * -*************************************************/ +/* +* make the value an octet string for encoding +*/ SecureVector<byte> EAC_Time::encoded_eac_time() const { SecureVector<byte> result; diff --git a/src/cert/cvc/cvc_ado.cpp b/src/cert/cvc/cvc_ado.cpp index 6ea8d59c2..6e1484e90 100644 --- a/src/cert/cvc/cvc_ado.cpp +++ b/src/cert/cvc/cvc_ado.cpp @@ -1,8 +1,10 @@ -/************************************************* -* CVC Certificate Constructor * -* (C) 2007 FlexSecure GmbH * -* 2008 Jack Lloyd * -*************************************************/ +/* +* CVC Certificate Constructor +* (C) 2007 FlexSecure GmbH +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/cvc_ado.h> #include <fstream> diff --git a/src/cert/cvc/cvc_ado.h b/src/cert/cvc/cvc_ado.h index 5b79cacd9..2c4f3ce70 100644 --- a/src/cert/cvc/cvc_ado.h +++ b/src/cert/cvc/cvc_ado.h @@ -1,8 +1,10 @@ -/************************************************* -* EAC1_1 CVC ADO Header File * -* (C) 2008 Falko Strenzke * -* [email protected] * -*************************************************/ +/* +* EAC1_1 CVC ADO +* (C) 2008 Falko Strenzke +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_EAC_CVC_ADO_H__ #define BOTAN_EAC_CVC_ADO_H__ diff --git a/src/cert/cvc/cvc_ca.h b/src/cert/cvc/cvc_ca.h index b1296cbfb..3ec307bb3 100644 --- a/src/cert/cvc/cvc_ca.h +++ b/src/cert/cvc/cvc_ca.h @@ -1,8 +1,10 @@ -/************************************************* -* EAC1.1 CVC Certificate Authority Header File * -* (C) 2007 FlexSecure GmbH * -* 2008 Jack Lloyd * -*************************************************/ +/* +* EAC1.1 CVC Certificate Authority +* (C) 2007 FlexSecure GmbH +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_CVC_CA_H__ #define BOTAN_CVC_CA_H__ diff --git a/src/cert/cvc/cvc_cert.cpp b/src/cert/cvc/cvc_cert.cpp index 11539ef1e..71ca0cf16 100644 --- a/src/cert/cvc/cvc_cert.cpp +++ b/src/cert/cvc/cvc_cert.cpp @@ -1,6 +1,8 @@ /* (C) 2007 FlexSecure GmbH 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license */ #include <botan/cvc_cert.h> @@ -27,9 +29,9 @@ u32bit EAC1_1_CVC::get_chat_value() const return m_chat_val; } -/************************************************* -* Decode the TBSCertificate data * -*************************************************/ +/* +* Decode the TBSCertificate data +*/ void EAC1_1_CVC::force_decode() { SecureVector<byte> enc_pk; @@ -73,9 +75,9 @@ void EAC1_1_CVC::force_decode() #endif } -/************************************************* -* CVC Certificate Constructor * -*************************************************/ +/* +* CVC Certificate Constructor +*/ EAC1_1_CVC::EAC1_1_CVC(std::tr1::shared_ptr<DataSource>& in) { init(in); diff --git a/src/cert/cvc/cvc_cert.h b/src/cert/cvc/cvc_cert.h index c007a42e8..17671d332 100644 --- a/src/cert/cvc/cvc_cert.h +++ b/src/cert/cvc/cvc_cert.h @@ -1,8 +1,10 @@ -/************************************************* -* EAC1_1 CVC Header File * -* (C) 2008 Falko Strenzke * -* 2008 Jack Lloyd * -*************************************************/ +/* +* EAC1_1 CVC +* (C) 2008 Falko Strenzke +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_CVC_EAC_H__ #define BOTAN_CVC_EAC_H__ @@ -78,9 +80,9 @@ class BOTAN_DLL EAC1_1_CVC : public EAC1_1_gen_CVC<EAC1_1_CVC>//Signed_Object OID m_chat_oid; }; -/************************************************* -* Comparison * -*************************************************/ +/* +* Comparison +*/ inline bool operator!=(EAC1_1_CVC const& lhs, EAC1_1_CVC const& rhs) { return !(lhs == rhs); diff --git a/src/cert/cvc/cvc_gen_cert.h b/src/cert/cvc/cvc_gen_cert.h index ea53f7f0f..4a788026c 100644 --- a/src/cert/cvc/cvc_gen_cert.h +++ b/src/cert/cvc/cvc_gen_cert.h @@ -1,8 +1,10 @@ -/************************************************* -* EAC1_1 general CVC Header File * -* (C) 2008 Falko Strenzke * -* 2008 Jack Lloyd * -*************************************************/ +/* +* EAC1_1 general CVC +* (C) 2008 Falko Strenzke +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_EAC_CVC_GEN_CERT_H__ #define BOTAN_EAC_CVC_GEN_CERT_H__ diff --git a/src/cert/cvc/cvc_key.h b/src/cert/cvc/cvc_key.h index e24c42e41..67b6cef17 100644 --- a/src/cert/cvc/cvc_key.h +++ b/src/cert/cvc/cvc_key.h @@ -1,9 +1,11 @@ -/************************************************* -* EAC CVC Public Key Header File * -* (C) 2008 FlexSecure Gmbh * -* Falko Strenzke * -* [email protected] * -*************************************************/ +/* +* EAC CVC Public Key +* (C) 2008 FlexSecure Gmbh +* Falko Strenzke +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_EAC1_1_CVC_PUBLIC_KEY_H__ #define BOTAN_EAC1_1_CVC_PUBLIC_KEY_H__ diff --git a/src/cert/cvc/cvc_req.cpp b/src/cert/cvc/cvc_req.cpp index 84ea3ba8a..a9a94827c 100644 --- a/src/cert/cvc/cvc_req.cpp +++ b/src/cert/cvc/cvc_req.cpp @@ -1,6 +1,8 @@ /* (C) 2007 FlexSecure GmbH 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license */ #include <botan/cvc_cert.h> diff --git a/src/cert/cvc/cvc_req.h b/src/cert/cvc/cvc_req.h index 484d01f25..8599f539d 100644 --- a/src/cert/cvc/cvc_req.h +++ b/src/cert/cvc/cvc_req.h @@ -1,8 +1,10 @@ -/************************************************* -* EAC1_1 CVC Request Header File * -* (C) 2008 Falko Strenzke * -* [email protected] * -*************************************************/ +/* +* EAC1_1 CVC Request +* (C) 2008 Falko Strenzke +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_EAC_CVC_REQ_H__ #define BOTAN_EAC_CVC_REQ_H__ @@ -48,9 +50,9 @@ class BOTAN_DLL EAC1_1_Req : public EAC1_1_gen_CVC<EAC1_1_Req> EAC1_1_Req() {} }; -/************************************************* -* Comparison Operator * -*************************************************/ +/* +* Comparison Operator +*/ inline bool operator!=(EAC1_1_Req const& lhs, EAC1_1_Req const& rhs) { return !(lhs == rhs); diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp index 8b49d3186..45a584cb3 100644 --- a/src/cert/cvc/cvc_self.cpp +++ b/src/cert/cvc/cvc_self.cpp @@ -1,6 +1,8 @@ /* (C) 2007 FlexSecure GmbH 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license */ #include <botan/cvc_self.h> @@ -20,7 +22,7 @@ namespace Botan { namespace { /******************************* -* cvc CHAT values * +* cvc CHAT values *******************************/ enum CHAT_values{ CVCA = 0xC0, diff --git a/src/cert/cvc/cvc_self.h b/src/cert/cvc/cvc_self.h index 735301989..db23547b9 100644 --- a/src/cert/cvc/cvc_self.h +++ b/src/cert/cvc/cvc_self.h @@ -1,8 +1,10 @@ -/************************************************* -* CVC Self-Signed Certificate Header File * -* (C) 2007 FlexSecure GmbH * -* 2008 Jack Lloyd * -*************************************************/ +/* +* CVC Self-Signed Certificate +* (C) 2007 FlexSecure GmbH +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_CVC_EAC_SELF_H__ #define BOTAN_CVC_EAC_SELF_H__ diff --git a/src/cert/cvc/eac_asn_obj.h b/src/cert/cvc/eac_asn_obj.h index 61a204eff..3e70f6b74 100644 --- a/src/cert/cvc/eac_asn_obj.h +++ b/src/cert/cvc/eac_asn_obj.h @@ -1,8 +1,10 @@ -/************************************************* -* EAC ASN.1 Objects Header File * -* (C) 2007-2008 FlexSecure GmbH * -* 2008 Jack Lloyd * -*************************************************/ +/* +* EAC ASN.1 Objects +* (C) 2007-2008 FlexSecure GmbH +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_EAC_ASN1_OBJ_H__ #define BOTAN_EAC_ASN1_OBJ_H__ @@ -221,9 +223,9 @@ class BOTAN_DLL ASN1_Chr : public ASN1_EAC_String ASN1_Chr(std::string const& str = ""); }; -/************************************************* -* Comparison Operations * -*************************************************/ +/* +* Comparison Operations +*/ bool operator==(const EAC_Time&, const EAC_Time&); bool operator!=(const EAC_Time&, const EAC_Time&); bool operator<=(const EAC_Time&, const EAC_Time&); diff --git a/src/cert/cvc/eac_obj.h b/src/cert/cvc/eac_obj.h index 72d897700..04afd7e59 100644 --- a/src/cert/cvc/eac_obj.h +++ b/src/cert/cvc/eac_obj.h @@ -1,8 +1,10 @@ -/************************************************* -* EAC1_1 objects Header File * -* (C) 2008 Falko Strenzke * -* [email protected] * -*************************************************/ +/* +* EAC1_1 objects +* (C) 2008 Falko Strenzke +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_EAC_OBJ_H__ #define BOTAN_EAC_OBJ_H__ @@ -23,9 +25,9 @@ namespace Botan { const std::string eac_cvc_emsa("EMSA1_BSI"); -/************************************************* -* TR03110 v1.1 EAC CV Certificate * -*************************************************/ +/* +* TR03110 v1.1 EAC CV Certificate +*/ template<typename Derived> // CRTP is used enable the call sequence: class BOTAN_DLL EAC1_1_obj : public EAC_Signed_Object { diff --git a/src/cert/cvc/ecdsa_sig.h b/src/cert/cvc/ecdsa_sig.h index 720acaedc..15015c76d 100644 --- a/src/cert/cvc/ecdsa_sig.h +++ b/src/cert/cvc/ecdsa_sig.h @@ -1,8 +1,10 @@ -/************************************************* -* ECDSA Header File * -* (C) 2007 Falko Strenzke, FlexSecure GmbH * -* (C) 2008 Jack Lloyd * -*************************************************/ +/* +* ECDSA +* (C) 2007 Falko Strenzke, FlexSecure GmbH +* (C) 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_ECDSA_SIGNATURE_H__ #define BOTAN_ECDSA_SIGNATURE_H__ diff --git a/src/cert/cvc/freestore.h b/src/cert/cvc/freestore.h index e33c0f094..f95afa802 100644 --- a/src/cert/cvc/freestore.h +++ b/src/cert/cvc/freestore.h @@ -1,7 +1,7 @@ -/************************************************** -* (C) 2007 Christoph Ludwig * -* [email protected] * -**************************************************/ +/** +* (C) 2007 Christoph Ludwig +**/ #ifndef BOTAN_FREESTORE_H__ #define BOTAN_FREESTORE_H__ @@ -23,6 +23,8 @@ namespace Botan { * enables convenient automatic conversions between plain and smart * pointer types. It internally stores a SharedPointer which can be * accessed. +* +* Distributed under the terms of the Botan license */ template<typename T> class BOTAN_DLL SharedPtrConverter diff --git a/src/cert/cvc/signed_obj.cpp b/src/cert/cvc/signed_obj.cpp index 73ae6b917..4a08ed0ac 100644 --- a/src/cert/cvc/signed_obj.cpp +++ b/src/cert/cvc/signed_obj.cpp @@ -1,16 +1,18 @@ -/************************************************* -* X.509 SIGNED Object Source File * -* (C) 1999-2007 Jack Lloyd * -* 2007 FlexSecure GmbH * -*************************************************/ +/* +* X.509 SIGNED Object +* (C) 1999-2007 Jack Lloyd +* 2007 FlexSecure GmbH +* +* Distributed under the terms of the Botan license +*/ #include <botan/signed_obj.h> namespace Botan { -/************************************************* -* Return a BER encoded X.509 object * -*************************************************/ +/* +* Return a BER encoded X.509 object +*/ SecureVector<byte> EAC_Signed_Object::BER_encode() const { Pipe ber; @@ -20,9 +22,9 @@ SecureVector<byte> EAC_Signed_Object::BER_encode() const return ber.read_all(); } -/************************************************* -* Return a PEM encoded X.509 object * -*************************************************/ +/* +* Return a PEM encoded X.509 object +*/ std::string EAC_Signed_Object::PEM_encode() const { Pipe pem; @@ -32,17 +34,17 @@ std::string EAC_Signed_Object::PEM_encode() const return pem.read_all_as_string(); } -/************************************************* -* Return the algorithm used to sign this object * -*************************************************/ +/* +* Return the algorithm used to sign this object +*/ AlgorithmIdentifier EAC_Signed_Object::signature_algorithm() const { return sig_algo; } -/************************************************* -* Try to decode the actual information * -*************************************************/ +/* +* Try to decode the actual information +*/ void EAC_Signed_Object::do_decode() { try { diff --git a/src/cert/cvc/signed_obj.h b/src/cert/cvc/signed_obj.h index 918a20db5..3c233d21b 100644 --- a/src/cert/cvc/signed_obj.h +++ b/src/cert/cvc/signed_obj.h @@ -1,8 +1,10 @@ -/************************************************* -* EAC SIGNED Object Header File * -* (C) 2007 FlexSecure GmbH * -* 2008 Jack Lloyd * -*************************************************/ +/* +* EAC SIGNED Object +* (C) 2007 FlexSecure GmbH +* 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_EAC_SIGNED_OBJECT_H__ #define BOTAN_EAC_SIGNED_OBJECT_H__ diff --git a/src/cert/x509/certstor.cpp b/src/cert/x509/certstor.cpp index 2b51590ad..96f2699df 100644 --- a/src/cert/x509/certstor.cpp +++ b/src/cert/x509/certstor.cpp @@ -1,42 +1,44 @@ -/************************************************* -* Certificate Store Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* Certificate Store +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/certstor.h> namespace Botan { -/************************************************* -* Search by name * -*************************************************/ +/* +* Search by name +*/ std::vector<X509_Certificate> Certificate_Store::by_name(const std::string&) const { return std::vector<X509_Certificate>(); } -/************************************************* -* Search by email * -*************************************************/ +/* +* Search by email +*/ std::vector<X509_Certificate> Certificate_Store::by_email(const std::string&) const { return std::vector<X509_Certificate>(); } -/************************************************* -* Search by X.500 distinguished name * -*************************************************/ +/* +* Search by X.500 distinguished name +*/ std::vector<X509_Certificate> Certificate_Store::by_dn(const X509_DN&) const { return std::vector<X509_Certificate>(); } -/************************************************* -* Find any CRLs that might be useful * -*************************************************/ +/* +* Find any CRLs that might be useful +*/ std::vector<X509_CRL> Certificate_Store::get_crls_for(const X509_Certificate&) const { diff --git a/src/cert/x509/certstor.h b/src/cert/x509/certstor.h index ca0480496..d5004e366 100644 --- a/src/cert/x509/certstor.h +++ b/src/cert/x509/certstor.h @@ -1,7 +1,9 @@ -/************************************************* -* Certificate Store Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* Certificate Store +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_CERT_STORE_H__ #define BOTAN_CERT_STORE_H__ @@ -11,9 +13,9 @@ namespace Botan { -/************************************************* -* Certificate Store Interface * -*************************************************/ +/* +* Certificate Store Interface +*/ class BOTAN_DLL Certificate_Store { public: diff --git a/src/cert/x509/crl_ent.cpp b/src/cert/x509/crl_ent.cpp index dbf550f13..afea8cf6b 100644 --- a/src/cert/x509/crl_ent.cpp +++ b/src/cert/x509/crl_ent.cpp @@ -1,7 +1,9 @@ -/************************************************* -* CRL Entry Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* CRL Entry +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/crl_ent.h> #include <botan/x509_ext.h> @@ -13,18 +15,18 @@ namespace Botan { -/************************************************* -* Create a CRL_Entry * -*************************************************/ +/* +* Create a CRL_Entry +*/ CRL_Entry::CRL_Entry(bool t_on_unknown_crit) : throw_on_unknown_critical(t_on_unknown_crit) { reason = UNSPECIFIED; } -/************************************************* -* Create a CRL_Entry * -*************************************************/ +/* +* Create a CRL_Entry +*/ CRL_Entry::CRL_Entry(const X509_Certificate& cert, CRL_Code why) : throw_on_unknown_critical(false) { @@ -33,9 +35,9 @@ CRL_Entry::CRL_Entry(const X509_Certificate& cert, CRL_Code why) : reason = why; } -/************************************************* -* Compare two CRL_Entrys for equality * -*************************************************/ +/* +* Compare two CRL_Entrys for equality +*/ bool operator==(const CRL_Entry& a1, const CRL_Entry& a2) { if(a1.serial_number() != a2.serial_number()) @@ -47,25 +49,25 @@ bool operator==(const CRL_Entry& a1, const CRL_Entry& a2) return true; } -/************************************************* -* Compare two CRL_Entrys for inequality * -*************************************************/ +/* +* Compare two CRL_Entrys for inequality +*/ bool operator!=(const CRL_Entry& a1, const CRL_Entry& a2) { return !(a1 == a2); } -/************************************************* -* Compare two CRL_Entrys * -*************************************************/ +/* +* Compare two CRL_Entrys +*/ bool operator<(const CRL_Entry& a1, const CRL_Entry& a2) { return (a1.expire_time().cmp(a2.expire_time()) < 0); } -/************************************************* -* DER encode a CRL_Entry * -*************************************************/ +/* +* DER encode a CRL_Entry +*/ void CRL_Entry::encode_into(DER_Encoder& der) const { Extensions extensions; @@ -79,9 +81,9 @@ void CRL_Entry::encode_into(DER_Encoder& der) const .end_cons(); } -/************************************************* -* Decode a BER encoded CRL_Entry * -*************************************************/ +/* +* Decode a BER encoded CRL_Entry +*/ void CRL_Entry::decode_from(BER_Decoder& source) { BigInt serial_number_bn; diff --git a/src/cert/x509/crl_ent.h b/src/cert/x509/crl_ent.h index 40d82a8d7..050356c84 100644 --- a/src/cert/x509/crl_ent.h +++ b/src/cert/x509/crl_ent.h @@ -1,7 +1,9 @@ -/************************************************* -* CRL Entry Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* CRL Entry +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_CRL_ENTRY_H__ #define BOTAN_CRL_ENTRY_H__ diff --git a/src/cert/x509/pkcs10.cpp b/src/cert/x509/pkcs10.cpp index bd21cca7d..5617cece4 100644 --- a/src/cert/x509/pkcs10.cpp +++ b/src/cert/x509/pkcs10.cpp @@ -1,7 +1,9 @@ -/************************************************* -* PKCS #10 Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* PKCS #10 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/pkcs10.h> #include <botan/der_enc.h> @@ -14,27 +16,27 @@ namespace Botan { -/************************************************* -* PKCS10_Request Constructor * -*************************************************/ +/* +* PKCS10_Request Constructor +*/ PKCS10_Request::PKCS10_Request(DataSource& in) : X509_Object(in, "CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST") { do_decode(); } -/************************************************* -* PKCS10_Request Constructor * -*************************************************/ +/* +* PKCS10_Request Constructor +*/ PKCS10_Request::PKCS10_Request(const std::string& in) : X509_Object(in, "CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST") { do_decode(); } -/************************************************* -* Deocde the CertificateRequestInfo * -*************************************************/ +/* +* Deocde the CertificateRequestInfo +*/ void PKCS10_Request::force_decode() { BER_Decoder cert_req_info(tbs_bits); @@ -87,9 +89,9 @@ void PKCS10_Request::force_decode() throw Decoding_Error("PKCS #10 request: Bad signature detected"); } -/************************************************* -* Handle attributes in a PKCS #10 request * -*************************************************/ +/* +* Handle attributes in a PKCS #10 request +*/ void PKCS10_Request::handle_attribute(const Attribute& attr) { BER_Decoder value(attr.parameters); @@ -116,59 +118,59 @@ void PKCS10_Request::handle_attribute(const Attribute& attr) } } -/************************************************* -* Return the challenge password (if any) * -*************************************************/ +/* +* Return the challenge password (if any) +*/ std::string PKCS10_Request::challenge_password() const { return info.get1("PKCS9.ChallengePassword"); } -/************************************************* -* Return the name of the requestor * -*************************************************/ +/* +* Return the name of the requestor +*/ X509_DN PKCS10_Request::subject_dn() const { return create_dn(info); } -/************************************************* -* Return the public key of the requestor * -*************************************************/ +/* +* Return the public key of the requestor +*/ MemoryVector<byte> PKCS10_Request::raw_public_key() const { DataSource_Memory source(info.get1("X509.Certificate.public_key")); return PEM_Code::decode_check_label(source, "PUBLIC KEY"); } -/************************************************* -* Return the public key of the requestor * -*************************************************/ +/* +* Return the public key of the requestor +*/ Public_Key* PKCS10_Request::subject_public_key() const { DataSource_Memory source(info.get1("X509.Certificate.public_key")); return X509::load_key(source); } -/************************************************* -* Return the alternative names of the requestor * -*************************************************/ +/* +* Return the alternative names of the requestor +*/ AlternativeName PKCS10_Request::subject_alt_name() const { return create_alt_name(info); } -/************************************************* -* Return the key constraints (if any) * -*************************************************/ +/* +* Return the key constraints (if any) +*/ Key_Constraints PKCS10_Request::constraints() const { return Key_Constraints(info.get1_u32bit("X509v3.KeyUsage", NO_CONSTRAINTS)); } -/************************************************* -* Return the extendend key constraints (if any) * -*************************************************/ +/* +* Return the extendend key constraints (if any) +*/ std::vector<OID> PKCS10_Request::ex_constraints() const { std::vector<std::string> oids = info.get("X509v3.ExtendedKeyUsage"); @@ -179,17 +181,17 @@ std::vector<OID> PKCS10_Request::ex_constraints() const return result; } -/************************************************* -* Return is a CA certificate is requested * -*************************************************/ +/* +* Return is a CA certificate is requested +*/ bool PKCS10_Request::is_CA() const { return info.get1_u32bit("X509v3.BasicConstraints.is_ca"); } -/************************************************* -* Return the desired path limit (if any) * -*************************************************/ +/* +* Return the desired path limit (if any) +*/ u32bit PKCS10_Request::path_limit() const { return info.get1_u32bit("X509v3.BasicConstraints.path_constraint", 0); diff --git a/src/cert/x509/pkcs10.h b/src/cert/x509/pkcs10.h index c755bdfad..9b435de52 100644 --- a/src/cert/x509/pkcs10.h +++ b/src/cert/x509/pkcs10.h @@ -1,7 +1,9 @@ -/************************************************* -* PKCS #10 Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* PKCS #10 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_PKCS10_H__ #define BOTAN_PKCS10_H__ diff --git a/src/cert/x509/x509_ca.cpp b/src/cert/x509/x509_ca.cpp index 2f158e27f..41e314724 100644 --- a/src/cert/x509/x509_ca.cpp +++ b/src/cert/x509/x509_ca.cpp @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Authority Source File * -* (C) 1999-2008 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Authority +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509_ca.h> #include <botan/x509stor.h> @@ -20,9 +22,9 @@ namespace Botan { -/************************************************* -* Load the certificate and private key * -*************************************************/ +/* +* Load the certificate and private key +*/ X509_CA::X509_CA(const X509_Certificate& c, const Private_Key& key) : cert(c) { @@ -36,9 +38,9 @@ X509_CA::X509_CA(const X509_Certificate& c, signer = choose_sig_format(key, ca_sig_algo); } -/************************************************* -* Sign a PKCS #10 certificate request * -*************************************************/ +/* +* Sign a PKCS #10 certificate request +*/ X509_Certificate X509_CA::sign_request(const PKCS10_Request& req, RandomNumberGenerator& rng, const X509_Time& not_before, @@ -74,9 +76,9 @@ X509_Certificate X509_CA::sign_request(const PKCS10_Request& req, extensions); } -/************************************************* -* Create a new certificate * -*************************************************/ +/* +* Create a new certificate +*/ X509_Certificate X509_CA::make_cert(PK_Signer* signer, RandomNumberGenerator& rng, const AlgorithmIdentifier& sig_algo, @@ -123,9 +125,9 @@ X509_Certificate X509_CA::make_cert(PK_Signer* signer, return X509_Certificate(source); } -/************************************************* -* Create a new, empty CRL * -*************************************************/ +/* +* Create a new, empty CRL +*/ X509_CRL X509_CA::new_crl(RandomNumberGenerator& rng, u32bit next_update) const { @@ -133,9 +135,9 @@ X509_CRL X509_CA::new_crl(RandomNumberGenerator& rng, return make_crl(empty, 1, next_update, rng); } -/************************************************* -* Update a CRL with new entries * -*************************************************/ +/* +* Update a CRL with new entries +*/ X509_CRL X509_CA::update_crl(const X509_CRL& crl, const std::vector<CRL_Entry>& new_revoked, RandomNumberGenerator& rng, @@ -175,9 +177,9 @@ X509_CRL X509_CA::update_crl(const X509_CRL& crl, return make_crl(cert_list, crl.crl_number() + 1, next_update, rng); } -/************************************************* -* Create a CRL * -*************************************************/ +/* +* Create a CRL +*/ X509_CRL X509_CA::make_crl(const std::vector<CRL_Entry>& revoked, u32bit crl_number, u32bit next_update, RandomNumberGenerator& rng) const @@ -220,25 +222,25 @@ X509_CRL X509_CA::make_crl(const std::vector<CRL_Entry>& revoked, return X509_CRL(source); } -/************************************************* -* Return the CA's certificate * -*************************************************/ +/* +* Return the CA's certificate +*/ X509_Certificate X509_CA::ca_certificate() const { return cert; } -/************************************************* -* X509_CA Destructor * -*************************************************/ +/* +* X509_CA Destructor +*/ X509_CA::~X509_CA() { delete signer; } -/************************************************* -* Choose a signing format for the key * -*************************************************/ +/* +* Choose a signing format for the key +*/ PK_Signer* choose_sig_format(const Private_Key& key, AlgorithmIdentifier& sig_algo) { diff --git a/src/cert/x509/x509_ca.h b/src/cert/x509/x509_ca.h index 8f78181b2..ef2a8d134 100644 --- a/src/cert/x509/x509_ca.h +++ b/src/cert/x509/x509_ca.h @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Authority Header File * -* (C) 1999-2008 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Authority +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_X509_CA_H__ #define BOTAN_X509_CA_H__ diff --git a/src/cert/x509/x509_crl.cpp b/src/cert/x509/x509_crl.cpp index 6805abef6..f6a344dba 100644 --- a/src/cert/x509/x509_crl.cpp +++ b/src/cert/x509/x509_crl.cpp @@ -1,7 +1,9 @@ -/************************************************* -* X.509 CRL Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 CRL +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509_crl.h> #include <botan/x509_ext.h> @@ -12,27 +14,27 @@ namespace Botan { -/************************************************* -* Load a X.509 CRL * -*************************************************/ +/* +* Load a X.509 CRL +*/ X509_CRL::X509_CRL(DataSource& in, bool touc) : X509_Object(in, "X509 CRL/CRL"), throw_on_unknown_critical(touc) { do_decode(); } -/************************************************* -* Load a X.509 CRL * -*************************************************/ +/* +* Load a X.509 CRL +*/ X509_CRL::X509_CRL(const std::string& in, bool touc) : X509_Object(in, "CRL/X509 CRL"), throw_on_unknown_critical(touc) { do_decode(); } -/************************************************* -* Decode the TBSCertList data * -*************************************************/ +/* +* Decode the TBSCertList data +*/ void X509_CRL::force_decode() { BER_Decoder tbs_crl(tbs_bits); @@ -94,49 +96,49 @@ void X509_CRL::force_decode() tbs_crl.verify_end(); } -/************************************************* -* Return the list of revoked certificates * -*************************************************/ +/* +* Return the list of revoked certificates +*/ std::vector<CRL_Entry> X509_CRL::get_revoked() const { return revoked; } -/************************************************* -* Return the distinguished name of the issuer * -*************************************************/ +/* +* Return the distinguished name of the issuer +*/ X509_DN X509_CRL::issuer_dn() const { return create_dn(info); } -/************************************************* -* Return the key identifier of the issuer * -*************************************************/ +/* +* Return the key identifier of the issuer +*/ MemoryVector<byte> X509_CRL::authority_key_id() const { return info.get1_memvec("X509v3.AuthorityKeyIdentifier"); } -/************************************************* -* Return the CRL number of this CRL * -*************************************************/ +/* +* Return the CRL number of this CRL +*/ u32bit X509_CRL::crl_number() const { return info.get1_u32bit("X509v3.CRLNumber"); } -/************************************************* -* Return the issue data of the CRL * -*************************************************/ +/* +* Return the issue data of the CRL +*/ X509_Time X509_CRL::this_update() const { return info.get1("X509.CRL.start"); } -/************************************************* -* Return the date when a new CRL will be issued * -*************************************************/ +/* +* Return the date when a new CRL will be issued +*/ X509_Time X509_CRL::next_update() const { return info.get1("X509.CRL.end"); diff --git a/src/cert/x509/x509_crl.h b/src/cert/x509/x509_crl.h index dd1ea372e..6caef42cc 100644 --- a/src/cert/x509/x509_crl.h +++ b/src/cert/x509/x509_crl.h @@ -1,7 +1,9 @@ -/************************************************* -* X.509 CRL Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 CRL +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_X509_CRL_H__ #define BOTAN_X509_CRL_H__ diff --git a/src/cert/x509/x509_ext.cpp b/src/cert/x509/x509_ext.cpp index 54e8be8bd..5e07cbd27 100644 --- a/src/cert/x509/x509_ext.cpp +++ b/src/cert/x509/x509_ext.cpp @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Extensions Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Extensions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509_ext.h> #include <botan/sha160.h> @@ -15,9 +17,9 @@ namespace Botan { -/************************************************* -* List of X.509 Certificate Extensions * -*************************************************/ +/* +* List of X.509 Certificate Extensions +*/ Certificate_Extension* Extensions::get_extension(const OID& oid) { #define X509_EXTENSION(NAME, TYPE) \ @@ -37,17 +39,17 @@ Certificate_Extension* Extensions::get_extension(const OID& oid) return 0; } -/************************************************* -* Extensions Copy Constructor * -*************************************************/ +/* +* Extensions Copy Constructor +*/ Extensions::Extensions(const Extensions& extensions) : ASN1_Object() { *this = extensions; } -/************************************************* -* Extensions Assignment Operator * -*************************************************/ +/* +* Extensions Assignment Operator +*/ Extensions& Extensions::operator=(const Extensions& other) { for(u32bit j = 0; j != extensions.size(); ++j) @@ -60,17 +62,17 @@ Extensions& Extensions::operator=(const Extensions& other) return (*this); } -/************************************************* -* Return the OID of this extension * -*************************************************/ +/* +* Return the OID of this extension +*/ OID Certificate_Extension::oid_of() const { return OIDS::lookup(oid_name()); } -/************************************************* -* Encode an Extensions list * -*************************************************/ +/* +* Encode an Extensions list +*/ void Extensions::encode_into(DER_Encoder& to_object) const { for(u32bit j = 0; j != extensions.size(); ++j) @@ -104,9 +106,9 @@ void Extensions::encode_into(DER_Encoder& to_object) const } } -/************************************************* -* Decode a list of Extensions * -*************************************************/ +/* +* Decode a list of Extensions +*/ void Extensions::decode_from(BER_Decoder& from_source) { for(u32bit j = 0; j != extensions.size(); ++j) @@ -145,9 +147,9 @@ void Extensions::decode_from(BER_Decoder& from_source) sequence.verify_end(); } -/************************************************* -* Write the extensions to an info store * -*************************************************/ +/* +* Write the extensions to an info store +*/ void Extensions::contents_to(Data_Store& subject_info, Data_Store& issuer_info) const { @@ -155,9 +157,9 @@ void Extensions::contents_to(Data_Store& subject_info, extensions[j]->contents_to(subject_info, issuer_info); } -/************************************************* -* Delete an Extensions list * -*************************************************/ +/* +* Delete an Extensions list +*/ Extensions::~Extensions() { for(u32bit j = 0; j != extensions.size(); ++j) @@ -166,9 +168,9 @@ Extensions::~Extensions() namespace Cert_Extension { -/************************************************* -* Checked accessor for the path_limit member * -*************************************************/ +/* +* Checked accessor for the path_limit member +*/ u32bit Basic_Constraints::get_path_limit() const { if(!is_ca) @@ -176,9 +178,9 @@ u32bit Basic_Constraints::get_path_limit() const return path_limit; } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> Basic_Constraints::encode_inner() const { return DER_Encoder() @@ -192,9 +194,9 @@ MemoryVector<byte> Basic_Constraints::encode_inner() const .get_contents(); } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void Basic_Constraints::decode_inner(const MemoryRegion<byte>& in) { BER_Decoder(in) @@ -208,18 +210,18 @@ void Basic_Constraints::decode_inner(const MemoryRegion<byte>& in) path_limit = 0; } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void Basic_Constraints::contents_to(Data_Store& subject, Data_Store&) const { subject.add("X509v3.BasicConstraints.is_ca", (is_ca ? 1 : 0)); subject.add("X509v3.BasicConstraints.path_constraint", path_limit); } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> Key_Usage::encode_inner() const { if(constraints == NO_CONSTRAINTS) @@ -238,9 +240,9 @@ MemoryVector<byte> Key_Usage::encode_inner() const return der; } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void Key_Usage::decode_inner(const MemoryRegion<byte>& in) { BER_Decoder ber(in); @@ -266,50 +268,50 @@ void Key_Usage::decode_inner(const MemoryRegion<byte>& in) constraints = Key_Constraints(usage); } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void Key_Usage::contents_to(Data_Store& subject, Data_Store&) const { subject.add("X509v3.KeyUsage", constraints); } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> Subject_Key_ID::encode_inner() const { return DER_Encoder().encode(key_id, OCTET_STRING).get_contents(); } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void Subject_Key_ID::decode_inner(const MemoryRegion<byte>& in) { BER_Decoder(in).decode(key_id, OCTET_STRING).verify_end(); } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void Subject_Key_ID::contents_to(Data_Store& subject, Data_Store&) const { subject.add("X509v3.SubjectKeyIdentifier", key_id); } -/************************************************* -* Subject_Key_ID Constructor * -*************************************************/ +/* +* Subject_Key_ID Constructor +*/ Subject_Key_ID::Subject_Key_ID(const MemoryRegion<byte>& pub_key) { SHA_160 hash; key_id = hash.process(pub_key); } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> Authority_Key_ID::encode_inner() const { return DER_Encoder() @@ -319,9 +321,9 @@ MemoryVector<byte> Authority_Key_ID::encode_inner() const .get_contents(); } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void Authority_Key_ID::decode_inner(const MemoryRegion<byte>& in) { BER_Decoder(in) @@ -329,34 +331,34 @@ void Authority_Key_ID::decode_inner(const MemoryRegion<byte>& in) .decode_optional_string(key_id, OCTET_STRING, 0); } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void Authority_Key_ID::contents_to(Data_Store&, Data_Store& issuer) const { if(key_id.size()) issuer.add("X509v3.AuthorityKeyIdentifier", key_id); } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> Alternative_Name::encode_inner() const { return DER_Encoder().encode(alt_name).get_contents(); } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void Alternative_Name::decode_inner(const MemoryRegion<byte>& in) { BER_Decoder(in).decode(alt_name); } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void Alternative_Name::contents_to(Data_Store& subject_info, Data_Store& issuer_info) const { @@ -372,9 +374,9 @@ void Alternative_Name::contents_to(Data_Store& subject_info, oid_name_str); } -/************************************************* -* Alternative_Name Constructor * -*************************************************/ +/* +* Alternative_Name Constructor +*/ Alternative_Name::Alternative_Name(const AlternativeName& alt_name, const std::string& oid_name_str, const std::string& config_name_str) @@ -384,9 +386,9 @@ Alternative_Name::Alternative_Name(const AlternativeName& alt_name, this->config_name_str = config_name_str; } -/************************************************* -* Subject_Alternative_Name Constructor * -*************************************************/ +/* +* Subject_Alternative_Name Constructor +*/ Subject_Alternative_Name::Subject_Alternative_Name( const AlternativeName& name) : @@ -395,18 +397,18 @@ Subject_Alternative_Name::Subject_Alternative_Name( { } -/************************************************* -* Issuer_Alternative_Name Constructor * -*************************************************/ +/* +* Issuer_Alternative_Name Constructor +*/ Issuer_Alternative_Name::Issuer_Alternative_Name(const AlternativeName& name) : Alternative_Name(name, "X509v3.IssuerAlternativeName", "issuer_alternative_name") { } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> Extended_Key_Usage::encode_inner() const { return DER_Encoder() @@ -416,9 +418,9 @@ MemoryVector<byte> Extended_Key_Usage::encode_inner() const .get_contents(); } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void Extended_Key_Usage::decode_inner(const MemoryRegion<byte>& in) { BER_Decoder(in) @@ -427,9 +429,9 @@ void Extended_Key_Usage::decode_inner(const MemoryRegion<byte>& in) .end_cons(); } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void Extended_Key_Usage::contents_to(Data_Store& subject, Data_Store&) const { for(u32bit j = 0; j != oids.size(); ++j) @@ -438,9 +440,9 @@ void Extended_Key_Usage::contents_to(Data_Store& subject, Data_Store&) const namespace { -/************************************************* -* A policy specifier * -*************************************************/ +/* +* A policy specifier +*/ class Policy_Information : public ASN1_Object { public: @@ -464,9 +466,9 @@ class Policy_Information : public ASN1_Object } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> Certificate_Policies::encode_inner() const { throw Exception("Certificate_Policies::encode_inner: Bugged"); @@ -480,9 +482,9 @@ MemoryVector<byte> Certificate_Policies::encode_inner() const .get_contents(); } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void Certificate_Policies::decode_inner(const MemoryRegion<byte>& in) { std::vector<Policy_Information> policies; @@ -493,18 +495,18 @@ void Certificate_Policies::decode_inner(const MemoryRegion<byte>& in) .end_cons(); } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void Certificate_Policies::contents_to(Data_Store& info, Data_Store&) const { for(u32bit j = 0; j != oids.size(); ++j) info.add("X509v3.ExtendedKeyUsage", oids[j].as_string()); } -/************************************************* -* Checked accessor for the crl_number member * -*************************************************/ +/* +* Checked accessor for the crl_number member +*/ u32bit CRL_Number::get_crl_number() const { if(!has_value) @@ -512,9 +514,9 @@ u32bit CRL_Number::get_crl_number() const return crl_number; } -/************************************************* -* Copy a CRL_Number extension * -*************************************************/ +/* +* Copy a CRL_Number extension +*/ CRL_Number* CRL_Number::copy() const { if(!has_value) @@ -522,33 +524,33 @@ CRL_Number* CRL_Number::copy() const return new CRL_Number(crl_number); } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> CRL_Number::encode_inner() const { return DER_Encoder().encode(crl_number).get_contents(); } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void CRL_Number::decode_inner(const MemoryRegion<byte>& in) { BER_Decoder(in).decode(crl_number); } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void CRL_Number::contents_to(Data_Store& info, Data_Store&) const { info.add("X509v3.CRLNumber", crl_number); } -/************************************************* -* Encode the extension * -*************************************************/ +/* +* Encode the extension +*/ MemoryVector<byte> CRL_ReasonCode::encode_inner() const { return DER_Encoder() @@ -556,9 +558,9 @@ MemoryVector<byte> CRL_ReasonCode::encode_inner() const .get_contents(); } -/************************************************* -* Decode the extension * -*************************************************/ +/* +* Decode the extension +*/ void CRL_ReasonCode::decode_inner(const MemoryRegion<byte>& in) { u32bit reason_code = 0; @@ -566,9 +568,9 @@ void CRL_ReasonCode::decode_inner(const MemoryRegion<byte>& in) reason = static_cast<CRL_Code>(reason_code); } -/************************************************* -* Return a textual representation * -*************************************************/ +/* +* Return a textual representation +*/ void CRL_ReasonCode::contents_to(Data_Store& info, Data_Store&) const { info.add("X509v3.CRLReasonCode", reason); diff --git a/src/cert/x509/x509_ext.h b/src/cert/x509/x509_ext.h index 6b055ea29..108215ee7 100644 --- a/src/cert/x509/x509_ext.h +++ b/src/cert/x509/x509_ext.h @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Extensions Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Extensions +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_X509_EXTENSIONS_H__ #define BOTAN_X509_EXTENSIONS_H__ @@ -14,9 +16,9 @@ namespace Botan { -/************************************************* -* X.509 Certificate Extension * -*************************************************/ +/* +* X.509 Certificate Extension +*/ class BOTAN_DLL Certificate_Extension { public: @@ -36,9 +38,9 @@ class BOTAN_DLL Certificate_Extension virtual void decode_inner(const MemoryRegion<byte>&) = 0; }; -/************************************************* -* X.509 Certificate Extension List * -*************************************************/ +/* +* X.509 Certificate Extension List +*/ class BOTAN_DLL Extensions : public ASN1_Object { public: @@ -64,9 +66,9 @@ class BOTAN_DLL Extensions : public ASN1_Object namespace Cert_Extension { -/************************************************* -* Basic Constraints Extension * -*************************************************/ +/* +* Basic Constraints Extension +*/ class BOTAN_DLL Basic_Constraints : public Certificate_Extension { public: @@ -90,9 +92,9 @@ class BOTAN_DLL Basic_Constraints : public Certificate_Extension u32bit path_limit; }; -/************************************************* -* Key Usage Constraints Extension * -*************************************************/ +/* +* Key Usage Constraints Extension +*/ class BOTAN_DLL Key_Usage : public Certificate_Extension { public: @@ -113,9 +115,9 @@ class BOTAN_DLL Key_Usage : public Certificate_Extension Key_Constraints constraints; }; -/************************************************* -* Subject Key Identifier Extension * -*************************************************/ +/* +* Subject Key Identifier Extension +*/ class BOTAN_DLL Subject_Key_ID : public Certificate_Extension { public: @@ -137,9 +139,9 @@ class BOTAN_DLL Subject_Key_ID : public Certificate_Extension MemoryVector<byte> key_id; }; -/************************************************* -* Authority Key Identifier Extension * -*************************************************/ +/* +* Authority Key Identifier Extension +*/ class BOTAN_DLL Authority_Key_ID : public Certificate_Extension { public: @@ -161,9 +163,9 @@ class BOTAN_DLL Authority_Key_ID : public Certificate_Extension MemoryVector<byte> key_id; }; -/************************************************* -* Alternative Name Extension Base Class * -*************************************************/ +/* +* Alternative Name Extension Base Class +*/ class BOTAN_DLL Alternative_Name : public Certificate_Extension { public: @@ -187,9 +189,9 @@ class BOTAN_DLL Alternative_Name : public Certificate_Extension AlternativeName alt_name; }; -/************************************************* -* Subject Alternative Name Extension * -*************************************************/ +/* +* Subject Alternative Name Extension +*/ class BOTAN_DLL Subject_Alternative_Name : public Alternative_Name { public: @@ -199,9 +201,9 @@ class BOTAN_DLL Subject_Alternative_Name : public Alternative_Name Subject_Alternative_Name(const AlternativeName& = AlternativeName()); }; -/************************************************* -* Issuer Alternative Name Extension * -*************************************************/ +/* +* Issuer Alternative Name Extension +*/ class BOTAN_DLL Issuer_Alternative_Name : public Alternative_Name { public: @@ -211,9 +213,9 @@ class BOTAN_DLL Issuer_Alternative_Name : public Alternative_Name Issuer_Alternative_Name(const AlternativeName& = AlternativeName()); }; -/************************************************* -* Extended Key Usage Extension * -*************************************************/ +/* +* Extended Key Usage Extension +*/ class BOTAN_DLL Extended_Key_Usage : public Certificate_Extension { public: @@ -235,9 +237,9 @@ class BOTAN_DLL Extended_Key_Usage : public Certificate_Extension std::vector<OID> oids; }; -/************************************************* -* Certificate Policies Extension * -*************************************************/ +/* +* Certificate Policies Extension +*/ class BOTAN_DLL Certificate_Policies : public Certificate_Extension { public: @@ -260,9 +262,9 @@ class BOTAN_DLL Certificate_Policies : public Certificate_Extension std::vector<OID> oids; }; -/************************************************* -* CRL Number Extension * -*************************************************/ +/* +* CRL Number Extension +*/ class BOTAN_DLL CRL_Number : public Certificate_Extension { public: @@ -285,9 +287,9 @@ class BOTAN_DLL CRL_Number : public Certificate_Extension u32bit crl_number; }; -/************************************************* -* CRL Entry Reason Code Extension * -*************************************************/ +/* +* CRL Entry Reason Code Extension +*/ class BOTAN_DLL CRL_ReasonCode : public Certificate_Extension { public: diff --git a/src/cert/x509/x509_obj.cpp b/src/cert/x509/x509_obj.cpp index e78790949..31b4a309f 100644 --- a/src/cert/x509/x509_obj.cpp +++ b/src/cert/x509/x509_obj.cpp @@ -1,7 +1,9 @@ -/************************************************* -* X.509 SIGNED Object Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 SIGNED Object +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509_obj.h> #include <botan/x509_key.h> @@ -16,26 +18,26 @@ namespace Botan { -/************************************************* -* Create a generic X.509 object * -*************************************************/ +/* +* Create a generic X.509 object +*/ X509_Object::X509_Object(DataSource& stream, const std::string& labels) { init(stream, labels); } -/************************************************* -* Createa a generic X.509 object * -*************************************************/ +/* +* Createa a generic X.509 object +*/ X509_Object::X509_Object(const std::string& file, const std::string& labels) { DataSource_Stream stream(file, true); init(stream, labels); } -/************************************************* -* Read a PEM or BER X.509 object * -*************************************************/ +/* +* Read a PEM or BER X.509 object +*/ void X509_Object::init(DataSource& in, const std::string& labels) { PEM_labels_allowed = split_on(labels, '/'); @@ -65,9 +67,9 @@ void X509_Object::init(DataSource& in, const std::string& labels) } } -/************************************************* -* Read a BER encoded X.509 object * -*************************************************/ +/* +* Read a BER encoded X.509 object +*/ void X509_Object::decode_info(DataSource& source) { BER_Decoder(source) @@ -81,9 +83,9 @@ void X509_Object::decode_info(DataSource& source) .end_cons(); } -/************************************************* -* Return a BER or PEM encoded X.509 object * -*************************************************/ +/* +* Return a BER or PEM encoded X.509 object +*/ void X509_Object::encode(Pipe& out, X509_Encoding encoding) const { SecureVector<byte> der = DER_Encoder() @@ -102,9 +104,9 @@ void X509_Object::encode(Pipe& out, X509_Encoding encoding) const out.write(der); } -/************************************************* -* Return a BER encoded X.509 object * -*************************************************/ +/* +* Return a BER encoded X.509 object +*/ SecureVector<byte> X509_Object::BER_encode() const { Pipe ber; @@ -114,9 +116,9 @@ SecureVector<byte> X509_Object::BER_encode() const return ber.read_all(); } -/************************************************* -* Return a PEM encoded X.509 object * -*************************************************/ +/* +* Return a PEM encoded X.509 object +*/ std::string X509_Object::PEM_encode() const { Pipe pem; @@ -126,33 +128,33 @@ std::string X509_Object::PEM_encode() const return pem.read_all_as_string(); } -/************************************************* -* Return the TBS data * -*************************************************/ +/* +* Return the TBS data +*/ SecureVector<byte> X509_Object::tbs_data() const { return ASN1::put_in_sequence(tbs_bits); } -/************************************************* -* Return the signature of this object * -*************************************************/ +/* +* Return the signature of this object +*/ SecureVector<byte> X509_Object::signature() const { return sig; } -/************************************************* -* Return the algorithm used to sign this object * -*************************************************/ +/* +* Return the algorithm used to sign this object +*/ AlgorithmIdentifier X509_Object::signature_algorithm() const { return sig_algo; } -/************************************************* -* Check the signature on an object * -*************************************************/ +/* +* Check the signature on an object +*/ bool X509_Object::check_signature(Public_Key& pub_key) const { try { @@ -191,9 +193,9 @@ bool X509_Object::check_signature(Public_Key& pub_key) const } } -/************************************************* -* Apply the X.509 SIGNED macro * -*************************************************/ +/* +* Apply the X.509 SIGNED macro +*/ MemoryVector<byte> X509_Object::make_signed(PK_Signer* signer, RandomNumberGenerator& rng, const AlgorithmIdentifier& algo, @@ -208,9 +210,9 @@ MemoryVector<byte> X509_Object::make_signed(PK_Signer* signer, .get_contents(); } -/************************************************* -* Try to decode the actual information * -*************************************************/ +/* +* Try to decode the actual information +*/ void X509_Object::do_decode() { try { diff --git a/src/cert/x509/x509_obj.h b/src/cert/x509/x509_obj.h index d80560eb2..c7f92fa9d 100644 --- a/src/cert/x509/x509_obj.h +++ b/src/cert/x509/x509_obj.h @@ -1,7 +1,9 @@ -/************************************************* -* X.509 SIGNED Object Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 SIGNED Object +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_X509_OBJECT_H__ #define BOTAN_X509_OBJECT_H__ diff --git a/src/cert/x509/x509cert.cpp b/src/cert/x509/x509cert.cpp index b24e6a036..ac5839fb6 100644 --- a/src/cert/x509/x509cert.cpp +++ b/src/cert/x509/x509cert.cpp @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificates Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificates +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509cert.h> #include <botan/x509_ext.h> @@ -18,9 +20,9 @@ namespace Botan { namespace { -/************************************************* -* Lookup each OID in the vector * -*************************************************/ +/* +* Lookup each OID in the vector +*/ std::vector<std::string> lookup_oids(const std::vector<std::string>& in) { std::vector<std::string> out; @@ -36,9 +38,9 @@ std::vector<std::string> lookup_oids(const std::vector<std::string>& in) } -/************************************************* -* X509_Certificate Constructor * -*************************************************/ +/* +* X509_Certificate Constructor +*/ X509_Certificate::X509_Certificate(DataSource& in) : X509_Object(in, "CERTIFICATE/X509 CERTIFICATE") { @@ -46,9 +48,9 @@ X509_Certificate::X509_Certificate(DataSource& in) : do_decode(); } -/************************************************* -* X509_Certificate Constructor * -*************************************************/ +/* +* X509_Certificate Constructor +*/ X509_Certificate::X509_Certificate(const std::string& in) : X509_Object(in, "CERTIFICATE/X509 CERTIFICATE") { @@ -56,9 +58,9 @@ X509_Certificate::X509_Certificate(const std::string& in) : do_decode(); } -/************************************************* -* Decode the TBSCertificate data * -*************************************************/ +/* +* Decode the TBSCertificate data +*/ void X509_Certificate::force_decode() { u32bit version; @@ -141,60 +143,60 @@ void X509_Certificate::force_decode() } } -/************************************************* -* Return the X.509 version in use * -*************************************************/ +/* +* Return the X.509 version in use +*/ u32bit X509_Certificate::x509_version() const { return (subject.get1_u32bit("X509.Certificate.version") + 1); } -/************************************************* -* Return the time this cert becomes valid * -*************************************************/ +/* +* Return the time this cert becomes valid +*/ std::string X509_Certificate::start_time() const { return subject.get1("X509.Certificate.start"); } -/************************************************* -* Return the time this cert becomes invalid * -*************************************************/ +/* +* Return the time this cert becomes invalid +*/ std::string X509_Certificate::end_time() const { return subject.get1("X509.Certificate.end"); } -/************************************************* -* Return information about the subject * -*************************************************/ +/* +* Return information about the subject +*/ std::vector<std::string> X509_Certificate::subject_info(const std::string& what) const { return subject.get(X509_DN::deref_info_field(what)); } -/************************************************* -* Return information about the issuer * -*************************************************/ +/* +* Return information about the issuer +*/ std::vector<std::string> X509_Certificate::issuer_info(const std::string& what) const { return issuer.get(X509_DN::deref_info_field(what)); } -/************************************************* -* Return the public key in this certificate * -*************************************************/ +/* +* Return the public key in this certificate +*/ Public_Key* X509_Certificate::subject_public_key() const { DataSource_Memory source(subject.get1("X509.Certificate.public_key")); return X509::load_key(source); } -/************************************************* -* Check if the certificate is for a CA * -*************************************************/ +/* +* Check if the certificate is for a CA +*/ bool X509_Certificate::is_CA_cert() const { if(!subject.get1_u32bit("X509v3.BasicConstraints.is_ca")) @@ -204,82 +206,82 @@ bool X509_Certificate::is_CA_cert() const return false; } -/************************************************* -* Return the path length constraint * -*************************************************/ +/* +* Return the path length constraint +*/ u32bit X509_Certificate::path_limit() const { return subject.get1_u32bit("X509v3.BasicConstraints.path_constraint", 0); } -/************************************************* -* Return the key usage constraints * -*************************************************/ +/* +* Return the key usage constraints +*/ Key_Constraints X509_Certificate::constraints() const { return Key_Constraints(subject.get1_u32bit("X509v3.KeyUsage", NO_CONSTRAINTS)); } -/************************************************* -* Return the list of extended key usage OIDs * -*************************************************/ +/* +* Return the list of extended key usage OIDs +*/ std::vector<std::string> X509_Certificate::ex_constraints() const { return lookup_oids(subject.get("X509v3.ExtendedKeyUsage")); } -/************************************************* -* Return the list of certificate policies * -*************************************************/ +/* +* Return the list of certificate policies +*/ std::vector<std::string> X509_Certificate::policies() const { return lookup_oids(subject.get("X509v3.CertificatePolicies")); } -/************************************************* -* Return the authority key id * -*************************************************/ +/* +* Return the authority key id +*/ MemoryVector<byte> X509_Certificate::authority_key_id() const { return issuer.get1_memvec("X509v3.AuthorityKeyIdentifier"); } -/************************************************* -* Return the subject key id * -*************************************************/ +/* +* Return the subject key id +*/ MemoryVector<byte> X509_Certificate::subject_key_id() const { return subject.get1_memvec("X509v3.SubjectKeyIdentifier"); } -/************************************************* -* Return the certificate serial number * -*************************************************/ +/* +* Return the certificate serial number +*/ MemoryVector<byte> X509_Certificate::serial_number() const { return subject.get1_memvec("X509.Certificate.serial"); } -/************************************************* -* Return the distinguished name of the issuer * -*************************************************/ +/* +* Return the distinguished name of the issuer +*/ X509_DN X509_Certificate::issuer_dn() const { return create_dn(issuer); } -/************************************************* -* Return the distinguished name of the subject * -*************************************************/ +/* +* Return the distinguished name of the subject +*/ X509_DN X509_Certificate::subject_dn() const { return create_dn(subject); } -/************************************************* -* Compare two certificates for equality * -*************************************************/ +/* +* Compare two certificates for equality +*/ bool X509_Certificate::operator==(const X509_Certificate& other) const { return (sig == other.sig && @@ -289,17 +291,17 @@ bool X509_Certificate::operator==(const X509_Certificate& other) const subject == other.subject); } -/************************************************* -* X.509 Certificate Comparison * -*************************************************/ +/* +* X.509 Certificate Comparison +*/ bool operator!=(const X509_Certificate& cert1, const X509_Certificate& cert2) { return !(cert1 == cert2); } -/************************************************* -* Create and populate a X509_DN * -*************************************************/ +/* +* Create and populate a X509_DN +*/ X509_DN create_dn(const Data_Store& info) { class DN_Matcher : public Data_Store::Matcher @@ -325,9 +327,9 @@ X509_DN create_dn(const Data_Store& info) return dn; } -/************************************************* -* Create and populate an AlternativeName * -*************************************************/ +/* +* Create and populate an AlternativeName +*/ AlternativeName create_alt_name(const Data_Store& info) { class AltName_Matcher : public Data_Store::Matcher diff --git a/src/cert/x509/x509cert.h b/src/cert/x509/x509cert.h index c02085dcb..4a9d11f7f 100644 --- a/src/cert/x509/x509cert.h +++ b/src/cert/x509/x509cert.h @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificates Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificates +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_X509_CERTS_H__ #define BOTAN_X509_CERTS_H__ @@ -172,9 +174,9 @@ class BOTAN_DLL X509_Certificate : public X509_Object */ BOTAN_DLL bool operator!=(const X509_Certificate&, const X509_Certificate&); -/************************************************* -* Data Store Extraction Operations * -*************************************************/ +/* +* Data Store Extraction Operations +*/ BOTAN_DLL X509_DN create_dn(const Data_Store&); BOTAN_DLL AlternativeName create_alt_name(const Data_Store&); diff --git a/src/cert/x509/x509find.cpp b/src/cert/x509/x509find.cpp index 83d02449d..257367da9 100644 --- a/src/cert/x509/x509find.cpp +++ b/src/cert/x509/x509find.cpp @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Store Searching Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Store Searching +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509find.h> #include <botan/charset.h> @@ -11,9 +13,9 @@ namespace Botan { namespace { -/************************************************* -* Compare based on case-insensive substrings * -*************************************************/ +/* +* Compare based on case-insensive substrings +*/ bool substring_match(const std::string& searching_for, const std::string& found) { @@ -23,9 +25,9 @@ bool substring_match(const std::string& searching_for, return false; } -/************************************************* -* Compare based on case-insensive match * -*************************************************/ +/* +* Compare based on case-insensive match +*/ bool ignore_case(const std::string& searching_for, const std::string& found) { if(searching_for.size() != found.size()) @@ -37,9 +39,9 @@ bool ignore_case(const std::string& searching_for, const std::string& found) } -/************************************************* -* Search based on the contents of a DN entry * -*************************************************/ +/* +* Search based on the contents of a DN entry +*/ bool DN_Check::match(const X509_Certificate& cert) const { std::vector<std::string> info = cert.subject_info(dn_entry); @@ -50,9 +52,9 @@ bool DN_Check::match(const X509_Certificate& cert) const return false; } -/************************************************* -* DN_Check Constructor * -*************************************************/ +/* +* DN_Check Constructor +*/ DN_Check::DN_Check(const std::string& dn_entry, const std::string& looking_for, compare_fn func) { @@ -61,9 +63,9 @@ DN_Check::DN_Check(const std::string& dn_entry, const std::string& looking_for, compare = func; } -/************************************************* -* DN_Check Constructor * -*************************************************/ +/* +* DN_Check Constructor +*/ DN_Check::DN_Check(const std::string& dn_entry, const std::string& looking_for, Search_Type method) { @@ -78,9 +80,9 @@ DN_Check::DN_Check(const std::string& dn_entry, const std::string& looking_for, throw Invalid_Argument("Unknown method argument to DN_Check()"); } -/************************************************* -* Match by issuer and serial number * -*************************************************/ +/* +* Match by issuer and serial number +*/ bool IandS_Match::match(const X509_Certificate& cert) const { if(cert.serial_number() != serial) @@ -88,9 +90,9 @@ bool IandS_Match::match(const X509_Certificate& cert) const return (cert.issuer_dn() == issuer); } -/************************************************* -* IandS_Match Constructor * -*************************************************/ +/* +* IandS_Match Constructor +*/ IandS_Match::IandS_Match(const X509_DN& issuer, const MemoryRegion<byte>& serial) { @@ -98,9 +100,9 @@ IandS_Match::IandS_Match(const X509_DN& issuer, this->serial = serial; } -/************************************************* -* Match by subject key identifier * -*************************************************/ +/* +* Match by subject key identifier +*/ bool SKID_Match::match(const X509_Certificate& cert) const { return (cert.subject_key_id() == skid); diff --git a/src/cert/x509/x509find.h b/src/cert/x509/x509find.h index 65781199f..a7a84c7a5 100644 --- a/src/cert/x509/x509find.h +++ b/src/cert/x509/x509find.h @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Store Searching Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Store Searching +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_X509_CERT_STORE_SEARCH_H__ #define BOTAN_X509_CERT_STORE_SEARCH_H__ @@ -10,9 +12,9 @@ namespace Botan { -/************************************************* -* Search based on the contents of a DN entry * -*************************************************/ +/* +* Search based on the contents of a DN entry +*/ class BOTAN_DLL DN_Check : public X509_Store::Search_Func { public: @@ -28,9 +30,9 @@ class BOTAN_DLL DN_Check : public X509_Store::Search_Func compare_fn compare; }; -/************************************************* -* Search for a certificate by issuer/serial * -*************************************************/ +/* +* Search for a certificate by issuer/serial +*/ class BOTAN_DLL IandS_Match : public X509_Store::Search_Func { public: @@ -41,9 +43,9 @@ class BOTAN_DLL IandS_Match : public X509_Store::Search_Func MemoryVector<byte> serial; }; -/************************************************* -* Search for a certificate by subject keyid * -*************************************************/ +/* +* Search for a certificate by subject keyid +*/ class BOTAN_DLL SKID_Match : public X509_Store::Search_Func { public: diff --git a/src/cert/x509/x509opt.cpp b/src/cert/x509/x509opt.cpp index 716884ed5..de9d589a3 100644 --- a/src/cert/x509/x509opt.cpp +++ b/src/cert/x509/x509opt.cpp @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Options Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Options +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509self.h> #include <botan/util.h> @@ -11,58 +13,58 @@ namespace Botan { -/************************************************* -* Set when the certificate should become valid * -*************************************************/ +/* +* Set when the certificate should become valid +*/ void X509_Cert_Options::not_before(const std::string& time_string) { start = X509_Time(time_string); } -/************************************************* -* Set when the certificate should expire * -*************************************************/ +/* +* Set when the certificate should expire +*/ void X509_Cert_Options::not_after(const std::string& time_string) { end = X509_Time(time_string); } -/************************************************* -* Set key constraint information * -*************************************************/ +/* +* Set key constraint information +*/ void X509_Cert_Options::add_constraints(Key_Constraints usage) { constraints = usage; } -/************************************************* -* Set key constraint information * -*************************************************/ +/* +* Set key constraint information +*/ void X509_Cert_Options::add_ex_constraint(const OID& oid) { ex_constraints.push_back(oid); } -/************************************************* -* Set key constraint information * -*************************************************/ +/* +* Set key constraint information +*/ void X509_Cert_Options::add_ex_constraint(const std::string& oid_str) { ex_constraints.push_back(OIDS::lookup(oid_str)); } -/************************************************* -* Mark this certificate for CA usage * -*************************************************/ +/* +* Mark this certificate for CA usage +*/ void X509_Cert_Options::CA_key(u32bit limit) { is_CA = true; path_limit = limit; } -/************************************************* -* Do basic sanity checks * -*************************************************/ +/* +* Do basic sanity checks +*/ void X509_Cert_Options::sanity_check() const { if(common_name == "" || country == "") @@ -73,9 +75,9 @@ void X509_Cert_Options::sanity_check() const throw Encoding_Error("X509_Cert_Options: invalid time constraints"); } -/************************************************* -* Initialize the certificate options * -*************************************************/ +/* +* Initialize the certificate options +*/ X509_Cert_Options::X509_Cert_Options(const std::string& initial_opts, u32bit expiration_time_in_seconds) { diff --git a/src/cert/x509/x509self.cpp b/src/cert/x509/x509self.cpp index 6c3baae9b..8afb22a7e 100644 --- a/src/cert/x509/x509self.cpp +++ b/src/cert/x509/x509self.cpp @@ -1,7 +1,9 @@ -/************************************************* -* PKCS #10/Self Signed Cert Creation Source File * -* (C) 1999-2008 Jack Lloyd * -*************************************************/ +/* +* PKCS #10/Self Signed Cert Creation +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509self.h> #include <botan/x509_ext.h> @@ -16,9 +18,9 @@ namespace Botan { namespace { -/************************************************* -* Shared setup for self-signed items * -*************************************************/ +/* +* Shared setup for self-signed items +*/ MemoryVector<byte> shared_setup(const X509_Cert_Options& opts, const Private_Key& key) { @@ -36,9 +38,9 @@ MemoryVector<byte> shared_setup(const X509_Cert_Options& opts, return key_encoder.read_all(); } -/************************************************* -* Load information from the X509_Cert_Options * -*************************************************/ +/* +* Load information from the X509_Cert_Options +*/ void load_info(const X509_Cert_Options& opts, X509_DN& subject_dn, AlternativeName& subject_alt) { @@ -58,9 +60,9 @@ void load_info(const X509_Cert_Options& opts, X509_DN& subject_dn, namespace X509 { -/************************************************* -* Create a new self-signed X.509 certificate * -*************************************************/ +/* +* Create a new self-signed X.509 certificate +*/ X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts, const Private_Key& key, RandomNumberGenerator& rng) @@ -96,9 +98,9 @@ X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts, extensions); } -/************************************************* -* Create a PKCS #10 certificate request * -*************************************************/ +/* +* Create a PKCS #10 certificate request +*/ PKCS10_Request create_cert_req(const X509_Cert_Options& opts, const Private_Key& key, RandomNumberGenerator& rng) diff --git a/src/cert/x509/x509self.h b/src/cert/x509/x509self.h index 8e912ae83..bd3e29179 100644 --- a/src/cert/x509/x509self.h +++ b/src/cert/x509/x509self.h @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Self-Signed Certificate Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Self-Signed Certificate +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_X509_SELF_H__ #define BOTAN_X509_SELF_H__ diff --git a/src/cert/x509/x509stor.cpp b/src/cert/x509/x509stor.cpp index f050b33b1..cb61bc2d2 100644 --- a/src/cert/x509/x509stor.cpp +++ b/src/cert/x509/x509stor.cpp @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Store Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Store +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/x509stor.h> #include <botan/parsing.h> @@ -16,9 +18,9 @@ namespace Botan { namespace { -/************************************************* -* Do a validity check * -*************************************************/ +/* +* Do a validity check +*/ s32bit validity_check(const X509_Time& start, const X509_Time& end, u64bit current_time, u32bit slack) { @@ -31,9 +33,9 @@ s32bit validity_check(const X509_Time& start, const X509_Time& end, return VALID_TIME; } -/************************************************* -* Compare the value of unique ID fields * -*************************************************/ +/* +* Compare the value of unique ID fields +*/ bool compare_ids(const MemoryVector<byte>& id1, const MemoryVector<byte>& id2) { @@ -42,9 +44,9 @@ bool compare_ids(const MemoryVector<byte>& id1, return (id1 == id2); } -/************************************************* -* Check a particular usage restriction * -*************************************************/ +/* +* Check a particular usage restriction +*/ bool check_usage(const X509_Certificate& cert, X509_Store::Cert_Usage usage, X509_Store::Cert_Usage check_for, Key_Constraints constraints) { @@ -57,9 +59,9 @@ bool check_usage(const X509_Certificate& cert, X509_Store::Cert_Usage usage, return false; } -/************************************************* -* Check a particular usage restriction * -*************************************************/ +/* +* Check a particular usage restriction +*/ bool check_usage(const X509_Certificate& cert, X509_Store::Cert_Usage usage, X509_Store::Cert_Usage check_for, const std::string& usage_oid) @@ -76,9 +78,9 @@ bool check_usage(const X509_Certificate& cert, X509_Store::Cert_Usage usage, usage_oid); } -/************************************************* -* Check the usage restrictions * -*************************************************/ +/* +* Check the usage restrictions +*/ X509_Code usage_check(const X509_Certificate& cert, X509_Store::Cert_Usage usage) { @@ -106,9 +108,9 @@ X509_Code usage_check(const X509_Certificate& cert, } -/************************************************* -* Define equality for revocation data * -*************************************************/ +/* +* Define equality for revocation data +*/ bool X509_Store::CRL_Data::operator==(const CRL_Data& other) const { if(issuer != other.issuer) @@ -118,17 +120,17 @@ bool X509_Store::CRL_Data::operator==(const CRL_Data& other) const return compare_ids(auth_key_id, other.auth_key_id); } -/************************************************* -* Define inequality for revocation data * -*************************************************/ +/* +* Define inequality for revocation data +*/ bool X509_Store::CRL_Data::operator!=(const CRL_Data& other) const { return !((*this) == other); } -/************************************************* -* Define an ordering for revocation data * -*************************************************/ +/* +* Define an ordering for revocation data +*/ bool X509_Store::CRL_Data::operator<(const X509_Store::CRL_Data& other) const { if(*this == other) @@ -164,9 +166,9 @@ bool X509_Store::CRL_Data::operator<(const X509_Store::CRL_Data& other) const return (issuer < other.issuer); } -/************************************************* -* X509_Store Constructor * -*************************************************/ +/* +* X509_Store Constructor +*/ X509_Store::X509_Store(u32bit slack, u32bit cache_timeout) { revoked_info_valid = true; @@ -175,9 +177,9 @@ X509_Store::X509_Store(u32bit slack, u32bit cache_timeout) time_slack = slack; } -/************************************************* -* X509_Store Copy Constructor * -*************************************************/ +/* +* X509_Store Copy Constructor +*/ X509_Store::X509_Store(const X509_Store& other) { certs = other.certs; @@ -188,18 +190,18 @@ X509_Store::X509_Store(const X509_Store& other) time_slack = other.time_slack; } -/************************************************* -* X509_Store Destructor * -*************************************************/ +/* +* X509_Store Destructor +*/ X509_Store::~X509_Store() { for(u32bit j = 0; j != stores.size(); ++j) delete stores[j]; } -/************************************************* -* Verify a certificate's authenticity * -*************************************************/ +/* +* Verify a certificate's authenticity +*/ X509_Code X509_Store::validate_cert(const X509_Certificate& cert, Cert_Usage cert_usage) { @@ -244,9 +246,9 @@ X509_Code X509_Store::validate_cert(const X509_Certificate& cert, return usage_check(cert, cert_usage); } -/************************************************* -* Find this certificate * -*************************************************/ +/* +* Find this certificate +*/ u32bit X509_Store::find_cert(const X509_DN& subject_dn, const MemoryRegion<byte>& subject_key_id) const { @@ -260,9 +262,9 @@ u32bit X509_Store::find_cert(const X509_DN& subject_dn, return NO_CERT_FOUND; } -/************************************************* -* Find the parent of this certificate * -*************************************************/ +/* +* Find the parent of this certificate +*/ u32bit X509_Store::find_parent_of(const X509_Certificate& cert) { const X509_DN issuer_dn = cert.issuer_dn(); @@ -291,9 +293,9 @@ u32bit X509_Store::find_parent_of(const X509_Certificate& cert) return NO_CERT_FOUND; } -/************************************************* -* Construct a chain of certificate relationships * -*************************************************/ +/* +* Construct a chain of certificate relationships +*/ X509_Code X509_Store::construct_cert_chain(const X509_Certificate& end_cert, std::vector<u32bit>& indexes, bool need_full_chain) @@ -354,9 +356,9 @@ X509_Code X509_Store::construct_cert_chain(const X509_Certificate& end_cert, return VERIFIED; } -/************************************************* -* Check the CAs signature on a certificate * -*************************************************/ +/* +* Check the CAs signature on a certificate +*/ X509_Code X509_Store::check_sig(const Cert_Info& cert_info, const Cert_Info& ca_cert_info) const { @@ -373,9 +375,9 @@ X509_Code X509_Store::check_sig(const Cert_Info& cert_info, return verify_code; } -/************************************************* -* Check a CA's signature * -*************************************************/ +/* +* Check a CA's signature +*/ X509_Code X509_Store::check_sig(const X509_Object& object, Public_Key* key) { std::auto_ptr<Public_Key> pub_key(key); @@ -422,9 +424,9 @@ X509_Code X509_Store::check_sig(const X509_Object& object, Public_Key* key) return UNKNOWN_X509_ERROR; } -/************************************************* -* Recompute the revocation status of the certs * -*************************************************/ +/* +* Recompute the revocation status of the certs +*/ void X509_Store::recompute_revoked_info() const { if(revoked_info_valid) @@ -443,9 +445,9 @@ void X509_Store::recompute_revoked_info() const revoked_info_valid = true; } -/************************************************* -* Check if a certificate is revoked * -*************************************************/ +/* +* Check if a certificate is revoked +*/ bool X509_Store::is_revoked(const X509_Certificate& cert) const { CRL_Data revoked_info; @@ -458,9 +460,9 @@ bool X509_Store::is_revoked(const X509_Certificate& cert) const return false; } -/************************************************* -* Retrieve all the certificates in the store * -*************************************************/ +/* +* Retrieve all the certificates in the store +*/ std::vector<X509_Certificate> X509_Store::get_certs(const Search_Func& search) const { @@ -473,9 +475,9 @@ X509_Store::get_certs(const Search_Func& search) const return found_certs; } -/************************************************* -* Construct a path back to a root for this cert * -*************************************************/ +/* +* Construct a path back to a root for this cert +*/ std::vector<X509_Certificate> X509_Store::get_cert_chain(const X509_Certificate& cert) { @@ -491,17 +493,17 @@ X509_Store::get_cert_chain(const X509_Certificate& cert) return result; } -/************************************************* -* Add a certificate store to the list of stores * -*************************************************/ +/* +* Add a certificate store to the list of stores +*/ void X509_Store::add_new_certstore(Certificate_Store* certstore) { stores.push_back(certstore); } -/************************************************* -* Add a certificate to the store * -*************************************************/ +/* +* Add a certificate to the store +*/ void X509_Store::add_cert(const X509_Certificate& cert, bool trusted) { if(trusted && !cert.is_self_signed()) @@ -524,9 +526,9 @@ void X509_Store::add_cert(const X509_Certificate& cert, bool trusted) } } -/************************************************* -* Add one or more certificates to the store * -*************************************************/ +/* +* Add one or more certificates to the store +*/ void X509_Store::do_add_certs(DataSource& source, bool trusted) { while(!source.end_of_data()) @@ -540,25 +542,25 @@ void X509_Store::do_add_certs(DataSource& source, bool trusted) } } -/************************************************* -* Add one or more certificates to the store * -*************************************************/ +/* +* Add one or more certificates to the store +*/ void X509_Store::add_certs(DataSource& source) { do_add_certs(source, false); } -/************************************************* -* Add one or more certificates to the store * -*************************************************/ +/* +* Add one or more certificates to the store +*/ void X509_Store::add_trusted_certs(DataSource& source) { do_add_certs(source, true); } -/************************************************* -* Add one or more certificates to the store * -*************************************************/ +/* +* Add one or more certificates to the store +*/ X509_Code X509_Store::add_crl(const X509_CRL& crl) { s32bit time_check = validity_check(crl.this_update(), crl.next_update(), @@ -622,9 +624,9 @@ X509_Code X509_Store::add_crl(const X509_CRL& crl) return VERIFIED; } -/************************************************* -* PEM encode the set of certificates * -*************************************************/ +/* +* PEM encode the set of certificates +*/ std::string X509_Store::PEM_encode() const { std::string cert_store; @@ -633,9 +635,9 @@ std::string X509_Store::PEM_encode() const return cert_store; } -/************************************************* -* Create a Cert_Info structure * -*************************************************/ +/* +* Create a Cert_Info structure +*/ X509_Store::Cert_Info::Cert_Info(const X509_Certificate& c, bool t) : cert(c), trusted(t) { @@ -644,9 +646,9 @@ X509_Store::Cert_Info::Cert_Info(const X509_Certificate& c, last_checked = 0; } -/************************************************* -* Return the verification results * -*************************************************/ +/* +* Return the verification results +*/ X509_Code X509_Store::Cert_Info::verify_result() const { if(!checked) @@ -654,9 +656,9 @@ X509_Code X509_Store::Cert_Info::verify_result() const return result; } -/************************************************* -* Set the verification results * -*************************************************/ +/* +* Set the verification results +*/ void X509_Store::Cert_Info::set_result(X509_Code code) const { result = code; @@ -664,17 +666,17 @@ void X509_Store::Cert_Info::set_result(X509_Code code) const checked = true; } -/************************************************* -* Check if this certificate can be trusted * -*************************************************/ +/* +* Check if this certificate can be trusted +*/ bool X509_Store::Cert_Info::is_trusted() const { return trusted; } -/************************************************* -* Check if this certificate has been verified * -*************************************************/ +/* +* Check if this certificate has been verified +*/ bool X509_Store::Cert_Info::is_verified(u32bit timeout) const { if(!checked) diff --git a/src/cert/x509/x509stor.h b/src/cert/x509/x509stor.h index 2667187af..4e6037883 100644 --- a/src/cert/x509/x509stor.h +++ b/src/cert/x509/x509stor.h @@ -1,7 +1,9 @@ -/************************************************* -* X.509 Certificate Store Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* X.509 Certificate Store +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #ifndef BOTAN_X509_CERT_STORE_H__ #define BOTAN_X509_CERT_STORE_H__ @@ -12,9 +14,9 @@ namespace Botan { -/************************************************* -* X.509 Certificate Validation Result * -*************************************************/ +/* +* X.509 Certificate Validation Result +*/ enum X509_Code { VERIFIED, UNKNOWN_X509_ERROR, @@ -40,9 +42,9 @@ enum X509_Code { CA_CERT_NOT_FOR_CRL_ISSUER }; -/************************************************* -* X.509 Certificate Store * -*************************************************/ +/* +* X.509 Certificate Store +*/ class BOTAN_DLL X509_Store { public: |