diff options
author | lloyd <[email protected]> | 2011-02-09 15:13:28 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-02-09 15:13:28 +0000 |
commit | 75eff6cba7ac959f0d3b5292aa5ca7e321bf2e0d (patch) | |
tree | ad44e3ce741c7d2c83c46a21f0242be4eec33402 /src/cert | |
parent | 5fa1a353fcdfc5fc83618f07a89b3d320596ae07 (diff) |
Convert the BER/DER coders to use size_t instead of u32bit for small
integer values. Update callers.
Diffstat (limited to 'src/cert')
-rw-r--r-- | src/cert/cvc/cvc_cert.cpp | 2 | ||||
-rw-r--r-- | src/cert/cvc/cvc_req.cpp | 2 | ||||
-rw-r--r-- | src/cert/pkcs10/pkcs10.cpp | 2 | ||||
-rw-r--r-- | src/cert/x509ca/x509_ca.cpp | 4 | ||||
-rw-r--r-- | src/cert/x509cert/x509_ext.cpp | 8 | ||||
-rw-r--r-- | src/cert/x509cert/x509_ext.h | 14 | ||||
-rw-r--r-- | src/cert/x509cert/x509cert.cpp | 6 | ||||
-rw-r--r-- | src/cert/x509crl/x509_crl.cpp | 2 | ||||
-rw-r--r-- | src/cert/x509self/x509opt.cpp | 2 | ||||
-rw-r--r-- | src/cert/x509self/x509self.cpp | 2 | ||||
-rw-r--r-- | src/cert/x509self/x509self.h | 4 |
11 files changed, 26 insertions, 22 deletions
diff --git a/src/cert/cvc/cvc_cert.cpp b/src/cert/cvc/cvc_cert.cpp index 536520b37..54f72ecfc 100644 --- a/src/cert/cvc/cvc_cert.cpp +++ b/src/cert/cvc/cvc_cert.cpp @@ -35,7 +35,7 @@ void EAC1_1_CVC::force_decode() { SecureVector<byte> enc_pk; SecureVector<byte> enc_chat_val; - u32bit cpi; + size_t cpi; BER_Decoder tbs_cert(tbs_bits); tbs_cert.decode(cpi, ASN1_Tag(41), APPLICATION) .decode(m_car) diff --git a/src/cert/cvc/cvc_req.cpp b/src/cert/cvc/cvc_req.cpp index 0a33d4dca..ad9e2f4ca 100644 --- a/src/cert/cvc/cvc_req.cpp +++ b/src/cert/cvc/cvc_req.cpp @@ -21,7 +21,7 @@ void EAC1_1_Req::force_decode() { SecureVector<byte> enc_pk; BER_Decoder tbs_cert(tbs_bits); - u32bit cpi; + size_t cpi; tbs_cert.decode(cpi, ASN1_Tag(41), APPLICATION) .start_cons(ASN1_Tag(73)) .raw_bytes(enc_pk) diff --git a/src/cert/pkcs10/pkcs10.cpp b/src/cert/pkcs10/pkcs10.cpp index 539022d08..784318d3d 100644 --- a/src/cert/pkcs10/pkcs10.cpp +++ b/src/cert/pkcs10/pkcs10.cpp @@ -41,7 +41,7 @@ void PKCS10_Request::force_decode() { BER_Decoder cert_req_info(tbs_bits); - u32bit version; + size_t version; cert_req_info.decode(version); if(version != 0) throw Decoding_Error("Unknown version code in PKCS #10 request: " + diff --git a/src/cert/x509ca/x509_ca.cpp b/src/cert/x509ca/x509_ca.cpp index 57307d67e..9cb4c0a7f 100644 --- a/src/cert/x509ca/x509_ca.cpp +++ b/src/cert/x509ca/x509_ca.cpp @@ -97,7 +97,7 @@ X509_Certificate X509_CA::make_cert(PK_Signer* signer, const X509_DN& subject_dn, const Extensions& extensions) { - const u32bit X509_CERT_VERSION = 3; + const size_t X509_CERT_VERSION = 3; const size_t SERIAL_BITS = 256; BigInt serial_no(rng, SERIAL_BITS); @@ -166,7 +166,7 @@ X509_CRL X509_CA::make_crl(const std::vector<CRL_Entry>& revoked, u32bit crl_number, u32bit next_update, RandomNumberGenerator& rng) const { - const u32bit X509_CRL_VERSION = 2; + const size_t X509_CRL_VERSION = 2; if(next_update == 0) next_update = timespec_to_u32bit("7d"); 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); } } diff --git a/src/cert/x509crl/x509_crl.cpp b/src/cert/x509crl/x509_crl.cpp index f6a344dba..01fce4c52 100644 --- a/src/cert/x509crl/x509_crl.cpp +++ b/src/cert/x509crl/x509_crl.cpp @@ -39,7 +39,7 @@ void X509_CRL::force_decode() { BER_Decoder tbs_crl(tbs_bits); - u32bit version; + size_t version; tbs_crl.decode_optional(version, INTEGER, UNIVERSAL); if(version != 0 && version != 1) diff --git a/src/cert/x509self/x509opt.cpp b/src/cert/x509self/x509opt.cpp index 0702ebf19..345df1fe0 100644 --- a/src/cert/x509self/x509opt.cpp +++ b/src/cert/x509self/x509opt.cpp @@ -55,7 +55,7 @@ void X509_Cert_Options::add_ex_constraint(const std::string& oid_str) /* * Mark this certificate for CA usage */ -void X509_Cert_Options::CA_key(u32bit limit) +void X509_Cert_Options::CA_key(size_t limit) { is_CA = true; path_limit = limit; diff --git a/src/cert/x509self/x509self.cpp b/src/cert/x509self/x509self.cpp index e420ca503..a2f89159f 100644 --- a/src/cert/x509self/x509self.cpp +++ b/src/cert/x509self/x509self.cpp @@ -103,7 +103,7 @@ PKCS10_Request create_cert_req(const X509_Cert_Options& opts, std::auto_ptr<PK_Signer> signer(choose_sig_format(key, hash_fn, sig_algo)); load_info(opts, subject_dn, subject_alt); - const u32bit PKCS10_VERSION = 0; + const size_t PKCS10_VERSION = 0; Extensions extensions; diff --git a/src/cert/x509self/x509self.h b/src/cert/x509self/x509self.h index df5731050..2850096c8 100644 --- a/src/cert/x509self/x509self.h +++ b/src/cert/x509self/x509self.h @@ -102,7 +102,7 @@ class BOTAN_DLL X509_Cert_Options /** * Indicates the BasicConstraints path limit */ - u32bit path_limit; + size_t path_limit; /** * The key constraints for the subject public key @@ -123,7 +123,7 @@ class BOTAN_DLL X509_Cert_Options * Mark the certificate as a CA certificate and set the path limit. * @param limit the path limit to be set in the BasicConstraints extension. */ - void CA_key(u32bit limit = 1); + void CA_key(size_t limit = 1); /** * Set the notBefore of the certificate. |