aboutsummaryrefslogtreecommitdiffstats
path: root/src/cert/x509cert
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-02-09 15:13:28 +0000
committerlloyd <[email protected]>2011-02-09 15:13:28 +0000
commit75eff6cba7ac959f0d3b5292aa5ca7e321bf2e0d (patch)
treead44e3ce741c7d2c83c46a21f0242be4eec33402 /src/cert/x509cert
parent5fa1a353fcdfc5fc83618f07a89b3d320596ae07 (diff)
Convert the BER/DER coders to use size_t instead of u32bit for small
integer values. Update callers.
Diffstat (limited to 'src/cert/x509cert')
-rw-r--r--src/cert/x509cert/x509_ext.cpp8
-rw-r--r--src/cert/x509cert/x509_ext.h14
-rw-r--r--src/cert/x509cert/x509cert.cpp6
3 files changed, 16 insertions, 12 deletions
diff --git a/src/cert/x509cert/x509_ext.cpp b/src/cert/x509cert/x509_ext.cpp
index 88cab96c5..462b29669 100644
--- a/src/cert/x509cert/x509_ext.cpp
+++ b/src/cert/x509cert/x509_ext.cpp
@@ -166,7 +166,7 @@ namespace Cert_Extension {
/*
* Checked accessor for the path_limit member
*/
-u32bit Basic_Constraints::get_path_limit() const
+size_t Basic_Constraints::get_path_limit() const
{
if(!is_ca)
throw Invalid_State("Basic_Constraints::get_path_limit: Not a CA");
@@ -505,7 +505,7 @@ void Certificate_Policies::contents_to(Data_Store& info, Data_Store&) const
/*
* Checked accessor for the crl_number member
*/
-u32bit CRL_Number::get_crl_number() const
+size_t CRL_Number::get_crl_number() const
{
if(!has_value)
throw Invalid_State("CRL_Number::get_crl_number: Not set");
@@ -552,7 +552,7 @@ void CRL_Number::contents_to(Data_Store& info, Data_Store&) const
MemoryVector<byte> CRL_ReasonCode::encode_inner() const
{
return DER_Encoder()
- .encode(static_cast<u32bit>(reason), ENUMERATED, UNIVERSAL)
+ .encode(static_cast<size_t>(reason), ENUMERATED, UNIVERSAL)
.get_contents();
}
@@ -561,7 +561,7 @@ MemoryVector<byte> CRL_ReasonCode::encode_inner() const
*/
void CRL_ReasonCode::decode_inner(const MemoryRegion<byte>& in)
{
- u32bit reason_code = 0;
+ size_t reason_code = 0;
BER_Decoder(in).decode(reason_code, ENUMERATED, UNIVERSAL);
reason = static_cast<CRL_Code>(reason_code);
}
diff --git a/src/cert/x509cert/x509_ext.h b/src/cert/x509cert/x509_ext.h
index 213a077a2..c32e39fdc 100644
--- a/src/cert/x509cert/x509_ext.h
+++ b/src/cert/x509cert/x509_ext.h
@@ -93,14 +93,16 @@ namespace Cert_Extension {
class BOTAN_DLL Basic_Constraints : public Certificate_Extension
{
public:
+ static const size_t NO_CERT_PATH_LIMIT = 0xFFFFFFF0;
+
Basic_Constraints* copy() const
{ return new Basic_Constraints(is_ca, path_limit); }
- Basic_Constraints(bool ca = false, u32bit limit = 0) :
+ Basic_Constraints(bool ca = false, size_t limit = 0) :
is_ca(ca), path_limit(limit) {}
bool get_is_ca() const { return is_ca; }
- u32bit get_path_limit() const;
+ size_t get_path_limit() const;
private:
std::string config_id() const { return "basic_constraints"; }
std::string oid_name() const { return "X509v3.BasicConstraints"; }
@@ -110,7 +112,7 @@ class BOTAN_DLL Basic_Constraints : public Certificate_Extension
void contents_to(Data_Store&, Data_Store&) const;
bool is_ca;
- u32bit path_limit;
+ size_t path_limit;
};
/**
@@ -292,9 +294,9 @@ class BOTAN_DLL CRL_Number : public Certificate_Extension
CRL_Number* copy() const;
CRL_Number() : has_value(false), crl_number(0) {}
- CRL_Number(u32bit n) : has_value(true), crl_number(n) {}
+ CRL_Number(size_t n) : has_value(true), crl_number(n) {}
- u32bit get_crl_number() const;
+ size_t get_crl_number() const;
private:
std::string config_id() const { return "crl_number"; }
std::string oid_name() const { return "X509v3.CRLNumber"; }
@@ -305,7 +307,7 @@ class BOTAN_DLL CRL_Number : public Certificate_Extension
void contents_to(Data_Store&, Data_Store&) const;
bool has_value;
- u32bit crl_number;
+ size_t crl_number;
};
/**
diff --git a/src/cert/x509cert/x509cert.cpp b/src/cert/x509cert/x509cert.cpp
index 4eef215f8..71ad8af82 100644
--- a/src/cert/x509cert/x509cert.cpp
+++ b/src/cert/x509cert/x509cert.cpp
@@ -66,7 +66,7 @@ X509_Certificate::X509_Certificate(const std::string& in) :
*/
void X509_Certificate::force_decode()
{
- u32bit version;
+ size_t version;
BigInt serial_bn;
AlgorithmIdentifier sig_algo_inner;
X509_DN dn_issuer, dn_subject;
@@ -141,7 +141,9 @@ void X509_Certificate::force_decode()
if(is_CA_cert() &&
!subject.has_value("X509v3.BasicConstraints.path_constraint"))
{
- u32bit limit = (x509_version() < 3) ? NO_CERT_PATH_LIMIT : 0;
+ const size_t limit = (x509_version() < 3) ?
+ Cert_Extension::Basic_Constraints::NO_CERT_PATH_LIMIT : 0;
+
subject.add("X509v3.BasicConstraints.path_constraint", limit);
}
}