aboutsummaryrefslogtreecommitdiffstats
path: root/src/cms
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-03-30 18:27:18 +0000
committerlloyd <[email protected]>2009-03-30 18:27:18 +0000
commit96d6eb6f29c55e16a37cf11899547886f735b065 (patch)
tree9f13901e9b44c98d58b2589c9b09c6a7443eb7cd /src/cms
parent3cc3dd72c5f87b76852a55c1f2d1821dba967d8c (diff)
Thomas Moschny passed along a request from the Fedora packagers which came
up during the Fedora submission review, that each source file include some text about the license. One handy Perl script later and each file now has the line Distributed under the terms of the Botan license after the copyright notices. While I was in there modifying every file anyway, I also stripped out the remainder of the block comments (lots of astericks before and after the text); this is stylistic thing I picked up when I was first learning C++ but in retrospect it is not a good style as the structure makes it harder to modify comments (with the result that comments become fewer, shorter and are less likely to be updated, which are not good things).
Diffstat (limited to 'src/cms')
-rw-r--r--src/cms/cms_algo.cpp34
-rw-r--r--src/cms/cms_comp.cpp28
-rw-r--r--src/cms/cms_dalg.cpp40
-rw-r--r--src/cms/cms_dec.cpp58
-rw-r--r--src/cms/cms_dec.h16
-rw-r--r--src/cms/cms_ealg.cpp100
-rw-r--r--src/cms/cms_enc.cpp46
-rw-r--r--src/cms/cms_enc.h16
8 files changed, 177 insertions, 161 deletions
diff --git a/src/cms/cms_algo.cpp b/src/cms/cms_algo.cpp
index 8db27c65f..748aa73da 100644
--- a/src/cms/cms_algo.cpp
+++ b/src/cms/cms_algo.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CMS Algorithm Specific Code Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CMS Algorithm Specific Code
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cms_enc.h>
#include <botan/der_enc.h>
@@ -18,9 +20,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Wrap a key as specified in RFC 3217 *
-*************************************************/
+/*
+* Wrap a key as specified in RFC 3217
+*/
SecureVector<byte> do_rfc3217_wrap(RandomNumberGenerator& rng,
const std::string& cipher_name,
const SymmetricKey& kek,
@@ -70,9 +72,9 @@ SecureVector<byte> do_rfc3217_wrap(RandomNumberGenerator& rng,
}
-/*************************************************
-* Wrap a CEK with a KEK *
-*************************************************/
+/*
+* Wrap a CEK with a KEK
+*/
SecureVector<byte> CMS_Encoder::wrap_key(RandomNumberGenerator& rng,
const std::string& cipher,
const SymmetricKey& cek,
@@ -105,9 +107,9 @@ SecureVector<byte> CMS_Encoder::wrap_key(RandomNumberGenerator& rng,
throw Invalid_Argument("CMS_Encoder::wrap: Unknown cipher " + cipher);
}
-/*************************************************
-* Encode the parameters for an encryption algo *
-*************************************************/
+/*
+* Encode the parameters for an encryption algo
+*/
SecureVector<byte> CMS_Encoder::encode_params(const std::string& cipher,
const SymmetricKey& key,
const InitializationVector& iv)
@@ -138,9 +140,9 @@ SecureVector<byte> CMS_Encoder::encode_params(const std::string& cipher,
return encoder.get_contents();
}
-/*************************************************
-* Generate a CEK or KEK for the cipher *
-*************************************************/
+/*
+* Generate a CEK or KEK for the cipher
+*/
SymmetricKey CMS_Encoder::setup_key(RandomNumberGenerator& rng,
const std::string& cipher)
{
diff --git a/src/cms/cms_comp.cpp b/src/cms/cms_comp.cpp
index a0e777321..b11cf909b 100644
--- a/src/cms/cms_comp.cpp
+++ b/src/cms/cms_comp.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CMS Compression Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CMS Compression
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cms_enc.h>
#include <botan/cms_dec.h>
@@ -16,9 +18,9 @@
namespace Botan {
-/*************************************************
-* Compress a message *
-*************************************************/
+/*
+* Compress a message
+*/
void CMS_Encoder::compress(const std::string& algo)
{
if(!CMS_Encoder::can_compress_with(algo))
@@ -48,9 +50,9 @@ void CMS_Encoder::compress(const std::string& algo)
add_layer("CMS.CompressedData", encoder);
}
-/*************************************************
-* See if the named compression algo is available *
-*************************************************/
+/*
+* See if the named compression algo is available
+*/
bool CMS_Encoder::can_compress_with(const std::string& algo)
{
if(algo == "")
@@ -64,9 +66,9 @@ bool CMS_Encoder::can_compress_with(const std::string& algo)
return false;
}
-/*************************************************
-* Decompress a message *
-*************************************************/
+/*
+* Decompress a message
+*/
void CMS_Decoder::decompress(BER_Decoder& decoder)
{
u32bit version;
diff --git a/src/cms/cms_dalg.cpp b/src/cms/cms_dalg.cpp
index 501ea7873..7ed793f4f 100644
--- a/src/cms/cms_dalg.cpp
+++ b/src/cms/cms_dalg.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CMS Decoding Operations Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CMS Decoding Operations
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cms_dec.h>
#include <botan/x509find.h>
@@ -17,9 +19,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Compute the hash of some content *
-*************************************************/
+/*
+* Compute the hash of some content
+*/
SecureVector<byte> hash_of(const SecureVector<byte>& content,
const AlgorithmIdentifier& hash_algo,
std::string& hash_name)
@@ -32,9 +34,9 @@ SecureVector<byte> hash_of(const SecureVector<byte>& content,
return hash_fn->process(content);
}
-/*************************************************
-* Find a cert based on SignerIdentifier *
-*************************************************/
+/*
+* Find a cert based on SignerIdentifier
+*/
std::vector<X509_Certificate> get_cert(BER_Decoder& signer_info,
X509_Store& store)
{
@@ -64,9 +66,9 @@ std::vector<X509_Certificate> get_cert(BER_Decoder& signer_info,
return found;
}
-/*************************************************
-* Read OriginatorInfo *
-*************************************************/
+/*
+* Read OriginatorInfo
+*/
void read_orig_info(BER_Decoder& info, X509_Store& store)
{
BER_Object next = info.get_next_object();
@@ -99,9 +101,9 @@ void read_orig_info(BER_Decoder& info, X509_Store& store)
info.push_back(next);
}
-/*************************************************
-* Decode any Attributes, and check type *
-*************************************************/
+/*
+* Decode any Attributes, and check type
+*/
SecureVector<byte> decode_attributes(BER_Decoder& ber, const OID& type,
bool& bad_attributes)
{
@@ -150,9 +152,9 @@ SecureVector<byte> decode_attributes(BER_Decoder& ber, const OID& type,
}
-/*************************************************
-* Decode this layer of CMS encoding *
-*************************************************/
+/*
+* Decode this layer of CMS encoding
+*/
void CMS_Decoder::decode_layer()
{
try {
diff --git a/src/cms/cms_dec.cpp b/src/cms/cms_dec.cpp
index 55c1c8cd5..222399f6c 100644
--- a/src/cms/cms_dec.cpp
+++ b/src/cms/cms_dec.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CMS Decoding Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CMS Decoding
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cms_dec.h>
#include <botan/ber_dec.h>
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* CMS_Decoder Constructor *
-*************************************************/
+/*
+* CMS_Decoder Constructor
+*/
CMS_Decoder::CMS_Decoder(DataSource& in, const X509_Store& x509store,
User_Interface& ui_ref, PKCS8_PrivateKey* key) :
ui(ui_ref), store(x509store)
@@ -31,9 +33,9 @@ CMS_Decoder::CMS_Decoder(DataSource& in, const X509_Store& x509store,
}
}
-/*************************************************
-* Read the outermost ContentInfo *
-*************************************************/
+/*
+* Read the outermost ContentInfo
+*/
void CMS_Decoder::initial_read(DataSource&)
{
// FIXME...
@@ -52,9 +54,9 @@ void CMS_Decoder::initial_read(DataSource&)
decode_layer();
}
-/*************************************************
-* Add another private key to use *
-*************************************************/
+/*
+* Add another private key to use
+*/
void CMS_Decoder::add_key(PKCS8_PrivateKey* key)
{
if(!key)
@@ -69,17 +71,17 @@ void CMS_Decoder::add_key(PKCS8_PrivateKey* key)
keys.push_back(key);
}
-/*************************************************
-* Return the status information *
-*************************************************/
+/*
+* Return the status information
+*/
CMS_Decoder::Status CMS_Decoder::layer_status() const
{
return status;
}
-/*************************************************
-* Return the final data content *
-*************************************************/
+/*
+* Return the final data content
+*/
std::string CMS_Decoder::get_data() const
{
if(layer_type() != DATA)
@@ -87,9 +89,9 @@ std::string CMS_Decoder::get_data() const
return std::string((const char*)data.begin(), data.size());
}
-/*************************************************
-* Return the content type of this layer *
-*************************************************/
+/*
+* Return the content type of this layer
+*/
CMS_Decoder::Content_Type CMS_Decoder::layer_type() const
{
if(type == OIDS::lookup("CMS.DataContent")) return DATA;
@@ -101,17 +103,17 @@ CMS_Decoder::Content_Type CMS_Decoder::layer_type() const
return UNKNOWN;
}
-/*************************************************
-* Return some information about this layer *
-*************************************************/
+/*
+* Return some information about this layer
+*/
std::string CMS_Decoder::layer_info() const
{
return info;
}
-/*************************************************
-* Return some information about this layer *
-*************************************************/
+/*
+* Return some information about this layer
+*/
void CMS_Decoder::read_econtent(BER_Decoder& decoder)
{
BER_Decoder econtent_info = decoder.start_cons(SEQUENCE);
diff --git a/src/cms/cms_dec.h b/src/cms/cms_dec.h
index a338e4c0f..75b61c9cb 100644
--- a/src/cms/cms_dec.h
+++ b/src/cms/cms_dec.h
@@ -1,7 +1,9 @@
-/*************************************************
-* CMS Decoding Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CMS Decoding
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_CMS_DECODER_H__
#define BOTAN_CMS_DECODER_H__
@@ -14,9 +16,9 @@
namespace Botan {
-/*************************************************
-* CMS Decoding Operation *
-*************************************************/
+/*
+* CMS Decoding Operation
+*/
class BOTAN_DLL CMS_Decoder
{
public:
diff --git a/src/cms/cms_ealg.cpp b/src/cms/cms_ealg.cpp
index 85b933197..2970e8e79 100644
--- a/src/cms/cms_ealg.cpp
+++ b/src/cms/cms_ealg.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CMS Encoding Operations Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CMS Encoding Operations
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cms_enc.h>
#include <botan/der_enc.h>
@@ -19,9 +21,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Choose an algorithm *
-*************************************************/
+/*
+* Choose an algorithm
+*/
std::string choose_algo(const std::string& user_algo,
const std::string& default_algo)
{
@@ -30,9 +32,9 @@ std::string choose_algo(const std::string& user_algo,
return global_state().deref_alias(user_algo);
}
-/*************************************************
-* Encode a SignerIdentifier/RecipientIdentifier *
-*************************************************/
+/*
+* Encode a SignerIdentifier/RecipientIdentifier
+*/
DER_Encoder& encode_si(DER_Encoder& der, const X509_Certificate& cert,
bool use_skid_encoding = false)
{
@@ -49,9 +51,9 @@ DER_Encoder& encode_si(DER_Encoder& der, const X509_Certificate& cert,
return der;
}
-/*************************************************
-* Compute the hash of some content *
-*************************************************/
+/*
+* Compute the hash of some content
+*/
SecureVector<byte> hash_of(const SecureVector<byte>& content,
const std::string& hash_name)
{
@@ -60,9 +62,9 @@ SecureVector<byte> hash_of(const SecureVector<byte>& content,
return hash_fn->process(content);
}
-/*************************************************
-* Encode Attributes containing info on content *
-*************************************************/
+/*
+* Encode Attributes containing info on content
+*/
SecureVector<byte> encode_attr(const SecureVector<byte>& data,
const std::string& type,
const std::string& hash)
@@ -86,9 +88,9 @@ SecureVector<byte> encode_attr(const SecureVector<byte>& data,
}
-/*************************************************
-* Encrypt a message *
-*************************************************/
+/*
+* Encrypt a message
+*/
void CMS_Encoder::encrypt(RandomNumberGenerator& rng,
const X509_Certificate& to,
const std::string user_cipher)
@@ -123,9 +125,9 @@ void CMS_Encoder::encrypt(RandomNumberGenerator& rng,
throw Invalid_Argument("Unknown CMS PK encryption algorithm " + algo);
}
-/*************************************************
-* Encrypt a message with a key transport algo *
-*************************************************/
+/*
+* Encrypt a message with a key transport algo
+*/
void CMS_Encoder::encrypt_ktri(RandomNumberGenerator& rng,
const X509_Certificate& to,
PK_Encrypting_Key* pub_key,
@@ -158,9 +160,9 @@ void CMS_Encoder::encrypt_ktri(RandomNumberGenerator& rng,
add_layer("CMS.EnvelopedData", encoder);
}
-/*************************************************
-* Encrypt a message with a key agreement algo *
-*************************************************/
+/*
+* Encrypt a message with a key agreement algo
+*/
void CMS_Encoder::encrypt_kari(RandomNumberGenerator&,
const X509_Certificate&,
X509_PublicKey*,
@@ -189,9 +191,9 @@ void CMS_Encoder::encrypt_kari(RandomNumberGenerator&,
#endif
}
-/*************************************************
-* Encrypt a message with a shared key *
-*************************************************/
+/*
+* Encrypt a message with a shared key
+*/
void CMS_Encoder::encrypt(RandomNumberGenerator& rng,
const SymmetricKey& kek,
const std::string& user_cipher)
@@ -222,9 +224,9 @@ void CMS_Encoder::encrypt(RandomNumberGenerator& rng,
add_layer("CMS.EnvelopedData", encoder);
}
-/*************************************************
-* Encrypt a message with a passphrase *
-*************************************************/
+/*
+* Encrypt a message with a passphrase
+*/
void CMS_Encoder::encrypt(RandomNumberGenerator&,
const std::string&,
const std::string& user_cipher)
@@ -244,9 +246,9 @@ void CMS_Encoder::encrypt(RandomNumberGenerator&,
*/
}
-/*************************************************
-* Encrypt the content with the chosen key/cipher *
-*************************************************/
+/*
+* Encrypt the content with the chosen key/cipher
+*/
SecureVector<byte> CMS_Encoder::do_encrypt(RandomNumberGenerator& rng,
const SymmetricKey& key,
const std::string& cipher_name)
@@ -281,9 +283,9 @@ SecureVector<byte> CMS_Encoder::do_encrypt(RandomNumberGenerator& rng,
return encoder.get_contents();
}
-/*************************************************
-* Sign a message *
-*************************************************/
+/*
+* Sign a message
+*/
void CMS_Encoder::sign(const X509_Certificate& cert,
const PKCS8_PrivateKey& key,
RandomNumberGenerator& rng,
@@ -343,9 +345,9 @@ void CMS_Encoder::sign(const X509_Certificate& cert,
add_layer("CMS.SignedData", encoder);
}
-/*************************************************
-* Digest a message *
-*************************************************/
+/*
+* Digest a message
+*/
void CMS_Encoder::digest(const std::string& user_hash)
{
const std::string hash = choose_algo(user_hash, "SHA-1");
@@ -366,9 +368,9 @@ void CMS_Encoder::digest(const std::string& user_hash)
add_layer("CMS.DigestedData", encoder);
}
-/*************************************************
-* MAC a message with an encrypted key *
-*************************************************/
+/*
+* MAC a message with an encrypted key
+*/
void CMS_Encoder::authenticate(const X509_Certificate&,
const std::string& mac_algo)
{
@@ -376,9 +378,9 @@ void CMS_Encoder::authenticate(const X509_Certificate&,
throw Exception("FIXME: unimplemented");
}
-/*************************************************
-* MAC a message with a shared key *
-*************************************************/
+/*
+* MAC a message with a shared key
+*/
void CMS_Encoder::authenticate(const SymmetricKey&,
const std::string& mac_algo)
{
@@ -386,9 +388,9 @@ void CMS_Encoder::authenticate(const SymmetricKey&,
throw Exception("FIXME: unimplemented");
}
-/*************************************************
-* MAC a message with a passphrase *
-*************************************************/
+/*
+* MAC a message with a passphrase
+*/
void CMS_Encoder::authenticate(const std::string&,
const std::string& mac_algo)
{
diff --git a/src/cms/cms_enc.cpp b/src/cms/cms_enc.cpp
index 601fbc9b6..2413676d7 100644
--- a/src/cms/cms_enc.cpp
+++ b/src/cms/cms_enc.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* CMS Encoding Base Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CMS Encoding Base
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/cms_enc.h>
#include <botan/der_enc.h>
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* Setup the intitial layer of CMS data *
-*************************************************/
+/*
+* Setup the intitial layer of CMS data
+*/
void CMS_Encoder::set_data(const byte buf[], u32bit length)
{
if(data.has_items())
@@ -22,17 +24,17 @@ void CMS_Encoder::set_data(const byte buf[], u32bit length)
type = "CMS.DataContent";
}
-/*************************************************
-* Setup the intitial layer of CMS data *
-*************************************************/
+/*
+* Setup the intitial layer of CMS data
+*/
void CMS_Encoder::set_data(const std::string& str)
{
set_data((const byte*)str.c_str(), str.length());
}
-/*************************************************
-* Finalize and return the CMS encoded data *
-*************************************************/
+/*
+* Finalize and return the CMS encoded data
+*/
SecureVector<byte> CMS_Encoder::get_contents()
{
DER_Encoder encoder;
@@ -49,26 +51,26 @@ SecureVector<byte> CMS_Encoder::get_contents()
return encoder.get_contents();
}
-/*************************************************
-* Add a new layer of encapsulation *
-*************************************************/
+/*
+* Add a new layer of encapsulation
+*/
void CMS_Encoder::add_layer(const std::string& oid, DER_Encoder& new_layer)
{
data = new_layer.get_contents();
type = oid;
}
-/*************************************************
-* Return the PEM-encoded data *
-*************************************************/
+/*
+* Return the PEM-encoded data
+*/
std::string CMS_Encoder::PEM_contents()
{
return PEM_Code::encode(get_contents(), "PKCS7");
}
-/*************************************************
-* Make an EncapsulatedContentInfo *
-*************************************************/
+/*
+* Make an EncapsulatedContentInfo
+*/
SecureVector<byte> CMS_Encoder::make_econtent(const SecureVector<byte>& data,
const std::string& type)
{
diff --git a/src/cms/cms_enc.h b/src/cms/cms_enc.h
index f62c56ffa..6fdd2b726 100644
--- a/src/cms/cms_enc.h
+++ b/src/cms/cms_enc.h
@@ -1,7 +1,9 @@
-/*************************************************
-* CMS Encoding Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* CMS Encoding
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_CMS_ENCODER_H__
#define BOTAN_CMS_ENCODER_H__
@@ -13,9 +15,9 @@
namespace Botan {
-/*************************************************
-* CMS Encoding Operation *
-*************************************************/
+/*
+* CMS Encoding Operation
+*/
class BOTAN_DLL CMS_Encoder
{
public: