diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/benchmark/benchmark.cpp | 8 | ||||
-rw-r--r-- | src/cert/cvc/cvc_self.cpp | 15 | ||||
-rw-r--r-- | src/cms/cms_dalg.cpp | 2 | ||||
-rw-r--r-- | src/cms/cms_ealg.cpp | 4 | ||||
-rw-r--r-- | src/constructs/tss/tss.cpp | 2 | ||||
-rw-r--r-- | src/pubkey/blinding.cpp | 6 | ||||
-rw-r--r-- | src/ssl/cert_ver.cpp | 2 | ||||
-rw-r--r-- | src/ssl/s_kex.cpp | 2 | ||||
-rw-r--r-- | src/wrap/python/core.cpp | 2 | ||||
-rw-r--r-- | src/wrap/python/filter.cpp | 14 | ||||
-rw-r--r-- | src/wrap/python/rsa.cpp | 8 |
11 files changed, 37 insertions, 28 deletions
diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp index 7a78461c2..348882b2a 100644 --- a/src/benchmark/benchmark.cpp +++ b/src/benchmark/benchmark.cpp @@ -162,7 +162,7 @@ algorithm_benchmark(const std::string& name, if(const BlockCipher* proto = af.prototype_block_cipher(name, provider)) { - std::auto_ptr<BlockCipher> block_cipher(proto->clone()); + std::unique_ptr<BlockCipher> block_cipher(proto->clone()); results = bench_block_cipher(block_cipher.get(), ns_per_provider, &buf[0], buf.size()); @@ -170,7 +170,7 @@ algorithm_benchmark(const std::string& name, else if(const StreamCipher* proto = af.prototype_stream_cipher(name, provider)) { - std::auto_ptr<StreamCipher> stream_cipher(proto->clone()); + std::unique_ptr<StreamCipher> stream_cipher(proto->clone()); results = bench_stream_cipher(stream_cipher.get(), ns_per_provider, &buf[0], buf.size()); @@ -178,14 +178,14 @@ algorithm_benchmark(const std::string& name, else if(const HashFunction* proto = af.prototype_hash_function(name, provider)) { - std::auto_ptr<HashFunction> hash(proto->clone()); + std::unique_ptr<HashFunction> hash(proto->clone()); results = bench_hash(hash.get(), ns_per_provider, &buf[0], buf.size()); } else if(const MessageAuthenticationCode* proto = af.prototype_mac(name, provider)) { - std::auto_ptr<MessageAuthenticationCode> mac(proto->clone()); + std::unique_ptr<MessageAuthenticationCode> mac(proto->clone()); results = bench_mac(mac.get(), ns_per_provider, &buf[0], buf.size()); } diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp index 0c765347f..9489ede85 100644 --- a/src/cert/cvc/cvc_self.cpp +++ b/src/cert/cvc/cvc_self.cpp @@ -168,7 +168,8 @@ EAC1_1_ADO create_ado_req(Private_Key const& key, PK_Signer signer(*priv_key, padding_and_hash); SecureVector<byte> tbs_bits = req.BER_encode(); tbs_bits.append(DER_Encoder().encode(car).get_contents()); - MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(*signer.get(), tbs_bits, rng); + MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(signer, + tbs_bits, rng); DataSource_Memory source(signed_cert); return EAC1_1_ADO(source); @@ -229,7 +230,7 @@ EAC1_1_CVC link_cvca(EAC1_1_CVC const& signer, AlgorithmIdentifier sig_algo = signer.signature_algorithm(); std::string padding_and_hash = padding_and_hash_from_oid(sig_algo.oid); PK_Signer pk_signer(*priv_key, padding_and_hash); - std::auto_ptr<Public_Key> pk = signee.subject_public_key(); + std::unique_ptr<Public_Key> pk = signee.subject_public_key(); ECDSA_PublicKey* subj_pk = dynamic_cast<ECDSA_PublicKey*>(pk.get()); subj_pk->set_parameter_encoding(EC_DOMPAR_ENC_EXPLICIT); @@ -259,11 +260,17 @@ EAC1_1_CVC sign_request(EAC1_1_CVC const& signer_cert, throw Invalid_Argument("CVC_EAC::create_self_signed_cert(): unsupported key type"); } std::string chr_str = signee.get_chr().value(); - chr_str += to_string(seqnr, seqnr_len); + + std::string seqnr_string = std::to_string(seqnr); + + while(seqnr_string.size() < seqnr_len) + seqnr_string = '0' + seqnr_string; + + chr_str += seqnr_string; ASN1_Chr chr(chr_str); std::string padding_and_hash = padding_and_hash_from_oid(signee.signature_algorithm().oid); PK_Signer pk_signer(*priv_key, padding_and_hash); - std::auto_ptr<Public_Key> pk = signee.subject_public_key(); + std::unique_ptr<Public_Key> pk = signee.subject_public_key(); ECDSA_PublicKey* subj_pk = dynamic_cast<ECDSA_PublicKey*>(pk.get()); std::unique_ptr<Public_Key> signer_pk = signer_cert.subject_public_key(); diff --git a/src/cms/cms_dalg.cpp b/src/cms/cms_dalg.cpp index 2a380b596..f727f2a3f 100644 --- a/src/cms/cms_dalg.cpp +++ b/src/cms/cms_dalg.cpp @@ -29,7 +29,7 @@ SecureVector<byte> hash_of(const SecureVector<byte>& content, Algorithm_Factory& af = global_state().algorithm_factory(); - std::auto_ptr<HashFunction> hash_fn(af.make_hash_function(hash_name)); + std::unique_ptr<HashFunction> hash_fn(af.make_hash_function(hash_name)); return hash_fn->process(content); } diff --git a/src/cms/cms_ealg.cpp b/src/cms/cms_ealg.cpp index 3ddf8a39e..b910b89d2 100644 --- a/src/cms/cms_ealg.cpp +++ b/src/cms/cms_ealg.cpp @@ -58,7 +58,7 @@ SecureVector<byte> hash_of(const SecureVector<byte>& content, const std::string& hash_name) { Algorithm_Factory& af = global_state().algorithm_factory(); - std::auto_ptr<HashFunction> hash_fn(af.make_hash_function(hash_name)); + std::unique_ptr<HashFunction> hash_fn(af.make_hash_function(hash_name)); return hash_fn->process(content); } @@ -97,7 +97,7 @@ void CMS_Encoder::encrypt(RandomNumberGenerator& rng, { const std::string cipher = choose_algo(user_cipher, "TripleDES"); - std::auto_ptr<Public_Key> key(to.subject_public_key()); + std::unique_ptr<Public_Key> key(to.subject_public_key()); const std::string algo = key->algo_name(); Key_Constraints constraints = to.constraints(); diff --git a/src/constructs/tss/tss.cpp b/src/constructs/tss/tss.cpp index 0782a27d1..101640f96 100644 --- a/src/constructs/tss/tss.cpp +++ b/src/constructs/tss/tss.cpp @@ -209,7 +209,7 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares) byte hash_id = shares[0].contents[16]; - std::auto_ptr<HashFunction> hash(get_rtss_hash_by_id(hash_id)); + std::unique_ptr<HashFunction> hash(get_rtss_hash_by_id(hash_id)); if(shares[0].size() != secret_len + hash->OUTPUT_LENGTH + RTSS_HEADER_SIZE + 1) throw Decoding_Error("Bad RTSS length field in header"); diff --git a/src/pubkey/blinding.cpp b/src/pubkey/blinding.cpp index 819d0dd20..8da50249f 100644 --- a/src/pubkey/blinding.cpp +++ b/src/pubkey/blinding.cpp @@ -32,7 +32,7 @@ BigInt Blinder::choose_nonce(const BigInt& x, const BigInt& mod) { Algorithm_Factory& af = global_state().algorithm_factory(); - std::auto_ptr<HashFunction> hash(af.make_hash_function("SHA-512")); + std::unique_ptr<HashFunction> hash(af.make_hash_function("SHA-512")); u64bit ns_clock = get_nanoseconds_clock(); for(size_t i = 0; i != sizeof(ns_clock); ++i) @@ -41,7 +41,9 @@ BigInt Blinder::choose_nonce(const BigInt& x, const BigInt& mod) hash->update(BigInt::encode(x)); hash->update(BigInt::encode(mod)); - u64bit timestamp = system_time(); + auto timestamp = std::chrono::system_clock::to_time_t( + std::chrono::system_clock::now()); + for(size_t i = 0; i != sizeof(timestamp); ++i) hash->update(get_byte(i, timestamp)); diff --git a/src/ssl/cert_ver.cpp b/src/ssl/cert_ver.cpp index 7e17dbfab..0bf6c85be 100644 --- a/src/ssl/cert_ver.cpp +++ b/src/ssl/cert_ver.cpp @@ -80,7 +80,7 @@ bool Certificate_Verify::verify(const X509_Certificate& cert, { // FIXME: duplicate of Server_Key_Exchange::verify - std::auto_ptr<Public_Key> key(cert.subject_public_key()); + std::unique_ptr<Public_Key> key(cert.subject_public_key()); std::string padding = ""; Signature_Format format = IEEE_1363; diff --git a/src/ssl/s_kex.cpp b/src/ssl/s_kex.cpp index 94b17cb7e..3223adc5b 100644 --- a/src/ssl/s_kex.cpp +++ b/src/ssl/s_kex.cpp @@ -157,7 +157,7 @@ bool Server_Key_Exchange::verify(const X509_Certificate& cert, const MemoryRegion<byte>& s_random) const { - std::auto_ptr<Public_Key> key(cert.subject_public_key()); + std::unique_ptr<Public_Key> key(cert.subject_public_key()); std::string padding = ""; Signature_Format format = IEEE_1363; diff --git a/src/wrap/python/core.cpp b/src/wrap/python/core.cpp index b1be3b71f..67e17c4d5 100644 --- a/src/wrap/python/core.cpp +++ b/src/wrap/python/core.cpp @@ -178,7 +178,7 @@ std::string python_kdf2(const std::string& param, const std::string& masterkey, u32bit outputlength) { - std::auto_ptr<KDF> kdf(get_kdf("KDF2(SHA-1)")); + std::unique_ptr<KDF> kdf(get_kdf("KDF2(SHA-1)")); return make_string( kdf->derive_key(outputlength, diff --git a/src/wrap/python/filter.cpp b/src/wrap/python/filter.cpp index 48a3f84eb..0076f0c49 100644 --- a/src/wrap/python/filter.cpp +++ b/src/wrap/python/filter.cpp @@ -109,19 +109,19 @@ Filter* make_filter4(const std::string& name, name); } -void append_filter(Pipe& pipe, std::auto_ptr<Filter> filter) +void append_filter(Pipe& pipe, std::unique_ptr<Filter> filter) { pipe.append(filter.get()); filter.release(); } -void prepend_filter(Pipe& pipe, std::auto_ptr<Filter> filter) +void prepend_filter(Pipe& pipe, std::unique_ptr<Filter> filter) { pipe.prepend(filter.get()); filter.release(); } -void do_send(std::auto_ptr<FilterWrapper> filter, const std::string& data) +void do_send(std::unique_ptr<FilterWrapper> filter, const std::string& data) { printf("Sending %s to %p\n", data.c_str(), filter.get()); filter->send_str(data); @@ -131,7 +131,7 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(rallas_ovls, read_all_as_string, 0, 1) void export_filters() { - class_<Filter, std::auto_ptr<Filter>, boost::noncopyable> + class_<Filter, std::unique_ptr<Filter>, boost::noncopyable> ("__Internal_FilterObj", no_init); def("make_filter", make_filter1, @@ -145,7 +145,7 @@ void export_filters() // This might not work - Pipe will delete the filter, but Python // might have allocated the space with malloc() or who-knows-what -> bad - class_<FilterWrapper, std::auto_ptr<FilterWrapper>, + class_<FilterWrapper, std::unique_ptr<FilterWrapper>, bases<Filter>, boost::noncopyable> ("FilterObj") .def("write", pure_virtual(&Py_Filter::write_str)) @@ -153,8 +153,8 @@ void export_filters() .def("start_msg", &Filter::start_msg, &FilterWrapper::default_start_msg) .def("end_msg", &Filter::end_msg, &FilterWrapper::default_end_msg); - implicitly_convertible<std::auto_ptr<FilterWrapper>, - std::auto_ptr<Filter> >(); + implicitly_convertible<std::unique_ptr<FilterWrapper>, + std::unique_ptr<Filter> >(); void (Pipe::*pipe_write_str)(const std::string&) = &Pipe::write; void (Pipe::*pipe_process_str)(const std::string&) = &Pipe::process_msg; diff --git a/src/wrap/python/rsa.cpp b/src/wrap/python/rsa.cpp index 900c3f93d..41d9bd4d1 100644 --- a/src/wrap/python/rsa.cpp +++ b/src/wrap/python/rsa.cpp @@ -55,7 +55,7 @@ class Py_RSA_PrivateKey std::string Py_RSA_PrivateKey::decrypt(const std::string& in, const std::string& padding) { - std::auto_ptr<PK_Decryptor> enc(get_pk_decryptor(*rsa_key, padding)); + std::unique_ptr<PK_Decryptor> enc(get_pk_decryptor(*rsa_key, padding)); const byte* in_bytes = reinterpret_cast<const byte*>(in.data()); @@ -66,7 +66,7 @@ std::string Py_RSA_PrivateKey::sign(const std::string& in, const std::string& padding, Python_RandomNumberGenerator& rng) { - std::auto_ptr<PK_Signer> sign(get_pk_signer(*rsa_key, padding)); + std::unique_ptr<PK_Signer> sign(get_pk_signer(*rsa_key, padding)); const byte* in_bytes = reinterpret_cast<const byte*>(in.data()); sign->update(in_bytes, in.size()); return make_string(sign->signature(rng.get_underlying_rng())); @@ -144,7 +144,7 @@ std::string Py_RSA_PublicKey::encrypt(const std::string& in, const std::string& padding, Python_RandomNumberGenerator& rng) { - std::auto_ptr<PK_Encryptor> enc(get_pk_encryptor(*rsa_key, padding)); + std::unique_ptr<PK_Encryptor> enc(get_pk_encryptor(*rsa_key, padding)); const byte* in_bytes = reinterpret_cast<const byte*>(in.data()); @@ -156,7 +156,7 @@ bool Py_RSA_PublicKey::verify(const std::string& in, const std::string& signature, const std::string& padding) { - std::auto_ptr<PK_Verifier> ver(get_pk_verifier(*rsa_key, padding)); + std::unique_ptr<PK_Verifier> ver(get_pk_verifier(*rsa_key, padding)); const byte* in_bytes = reinterpret_cast<const byte*>(in.data()); const byte* sig_bytes = reinterpret_cast<const byte*>(signature.data()); |