diff options
author | lloyd <[email protected]> | 2008-09-30 04:09:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-30 04:09:19 +0000 |
commit | 443f02eecbce215b67a8418c991e66c217b4d7c2 (patch) | |
tree | 88dea7d698721bf53ca614cd0f13e88c2d40ec4f | |
parent | ae0901dde9282d1b9c2de7a1fac4a41c8043d59c (diff) |
Update CMS to at least compile (though in a couple of cases by just
#ifdef'ing out code); it still needs a good bit of work and has
not been tested at all.
-rw-r--r-- | src/cms/cms_dec.cpp | 4 | ||||
-rw-r--r-- | src/cms/cms_ealg.cpp | 27 | ||||
-rw-r--r-- | src/cms/cms_enc.h | 9 |
3 files changed, 24 insertions, 16 deletions
diff --git a/src/cms/cms_dec.cpp b/src/cms/cms_dec.cpp index edd1cd489..55c1c8cd5 100644 --- a/src/cms/cms_dec.cpp +++ b/src/cms/cms_dec.cpp @@ -34,7 +34,7 @@ CMS_Decoder::CMS_Decoder(DataSource& in, const X509_Store& x509store, /************************************************* * Read the outermost ContentInfo * *************************************************/ -void CMS_Decoder::initial_read(DataSource& in) +void CMS_Decoder::initial_read(DataSource&) { // FIXME... @@ -60,9 +60,11 @@ void CMS_Decoder::add_key(PKCS8_PrivateKey* key) if(!key) return; +#if 0 for(u32bit j = 0; j != keys.size(); j++) if(keys[j]->key_id() == key->key_id()) return; +#endif keys.push_back(key); } diff --git a/src/cms/cms_ealg.cpp b/src/cms/cms_ealg.cpp index becf24000..b0a15d9f9 100644 --- a/src/cms/cms_ealg.cpp +++ b/src/cms/cms_ealg.cpp @@ -6,7 +6,6 @@ #include <botan/cms_enc.h> #include <botan/der_enc.h> #include <botan/x509find.h> -#include <botan/x509_ca.h> #include <botan/bigint.h> #include <botan/oids.h> #include <botan/lookup.h> @@ -219,7 +218,7 @@ void CMS_Encoder::encrypt(RandomNumberGenerator& rng, /************************************************* * Encrypt a message with a passphrase * *************************************************/ -void CMS_Encoder::encrypt(RandomNumberGenerator& rng, +void CMS_Encoder::encrypt(RandomNumberGenerator&, const std::string&, const std::string& user_cipher) { @@ -274,21 +273,23 @@ SecureVector<byte> CMS_Encoder::do_encrypt(RandomNumberGenerator& rng, /************************************************* * Sign a message * *************************************************/ -void CMS_Encoder::sign(X509_Store& store, const PKCS8_PrivateKey& key, - RandomNumberGenerator& rng) +void CMS_Encoder::sign(const X509_Certificate& cert, + const PKCS8_PrivateKey& key, + RandomNumberGenerator& rng, + const std::vector<X509_Certificate>& chain, + const std::string& hash, + const std::string& pad_algo) { - std::vector<X509_Certificate> matching = - store.get_certs(SKID_Match(key.key_id())); - - if(matching.size() == 0) - throw Encoding_Error("CMS::sign: Cannot find cert matching given key"); + std::string padding = pad_algo + "(" + hash + ")"; - const X509_Certificate& cert = matching[0]; + // FIXME: Add new get_format() func to PK_Signing_Key, PK_Verifying_*_Key + Signature_Format format = IEEE_1363; - std::vector<X509_Certificate> chain = store.get_cert_chain(cert); + const PK_Signing_Key& sig_key = dynamic_cast<const PK_Signing_Key&>(key); + std::auto_ptr<PK_Signer> signer(get_pk_signer(sig_key, padding, format)); - AlgorithmIdentifier sig_algo; - std::auto_ptr<PK_Signer> signer(choose_sig_format(key, sig_algo)); + AlgorithmIdentifier sig_algo(OIDS::lookup(key.algo_name() + "/" + padding), + AlgorithmIdentifier::USE_NULL_PARAM); SecureVector<byte> signed_attr = encode_attr(data, type, hash); signer->update(signed_attr); diff --git a/src/cms/cms_enc.h b/src/cms/cms_enc.h index c1c49b2e4..f3907cd7b 100644 --- a/src/cms/cms_enc.h +++ b/src/cms/cms_enc.h @@ -32,8 +32,13 @@ class CMS_Encoder void authenticate(const std::string&, const std::string& = ""); void authenticate(const SymmetricKey&, const std::string& = ""); - void sign(X509_Store&, const PKCS8_PrivateKey&, - RandomNumberGenerator& rng); + void sign(const X509_Certificate& cert, + const PKCS8_PrivateKey& key, + RandomNumberGenerator& rng, + const std::vector<X509_Certificate>& cert_chain, + const std::string& hash, + const std::string& padding); + void digest(const std::string& = ""); void compress(const std::string&); |